babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676158677158678158679158680158681158682158683158684158685158686158687158688158689158690158691158692158693158694158695158696158697158698158699158700158701158702158703158704158705158706158707158708158709158710158711158712158713158714158715158716158717158718158719158720158721158722158723158724158725158726158727158728158729158730158731158732158733158734158735158736158737158738158739158740158741158742158743158744158745158746158747158748158749158750158751158752158753158754158755158756158757158758158759158760158761158762158763158764158765158766158767158768158769158770158771158772158773158774158775158776158777158778158779158780158781158782158783158784158785158786158787158788158789158790158791158792158793158794158795158796158797158798158799158800158801158802158803158804158805158806158807158808158809158810158811158812158813158814158815158816158817158818158819158820158821158822158823158824158825158826158827158828158829158830158831158832158833158834158835158836158837158838158839158840158841158842158843158844158845158846158847158848158849158850158851158852158853158854158855158856158857158858158859158860158861158862158863158864158865158866158867158868158869158870158871158872158873158874158875158876158877158878158879158880158881158882158883158884158885158886158887158888158889158890158891158892158893158894158895158896158897158898158899158900158901158902158903158904158905158906158907158908158909158910158911158912158913158914158915158916158917158918158919158920158921158922158923158924158925158926158927158928158929158930158931158932158933158934158935158936158937158938158939158940158941158942158943158944158945158946158947158948158949158950158951158952158953158954158955158956158957158958158959158960158961158962158963158964158965158966158967158968158969158970158971158972158973158974158975158976158977158978158979158980158981158982158983158984158985158986158987158988158989158990158991158992158993158994158995158996158997158998158999159000159001159002159003159004159005159006159007159008159009159010159011159012159013159014159015159016159017159018159019159020159021159022159023159024159025159026159027159028159029159030159031159032159033159034159035159036159037159038159039159040159041159042159043159044159045159046159047159048159049159050159051159052159053159054159055159056159057159058159059159060159061159062159063159064159065159066159067159068159069159070159071159072159073159074159075159076159077159078159079159080159081159082159083159084159085159086159087159088159089159090159091159092159093159094159095159096159097159098159099159100159101159102159103159104159105159106159107159108159109159110159111159112159113159114159115159116159117159118159119159120159121159122159123159124159125159126159127159128159129159130159131159132159133159134159135159136159137159138159139159140159141159142159143159144159145159146159147159148159149159150159151159152159153159154159155159156159157159158159159159160159161159162159163159164159165159166159167159168159169159170159171159172159173159174159175159176159177159178159179159180159181159182159183159184159185159186159187159188159189159190159191159192159193159194159195159196159197159198159199159200159201159202159203159204159205159206159207159208159209159210159211159212159213159214159215159216159217159218159219159220159221159222159223159224159225159226159227159228159229159230159231159232159233159234159235159236159237159238159239159240159241159242159243159244159245159246159247159248159249159250159251159252159253159254159255159256159257159258159259159260159261159262159263159264159265159266159267159268159269159270159271159272159273159274159275159276159277159278159279159280159281159282159283159284159285159286159287159288159289159290159291159292159293159294159295159296159297159298159299159300159301159302159303159304159305159306159307159308159309159310159311159312159313159314159315159316159317159318159319159320159321159322159323159324159325159326159327159328159329159330159331159332159333159334159335159336159337159338159339159340159341159342159343159344159345159346159347159348159349159350159351159352159353159354159355159356159357159358159359159360159361159362159363159364159365159366159367159368159369159370159371159372159373159374159375159376159377159378159379159380159381159382159383159384159385159386159387159388159389159390159391159392159393159394159395159396159397159398159399159400159401159402159403159404159405159406159407159408159409159410159411159412159413159414159415159416159417159418159419159420159421159422159423159424159425159426159427159428159429159430159431159432159433159434159435159436159437159438159439159440159441159442159443159444159445159446159447159448159449159450159451159452159453159454159455159456159457159458159459159460159461159462159463159464159465159466159467159468159469159470159471159472159473159474159475159476159477159478159479159480159481159482159483159484159485159486159487159488159489159490159491159492159493159494159495159496159497159498159499159500159501159502159503159504159505159506159507159508159509159510159511159512159513159514159515159516159517159518159519159520159521159522159523159524159525159526159527159528159529159530159531159532159533159534159535159536159537159538159539159540159541159542159543159544159545159546159547159548159549159550159551159552159553159554159555159556159557159558159559159560159561159562159563159564159565159566159567159568159569159570159571159572159573159574159575159576159577159578159579159580159581159582159583159584159585159586159587159588159589159590159591159592159593159594159595159596159597159598159599159600159601159602159603159604159605159606159607159608159609159610159611159612159613159614159615159616159617159618159619159620159621159622159623159624159625159626159627159628159629159630159631159632159633159634159635159636159637159638159639159640159641159642159643159644159645159646159647159648159649159650159651159652159653159654159655159656159657159658159659159660159661159662159663159664159665159666159667159668159669159670159671159672159673159674159675159676159677159678159679159680159681159682159683159684159685159686159687159688159689159690159691159692159693159694159695159696159697159698159699159700159701159702159703159704159705159706159707159708159709159710159711159712159713159714159715159716159717159718159719
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. /**
  95. * User defined information that will be sent to observers
  96. */
  97. userInfo?: any;
  98. }
  99. /**
  100. * Represent an Observer registered to a given Observable object.
  101. */
  102. export class Observer<T> {
  103. /**
  104. * Defines the callback to call when the observer is notified
  105. */
  106. callback: (eventData: T, eventState: EventState) => void;
  107. /**
  108. * Defines the mask of the observer (used to filter notifications)
  109. */
  110. mask: number;
  111. /**
  112. * Defines the current scope used to restore the JS context
  113. */
  114. scope: any;
  115. /** @hidden */
  116. _willBeUnregistered: boolean;
  117. /**
  118. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  119. */
  120. unregisterOnNextCall: boolean;
  121. /**
  122. * Creates a new observer
  123. * @param callback defines the callback to call when the observer is notified
  124. * @param mask defines the mask of the observer (used to filter notifications)
  125. * @param scope defines the current scope used to restore the JS context
  126. */
  127. constructor(
  128. /**
  129. * Defines the callback to call when the observer is notified
  130. */
  131. callback: (eventData: T, eventState: EventState) => void,
  132. /**
  133. * Defines the mask of the observer (used to filter notifications)
  134. */
  135. mask: number,
  136. /**
  137. * Defines the current scope used to restore the JS context
  138. */
  139. scope?: any);
  140. }
  141. /**
  142. * Represent a list of observers registered to multiple Observables object.
  143. */
  144. export class MultiObserver<T> {
  145. private _observers;
  146. private _observables;
  147. /**
  148. * Release associated resources
  149. */
  150. dispose(): void;
  151. /**
  152. * Raise a callback when one of the observable will notify
  153. * @param observables defines a list of observables to watch
  154. * @param callback defines the callback to call on notification
  155. * @param mask defines the mask used to filter notifications
  156. * @param scope defines the current scope used to restore the JS context
  157. * @returns the new MultiObserver
  158. */
  159. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  160. }
  161. /**
  162. * The Observable class is a simple implementation of the Observable pattern.
  163. *
  164. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  165. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  166. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  167. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  168. */
  169. export class Observable<T> {
  170. private _observers;
  171. private _eventState;
  172. private _onObserverAdded;
  173. /**
  174. * Gets the list of observers
  175. */
  176. get observers(): Array<Observer<T>>;
  177. /**
  178. * Creates a new observable
  179. * @param onObserverAdded defines a callback to call when a new observer is added
  180. */
  181. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  182. /**
  183. * Create a new Observer with the specified callback
  184. * @param callback the callback that will be executed for that Observer
  185. * @param mask the mask used to filter observers
  186. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  187. * @param scope optional scope for the callback to be called from
  188. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  189. * @returns the new observer created for the callback
  190. */
  191. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  192. /**
  193. * Create a new Observer with the specified callback and unregisters after the next notification
  194. * @param callback the callback that will be executed for that Observer
  195. * @returns the new observer created for the callback
  196. */
  197. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  198. /**
  199. * Remove an Observer from the Observable object
  200. * @param observer the instance of the Observer to remove
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. remove(observer: Nullable<Observer<T>>): boolean;
  204. /**
  205. * Remove a callback from the Observable object
  206. * @param callback the callback to remove
  207. * @param scope optional scope. If used only the callbacks with this scope will be removed
  208. * @returns false if it doesn't belong to this Observable
  209. */
  210. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  211. private _deferUnregister;
  212. private _remove;
  213. /**
  214. * Moves the observable to the top of the observer list making it get called first when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverTopPriority(observer: Observer<T>): void;
  218. /**
  219. * Moves the observable to the bottom of the observer list making it get called last when notified
  220. * @param observer the observer to move
  221. */
  222. makeObserverBottomPriority(observer: Observer<T>): void;
  223. /**
  224. * Notify all Observers by calling their respective callback with the given data
  225. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  226. * @param eventData defines the data to send to all observers
  227. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  228. * @param target defines the original target of the state
  229. * @param currentTarget defines the current target of the state
  230. * @param userInfo defines any user info to send to observers
  231. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  232. */
  233. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  234. /**
  235. * Calling this will execute each callback, expecting it to be a promise or return a value.
  236. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  237. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  238. * and it is crucial that all callbacks will be executed.
  239. * The order of the callbacks is kept, callbacks are not executed parallel.
  240. *
  241. * @param eventData The data to be sent to each callback
  242. * @param mask is used to filter observers defaults to -1
  243. * @param target defines the callback target (see EventState)
  244. * @param currentTarget defines he current object in the bubbling phase
  245. * @param userInfo defines any user info to send to observers
  246. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  247. */
  248. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  249. /**
  250. * Notify a specific observer
  251. * @param observer defines the observer to notify
  252. * @param eventData defines the data to be sent to each callback
  253. * @param mask is used to filter observers defaults to -1
  254. */
  255. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  256. /**
  257. * Gets a boolean indicating if the observable has at least one observer
  258. * @returns true is the Observable has at least one Observer registered
  259. */
  260. hasObservers(): boolean;
  261. /**
  262. * Clear the list of observers
  263. */
  264. clear(): void;
  265. /**
  266. * Clone the current observable
  267. * @returns a new observable
  268. */
  269. clone(): Observable<T>;
  270. /**
  271. * Does this observable handles observer registered with a given mask
  272. * @param mask defines the mask to be tested
  273. * @return whether or not one observer registered with the given mask is handeled
  274. **/
  275. hasSpecificMask(mask?: number): boolean;
  276. }
  277. }
  278. declare module "babylonjs/Misc/domManagement" {
  279. /**
  280. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  281. * Babylon.js
  282. */
  283. export class DomManagement {
  284. /**
  285. * Checks if the window object exists
  286. * @returns true if the window object exists
  287. */
  288. static IsWindowObjectExist(): boolean;
  289. /**
  290. * Checks if the navigator object exists
  291. * @returns true if the navigator object exists
  292. */
  293. static IsNavigatorAvailable(): boolean;
  294. /**
  295. * Check if the document object exists
  296. * @returns true if the document object exists
  297. */
  298. static IsDocumentAvailable(): boolean;
  299. /**
  300. * Extracts text content from a DOM element hierarchy
  301. * @param element defines the root element
  302. * @returns a string
  303. */
  304. static GetDOMTextContent(element: HTMLElement): string;
  305. }
  306. }
  307. declare module "babylonjs/Misc/logger" {
  308. /**
  309. * Logger used througouht the application to allow configuration of
  310. * the log level required for the messages.
  311. */
  312. export class Logger {
  313. /**
  314. * No log
  315. */
  316. static readonly NoneLogLevel: number;
  317. /**
  318. * Only message logs
  319. */
  320. static readonly MessageLogLevel: number;
  321. /**
  322. * Only warning logs
  323. */
  324. static readonly WarningLogLevel: number;
  325. /**
  326. * Only error logs
  327. */
  328. static readonly ErrorLogLevel: number;
  329. /**
  330. * All logs
  331. */
  332. static readonly AllLogLevel: number;
  333. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  402. * @param str Source string
  403. * @param suffix Suffix to search for in the source string
  404. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  405. */
  406. static StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private readonly _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  699. static readonly GEQUAL: number;
  700. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. * @param options options to be passed to the loader
  1129. */
  1130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1131. /**
  1132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1133. * @param data contains the texture data
  1134. * @param texture defines the BabylonJS internal texture
  1135. * @param callback defines the method to call once ready to upload
  1136. * @param options options to be passed to the loader
  1137. */
  1138. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/IPipelineContext" {
  1142. /**
  1143. * Class used to store and describe the pipeline context associated with an effect
  1144. */
  1145. export interface IPipelineContext {
  1146. /**
  1147. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1148. */
  1149. isAsync: boolean;
  1150. /**
  1151. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1152. */
  1153. isReady: boolean;
  1154. /** @hidden */
  1155. _getVertexShaderCode(): string | null;
  1156. /** @hidden */
  1157. _getFragmentShaderCode(): string | null;
  1158. /** @hidden */
  1159. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1160. }
  1161. }
  1162. declare module "babylonjs/Meshes/dataBuffer" {
  1163. /**
  1164. * Class used to store gfx data (like WebGLBuffer)
  1165. */
  1166. export class DataBuffer {
  1167. /**
  1168. * Gets or sets the number of objects referencing this buffer
  1169. */
  1170. references: number;
  1171. /** Gets or sets the size of the underlying buffer */
  1172. capacity: number;
  1173. /**
  1174. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1175. */
  1176. is32Bits: boolean;
  1177. /**
  1178. * Gets the underlying buffer
  1179. */
  1180. get underlyingResource(): any;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1185. /** @hidden */
  1186. export interface IShaderProcessor {
  1187. attributeProcessor?: (attribute: string) => string;
  1188. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1189. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1190. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1191. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1192. lineProcessor?: (line: string, isFragment: boolean) => string;
  1193. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1194. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1198. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1199. /** @hidden */
  1200. export interface ProcessingOptions {
  1201. defines: string[];
  1202. indexParameters: any;
  1203. isFragment: boolean;
  1204. shouldUseHighPrecisionShader: boolean;
  1205. supportsUniformBuffers: boolean;
  1206. shadersRepository: string;
  1207. includesShadersStore: {
  1208. [key: string]: string;
  1209. };
  1210. processor?: IShaderProcessor;
  1211. version: string;
  1212. platformName: string;
  1213. lookForClosingBracketForUniformBuffer?: boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1217. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1218. /** @hidden */
  1219. export class ShaderCodeNode {
  1220. line: string;
  1221. children: ShaderCodeNode[];
  1222. additionalDefineKey?: string;
  1223. additionalDefineValue?: string;
  1224. isValid(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. process(preprocessors: {
  1228. [key: string]: string;
  1229. }, options: ProcessingOptions): string;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1233. /** @hidden */
  1234. export class ShaderCodeCursor {
  1235. private _lines;
  1236. lineIndex: number;
  1237. get currentLine(): string;
  1238. get canRead(): boolean;
  1239. set lines(value: string[]);
  1240. }
  1241. }
  1242. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1243. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1244. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1245. /** @hidden */
  1246. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1247. process(preprocessors: {
  1248. [key: string]: string;
  1249. }, options: ProcessingOptions): string;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1253. /** @hidden */
  1254. export class ShaderDefineExpression {
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. private static _OperatorPriority;
  1259. private static _Stack;
  1260. static postfixToInfix(postfix: string[]): string;
  1261. static infixToPostfix(infix: string): string[];
  1262. }
  1263. }
  1264. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1265. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1266. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1267. /** @hidden */
  1268. export class ShaderCodeTestNode extends ShaderCodeNode {
  1269. testExpression: ShaderDefineExpression;
  1270. isValid(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1276. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1277. /** @hidden */
  1278. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1279. define: string;
  1280. not: boolean;
  1281. constructor(define: string, not?: boolean);
  1282. isTrue(preprocessors: {
  1283. [key: string]: string;
  1284. }): boolean;
  1285. }
  1286. }
  1287. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1288. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1289. /** @hidden */
  1290. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1291. leftOperand: ShaderDefineExpression;
  1292. rightOperand: ShaderDefineExpression;
  1293. isTrue(preprocessors: {
  1294. [key: string]: string;
  1295. }): boolean;
  1296. }
  1297. }
  1298. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1299. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1300. /** @hidden */
  1301. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1302. leftOperand: ShaderDefineExpression;
  1303. rightOperand: ShaderDefineExpression;
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1310. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1311. /** @hidden */
  1312. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1313. define: string;
  1314. operand: string;
  1315. testValue: string;
  1316. constructor(define: string, operand: string, testValue: string);
  1317. isTrue(preprocessors: {
  1318. [key: string]: string;
  1319. }): boolean;
  1320. }
  1321. }
  1322. declare module "babylonjs/Offline/IOfflineProvider" {
  1323. /**
  1324. * Class used to enable access to offline support
  1325. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1326. */
  1327. export interface IOfflineProvider {
  1328. /**
  1329. * Gets a boolean indicating if scene must be saved in the database
  1330. */
  1331. enableSceneOffline: boolean;
  1332. /**
  1333. * Gets a boolean indicating if textures must be saved in the database
  1334. */
  1335. enableTexturesOffline: boolean;
  1336. /**
  1337. * Open the offline support and make it available
  1338. * @param successCallback defines the callback to call on success
  1339. * @param errorCallback defines the callback to call on error
  1340. */
  1341. open(successCallback: () => void, errorCallback: () => void): void;
  1342. /**
  1343. * Loads an image from the offline support
  1344. * @param url defines the url to load from
  1345. * @param image defines the target DOM image
  1346. */
  1347. loadImage(url: string, image: HTMLImageElement): void;
  1348. /**
  1349. * Loads a file from offline support
  1350. * @param url defines the URL to load from
  1351. * @param sceneLoaded defines a callback to call on success
  1352. * @param progressCallBack defines a callback to call when progress changed
  1353. * @param errorCallback defines a callback to call on error
  1354. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1355. */
  1356. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1357. }
  1358. }
  1359. declare module "babylonjs/Misc/filesInputStore" {
  1360. /**
  1361. * Class used to help managing file picking and drag'n'drop
  1362. * File Storage
  1363. */
  1364. export class FilesInputStore {
  1365. /**
  1366. * List of files ready to be loaded
  1367. */
  1368. static FilesToLoad: {
  1369. [key: string]: File;
  1370. };
  1371. }
  1372. }
  1373. declare module "babylonjs/Misc/retryStrategy" {
  1374. import { WebRequest } from "babylonjs/Misc/webRequest";
  1375. /**
  1376. * Class used to define a retry strategy when error happens while loading assets
  1377. */
  1378. export class RetryStrategy {
  1379. /**
  1380. * Function used to defines an exponential back off strategy
  1381. * @param maxRetries defines the maximum number of retries (3 by default)
  1382. * @param baseInterval defines the interval between retries
  1383. * @returns the strategy function to use
  1384. */
  1385. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/baseError" {
  1389. /**
  1390. * @ignore
  1391. * Application error to support additional information when loading a file
  1392. */
  1393. export abstract class BaseError extends Error {
  1394. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1395. }
  1396. }
  1397. declare module "babylonjs/Misc/fileTools" {
  1398. import { WebRequest } from "babylonjs/Misc/webRequest";
  1399. import { Nullable } from "babylonjs/types";
  1400. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1401. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1402. import { BaseError } from "babylonjs/Misc/baseError";
  1403. /** @ignore */
  1404. export class LoadFileError extends BaseError {
  1405. request?: WebRequest;
  1406. file?: File;
  1407. /**
  1408. * Creates a new LoadFileError
  1409. * @param message defines the message of the error
  1410. * @param request defines the optional web request
  1411. * @param file defines the optional file
  1412. */
  1413. constructor(message: string, object?: WebRequest | File);
  1414. }
  1415. /** @ignore */
  1416. export class RequestFileError extends BaseError {
  1417. request: WebRequest;
  1418. /**
  1419. * Creates a new LoadFileError
  1420. * @param message defines the message of the error
  1421. * @param request defines the optional web request
  1422. */
  1423. constructor(message: string, request: WebRequest);
  1424. }
  1425. /** @ignore */
  1426. export class ReadFileError extends BaseError {
  1427. file: File;
  1428. /**
  1429. * Creates a new ReadFileError
  1430. * @param message defines the message of the error
  1431. * @param file defines the optional file
  1432. */
  1433. constructor(message: string, file: File);
  1434. }
  1435. /**
  1436. * @hidden
  1437. */
  1438. export class FileTools {
  1439. /**
  1440. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1441. */
  1442. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1443. /**
  1444. * Gets or sets the base URL to use to load assets
  1445. */
  1446. static BaseUrl: string;
  1447. /**
  1448. * Default behaviour for cors in the application.
  1449. * It can be a string if the expected behavior is identical in the entire app.
  1450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1451. */
  1452. static CorsBehavior: string | ((url: string | string[]) => string);
  1453. /**
  1454. * Gets or sets a function used to pre-process url before using them to load assets
  1455. */
  1456. static PreprocessUrl: (url: string) => string;
  1457. /**
  1458. * Removes unwanted characters from an url
  1459. * @param url defines the url to clean
  1460. * @returns the cleaned url
  1461. */
  1462. private static _CleanUrl;
  1463. /**
  1464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1465. * @param url define the url we are trying
  1466. * @param element define the dom element where to configure the cors policy
  1467. */
  1468. static SetCorsBehavior(url: string | string[], element: {
  1469. crossOrigin: string | null;
  1470. }): void;
  1471. /**
  1472. * Loads an image as an HTMLImageElement.
  1473. * @param input url string, ArrayBuffer, or Blob to load
  1474. * @param onLoad callback called when the image successfully loads
  1475. * @param onError callback called when the image fails to load
  1476. * @param offlineProvider offline provider for caching
  1477. * @param mimeType optional mime type
  1478. * @returns the HTMLImageElement of the loaded image
  1479. */
  1480. 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>;
  1481. /**
  1482. * Reads a file from a File object
  1483. * @param file defines the file to load
  1484. * @param onSuccess defines the callback to call when data is loaded
  1485. * @param onProgress defines the callback to call during loading process
  1486. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1487. * @param onError defines the callback to call when an error occurs
  1488. * @returns a file request object
  1489. */
  1490. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. */
  1501. 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;
  1502. /**
  1503. * Loads a file
  1504. * @param url url to load
  1505. * @param onSuccess callback called when the file successfully loads
  1506. * @param onProgress callback called while file is loading (if the server supports this mode)
  1507. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1508. * @param onError callback called when the file fails to load
  1509. * @param onOpened callback called when the web request is opened
  1510. * @returns a file request object
  1511. */
  1512. 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;
  1513. /**
  1514. * Checks if the loaded document was accessed via `file:`-Protocol.
  1515. * @returns boolean
  1516. */
  1517. static IsFileURL(): boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1521. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1522. import { WebRequest } from "babylonjs/Misc/webRequest";
  1523. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1524. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1525. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1526. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1527. /** @hidden */
  1528. export class ShaderProcessor {
  1529. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1530. private static _ProcessPrecision;
  1531. private static _ExtractOperation;
  1532. private static _BuildSubExpression;
  1533. private static _BuildExpression;
  1534. private static _MoveCursorWithinIf;
  1535. private static _MoveCursor;
  1536. private static _EvaluatePreProcessors;
  1537. private static _PreparePreProcessors;
  1538. private static _ProcessShaderConversion;
  1539. private static _ProcessIncludes;
  1540. /**
  1541. * Loads a file from a url
  1542. * @param url url to load
  1543. * @param onSuccess callback called when the file successfully loads
  1544. * @param onProgress callback called while file is loading (if the server supports this mode)
  1545. * @param offlineProvider defines the offline provider for caching
  1546. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1547. * @param onError callback called when the file fails to load
  1548. * @returns a file request object
  1549. * @hidden
  1550. */
  1551. 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;
  1552. }
  1553. }
  1554. declare module "babylonjs/Maths/math.like" {
  1555. import { float, int, DeepImmutable } from "babylonjs/types";
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IColor4Like {
  1560. r: float;
  1561. g: float;
  1562. b: float;
  1563. a: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IColor3Like {
  1569. r: float;
  1570. g: float;
  1571. b: float;
  1572. }
  1573. /**
  1574. * @hidden
  1575. */
  1576. export interface IVector4Like {
  1577. x: float;
  1578. y: float;
  1579. z: float;
  1580. w: float;
  1581. }
  1582. /**
  1583. * @hidden
  1584. */
  1585. export interface IVector3Like {
  1586. x: float;
  1587. y: float;
  1588. z: float;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IVector2Like {
  1594. x: float;
  1595. y: float;
  1596. }
  1597. /**
  1598. * @hidden
  1599. */
  1600. export interface IMatrixLike {
  1601. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1602. updateFlag: int;
  1603. }
  1604. /**
  1605. * @hidden
  1606. */
  1607. export interface IViewportLike {
  1608. x: float;
  1609. y: float;
  1610. width: float;
  1611. height: float;
  1612. }
  1613. /**
  1614. * @hidden
  1615. */
  1616. export interface IPlaneLike {
  1617. normal: IVector3Like;
  1618. d: float;
  1619. normalize(): void;
  1620. }
  1621. }
  1622. declare module "babylonjs/Materials/iEffectFallbacks" {
  1623. import { Effect } from "babylonjs/Materials/effect";
  1624. /**
  1625. * Interface used to define common properties for effect fallbacks
  1626. */
  1627. export interface IEffectFallbacks {
  1628. /**
  1629. * Removes the defines that should be removed when falling back.
  1630. * @param currentDefines defines the current define statements for the shader.
  1631. * @param effect defines the current effect we try to compile
  1632. * @returns The resulting defines with defines of the current rank removed.
  1633. */
  1634. reduce(currentDefines: string, effect: Effect): string;
  1635. /**
  1636. * Removes the fallback from the bound mesh.
  1637. */
  1638. unBindMesh(): void;
  1639. /**
  1640. * Checks to see if more fallbacks are still availible.
  1641. */
  1642. hasMoreFallbacks: boolean;
  1643. }
  1644. }
  1645. declare module "babylonjs/Maths/math.size" {
  1646. /**
  1647. * Interface for the size containing width and height
  1648. */
  1649. export interface ISize {
  1650. /**
  1651. * Width
  1652. */
  1653. width: number;
  1654. /**
  1655. * Heighht
  1656. */
  1657. height: number;
  1658. }
  1659. /**
  1660. * Size containing widht and height
  1661. */
  1662. export class Size implements ISize {
  1663. /**
  1664. * Width
  1665. */
  1666. width: number;
  1667. /**
  1668. * Height
  1669. */
  1670. height: number;
  1671. /**
  1672. * Creates a Size object from the given width and height (floats).
  1673. * @param width width of the new size
  1674. * @param height height of the new size
  1675. */
  1676. constructor(width: number, height: number);
  1677. /**
  1678. * Returns a string with the Size width and height
  1679. * @returns a string with the Size width and height
  1680. */
  1681. toString(): string;
  1682. /**
  1683. * "Size"
  1684. * @returns the string "Size"
  1685. */
  1686. getClassName(): string;
  1687. /**
  1688. * Returns the Size hash code.
  1689. * @returns a hash code for a unique width and height
  1690. */
  1691. getHashCode(): number;
  1692. /**
  1693. * Updates the current size from the given one.
  1694. * @param src the given size
  1695. */
  1696. copyFrom(src: Size): void;
  1697. /**
  1698. * Updates in place the current Size from the given floats.
  1699. * @param width width of the new size
  1700. * @param height height of the new size
  1701. * @returns the updated Size.
  1702. */
  1703. copyFromFloats(width: number, height: number): Size;
  1704. /**
  1705. * Updates in place the current Size from the given floats.
  1706. * @param width width to set
  1707. * @param height height to set
  1708. * @returns the updated Size.
  1709. */
  1710. set(width: number, height: number): Size;
  1711. /**
  1712. * Multiplies the width and height by numbers
  1713. * @param w factor to multiple the width by
  1714. * @param h factor to multiple the height by
  1715. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1716. */
  1717. multiplyByFloats(w: number, h: number): Size;
  1718. /**
  1719. * Clones the size
  1720. * @returns a new Size copied from the given one.
  1721. */
  1722. clone(): Size;
  1723. /**
  1724. * True if the current Size and the given one width and height are strictly equal.
  1725. * @param other the other size to compare against
  1726. * @returns True if the current Size and the given one width and height are strictly equal.
  1727. */
  1728. equals(other: Size): boolean;
  1729. /**
  1730. * The surface of the Size : width * height (float).
  1731. */
  1732. get surface(): number;
  1733. /**
  1734. * Create a new size of zero
  1735. * @returns a new Size set to (0.0, 0.0)
  1736. */
  1737. static Zero(): Size;
  1738. /**
  1739. * Sums the width and height of two sizes
  1740. * @param otherSize size to add to this size
  1741. * @returns a new Size set as the addition result of the current Size and the given one.
  1742. */
  1743. add(otherSize: Size): Size;
  1744. /**
  1745. * Subtracts the width and height of two
  1746. * @param otherSize size to subtract to this size
  1747. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1748. */
  1749. subtract(otherSize: Size): Size;
  1750. /**
  1751. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1752. * @param start starting size to lerp between
  1753. * @param end end size to lerp between
  1754. * @param amount amount to lerp between the start and end values
  1755. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1756. */
  1757. static Lerp(start: Size, end: Size, amount: number): Size;
  1758. }
  1759. }
  1760. declare module "babylonjs/Materials/Textures/thinTexture" {
  1761. import { Nullable } from "babylonjs/types";
  1762. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1763. import { ISize } from "babylonjs/Maths/math.size";
  1764. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1765. /**
  1766. * Base class of all the textures in babylon.
  1767. * It groups all the common properties required to work with Thin Engine.
  1768. */
  1769. export class ThinTexture {
  1770. protected _wrapU: number;
  1771. /**
  1772. * | Value | Type | Description |
  1773. * | ----- | ------------------ | ----------- |
  1774. * | 0 | CLAMP_ADDRESSMODE | |
  1775. * | 1 | WRAP_ADDRESSMODE | |
  1776. * | 2 | MIRROR_ADDRESSMODE | |
  1777. */
  1778. get wrapU(): number;
  1779. set wrapU(value: number);
  1780. protected _wrapV: number;
  1781. /**
  1782. * | Value | Type | Description |
  1783. * | ----- | ------------------ | ----------- |
  1784. * | 0 | CLAMP_ADDRESSMODE | |
  1785. * | 1 | WRAP_ADDRESSMODE | |
  1786. * | 2 | MIRROR_ADDRESSMODE | |
  1787. */
  1788. get wrapV(): number;
  1789. set wrapV(value: number);
  1790. /**
  1791. * | Value | Type | Description |
  1792. * | ----- | ------------------ | ----------- |
  1793. * | 0 | CLAMP_ADDRESSMODE | |
  1794. * | 1 | WRAP_ADDRESSMODE | |
  1795. * | 2 | MIRROR_ADDRESSMODE | |
  1796. */
  1797. wrapR: number;
  1798. /**
  1799. * With compliant hardware and browser (supporting anisotropic filtering)
  1800. * this defines the level of anisotropic filtering in the texture.
  1801. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  1802. */
  1803. anisotropicFilteringLevel: number;
  1804. /**
  1805. * Define the current state of the loading sequence when in delayed load mode.
  1806. */
  1807. delayLoadState: number;
  1808. /**
  1809. * How a texture is mapped.
  1810. * Unused in thin texture mode.
  1811. */
  1812. get coordinatesMode(): number;
  1813. /**
  1814. * Define if the texture is a cube texture or if false a 2d texture.
  1815. */
  1816. get isCube(): boolean;
  1817. set isCube(value: boolean);
  1818. /**
  1819. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  1820. */
  1821. get is3D(): boolean;
  1822. set is3D(value: boolean);
  1823. /**
  1824. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  1825. */
  1826. get is2DArray(): boolean;
  1827. set is2DArray(value: boolean);
  1828. /**
  1829. * Get the class name of the texture.
  1830. * @returns "ThinTexture"
  1831. */
  1832. getClassName(): string;
  1833. /** @hidden */
  1834. _texture: Nullable<InternalTexture>;
  1835. protected _engine: Nullable<ThinEngine>;
  1836. private _cachedSize;
  1837. private _cachedBaseSize;
  1838. /**
  1839. * Instantiates a new ThinTexture.
  1840. * Base class of all the textures in babylon.
  1841. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  1842. * @param internalTexture Define the internalTexture to wrap
  1843. */
  1844. constructor(internalTexture: Nullable<InternalTexture>);
  1845. /**
  1846. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  1847. * @returns true if fully ready
  1848. */
  1849. isReady(): boolean;
  1850. /**
  1851. * Triggers the load sequence in delayed load mode.
  1852. */
  1853. delayLoad(): void;
  1854. /**
  1855. * Get the underlying lower level texture from Babylon.
  1856. * @returns the insternal texture
  1857. */
  1858. getInternalTexture(): Nullable<InternalTexture>;
  1859. /**
  1860. * Get the size of the texture.
  1861. * @returns the texture size.
  1862. */
  1863. getSize(): ISize;
  1864. /**
  1865. * Get the base size of the texture.
  1866. * It can be different from the size if the texture has been resized for POT for instance
  1867. * @returns the base size
  1868. */
  1869. getBaseSize(): ISize;
  1870. /**
  1871. * Update the sampling mode of the texture.
  1872. * Default is Trilinear mode.
  1873. *
  1874. * | Value | Type | Description |
  1875. * | ----- | ------------------ | ----------- |
  1876. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  1877. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  1878. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  1879. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  1880. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  1881. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  1882. * | 7 | NEAREST_LINEAR | |
  1883. * | 8 | NEAREST_NEAREST | |
  1884. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  1885. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  1886. * | 11 | LINEAR_LINEAR | |
  1887. * | 12 | LINEAR_NEAREST | |
  1888. *
  1889. * > _mag_: magnification filter (close to the viewer)
  1890. * > _min_: minification filter (far from the viewer)
  1891. * > _mip_: filter used between mip map levels
  1892. *@param samplingMode Define the new sampling mode of the texture
  1893. */
  1894. updateSamplingMode(samplingMode: number): void;
  1895. /**
  1896. * Release and destroy the underlying lower level texture aka internalTexture.
  1897. */
  1898. releaseInternalTexture(): void;
  1899. /**
  1900. * Dispose the texture and release its associated resources.
  1901. */
  1902. dispose(): void;
  1903. }
  1904. }
  1905. declare module "babylonjs/Misc/smartArray" {
  1906. /**
  1907. * Defines an array and its length.
  1908. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  1909. */
  1910. export interface ISmartArrayLike<T> {
  1911. /**
  1912. * The data of the array.
  1913. */
  1914. data: Array<T>;
  1915. /**
  1916. * The active length of the array.
  1917. */
  1918. length: number;
  1919. }
  1920. /**
  1921. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1922. */
  1923. export class SmartArray<T> implements ISmartArrayLike<T> {
  1924. /**
  1925. * The full set of data from the array.
  1926. */
  1927. data: Array<T>;
  1928. /**
  1929. * The active length of the array.
  1930. */
  1931. length: number;
  1932. protected _id: number;
  1933. /**
  1934. * Instantiates a Smart Array.
  1935. * @param capacity defines the default capacity of the array.
  1936. */
  1937. constructor(capacity: number);
  1938. /**
  1939. * Pushes a value at the end of the active data.
  1940. * @param value defines the object to push in the array.
  1941. */
  1942. push(value: T): void;
  1943. /**
  1944. * Iterates over the active data and apply the lambda to them.
  1945. * @param func defines the action to apply on each value.
  1946. */
  1947. forEach(func: (content: T) => void): void;
  1948. /**
  1949. * Sorts the full sets of data.
  1950. * @param compareFn defines the comparison function to apply.
  1951. */
  1952. sort(compareFn: (a: T, b: T) => number): void;
  1953. /**
  1954. * Resets the active data to an empty array.
  1955. */
  1956. reset(): void;
  1957. /**
  1958. * Releases all the data from the array as well as the array.
  1959. */
  1960. dispose(): void;
  1961. /**
  1962. * Concats the active data with a given array.
  1963. * @param array defines the data to concatenate with.
  1964. */
  1965. concat(array: any): void;
  1966. /**
  1967. * Returns the position of a value in the active data.
  1968. * @param value defines the value to find the index for
  1969. * @returns the index if found in the active data otherwise -1
  1970. */
  1971. indexOf(value: T): number;
  1972. /**
  1973. * Returns whether an element is part of the active data.
  1974. * @param value defines the value to look for
  1975. * @returns true if found in the active data otherwise false
  1976. */
  1977. contains(value: T): boolean;
  1978. private static _GlobalId;
  1979. }
  1980. /**
  1981. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  1982. * The data in this array can only be present once
  1983. */
  1984. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  1985. private _duplicateId;
  1986. /**
  1987. * Pushes a value at the end of the active data.
  1988. * THIS DOES NOT PREVENT DUPPLICATE DATA
  1989. * @param value defines the object to push in the array.
  1990. */
  1991. push(value: T): void;
  1992. /**
  1993. * Pushes a value at the end of the active data.
  1994. * If the data is already present, it won t be added again
  1995. * @param value defines the object to push in the array.
  1996. * @returns true if added false if it was already present
  1997. */
  1998. pushNoDuplicate(value: T): boolean;
  1999. /**
  2000. * Resets the active data to an empty array.
  2001. */
  2002. reset(): void;
  2003. /**
  2004. * Concats the active data with a given array.
  2005. * This ensures no dupplicate will be present in the result.
  2006. * @param array defines the data to concatenate with.
  2007. */
  2008. concatWithNoDuplicate(array: any): void;
  2009. }
  2010. }
  2011. declare module "babylonjs/Misc/andOrNotEvaluator" {
  2012. /**
  2013. * Class used to evalaute queries containing `and` and `or` operators
  2014. */
  2015. export class AndOrNotEvaluator {
  2016. /**
  2017. * Evaluate a query
  2018. * @param query defines the query to evaluate
  2019. * @param evaluateCallback defines the callback used to filter result
  2020. * @returns true if the query matches
  2021. */
  2022. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2023. private static _HandleParenthesisContent;
  2024. private static _SimplifyNegation;
  2025. }
  2026. }
  2027. declare module "babylonjs/Misc/tags" {
  2028. /**
  2029. * Class used to store custom tags
  2030. */
  2031. export class Tags {
  2032. /**
  2033. * Adds support for tags on the given object
  2034. * @param obj defines the object to use
  2035. */
  2036. static EnableFor(obj: any): void;
  2037. /**
  2038. * Removes tags support
  2039. * @param obj defines the object to use
  2040. */
  2041. static DisableFor(obj: any): void;
  2042. /**
  2043. * Gets a boolean indicating if the given object has tags
  2044. * @param obj defines the object to use
  2045. * @returns a boolean
  2046. */
  2047. static HasTags(obj: any): boolean;
  2048. /**
  2049. * Gets the tags available on a given object
  2050. * @param obj defines the object to use
  2051. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2052. * @returns the tags
  2053. */
  2054. static GetTags(obj: any, asString?: boolean): any;
  2055. /**
  2056. * Adds tags to an object
  2057. * @param obj defines the object to use
  2058. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2059. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2060. */
  2061. static AddTagsTo(obj: any, tagsString: string): void;
  2062. /**
  2063. * @hidden
  2064. */
  2065. static _AddTagTo(obj: any, tag: string): void;
  2066. /**
  2067. * Removes specific tags from a specific object
  2068. * @param obj defines the object to use
  2069. * @param tagsString defines the tags to remove
  2070. */
  2071. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2072. /**
  2073. * @hidden
  2074. */
  2075. static _RemoveTagFrom(obj: any, tag: string): void;
  2076. /**
  2077. * Defines if tags hosted on an object match a given query
  2078. * @param obj defines the object to use
  2079. * @param tagsQuery defines the tag query
  2080. * @returns a boolean
  2081. */
  2082. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2083. }
  2084. }
  2085. declare module "babylonjs/Maths/math.scalar" {
  2086. /**
  2087. * Scalar computation library
  2088. */
  2089. export class Scalar {
  2090. /**
  2091. * Two pi constants convenient for computation.
  2092. */
  2093. static TwoPi: number;
  2094. /**
  2095. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2096. * @param a number
  2097. * @param b number
  2098. * @param epsilon (default = 1.401298E-45)
  2099. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2100. */
  2101. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2102. /**
  2103. * Returns a string : the upper case translation of the number i to hexadecimal.
  2104. * @param i number
  2105. * @returns the upper case translation of the number i to hexadecimal.
  2106. */
  2107. static ToHex(i: number): string;
  2108. /**
  2109. * Returns -1 if value is negative and +1 is value is positive.
  2110. * @param value the value
  2111. * @returns the value itself if it's equal to zero.
  2112. */
  2113. static Sign(value: number): number;
  2114. /**
  2115. * Returns the value itself if it's between min and max.
  2116. * Returns min if the value is lower than min.
  2117. * Returns max if the value is greater than max.
  2118. * @param value the value to clmap
  2119. * @param min the min value to clamp to (default: 0)
  2120. * @param max the max value to clamp to (default: 1)
  2121. * @returns the clamped value
  2122. */
  2123. static Clamp(value: number, min?: number, max?: number): number;
  2124. /**
  2125. * the log2 of value.
  2126. * @param value the value to compute log2 of
  2127. * @returns the log2 of value.
  2128. */
  2129. static Log2(value: number): number;
  2130. /**
  2131. * Loops the value, so that it is never larger than length and never smaller than 0.
  2132. *
  2133. * This is similar to the modulo operator but it works with floating point numbers.
  2134. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2135. * With t = 5 and length = 2.5, the result would be 0.0.
  2136. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2137. * @param value the value
  2138. * @param length the length
  2139. * @returns the looped value
  2140. */
  2141. static Repeat(value: number, length: number): number;
  2142. /**
  2143. * Normalize the value between 0.0 and 1.0 using min and max values
  2144. * @param value value to normalize
  2145. * @param min max to normalize between
  2146. * @param max min to normalize between
  2147. * @returns the normalized value
  2148. */
  2149. static Normalize(value: number, min: number, max: number): number;
  2150. /**
  2151. * Denormalize the value from 0.0 and 1.0 using min and max values
  2152. * @param normalized value to denormalize
  2153. * @param min max to denormalize between
  2154. * @param max min to denormalize between
  2155. * @returns the denormalized value
  2156. */
  2157. static Denormalize(normalized: number, min: number, max: number): number;
  2158. /**
  2159. * Calculates the shortest difference between two given angles given in degrees.
  2160. * @param current current angle in degrees
  2161. * @param target target angle in degrees
  2162. * @returns the delta
  2163. */
  2164. static DeltaAngle(current: number, target: number): number;
  2165. /**
  2166. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2167. * @param tx value
  2168. * @param length length
  2169. * @returns The returned value will move back and forth between 0 and length
  2170. */
  2171. static PingPong(tx: number, length: number): number;
  2172. /**
  2173. * Interpolates between min and max with smoothing at the limits.
  2174. *
  2175. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2176. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2177. * @param from from
  2178. * @param to to
  2179. * @param tx value
  2180. * @returns the smooth stepped value
  2181. */
  2182. static SmoothStep(from: number, to: number, tx: number): number;
  2183. /**
  2184. * Moves a value current towards target.
  2185. *
  2186. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2187. * Negative values of maxDelta pushes the value away from target.
  2188. * @param current current value
  2189. * @param target target value
  2190. * @param maxDelta max distance to move
  2191. * @returns resulting value
  2192. */
  2193. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2194. /**
  2195. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2196. *
  2197. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2198. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2199. * @param current current value
  2200. * @param target target value
  2201. * @param maxDelta max distance to move
  2202. * @returns resulting angle
  2203. */
  2204. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2205. /**
  2206. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2207. * @param start start value
  2208. * @param end target value
  2209. * @param amount amount to lerp between
  2210. * @returns the lerped value
  2211. */
  2212. static Lerp(start: number, end: number, amount: number): number;
  2213. /**
  2214. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2215. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2216. * @param start start value
  2217. * @param end target value
  2218. * @param amount amount to lerp between
  2219. * @returns the lerped value
  2220. */
  2221. static LerpAngle(start: number, end: number, amount: number): number;
  2222. /**
  2223. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2224. * @param a start value
  2225. * @param b target value
  2226. * @param value value between a and b
  2227. * @returns the inverseLerp value
  2228. */
  2229. static InverseLerp(a: number, b: number, value: number): number;
  2230. /**
  2231. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2232. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2233. * @param value1 spline value
  2234. * @param tangent1 spline value
  2235. * @param value2 spline value
  2236. * @param tangent2 spline value
  2237. * @param amount input value
  2238. * @returns hermite result
  2239. */
  2240. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2241. /**
  2242. * Returns a random float number between and min and max values
  2243. * @param min min value of random
  2244. * @param max max value of random
  2245. * @returns random value
  2246. */
  2247. static RandomRange(min: number, max: number): number;
  2248. /**
  2249. * This function returns percentage of a number in a given range.
  2250. *
  2251. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2252. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2253. * @param number to convert to percentage
  2254. * @param min min range
  2255. * @param max max range
  2256. * @returns the percentage
  2257. */
  2258. static RangeToPercent(number: number, min: number, max: number): number;
  2259. /**
  2260. * This function returns number that corresponds to the percentage in a given range.
  2261. *
  2262. * PercentToRange(0.34,0,100) will return 34.
  2263. * @param percent to convert to number
  2264. * @param min min range
  2265. * @param max max range
  2266. * @returns the number
  2267. */
  2268. static PercentToRange(percent: number, min: number, max: number): number;
  2269. /**
  2270. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2271. * @param angle The angle to normalize in radian.
  2272. * @return The converted angle.
  2273. */
  2274. static NormalizeRadians(angle: number): number;
  2275. }
  2276. }
  2277. declare module "babylonjs/Maths/math.constants" {
  2278. /**
  2279. * Constant used to convert a value to gamma space
  2280. * @ignorenaming
  2281. */
  2282. export const ToGammaSpace: number;
  2283. /**
  2284. * Constant used to convert a value to linear space
  2285. * @ignorenaming
  2286. */
  2287. export const ToLinearSpace = 2.2;
  2288. /**
  2289. * Constant used to define the minimal number value in Babylon.js
  2290. * @ignorenaming
  2291. */
  2292. let Epsilon: number;
  2293. export { Epsilon };
  2294. }
  2295. declare module "babylonjs/Maths/math.viewport" {
  2296. /**
  2297. * Class used to represent a viewport on screen
  2298. */
  2299. export class Viewport {
  2300. /** viewport left coordinate */
  2301. x: number;
  2302. /** viewport top coordinate */
  2303. y: number;
  2304. /**viewport width */
  2305. width: number;
  2306. /** viewport height */
  2307. height: number;
  2308. /**
  2309. * Creates a Viewport object located at (x, y) and sized (width, height)
  2310. * @param x defines viewport left coordinate
  2311. * @param y defines viewport top coordinate
  2312. * @param width defines the viewport width
  2313. * @param height defines the viewport height
  2314. */
  2315. constructor(
  2316. /** viewport left coordinate */
  2317. x: number,
  2318. /** viewport top coordinate */
  2319. y: number,
  2320. /**viewport width */
  2321. width: number,
  2322. /** viewport height */
  2323. height: number);
  2324. /**
  2325. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2326. * @param renderWidth defines the rendering width
  2327. * @param renderHeight defines the rendering height
  2328. * @returns a new Viewport
  2329. */
  2330. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2331. /**
  2332. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2333. * @param renderWidth defines the rendering width
  2334. * @param renderHeight defines the rendering height
  2335. * @param ref defines the target viewport
  2336. * @returns the current viewport
  2337. */
  2338. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2339. /**
  2340. * Returns a new Viewport copied from the current one
  2341. * @returns a new Viewport
  2342. */
  2343. clone(): Viewport;
  2344. }
  2345. }
  2346. declare module "babylonjs/Misc/arrayTools" {
  2347. /**
  2348. * Class containing a set of static utilities functions for arrays.
  2349. */
  2350. export class ArrayTools {
  2351. /**
  2352. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2353. * @param size the number of element to construct and put in the array
  2354. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2355. * @returns a new array filled with new objects
  2356. */
  2357. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2358. }
  2359. }
  2360. declare module "babylonjs/Maths/math.plane" {
  2361. import { DeepImmutable } from "babylonjs/types";
  2362. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  2363. /**
  2364. * Represents a plane by the equation ax + by + cz + d = 0
  2365. */
  2366. export class Plane {
  2367. private static _TmpMatrix;
  2368. /**
  2369. * Normal of the plane (a,b,c)
  2370. */
  2371. normal: Vector3;
  2372. /**
  2373. * d component of the plane
  2374. */
  2375. d: number;
  2376. /**
  2377. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2378. * @param a a component of the plane
  2379. * @param b b component of the plane
  2380. * @param c c component of the plane
  2381. * @param d d component of the plane
  2382. */
  2383. constructor(a: number, b: number, c: number, d: number);
  2384. /**
  2385. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2386. */
  2387. asArray(): number[];
  2388. /**
  2389. * @returns a new plane copied from the current Plane.
  2390. */
  2391. clone(): Plane;
  2392. /**
  2393. * @returns the string "Plane".
  2394. */
  2395. getClassName(): string;
  2396. /**
  2397. * @returns the Plane hash code.
  2398. */
  2399. getHashCode(): number;
  2400. /**
  2401. * Normalize the current Plane in place.
  2402. * @returns the updated Plane.
  2403. */
  2404. normalize(): Plane;
  2405. /**
  2406. * Applies a transformation the plane and returns the result
  2407. * @param transformation the transformation matrix to be applied to the plane
  2408. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2409. */
  2410. transform(transformation: DeepImmutable<Matrix>): Plane;
  2411. /**
  2412. * Compute the dot product between the point and the plane normal
  2413. * @param point point to calculate the dot product with
  2414. * @returns the dot product (float) of the point coordinates and the plane normal.
  2415. */
  2416. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2417. /**
  2418. * Updates the current Plane from the plane defined by the three given points.
  2419. * @param point1 one of the points used to contruct the plane
  2420. * @param point2 one of the points used to contruct the plane
  2421. * @param point3 one of the points used to contruct the plane
  2422. * @returns the updated Plane.
  2423. */
  2424. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2425. /**
  2426. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2427. * Note that for this function to work as expected you should make sure that:
  2428. * - direction and the plane normal are normalized
  2429. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2430. * @param direction the direction to check if the plane is facing
  2431. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2432. * @returns True if the plane is facing the given direction
  2433. */
  2434. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2435. /**
  2436. * Calculates the distance to a point
  2437. * @param point point to calculate distance to
  2438. * @returns the signed distance (float) from the given point to the Plane.
  2439. */
  2440. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2441. /**
  2442. * Creates a plane from an array
  2443. * @param array the array to create a plane from
  2444. * @returns a new Plane from the given array.
  2445. */
  2446. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2447. /**
  2448. * Creates a plane from three points
  2449. * @param point1 point used to create the plane
  2450. * @param point2 point used to create the plane
  2451. * @param point3 point used to create the plane
  2452. * @returns a new Plane defined by the three given points.
  2453. */
  2454. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2455. /**
  2456. * Creates a plane from an origin point and a normal
  2457. * @param origin origin of the plane to be constructed
  2458. * @param normal normal of the plane to be constructed
  2459. * @returns a new Plane the normal vector to this plane at the given origin point.
  2460. * Note : the vector "normal" is updated because normalized.
  2461. */
  2462. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2463. /**
  2464. * Calculates the distance from a plane and a point
  2465. * @param origin origin of the plane to be constructed
  2466. * @param normal normal of the plane to be constructed
  2467. * @param point point to calculate distance to
  2468. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2469. */
  2470. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2471. }
  2472. }
  2473. declare module "babylonjs/Engines/performanceConfigurator" {
  2474. /** @hidden */
  2475. export class PerformanceConfigurator {
  2476. /** @hidden */
  2477. static MatrixUse64Bits: boolean;
  2478. /** @hidden */
  2479. static MatrixTrackPrecisionChange: boolean;
  2480. /** @hidden */
  2481. static MatrixCurrentType: any;
  2482. /** @hidden */
  2483. static MatrixTrackedMatrices: Array<any> | null;
  2484. /** @hidden */
  2485. static SetMatrixPrecision(use64bits: boolean): void;
  2486. }
  2487. }
  2488. declare module "babylonjs/Maths/math.vector" {
  2489. import { Viewport } from "babylonjs/Maths/math.viewport";
  2490. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2491. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2492. import { Plane } from "babylonjs/Maths/math.plane";
  2493. /**
  2494. * Class representing a vector containing 2 coordinates
  2495. */
  2496. export class Vector2 {
  2497. /** defines the first coordinate */
  2498. x: number;
  2499. /** defines the second coordinate */
  2500. y: number;
  2501. /**
  2502. * Creates a new Vector2 from the given x and y coordinates
  2503. * @param x defines the first coordinate
  2504. * @param y defines the second coordinate
  2505. */
  2506. constructor(
  2507. /** defines the first coordinate */
  2508. x?: number,
  2509. /** defines the second coordinate */
  2510. y?: number);
  2511. /**
  2512. * Gets a string with the Vector2 coordinates
  2513. * @returns a string with the Vector2 coordinates
  2514. */
  2515. toString(): string;
  2516. /**
  2517. * Gets class name
  2518. * @returns the string "Vector2"
  2519. */
  2520. getClassName(): string;
  2521. /**
  2522. * Gets current vector hash code
  2523. * @returns the Vector2 hash code as a number
  2524. */
  2525. getHashCode(): number;
  2526. /**
  2527. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2528. * @param array defines the source array
  2529. * @param index defines the offset in source array
  2530. * @returns the current Vector2
  2531. */
  2532. toArray(array: FloatArray, index?: number): Vector2;
  2533. /**
  2534. * Update the current vector from an array
  2535. * @param array defines the destination array
  2536. * @param index defines the offset in the destination array
  2537. * @returns the current Vector3
  2538. */
  2539. fromArray(array: FloatArray, index?: number): Vector2;
  2540. /**
  2541. * Copy the current vector to an array
  2542. * @returns a new array with 2 elements: the Vector2 coordinates.
  2543. */
  2544. asArray(): number[];
  2545. /**
  2546. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2547. * @param source defines the source Vector2
  2548. * @returns the current updated Vector2
  2549. */
  2550. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2551. /**
  2552. * Sets the Vector2 coordinates with the given floats
  2553. * @param x defines the first coordinate
  2554. * @param y defines the second coordinate
  2555. * @returns the current updated Vector2
  2556. */
  2557. copyFromFloats(x: number, y: number): Vector2;
  2558. /**
  2559. * Sets the Vector2 coordinates with the given floats
  2560. * @param x defines the first coordinate
  2561. * @param y defines the second coordinate
  2562. * @returns the current updated Vector2
  2563. */
  2564. set(x: number, y: number): Vector2;
  2565. /**
  2566. * Add another vector with the current one
  2567. * @param otherVector defines the other vector
  2568. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2569. */
  2570. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2571. /**
  2572. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2573. * @param otherVector defines the other vector
  2574. * @param result defines the target vector
  2575. * @returns the unmodified current Vector2
  2576. */
  2577. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2578. /**
  2579. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2580. * @param otherVector defines the other vector
  2581. * @returns the current updated Vector2
  2582. */
  2583. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2584. /**
  2585. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2586. * @param otherVector defines the other vector
  2587. * @returns a new Vector2
  2588. */
  2589. addVector3(otherVector: Vector3): Vector2;
  2590. /**
  2591. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2592. * @param otherVector defines the other vector
  2593. * @returns a new Vector2
  2594. */
  2595. subtract(otherVector: Vector2): Vector2;
  2596. /**
  2597. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2598. * @param otherVector defines the other vector
  2599. * @param result defines the target vector
  2600. * @returns the unmodified current Vector2
  2601. */
  2602. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2603. /**
  2604. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2605. * @param otherVector defines the other vector
  2606. * @returns the current updated Vector2
  2607. */
  2608. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2609. /**
  2610. * Multiplies in place the current Vector2 coordinates by the given ones
  2611. * @param otherVector defines the other vector
  2612. * @returns the current updated Vector2
  2613. */
  2614. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2615. /**
  2616. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2617. * @param otherVector defines the other vector
  2618. * @returns a new Vector2
  2619. */
  2620. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2621. /**
  2622. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2623. * @param otherVector defines the other vector
  2624. * @param result defines the target vector
  2625. * @returns the unmodified current Vector2
  2626. */
  2627. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2628. /**
  2629. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2630. * @param x defines the first coordinate
  2631. * @param y defines the second coordinate
  2632. * @returns a new Vector2
  2633. */
  2634. multiplyByFloats(x: number, y: number): Vector2;
  2635. /**
  2636. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2637. * @param otherVector defines the other vector
  2638. * @returns a new Vector2
  2639. */
  2640. divide(otherVector: Vector2): Vector2;
  2641. /**
  2642. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2643. * @param otherVector defines the other vector
  2644. * @param result defines the target vector
  2645. * @returns the unmodified current Vector2
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2648. /**
  2649. * Divides the current Vector2 coordinates by the given ones
  2650. * @param otherVector defines the other vector
  2651. * @returns the current updated Vector2
  2652. */
  2653. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2654. /**
  2655. * Gets a new Vector2 with current Vector2 negated coordinates
  2656. * @returns a new Vector2
  2657. */
  2658. negate(): Vector2;
  2659. /**
  2660. * Negate this vector in place
  2661. * @returns this
  2662. */
  2663. negateInPlace(): Vector2;
  2664. /**
  2665. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2666. * @param result defines the Vector3 object where to store the result
  2667. * @returns the current Vector2
  2668. */
  2669. negateToRef(result: Vector2): Vector2;
  2670. /**
  2671. * Multiply the Vector2 coordinates by scale
  2672. * @param scale defines the scaling factor
  2673. * @returns the current updated Vector2
  2674. */
  2675. scaleInPlace(scale: number): Vector2;
  2676. /**
  2677. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2678. * @param scale defines the scaling factor
  2679. * @returns a new Vector2
  2680. */
  2681. scale(scale: number): Vector2;
  2682. /**
  2683. * Scale the current Vector2 values by a factor to a given Vector2
  2684. * @param scale defines the scale factor
  2685. * @param result defines the Vector2 object where to store the result
  2686. * @returns the unmodified current Vector2
  2687. */
  2688. scaleToRef(scale: number, result: Vector2): Vector2;
  2689. /**
  2690. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2691. * @param scale defines the scale factor
  2692. * @param result defines the Vector2 object where to store the result
  2693. * @returns the unmodified current Vector2
  2694. */
  2695. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2696. /**
  2697. * Gets a boolean if two vectors are equals
  2698. * @param otherVector defines the other vector
  2699. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2700. */
  2701. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2702. /**
  2703. * Gets a boolean if two vectors are equals (using an epsilon value)
  2704. * @param otherVector defines the other vector
  2705. * @param epsilon defines the minimal distance to consider equality
  2706. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2707. */
  2708. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2709. /**
  2710. * Gets a new Vector2 from current Vector2 floored values
  2711. * @returns a new Vector2
  2712. */
  2713. floor(): Vector2;
  2714. /**
  2715. * Gets a new Vector2 from current Vector2 floored values
  2716. * @returns a new Vector2
  2717. */
  2718. fract(): Vector2;
  2719. /**
  2720. * Gets the length of the vector
  2721. * @returns the vector length (float)
  2722. */
  2723. length(): number;
  2724. /**
  2725. * Gets the vector squared length
  2726. * @returns the vector squared length (float)
  2727. */
  2728. lengthSquared(): number;
  2729. /**
  2730. * Normalize the vector
  2731. * @returns the current updated Vector2
  2732. */
  2733. normalize(): Vector2;
  2734. /**
  2735. * Gets a new Vector2 copied from the Vector2
  2736. * @returns a new Vector2
  2737. */
  2738. clone(): Vector2;
  2739. /**
  2740. * Gets a new Vector2(0, 0)
  2741. * @returns a new Vector2
  2742. */
  2743. static Zero(): Vector2;
  2744. /**
  2745. * Gets a new Vector2(1, 1)
  2746. * @returns a new Vector2
  2747. */
  2748. static One(): Vector2;
  2749. /**
  2750. * Gets a new Vector2 set from the given index element of the given array
  2751. * @param array defines the data source
  2752. * @param offset defines the offset in the data source
  2753. * @returns a new Vector2
  2754. */
  2755. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2756. /**
  2757. * Sets "result" from the given index element of the given array
  2758. * @param array defines the data source
  2759. * @param offset defines the offset in the data source
  2760. * @param result defines the target vector
  2761. */
  2762. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2763. /**
  2764. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2765. * @param value1 defines 1st point of control
  2766. * @param value2 defines 2nd point of control
  2767. * @param value3 defines 3rd point of control
  2768. * @param value4 defines 4th point of control
  2769. * @param amount defines the interpolation factor
  2770. * @returns a new Vector2
  2771. */
  2772. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2773. /**
  2774. * 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".
  2775. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2776. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2777. * @param value defines the value to clamp
  2778. * @param min defines the lower limit
  2779. * @param max defines the upper limit
  2780. * @returns a new Vector2
  2781. */
  2782. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2785. * @param value1 defines the 1st control point
  2786. * @param tangent1 defines the outgoing tangent
  2787. * @param value2 defines the 2nd control point
  2788. * @param tangent2 defines the incoming tangent
  2789. * @param amount defines the interpolation factor
  2790. * @returns a new Vector2
  2791. */
  2792. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2793. /**
  2794. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2795. * @param start defines the start vector
  2796. * @param end defines the end vector
  2797. * @param amount defines the interpolation factor
  2798. * @returns a new Vector2
  2799. */
  2800. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2801. /**
  2802. * Gets the dot product of the vector "left" and the vector "right"
  2803. * @param left defines first vector
  2804. * @param right defines second vector
  2805. * @returns the dot product (float)
  2806. */
  2807. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2808. /**
  2809. * Returns a new Vector2 equal to the normalized given vector
  2810. * @param vector defines the vector to normalize
  2811. * @returns a new Vector2
  2812. */
  2813. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2814. /**
  2815. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2816. * @param left defines 1st vector
  2817. * @param right defines 2nd vector
  2818. * @returns a new Vector2
  2819. */
  2820. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2821. /**
  2822. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2823. * @param left defines 1st vector
  2824. * @param right defines 2nd vector
  2825. * @returns a new Vector2
  2826. */
  2827. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2828. /**
  2829. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2830. * @param vector defines the vector to transform
  2831. * @param transformation defines the matrix to apply
  2832. * @returns a new Vector2
  2833. */
  2834. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2835. /**
  2836. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2837. * @param vector defines the vector to transform
  2838. * @param transformation defines the matrix to apply
  2839. * @param result defines the target vector
  2840. */
  2841. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2842. /**
  2843. * Determines if a given vector is included in a triangle
  2844. * @param p defines the vector to test
  2845. * @param p0 defines 1st triangle point
  2846. * @param p1 defines 2nd triangle point
  2847. * @param p2 defines 3rd triangle point
  2848. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2849. */
  2850. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2851. /**
  2852. * Gets the distance between the vectors "value1" and "value2"
  2853. * @param value1 defines first vector
  2854. * @param value2 defines second vector
  2855. * @returns the distance between vectors
  2856. */
  2857. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2858. /**
  2859. * Returns the squared distance between the vectors "value1" and "value2"
  2860. * @param value1 defines first vector
  2861. * @param value2 defines second vector
  2862. * @returns the squared distance between vectors
  2863. */
  2864. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2865. /**
  2866. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2867. * @param value1 defines first vector
  2868. * @param value2 defines second vector
  2869. * @returns a new Vector2
  2870. */
  2871. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2872. /**
  2873. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2874. * @param p defines the middle point
  2875. * @param segA defines one point of the segment
  2876. * @param segB defines the other point of the segment
  2877. * @returns the shortest distance
  2878. */
  2879. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2880. }
  2881. /**
  2882. * Class used to store (x,y,z) vector representation
  2883. * A Vector3 is the main object used in 3D geometry
  2884. * It can represent etiher the coordinates of a point the space, either a direction
  2885. * Reminder: js uses a left handed forward facing system
  2886. */
  2887. export class Vector3 {
  2888. private static _UpReadOnly;
  2889. private static _ZeroReadOnly;
  2890. /** @hidden */
  2891. _x: number;
  2892. /** @hidden */
  2893. _y: number;
  2894. /** @hidden */
  2895. _z: number;
  2896. /** @hidden */
  2897. _isDirty: boolean;
  2898. /** Gets or sets the x coordinate */
  2899. get x(): number;
  2900. set x(value: number);
  2901. /** Gets or sets the y coordinate */
  2902. get y(): number;
  2903. set y(value: number);
  2904. /** Gets or sets the z coordinate */
  2905. get z(): number;
  2906. set z(value: number);
  2907. /**
  2908. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2909. * @param x defines the first coordinates (on X axis)
  2910. * @param y defines the second coordinates (on Y axis)
  2911. * @param z defines the third coordinates (on Z axis)
  2912. */
  2913. constructor(x?: number, y?: number, z?: number);
  2914. /**
  2915. * Creates a string representation of the Vector3
  2916. * @returns a string with the Vector3 coordinates.
  2917. */
  2918. toString(): string;
  2919. /**
  2920. * Gets the class name
  2921. * @returns the string "Vector3"
  2922. */
  2923. getClassName(): string;
  2924. /**
  2925. * Creates the Vector3 hash code
  2926. * @returns a number which tends to be unique between Vector3 instances
  2927. */
  2928. getHashCode(): number;
  2929. /**
  2930. * Creates an array containing three elements : the coordinates of the Vector3
  2931. * @returns a new array of numbers
  2932. */
  2933. asArray(): number[];
  2934. /**
  2935. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2936. * @param array defines the destination array
  2937. * @param index defines the offset in the destination array
  2938. * @returns the current Vector3
  2939. */
  2940. toArray(array: FloatArray, index?: number): Vector3;
  2941. /**
  2942. * Update the current vector from an array
  2943. * @param array defines the destination array
  2944. * @param index defines the offset in the destination array
  2945. * @returns the current Vector3
  2946. */
  2947. fromArray(array: FloatArray, index?: number): Vector3;
  2948. /**
  2949. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2950. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2951. */
  2952. toQuaternion(): Quaternion;
  2953. /**
  2954. * Adds the given vector to the current Vector3
  2955. * @param otherVector defines the second operand
  2956. * @returns the current updated Vector3
  2957. */
  2958. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2959. /**
  2960. * Adds the given coordinates to the current Vector3
  2961. * @param x defines the x coordinate of the operand
  2962. * @param y defines the y coordinate of the operand
  2963. * @param z defines the z coordinate of the operand
  2964. * @returns the current updated Vector3
  2965. */
  2966. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2967. /**
  2968. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2969. * @param otherVector defines the second operand
  2970. * @returns the resulting Vector3
  2971. */
  2972. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2973. /**
  2974. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2975. * @param otherVector defines the second operand
  2976. * @param result defines the Vector3 object where to store the result
  2977. * @returns the current Vector3
  2978. */
  2979. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2980. /**
  2981. * Subtract the given vector from the current Vector3
  2982. * @param otherVector defines the second operand
  2983. * @returns the current updated Vector3
  2984. */
  2985. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2986. /**
  2987. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2988. * @param otherVector defines the second operand
  2989. * @returns the resulting Vector3
  2990. */
  2991. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2994. * @param otherVector defines the second operand
  2995. * @param result defines the Vector3 object where to store the result
  2996. * @returns the current Vector3
  2997. */
  2998. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3001. * @param x defines the x coordinate of the operand
  3002. * @param y defines the y coordinate of the operand
  3003. * @param z defines the z coordinate of the operand
  3004. * @returns the resulting Vector3
  3005. */
  3006. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3007. /**
  3008. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3009. * @param x defines the x coordinate of the operand
  3010. * @param y defines the y coordinate of the operand
  3011. * @param z defines the z coordinate of the operand
  3012. * @param result defines the Vector3 object where to store the result
  3013. * @returns the current Vector3
  3014. */
  3015. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3016. /**
  3017. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3018. * @returns a new Vector3
  3019. */
  3020. negate(): Vector3;
  3021. /**
  3022. * Negate this vector in place
  3023. * @returns this
  3024. */
  3025. negateInPlace(): Vector3;
  3026. /**
  3027. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3028. * @param result defines the Vector3 object where to store the result
  3029. * @returns the current Vector3
  3030. */
  3031. negateToRef(result: Vector3): Vector3;
  3032. /**
  3033. * Multiplies the Vector3 coordinates by the float "scale"
  3034. * @param scale defines the multiplier factor
  3035. * @returns the current updated Vector3
  3036. */
  3037. scaleInPlace(scale: number): Vector3;
  3038. /**
  3039. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3040. * @param scale defines the multiplier factor
  3041. * @returns a new Vector3
  3042. */
  3043. scale(scale: number): Vector3;
  3044. /**
  3045. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3046. * @param scale defines the multiplier factor
  3047. * @param result defines the Vector3 object where to store the result
  3048. * @returns the current Vector3
  3049. */
  3050. scaleToRef(scale: number, result: Vector3): Vector3;
  3051. /**
  3052. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3053. * @param scale defines the scale factor
  3054. * @param result defines the Vector3 object where to store the result
  3055. * @returns the unmodified current Vector3
  3056. */
  3057. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3058. /**
  3059. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3060. * @param origin defines the origin of the projection ray
  3061. * @param plane defines the plane to project to
  3062. * @returns the projected vector3
  3063. */
  3064. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3065. /**
  3066. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3067. * @param origin defines the origin of the projection ray
  3068. * @param plane defines the plane to project to
  3069. * @param result defines the Vector3 where to store the result
  3070. */
  3071. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3072. /**
  3073. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3074. * @param otherVector defines the second operand
  3075. * @returns true if both vectors are equals
  3076. */
  3077. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3078. /**
  3079. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3080. * @param otherVector defines the second operand
  3081. * @param epsilon defines the minimal distance to define values as equals
  3082. * @returns true if both vectors are distant less than epsilon
  3083. */
  3084. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3085. /**
  3086. * Returns true if the current Vector3 coordinates equals the given floats
  3087. * @param x defines the x coordinate of the operand
  3088. * @param y defines the y coordinate of the operand
  3089. * @param z defines the z coordinate of the operand
  3090. * @returns true if both vectors are equals
  3091. */
  3092. equalsToFloats(x: number, y: number, z: number): boolean;
  3093. /**
  3094. * Multiplies the current Vector3 coordinates by the given ones
  3095. * @param otherVector defines the second operand
  3096. * @returns the current updated Vector3
  3097. */
  3098. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3099. /**
  3100. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3101. * @param otherVector defines the second operand
  3102. * @returns the new Vector3
  3103. */
  3104. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3105. /**
  3106. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3107. * @param otherVector defines the second operand
  3108. * @param result defines the Vector3 object where to store the result
  3109. * @returns the current Vector3
  3110. */
  3111. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3112. /**
  3113. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3114. * @param x defines the x coordinate of the operand
  3115. * @param y defines the y coordinate of the operand
  3116. * @param z defines the z coordinate of the operand
  3117. * @returns the new Vector3
  3118. */
  3119. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3120. /**
  3121. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3122. * @param otherVector defines the second operand
  3123. * @returns the new Vector3
  3124. */
  3125. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3126. /**
  3127. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3128. * @param otherVector defines the second operand
  3129. * @param result defines the Vector3 object where to store the result
  3130. * @returns the current Vector3
  3131. */
  3132. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3133. /**
  3134. * Divides the current Vector3 coordinates by the given ones.
  3135. * @param otherVector defines the second operand
  3136. * @returns the current updated Vector3
  3137. */
  3138. divideInPlace(otherVector: Vector3): Vector3;
  3139. /**
  3140. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3141. * @param other defines the second operand
  3142. * @returns the current updated Vector3
  3143. */
  3144. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3145. /**
  3146. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3147. * @param other defines the second operand
  3148. * @returns the current updated Vector3
  3149. */
  3150. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3151. /**
  3152. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3153. * @param x defines the x coordinate of the operand
  3154. * @param y defines the y coordinate of the operand
  3155. * @param z defines the z coordinate of the operand
  3156. * @returns the current updated Vector3
  3157. */
  3158. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3159. /**
  3160. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3161. * @param x defines the x coordinate of the operand
  3162. * @param y defines the y coordinate of the operand
  3163. * @param z defines the z coordinate of the operand
  3164. * @returns the current updated Vector3
  3165. */
  3166. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3167. /**
  3168. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3169. * Check if is non uniform within a certain amount of decimal places to account for this
  3170. * @param epsilon the amount the values can differ
  3171. * @returns if the the vector is non uniform to a certain number of decimal places
  3172. */
  3173. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3174. /**
  3175. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3176. */
  3177. get isNonUniform(): boolean;
  3178. /**
  3179. * Gets a new Vector3 from current Vector3 floored values
  3180. * @returns a new Vector3
  3181. */
  3182. floor(): Vector3;
  3183. /**
  3184. * Gets a new Vector3 from current Vector3 floored values
  3185. * @returns a new Vector3
  3186. */
  3187. fract(): Vector3;
  3188. /**
  3189. * Gets the length of the Vector3
  3190. * @returns the length of the Vector3
  3191. */
  3192. length(): number;
  3193. /**
  3194. * Gets the squared length of the Vector3
  3195. * @returns squared length of the Vector3
  3196. */
  3197. lengthSquared(): number;
  3198. /**
  3199. * Normalize the current Vector3.
  3200. * Please note that this is an in place operation.
  3201. * @returns the current updated Vector3
  3202. */
  3203. normalize(): Vector3;
  3204. /**
  3205. * Reorders the x y z properties of the vector in place
  3206. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3207. * @returns the current updated vector
  3208. */
  3209. reorderInPlace(order: string): this;
  3210. /**
  3211. * Rotates the vector around 0,0,0 by a quaternion
  3212. * @param quaternion the rotation quaternion
  3213. * @param result vector to store the result
  3214. * @returns the resulting vector
  3215. */
  3216. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3217. /**
  3218. * Rotates a vector around a given point
  3219. * @param quaternion the rotation quaternion
  3220. * @param point the point to rotate around
  3221. * @param result vector to store the result
  3222. * @returns the resulting vector
  3223. */
  3224. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3225. /**
  3226. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3227. * The cross product is then orthogonal to both current and "other"
  3228. * @param other defines the right operand
  3229. * @returns the cross product
  3230. */
  3231. cross(other: Vector3): Vector3;
  3232. /**
  3233. * Normalize the current Vector3 with the given input length.
  3234. * Please note that this is an in place operation.
  3235. * @param len the length of the vector
  3236. * @returns the current updated Vector3
  3237. */
  3238. normalizeFromLength(len: number): Vector3;
  3239. /**
  3240. * Normalize the current Vector3 to a new vector
  3241. * @returns the new Vector3
  3242. */
  3243. normalizeToNew(): Vector3;
  3244. /**
  3245. * Normalize the current Vector3 to the reference
  3246. * @param reference define the Vector3 to update
  3247. * @returns the updated Vector3
  3248. */
  3249. normalizeToRef(reference: Vector3): Vector3;
  3250. /**
  3251. * Creates a new Vector3 copied from the current Vector3
  3252. * @returns the new Vector3
  3253. */
  3254. clone(): Vector3;
  3255. /**
  3256. * Copies the given vector coordinates to the current Vector3 ones
  3257. * @param source defines the source Vector3
  3258. * @returns the current updated Vector3
  3259. */
  3260. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3261. /**
  3262. * Copies the given floats to the current Vector3 coordinates
  3263. * @param x defines the x coordinate of the operand
  3264. * @param y defines the y coordinate of the operand
  3265. * @param z defines the z coordinate of the operand
  3266. * @returns the current updated Vector3
  3267. */
  3268. copyFromFloats(x: number, y: number, z: number): Vector3;
  3269. /**
  3270. * Copies the given floats to the current Vector3 coordinates
  3271. * @param x defines the x coordinate of the operand
  3272. * @param y defines the y coordinate of the operand
  3273. * @param z defines the z coordinate of the operand
  3274. * @returns the current updated Vector3
  3275. */
  3276. set(x: number, y: number, z: number): Vector3;
  3277. /**
  3278. * Copies the given float to the current Vector3 coordinates
  3279. * @param v defines the x, y and z coordinates of the operand
  3280. * @returns the current updated Vector3
  3281. */
  3282. setAll(v: number): Vector3;
  3283. /**
  3284. * Get the clip factor between two vectors
  3285. * @param vector0 defines the first operand
  3286. * @param vector1 defines the second operand
  3287. * @param axis defines the axis to use
  3288. * @param size defines the size along the axis
  3289. * @returns the clip factor
  3290. */
  3291. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3292. /**
  3293. * Get angle between two vectors
  3294. * @param vector0 angle between vector0 and vector1
  3295. * @param vector1 angle between vector0 and vector1
  3296. * @param normal direction of the normal
  3297. * @return the angle between vector0 and vector1
  3298. */
  3299. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3300. /**
  3301. * Returns a new Vector3 set from the index "offset" of the given array
  3302. * @param array defines the source array
  3303. * @param offset defines the offset in the source array
  3304. * @returns the new Vector3
  3305. */
  3306. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3307. /**
  3308. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3309. * @param array defines the source array
  3310. * @param offset defines the offset in the source array
  3311. * @returns the new Vector3
  3312. * @deprecated Please use FromArray instead.
  3313. */
  3314. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3315. /**
  3316. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3317. * @param array defines the source array
  3318. * @param offset defines the offset in the source array
  3319. * @param result defines the Vector3 where to store the result
  3320. */
  3321. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3322. /**
  3323. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3324. * @param array defines the source array
  3325. * @param offset defines the offset in the source array
  3326. * @param result defines the Vector3 where to store the result
  3327. * @deprecated Please use FromArrayToRef instead.
  3328. */
  3329. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3330. /**
  3331. * Sets the given vector "result" with the given floats.
  3332. * @param x defines the x coordinate of the source
  3333. * @param y defines the y coordinate of the source
  3334. * @param z defines the z coordinate of the source
  3335. * @param result defines the Vector3 where to store the result
  3336. */
  3337. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3338. /**
  3339. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3340. * @returns a new empty Vector3
  3341. */
  3342. static Zero(): Vector3;
  3343. /**
  3344. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3345. * @returns a new unit Vector3
  3346. */
  3347. static One(): Vector3;
  3348. /**
  3349. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3350. * @returns a new up Vector3
  3351. */
  3352. static Up(): Vector3;
  3353. /**
  3354. * Gets a up Vector3 that must not be updated
  3355. */
  3356. static get UpReadOnly(): DeepImmutable<Vector3>;
  3357. /**
  3358. * Gets a zero Vector3 that must not be updated
  3359. */
  3360. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3361. /**
  3362. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3363. * @returns a new down Vector3
  3364. */
  3365. static Down(): Vector3;
  3366. /**
  3367. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3368. * @param rightHandedSystem is the scene right-handed (negative z)
  3369. * @returns a new forward Vector3
  3370. */
  3371. static Forward(rightHandedSystem?: boolean): Vector3;
  3372. /**
  3373. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3374. * @param rightHandedSystem is the scene right-handed (negative-z)
  3375. * @returns a new forward Vector3
  3376. */
  3377. static Backward(rightHandedSystem?: boolean): Vector3;
  3378. /**
  3379. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3380. * @returns a new right Vector3
  3381. */
  3382. static Right(): Vector3;
  3383. /**
  3384. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3385. * @returns a new left Vector3
  3386. */
  3387. static Left(): Vector3;
  3388. /**
  3389. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3390. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3391. * @param vector defines the Vector3 to transform
  3392. * @param transformation defines the transformation matrix
  3393. * @returns the transformed Vector3
  3394. */
  3395. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3396. /**
  3397. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3398. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3399. * @param vector defines the Vector3 to transform
  3400. * @param transformation defines the transformation matrix
  3401. * @param result defines the Vector3 where to store the result
  3402. */
  3403. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3404. /**
  3405. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3406. * This method computes tranformed coordinates only, not transformed direction vectors
  3407. * @param x define the x coordinate of the source vector
  3408. * @param y define the y coordinate of the source vector
  3409. * @param z define the z coordinate of the source vector
  3410. * @param transformation defines the transformation matrix
  3411. * @param result defines the Vector3 where to store the result
  3412. */
  3413. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3414. /**
  3415. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3416. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3417. * @param vector defines the Vector3 to transform
  3418. * @param transformation defines the transformation matrix
  3419. * @returns the new Vector3
  3420. */
  3421. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3422. /**
  3423. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3424. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3425. * @param vector defines the Vector3 to transform
  3426. * @param transformation defines the transformation matrix
  3427. * @param result defines the Vector3 where to store the result
  3428. */
  3429. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3430. /**
  3431. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3432. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3433. * @param x define the x coordinate of the source vector
  3434. * @param y define the y coordinate of the source vector
  3435. * @param z define the z coordinate of the source vector
  3436. * @param transformation defines the transformation matrix
  3437. * @param result defines the Vector3 where to store the result
  3438. */
  3439. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3440. /**
  3441. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3442. * @param value1 defines the first control point
  3443. * @param value2 defines the second control point
  3444. * @param value3 defines the third control point
  3445. * @param value4 defines the fourth control point
  3446. * @param amount defines the amount on the spline to use
  3447. * @returns the new Vector3
  3448. */
  3449. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3450. /**
  3451. * 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"
  3452. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3453. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3454. * @param value defines the current value
  3455. * @param min defines the lower range value
  3456. * @param max defines the upper range value
  3457. * @returns the new Vector3
  3458. */
  3459. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3460. /**
  3461. * 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"
  3462. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3463. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3464. * @param value defines the current value
  3465. * @param min defines the lower range value
  3466. * @param max defines the upper range value
  3467. * @param result defines the Vector3 where to store the result
  3468. */
  3469. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3470. /**
  3471. * Checks if a given vector is inside a specific range
  3472. * @param v defines the vector to test
  3473. * @param min defines the minimum range
  3474. * @param max defines the maximum range
  3475. */
  3476. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3477. /**
  3478. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3479. * @param value1 defines the first control point
  3480. * @param tangent1 defines the first tangent vector
  3481. * @param value2 defines the second control point
  3482. * @param tangent2 defines the second tangent vector
  3483. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3484. * @returns the new Vector3
  3485. */
  3486. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3487. /**
  3488. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3489. * @param start defines the start value
  3490. * @param end defines the end value
  3491. * @param amount max defines amount between both (between 0 and 1)
  3492. * @returns the new Vector3
  3493. */
  3494. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3495. /**
  3496. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3497. * @param start defines the start value
  3498. * @param end defines the end value
  3499. * @param amount max defines amount between both (between 0 and 1)
  3500. * @param result defines the Vector3 where to store the result
  3501. */
  3502. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3503. /**
  3504. * Returns the dot product (float) between the vectors "left" and "right"
  3505. * @param left defines the left operand
  3506. * @param right defines the right operand
  3507. * @returns the dot product
  3508. */
  3509. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3510. /**
  3511. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3512. * The cross product is then orthogonal to both "left" and "right"
  3513. * @param left defines the left operand
  3514. * @param right defines the right operand
  3515. * @returns the cross product
  3516. */
  3517. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3518. /**
  3519. * Sets the given vector "result" with the cross product of "left" and "right"
  3520. * The cross product is then orthogonal to both "left" and "right"
  3521. * @param left defines the left operand
  3522. * @param right defines the right operand
  3523. * @param result defines the Vector3 where to store the result
  3524. */
  3525. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3526. /**
  3527. * Returns a new Vector3 as the normalization of the given vector
  3528. * @param vector defines the Vector3 to normalize
  3529. * @returns the new Vector3
  3530. */
  3531. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3532. /**
  3533. * Sets the given vector "result" with the normalization of the given first vector
  3534. * @param vector defines the Vector3 to normalize
  3535. * @param result defines the Vector3 where to store the result
  3536. */
  3537. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3538. /**
  3539. * Project a Vector3 onto screen space
  3540. * @param vector defines the Vector3 to project
  3541. * @param world defines the world matrix to use
  3542. * @param transform defines the transform (view x projection) matrix to use
  3543. * @param viewport defines the screen viewport to use
  3544. * @returns the new Vector3
  3545. */
  3546. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3547. /**
  3548. * Project a Vector3 onto screen space to reference
  3549. * @param vector defines the Vector3 to project
  3550. * @param world defines the world matrix to use
  3551. * @param transform defines the transform (view x projection) matrix to use
  3552. * @param viewport defines the screen viewport to use
  3553. * @param result the vector in which the screen space will be stored
  3554. * @returns the new Vector3
  3555. */
  3556. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3557. /** @hidden */
  3558. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3559. /**
  3560. * Unproject from screen space to object space
  3561. * @param source defines the screen space Vector3 to use
  3562. * @param viewportWidth defines the current width of the viewport
  3563. * @param viewportHeight defines the current height of the viewport
  3564. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3565. * @param transform defines the transform (view x projection) matrix to use
  3566. * @returns the new Vector3
  3567. */
  3568. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3569. /**
  3570. * Unproject from screen space to object space
  3571. * @param source defines the screen space Vector3 to use
  3572. * @param viewportWidth defines the current width of the viewport
  3573. * @param viewportHeight defines the current height of the viewport
  3574. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3575. * @param view defines the view matrix to use
  3576. * @param projection defines the projection matrix to use
  3577. * @returns the new Vector3
  3578. */
  3579. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3580. /**
  3581. * Unproject from screen space to object space
  3582. * @param source defines the screen space Vector3 to use
  3583. * @param viewportWidth defines the current width of the viewport
  3584. * @param viewportHeight defines the current height of the viewport
  3585. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3586. * @param view defines the view matrix to use
  3587. * @param projection defines the projection matrix to use
  3588. * @param result defines the Vector3 where to store the result
  3589. */
  3590. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3591. /**
  3592. * Unproject from screen space to object space
  3593. * @param sourceX defines the screen space x coordinate to use
  3594. * @param sourceY defines the screen space y coordinate to use
  3595. * @param sourceZ defines the screen space z coordinate to use
  3596. * @param viewportWidth defines the current width of the viewport
  3597. * @param viewportHeight defines the current height of the viewport
  3598. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3599. * @param view defines the view matrix to use
  3600. * @param projection defines the projection matrix to use
  3601. * @param result defines the Vector3 where to store the result
  3602. */
  3603. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3604. /**
  3605. * Gets the minimal coordinate values between two Vector3
  3606. * @param left defines the first operand
  3607. * @param right defines the second operand
  3608. * @returns the new Vector3
  3609. */
  3610. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3611. /**
  3612. * Gets the maximal coordinate values between two Vector3
  3613. * @param left defines the first operand
  3614. * @param right defines the second operand
  3615. * @returns the new Vector3
  3616. */
  3617. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3618. /**
  3619. * Returns the distance between the vectors "value1" and "value2"
  3620. * @param value1 defines the first operand
  3621. * @param value2 defines the second operand
  3622. * @returns the distance
  3623. */
  3624. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3625. /**
  3626. * Returns the squared distance between the vectors "value1" and "value2"
  3627. * @param value1 defines the first operand
  3628. * @param value2 defines the second operand
  3629. * @returns the squared distance
  3630. */
  3631. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3632. /**
  3633. * Returns a new Vector3 located at the center between "value1" and "value2"
  3634. * @param value1 defines the first operand
  3635. * @param value2 defines the second operand
  3636. * @returns the new Vector3
  3637. */
  3638. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3639. /**
  3640. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3641. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3642. * to something in order to rotate it from its local system to the given target system
  3643. * Note: axis1, axis2 and axis3 are normalized during this operation
  3644. * @param axis1 defines the first axis
  3645. * @param axis2 defines the second axis
  3646. * @param axis3 defines the third axis
  3647. * @returns a new Vector3
  3648. */
  3649. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3650. /**
  3651. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3652. * @param axis1 defines the first axis
  3653. * @param axis2 defines the second axis
  3654. * @param axis3 defines the third axis
  3655. * @param ref defines the Vector3 where to store the result
  3656. */
  3657. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3658. }
  3659. /**
  3660. * Vector4 class created for EulerAngle class conversion to Quaternion
  3661. */
  3662. export class Vector4 {
  3663. /** x value of the vector */
  3664. x: number;
  3665. /** y value of the vector */
  3666. y: number;
  3667. /** z value of the vector */
  3668. z: number;
  3669. /** w value of the vector */
  3670. w: number;
  3671. /**
  3672. * Creates a Vector4 object from the given floats.
  3673. * @param x x value of the vector
  3674. * @param y y value of the vector
  3675. * @param z z value of the vector
  3676. * @param w w value of the vector
  3677. */
  3678. constructor(
  3679. /** x value of the vector */
  3680. x: number,
  3681. /** y value of the vector */
  3682. y: number,
  3683. /** z value of the vector */
  3684. z: number,
  3685. /** w value of the vector */
  3686. w: number);
  3687. /**
  3688. * Returns the string with the Vector4 coordinates.
  3689. * @returns a string containing all the vector values
  3690. */
  3691. toString(): string;
  3692. /**
  3693. * Returns the string "Vector4".
  3694. * @returns "Vector4"
  3695. */
  3696. getClassName(): string;
  3697. /**
  3698. * Returns the Vector4 hash code.
  3699. * @returns a unique hash code
  3700. */
  3701. getHashCode(): number;
  3702. /**
  3703. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3704. * @returns the resulting array
  3705. */
  3706. asArray(): number[];
  3707. /**
  3708. * Populates the given array from the given index with the Vector4 coordinates.
  3709. * @param array array to populate
  3710. * @param index index of the array to start at (default: 0)
  3711. * @returns the Vector4.
  3712. */
  3713. toArray(array: FloatArray, index?: number): Vector4;
  3714. /**
  3715. * Update the current vector from an array
  3716. * @param array defines the destination array
  3717. * @param index defines the offset in the destination array
  3718. * @returns the current Vector3
  3719. */
  3720. fromArray(array: FloatArray, index?: number): Vector4;
  3721. /**
  3722. * Adds the given vector to the current Vector4.
  3723. * @param otherVector the vector to add
  3724. * @returns the updated Vector4.
  3725. */
  3726. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3727. /**
  3728. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3729. * @param otherVector the vector to add
  3730. * @returns the resulting vector
  3731. */
  3732. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3733. /**
  3734. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3735. * @param otherVector the vector to add
  3736. * @param result the vector to store the result
  3737. * @returns the current Vector4.
  3738. */
  3739. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3740. /**
  3741. * Subtract in place the given vector from the current Vector4.
  3742. * @param otherVector the vector to subtract
  3743. * @returns the updated Vector4.
  3744. */
  3745. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3746. /**
  3747. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3748. * @param otherVector the vector to add
  3749. * @returns the new vector with the result
  3750. */
  3751. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3752. /**
  3753. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3754. * @param otherVector the vector to subtract
  3755. * @param result the vector to store the result
  3756. * @returns the current Vector4.
  3757. */
  3758. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3759. /**
  3760. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3761. */
  3762. /**
  3763. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3764. * @param x value to subtract
  3765. * @param y value to subtract
  3766. * @param z value to subtract
  3767. * @param w value to subtract
  3768. * @returns new vector containing the result
  3769. */
  3770. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3771. /**
  3772. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3773. * @param x value to subtract
  3774. * @param y value to subtract
  3775. * @param z value to subtract
  3776. * @param w value to subtract
  3777. * @param result the vector to store the result in
  3778. * @returns the current Vector4.
  3779. */
  3780. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3781. /**
  3782. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3783. * @returns a new vector with the negated values
  3784. */
  3785. negate(): Vector4;
  3786. /**
  3787. * Negate this vector in place
  3788. * @returns this
  3789. */
  3790. negateInPlace(): Vector4;
  3791. /**
  3792. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3793. * @param result defines the Vector3 object where to store the result
  3794. * @returns the current Vector4
  3795. */
  3796. negateToRef(result: Vector4): Vector4;
  3797. /**
  3798. * Multiplies the current Vector4 coordinates by scale (float).
  3799. * @param scale the number to scale with
  3800. * @returns the updated Vector4.
  3801. */
  3802. scaleInPlace(scale: number): Vector4;
  3803. /**
  3804. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3805. * @param scale the number to scale with
  3806. * @returns a new vector with the result
  3807. */
  3808. scale(scale: number): Vector4;
  3809. /**
  3810. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3811. * @param scale the number to scale with
  3812. * @param result a vector to store the result in
  3813. * @returns the current Vector4.
  3814. */
  3815. scaleToRef(scale: number, result: Vector4): Vector4;
  3816. /**
  3817. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3818. * @param scale defines the scale factor
  3819. * @param result defines the Vector4 object where to store the result
  3820. * @returns the unmodified current Vector4
  3821. */
  3822. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3823. /**
  3824. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3825. * @param otherVector the vector to compare against
  3826. * @returns true if they are equal
  3827. */
  3828. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3829. /**
  3830. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3831. * @param otherVector vector to compare against
  3832. * @param epsilon (Default: very small number)
  3833. * @returns true if they are equal
  3834. */
  3835. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3836. /**
  3837. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3838. * @param x x value to compare against
  3839. * @param y y value to compare against
  3840. * @param z z value to compare against
  3841. * @param w w value to compare against
  3842. * @returns true if equal
  3843. */
  3844. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3845. /**
  3846. * Multiplies in place the current Vector4 by the given one.
  3847. * @param otherVector vector to multiple with
  3848. * @returns the updated Vector4.
  3849. */
  3850. multiplyInPlace(otherVector: Vector4): Vector4;
  3851. /**
  3852. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3853. * @param otherVector vector to multiple with
  3854. * @returns resulting new vector
  3855. */
  3856. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3857. /**
  3858. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3859. * @param otherVector vector to multiple with
  3860. * @param result vector to store the result
  3861. * @returns the current Vector4.
  3862. */
  3863. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3864. /**
  3865. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3866. * @param x x value multiply with
  3867. * @param y y value multiply with
  3868. * @param z z value multiply with
  3869. * @param w w value multiply with
  3870. * @returns resulting new vector
  3871. */
  3872. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3873. /**
  3874. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3875. * @param otherVector vector to devide with
  3876. * @returns resulting new vector
  3877. */
  3878. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3879. /**
  3880. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3881. * @param otherVector vector to devide with
  3882. * @param result vector to store the result
  3883. * @returns the current Vector4.
  3884. */
  3885. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3886. /**
  3887. * Divides the current Vector3 coordinates by the given ones.
  3888. * @param otherVector vector to devide with
  3889. * @returns the updated Vector3.
  3890. */
  3891. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3892. /**
  3893. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3894. * @param other defines the second operand
  3895. * @returns the current updated Vector4
  3896. */
  3897. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3898. /**
  3899. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3900. * @param other defines the second operand
  3901. * @returns the current updated Vector4
  3902. */
  3903. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3904. /**
  3905. * Gets a new Vector4 from current Vector4 floored values
  3906. * @returns a new Vector4
  3907. */
  3908. floor(): Vector4;
  3909. /**
  3910. * Gets a new Vector4 from current Vector3 floored values
  3911. * @returns a new Vector4
  3912. */
  3913. fract(): Vector4;
  3914. /**
  3915. * Returns the Vector4 length (float).
  3916. * @returns the length
  3917. */
  3918. length(): number;
  3919. /**
  3920. * Returns the Vector4 squared length (float).
  3921. * @returns the length squared
  3922. */
  3923. lengthSquared(): number;
  3924. /**
  3925. * Normalizes in place the Vector4.
  3926. * @returns the updated Vector4.
  3927. */
  3928. normalize(): Vector4;
  3929. /**
  3930. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3931. * @returns this converted to a new vector3
  3932. */
  3933. toVector3(): Vector3;
  3934. /**
  3935. * Returns a new Vector4 copied from the current one.
  3936. * @returns the new cloned vector
  3937. */
  3938. clone(): Vector4;
  3939. /**
  3940. * Updates the current Vector4 with the given one coordinates.
  3941. * @param source the source vector to copy from
  3942. * @returns the updated Vector4.
  3943. */
  3944. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3945. /**
  3946. * Updates the current Vector4 coordinates with the given floats.
  3947. * @param x float to copy from
  3948. * @param y float to copy from
  3949. * @param z float to copy from
  3950. * @param w float to copy from
  3951. * @returns the updated Vector4.
  3952. */
  3953. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3954. /**
  3955. * Updates the current Vector4 coordinates with the given floats.
  3956. * @param x float to set from
  3957. * @param y float to set from
  3958. * @param z float to set from
  3959. * @param w float to set from
  3960. * @returns the updated Vector4.
  3961. */
  3962. set(x: number, y: number, z: number, w: number): Vector4;
  3963. /**
  3964. * Copies the given float to the current Vector3 coordinates
  3965. * @param v defines the x, y, z and w coordinates of the operand
  3966. * @returns the current updated Vector3
  3967. */
  3968. setAll(v: number): Vector4;
  3969. /**
  3970. * Returns a new Vector4 set from the starting index of the given array.
  3971. * @param array the array to pull values from
  3972. * @param offset the offset into the array to start at
  3973. * @returns the new vector
  3974. */
  3975. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3976. /**
  3977. * Updates the given vector "result" from the starting index of the given array.
  3978. * @param array the array to pull values from
  3979. * @param offset the offset into the array to start at
  3980. * @param result the vector to store the result in
  3981. */
  3982. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3983. /**
  3984. * Updates the given vector "result" from the starting index of the given Float32Array.
  3985. * @param array the array to pull values from
  3986. * @param offset the offset into the array to start at
  3987. * @param result the vector to store the result in
  3988. */
  3989. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3990. /**
  3991. * Updates the given vector "result" coordinates from the given floats.
  3992. * @param x float to set from
  3993. * @param y float to set from
  3994. * @param z float to set from
  3995. * @param w float to set from
  3996. * @param result the vector to the floats in
  3997. */
  3998. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3999. /**
  4000. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4001. * @returns the new vector
  4002. */
  4003. static Zero(): Vector4;
  4004. /**
  4005. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4006. * @returns the new vector
  4007. */
  4008. static One(): Vector4;
  4009. /**
  4010. * Returns a new normalized Vector4 from the given one.
  4011. * @param vector the vector to normalize
  4012. * @returns the vector
  4013. */
  4014. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4015. /**
  4016. * Updates the given vector "result" from the normalization of the given one.
  4017. * @param vector the vector to normalize
  4018. * @param result the vector to store the result in
  4019. */
  4020. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4021. /**
  4022. * Returns a vector with the minimum values from the left and right vectors
  4023. * @param left left vector to minimize
  4024. * @param right right vector to minimize
  4025. * @returns a new vector with the minimum of the left and right vector values
  4026. */
  4027. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4028. /**
  4029. * Returns a vector with the maximum values from the left and right vectors
  4030. * @param left left vector to maximize
  4031. * @param right right vector to maximize
  4032. * @returns a new vector with the maximum of the left and right vector values
  4033. */
  4034. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4035. /**
  4036. * Returns the distance (float) between the vectors "value1" and "value2".
  4037. * @param value1 value to calulate the distance between
  4038. * @param value2 value to calulate the distance between
  4039. * @return the distance between the two vectors
  4040. */
  4041. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4042. /**
  4043. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4044. * @param value1 value to calulate the distance between
  4045. * @param value2 value to calulate the distance between
  4046. * @return the distance between the two vectors squared
  4047. */
  4048. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4049. /**
  4050. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4051. * @param value1 value to calulate the center between
  4052. * @param value2 value to calulate the center between
  4053. * @return the center between the two vectors
  4054. */
  4055. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4056. /**
  4057. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4058. * This methods computes transformed normalized direction vectors only.
  4059. * @param vector the vector to transform
  4060. * @param transformation the transformation matrix to apply
  4061. * @returns the new vector
  4062. */
  4063. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4064. /**
  4065. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4066. * This methods computes transformed normalized direction vectors only.
  4067. * @param vector the vector to transform
  4068. * @param transformation the transformation matrix to apply
  4069. * @param result the vector to store the result in
  4070. */
  4071. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4072. /**
  4073. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4074. * This methods computes transformed normalized direction vectors only.
  4075. * @param x value to transform
  4076. * @param y value to transform
  4077. * @param z value to transform
  4078. * @param w value to transform
  4079. * @param transformation the transformation matrix to apply
  4080. * @param result the vector to store the results in
  4081. */
  4082. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4083. /**
  4084. * Creates a new Vector4 from a Vector3
  4085. * @param source defines the source data
  4086. * @param w defines the 4th component (default is 0)
  4087. * @returns a new Vector4
  4088. */
  4089. static FromVector3(source: Vector3, w?: number): Vector4;
  4090. }
  4091. /**
  4092. * Class used to store quaternion data
  4093. * @see https://en.wikipedia.org/wiki/Quaternion
  4094. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4095. */
  4096. export class Quaternion {
  4097. /** @hidden */
  4098. _x: number;
  4099. /** @hidden */
  4100. _y: number;
  4101. /** @hidden */
  4102. _z: number;
  4103. /** @hidden */
  4104. _w: number;
  4105. /** @hidden */
  4106. _isDirty: boolean;
  4107. /** Gets or sets the x coordinate */
  4108. get x(): number;
  4109. set x(value: number);
  4110. /** Gets or sets the y coordinate */
  4111. get y(): number;
  4112. set y(value: number);
  4113. /** Gets or sets the z coordinate */
  4114. get z(): number;
  4115. set z(value: number);
  4116. /** Gets or sets the w coordinate */
  4117. get w(): number;
  4118. set w(value: number);
  4119. /**
  4120. * Creates a new Quaternion from the given floats
  4121. * @param x defines the first component (0 by default)
  4122. * @param y defines the second component (0 by default)
  4123. * @param z defines the third component (0 by default)
  4124. * @param w defines the fourth component (1.0 by default)
  4125. */
  4126. constructor(x?: number, y?: number, z?: number, w?: number);
  4127. /**
  4128. * Gets a string representation for the current quaternion
  4129. * @returns a string with the Quaternion coordinates
  4130. */
  4131. toString(): string;
  4132. /**
  4133. * Gets the class name of the quaternion
  4134. * @returns the string "Quaternion"
  4135. */
  4136. getClassName(): string;
  4137. /**
  4138. * Gets a hash code for this quaternion
  4139. * @returns the quaternion hash code
  4140. */
  4141. getHashCode(): number;
  4142. /**
  4143. * Copy the quaternion to an array
  4144. * @returns a new array populated with 4 elements from the quaternion coordinates
  4145. */
  4146. asArray(): number[];
  4147. /**
  4148. * Check if two quaternions are equals
  4149. * @param otherQuaternion defines the second operand
  4150. * @return true if the current quaternion and the given one coordinates are strictly equals
  4151. */
  4152. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4153. /**
  4154. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4155. * @param otherQuaternion defines the other quaternion
  4156. * @param epsilon defines the minimal distance to consider equality
  4157. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4158. */
  4159. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4160. /**
  4161. * Clone the current quaternion
  4162. * @returns a new quaternion copied from the current one
  4163. */
  4164. clone(): Quaternion;
  4165. /**
  4166. * Copy a quaternion to the current one
  4167. * @param other defines the other quaternion
  4168. * @returns the updated current quaternion
  4169. */
  4170. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4171. /**
  4172. * Updates the current quaternion with the given float coordinates
  4173. * @param x defines the x coordinate
  4174. * @param y defines the y coordinate
  4175. * @param z defines the z coordinate
  4176. * @param w defines the w coordinate
  4177. * @returns the updated current quaternion
  4178. */
  4179. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4180. /**
  4181. * Updates the current quaternion from the given float coordinates
  4182. * @param x defines the x coordinate
  4183. * @param y defines the y coordinate
  4184. * @param z defines the z coordinate
  4185. * @param w defines the w coordinate
  4186. * @returns the updated current quaternion
  4187. */
  4188. set(x: number, y: number, z: number, w: number): Quaternion;
  4189. /**
  4190. * Adds two quaternions
  4191. * @param other defines the second operand
  4192. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4193. */
  4194. add(other: DeepImmutable<Quaternion>): Quaternion;
  4195. /**
  4196. * Add a quaternion to the current one
  4197. * @param other defines the quaternion to add
  4198. * @returns the current quaternion
  4199. */
  4200. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4201. /**
  4202. * Subtract two quaternions
  4203. * @param other defines the second operand
  4204. * @returns a new quaternion as the subtraction result of the given one from the current one
  4205. */
  4206. subtract(other: Quaternion): Quaternion;
  4207. /**
  4208. * Multiplies the current quaternion by a scale factor
  4209. * @param value defines the scale factor
  4210. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4211. */
  4212. scale(value: number): Quaternion;
  4213. /**
  4214. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4215. * @param scale defines the scale factor
  4216. * @param result defines the Quaternion object where to store the result
  4217. * @returns the unmodified current quaternion
  4218. */
  4219. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4220. /**
  4221. * Multiplies in place the current quaternion by a scale factor
  4222. * @param value defines the scale factor
  4223. * @returns the current modified quaternion
  4224. */
  4225. scaleInPlace(value: number): Quaternion;
  4226. /**
  4227. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4228. * @param scale defines the scale factor
  4229. * @param result defines the Quaternion object where to store the result
  4230. * @returns the unmodified current quaternion
  4231. */
  4232. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4233. /**
  4234. * Multiplies two quaternions
  4235. * @param q1 defines the second operand
  4236. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4237. */
  4238. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4239. /**
  4240. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4241. * @param q1 defines the second operand
  4242. * @param result defines the target quaternion
  4243. * @returns the current quaternion
  4244. */
  4245. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4246. /**
  4247. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4248. * @param q1 defines the second operand
  4249. * @returns the currentupdated quaternion
  4250. */
  4251. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4252. /**
  4253. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4254. * @param ref defines the target quaternion
  4255. * @returns the current quaternion
  4256. */
  4257. conjugateToRef(ref: Quaternion): Quaternion;
  4258. /**
  4259. * Conjugates in place (1-q) the current quaternion
  4260. * @returns the current updated quaternion
  4261. */
  4262. conjugateInPlace(): Quaternion;
  4263. /**
  4264. * Conjugates in place (1-q) the current quaternion
  4265. * @returns a new quaternion
  4266. */
  4267. conjugate(): Quaternion;
  4268. /**
  4269. * Gets length of current quaternion
  4270. * @returns the quaternion length (float)
  4271. */
  4272. length(): number;
  4273. /**
  4274. * Normalize in place the current quaternion
  4275. * @returns the current updated quaternion
  4276. */
  4277. normalize(): Quaternion;
  4278. /**
  4279. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4280. * @param order is a reserved parameter and is ignored for now
  4281. * @returns a new Vector3 containing the Euler angles
  4282. */
  4283. toEulerAngles(order?: string): Vector3;
  4284. /**
  4285. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4286. * @param result defines the vector which will be filled with the Euler angles
  4287. * @returns the current unchanged quaternion
  4288. */
  4289. toEulerAnglesToRef(result: Vector3): Quaternion;
  4290. /**
  4291. * Updates the given rotation matrix with the current quaternion values
  4292. * @param result defines the target matrix
  4293. * @returns the current unchanged quaternion
  4294. */
  4295. toRotationMatrix(result: Matrix): Quaternion;
  4296. /**
  4297. * Updates the current quaternion from the given rotation matrix values
  4298. * @param matrix defines the source matrix
  4299. * @returns the current updated quaternion
  4300. */
  4301. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4302. /**
  4303. * Creates a new quaternion from a rotation matrix
  4304. * @param matrix defines the source matrix
  4305. * @returns a new quaternion created from the given rotation matrix values
  4306. */
  4307. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4308. /**
  4309. * Updates the given quaternion with the given rotation matrix values
  4310. * @param matrix defines the source matrix
  4311. * @param result defines the target quaternion
  4312. */
  4313. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4314. /**
  4315. * Returns the dot product (float) between the quaternions "left" and "right"
  4316. * @param left defines the left operand
  4317. * @param right defines the right operand
  4318. * @returns the dot product
  4319. */
  4320. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4321. /**
  4322. * Checks if the two quaternions are close to each other
  4323. * @param quat0 defines the first quaternion to check
  4324. * @param quat1 defines the second quaternion to check
  4325. * @returns true if the two quaternions are close to each other
  4326. */
  4327. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4328. /**
  4329. * Creates an empty quaternion
  4330. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4331. */
  4332. static Zero(): Quaternion;
  4333. /**
  4334. * Inverse a given quaternion
  4335. * @param q defines the source quaternion
  4336. * @returns a new quaternion as the inverted current quaternion
  4337. */
  4338. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4339. /**
  4340. * Inverse a given quaternion
  4341. * @param q defines the source quaternion
  4342. * @param result the quaternion the result will be stored in
  4343. * @returns the result quaternion
  4344. */
  4345. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4346. /**
  4347. * Creates an identity quaternion
  4348. * @returns the identity quaternion
  4349. */
  4350. static Identity(): Quaternion;
  4351. /**
  4352. * Gets a boolean indicating if the given quaternion is identity
  4353. * @param quaternion defines the quaternion to check
  4354. * @returns true if the quaternion is identity
  4355. */
  4356. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4357. /**
  4358. * Creates a quaternion from a rotation around an axis
  4359. * @param axis defines the axis to use
  4360. * @param angle defines the angle to use
  4361. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4362. */
  4363. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4364. /**
  4365. * Creates a rotation around an axis and stores it into the given quaternion
  4366. * @param axis defines the axis to use
  4367. * @param angle defines the angle to use
  4368. * @param result defines the target quaternion
  4369. * @returns the target quaternion
  4370. */
  4371. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4372. /**
  4373. * Creates a new quaternion from data stored into an array
  4374. * @param array defines the data source
  4375. * @param offset defines the offset in the source array where the data starts
  4376. * @returns a new quaternion
  4377. */
  4378. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4379. /**
  4380. * Updates the given quaternion "result" from the starting index of the given array.
  4381. * @param array the array to pull values from
  4382. * @param offset the offset into the array to start at
  4383. * @param result the quaternion to store the result in
  4384. */
  4385. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4386. /**
  4387. * Create a quaternion from Euler rotation angles
  4388. * @param x Pitch
  4389. * @param y Yaw
  4390. * @param z Roll
  4391. * @returns the new Quaternion
  4392. */
  4393. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4394. /**
  4395. * Updates a quaternion from Euler rotation angles
  4396. * @param x Pitch
  4397. * @param y Yaw
  4398. * @param z Roll
  4399. * @param result the quaternion to store the result
  4400. * @returns the updated quaternion
  4401. */
  4402. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4403. /**
  4404. * Create a quaternion from Euler rotation vector
  4405. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4406. * @returns the new Quaternion
  4407. */
  4408. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4409. /**
  4410. * Updates a quaternion from Euler rotation vector
  4411. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4412. * @param result the quaternion to store the result
  4413. * @returns the updated quaternion
  4414. */
  4415. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4416. /**
  4417. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4418. * @param yaw defines the rotation around Y axis
  4419. * @param pitch defines the rotation around X axis
  4420. * @param roll defines the rotation around Z axis
  4421. * @returns the new quaternion
  4422. */
  4423. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4424. /**
  4425. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4426. * @param yaw defines the rotation around Y axis
  4427. * @param pitch defines the rotation around X axis
  4428. * @param roll defines the rotation around Z axis
  4429. * @param result defines the target quaternion
  4430. */
  4431. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4432. /**
  4433. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4434. * @param alpha defines the rotation around first axis
  4435. * @param beta defines the rotation around second axis
  4436. * @param gamma defines the rotation around third axis
  4437. * @returns the new quaternion
  4438. */
  4439. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4440. /**
  4441. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4442. * @param alpha defines the rotation around first axis
  4443. * @param beta defines the rotation around second axis
  4444. * @param gamma defines the rotation around third axis
  4445. * @param result defines the target quaternion
  4446. */
  4447. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4448. /**
  4449. * 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)
  4450. * @param axis1 defines the first axis
  4451. * @param axis2 defines the second axis
  4452. * @param axis3 defines the third axis
  4453. * @returns the new quaternion
  4454. */
  4455. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4456. /**
  4457. * 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
  4458. * @param axis1 defines the first axis
  4459. * @param axis2 defines the second axis
  4460. * @param axis3 defines the third axis
  4461. * @param ref defines the target quaternion
  4462. */
  4463. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4464. /**
  4465. * Interpolates between two quaternions
  4466. * @param left defines first quaternion
  4467. * @param right defines second quaternion
  4468. * @param amount defines the gradient to use
  4469. * @returns the new interpolated quaternion
  4470. */
  4471. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4472. /**
  4473. * Interpolates between two quaternions and stores it into a target quaternion
  4474. * @param left defines first quaternion
  4475. * @param right defines second quaternion
  4476. * @param amount defines the gradient to use
  4477. * @param result defines the target quaternion
  4478. */
  4479. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4480. /**
  4481. * Interpolate between two quaternions using Hermite interpolation
  4482. * @param value1 defines first quaternion
  4483. * @param tangent1 defines the incoming tangent
  4484. * @param value2 defines second quaternion
  4485. * @param tangent2 defines the outgoing tangent
  4486. * @param amount defines the target quaternion
  4487. * @returns the new interpolated quaternion
  4488. */
  4489. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4490. }
  4491. /**
  4492. * Class used to store matrix data (4x4)
  4493. */
  4494. export class Matrix {
  4495. /**
  4496. * Gets the precision of matrix computations
  4497. */
  4498. static get Use64Bits(): boolean;
  4499. private static _updateFlagSeed;
  4500. private static _identityReadOnly;
  4501. private _isIdentity;
  4502. private _isIdentityDirty;
  4503. private _isIdentity3x2;
  4504. private _isIdentity3x2Dirty;
  4505. /**
  4506. * Gets the update flag of the matrix which is an unique number for the matrix.
  4507. * It will be incremented every time the matrix data change.
  4508. * You can use it to speed the comparison between two versions of the same matrix.
  4509. */
  4510. updateFlag: number;
  4511. private readonly _m;
  4512. /**
  4513. * Gets the internal data of the matrix
  4514. */
  4515. get m(): DeepImmutable<Float32Array | Array<number>>;
  4516. /** @hidden */
  4517. _markAsUpdated(): void;
  4518. /** @hidden */
  4519. private _updateIdentityStatus;
  4520. /**
  4521. * Creates an empty matrix (filled with zeros)
  4522. */
  4523. constructor();
  4524. /**
  4525. * Check if the current matrix is identity
  4526. * @returns true is the matrix is the identity matrix
  4527. */
  4528. isIdentity(): boolean;
  4529. /**
  4530. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4531. * @returns true is the matrix is the identity matrix
  4532. */
  4533. isIdentityAs3x2(): boolean;
  4534. /**
  4535. * Gets the determinant of the matrix
  4536. * @returns the matrix determinant
  4537. */
  4538. determinant(): number;
  4539. /**
  4540. * Returns the matrix as a Float32Array or Array<number>
  4541. * @returns the matrix underlying array
  4542. */
  4543. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4544. /**
  4545. * Returns the matrix as a Float32Array or Array<number>
  4546. * @returns the matrix underlying array.
  4547. */
  4548. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4549. /**
  4550. * Inverts the current matrix in place
  4551. * @returns the current inverted matrix
  4552. */
  4553. invert(): Matrix;
  4554. /**
  4555. * Sets all the matrix elements to zero
  4556. * @returns the current matrix
  4557. */
  4558. reset(): Matrix;
  4559. /**
  4560. * Adds the current matrix with a second one
  4561. * @param other defines the matrix to add
  4562. * @returns a new matrix as the addition of the current matrix and the given one
  4563. */
  4564. add(other: DeepImmutable<Matrix>): Matrix;
  4565. /**
  4566. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4567. * @param other defines the matrix to add
  4568. * @param result defines the target matrix
  4569. * @returns the current matrix
  4570. */
  4571. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4572. /**
  4573. * Adds in place the given matrix to the current matrix
  4574. * @param other defines the second operand
  4575. * @returns the current updated matrix
  4576. */
  4577. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4578. /**
  4579. * Sets the given matrix to the current inverted Matrix
  4580. * @param other defines the target matrix
  4581. * @returns the unmodified current matrix
  4582. */
  4583. invertToRef(other: Matrix): Matrix;
  4584. /**
  4585. * add a value at the specified position in the current Matrix
  4586. * @param index the index of the value within the matrix. between 0 and 15.
  4587. * @param value the value to be added
  4588. * @returns the current updated matrix
  4589. */
  4590. addAtIndex(index: number, value: number): Matrix;
  4591. /**
  4592. * mutiply the specified position in the current Matrix by a value
  4593. * @param index the index of the value within the matrix. between 0 and 15.
  4594. * @param value the value to be added
  4595. * @returns the current updated matrix
  4596. */
  4597. multiplyAtIndex(index: number, value: number): Matrix;
  4598. /**
  4599. * Inserts the translation vector (using 3 floats) in the current matrix
  4600. * @param x defines the 1st component of the translation
  4601. * @param y defines the 2nd component of the translation
  4602. * @param z defines the 3rd component of the translation
  4603. * @returns the current updated matrix
  4604. */
  4605. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4606. /**
  4607. * Adds the translation vector (using 3 floats) in the current matrix
  4608. * @param x defines the 1st component of the translation
  4609. * @param y defines the 2nd component of the translation
  4610. * @param z defines the 3rd component of the translation
  4611. * @returns the current updated matrix
  4612. */
  4613. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4614. /**
  4615. * Inserts the translation vector in the current matrix
  4616. * @param vector3 defines the translation to insert
  4617. * @returns the current updated matrix
  4618. */
  4619. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4620. /**
  4621. * Gets the translation value of the current matrix
  4622. * @returns a new Vector3 as the extracted translation from the matrix
  4623. */
  4624. getTranslation(): Vector3;
  4625. /**
  4626. * Fill a Vector3 with the extracted translation from the matrix
  4627. * @param result defines the Vector3 where to store the translation
  4628. * @returns the current matrix
  4629. */
  4630. getTranslationToRef(result: Vector3): Matrix;
  4631. /**
  4632. * Remove rotation and scaling part from the matrix
  4633. * @returns the updated matrix
  4634. */
  4635. removeRotationAndScaling(): Matrix;
  4636. /**
  4637. * Multiply two matrices
  4638. * @param other defines the second operand
  4639. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4640. */
  4641. multiply(other: DeepImmutable<Matrix>): Matrix;
  4642. /**
  4643. * Copy the current matrix from the given one
  4644. * @param other defines the source matrix
  4645. * @returns the current updated matrix
  4646. */
  4647. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4648. /**
  4649. * Populates the given array from the starting index with the current matrix values
  4650. * @param array defines the target array
  4651. * @param offset defines the offset in the target array where to start storing values
  4652. * @returns the current matrix
  4653. */
  4654. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4655. /**
  4656. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4657. * @param other defines the second operand
  4658. * @param result defines the matrix where to store the multiplication
  4659. * @returns the current matrix
  4660. */
  4661. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4662. /**
  4663. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4664. * @param other defines the second operand
  4665. * @param result defines the array where to store the multiplication
  4666. * @param offset defines the offset in the target array where to start storing values
  4667. * @returns the current matrix
  4668. */
  4669. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4670. /**
  4671. * Check equality between this matrix and a second one
  4672. * @param value defines the second matrix to compare
  4673. * @returns true is the current matrix and the given one values are strictly equal
  4674. */
  4675. equals(value: DeepImmutable<Matrix>): boolean;
  4676. /**
  4677. * Clone the current matrix
  4678. * @returns a new matrix from the current matrix
  4679. */
  4680. clone(): Matrix;
  4681. /**
  4682. * Returns the name of the current matrix class
  4683. * @returns the string "Matrix"
  4684. */
  4685. getClassName(): string;
  4686. /**
  4687. * Gets the hash code of the current matrix
  4688. * @returns the hash code
  4689. */
  4690. getHashCode(): number;
  4691. /**
  4692. * Decomposes the current Matrix into a translation, rotation and scaling components
  4693. * @param scale defines the scale vector3 given as a reference to update
  4694. * @param rotation defines the rotation quaternion given as a reference to update
  4695. * @param translation defines the translation vector3 given as a reference to update
  4696. * @returns true if operation was successful
  4697. */
  4698. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4699. /**
  4700. * Gets specific row of the matrix
  4701. * @param index defines the number of the row to get
  4702. * @returns the index-th row of the current matrix as a new Vector4
  4703. */
  4704. getRow(index: number): Nullable<Vector4>;
  4705. /**
  4706. * Sets the index-th row of the current matrix to the vector4 values
  4707. * @param index defines the number of the row to set
  4708. * @param row defines the target vector4
  4709. * @returns the updated current matrix
  4710. */
  4711. setRow(index: number, row: Vector4): Matrix;
  4712. /**
  4713. * Compute the transpose of the matrix
  4714. * @returns the new transposed matrix
  4715. */
  4716. transpose(): Matrix;
  4717. /**
  4718. * Compute the transpose of the matrix and store it in a given matrix
  4719. * @param result defines the target matrix
  4720. * @returns the current matrix
  4721. */
  4722. transposeToRef(result: Matrix): Matrix;
  4723. /**
  4724. * Sets the index-th row of the current matrix with the given 4 x float values
  4725. * @param index defines the row index
  4726. * @param x defines the x component to set
  4727. * @param y defines the y component to set
  4728. * @param z defines the z component to set
  4729. * @param w defines the w component to set
  4730. * @returns the updated current matrix
  4731. */
  4732. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4733. /**
  4734. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4735. * @param scale defines the scale factor
  4736. * @returns a new matrix
  4737. */
  4738. scale(scale: number): Matrix;
  4739. /**
  4740. * Scale the current matrix values by a factor to a given result matrix
  4741. * @param scale defines the scale factor
  4742. * @param result defines the matrix to store the result
  4743. * @returns the current matrix
  4744. */
  4745. scaleToRef(scale: number, result: Matrix): Matrix;
  4746. /**
  4747. * Scale the current matrix values by a factor and add the result to a given matrix
  4748. * @param scale defines the scale factor
  4749. * @param result defines the Matrix to store the result
  4750. * @returns the current matrix
  4751. */
  4752. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4753. /**
  4754. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4755. * @param ref matrix to store the result
  4756. */
  4757. toNormalMatrix(ref: Matrix): void;
  4758. /**
  4759. * Gets only rotation part of the current matrix
  4760. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4761. */
  4762. getRotationMatrix(): Matrix;
  4763. /**
  4764. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4765. * @param result defines the target matrix to store data to
  4766. * @returns the current matrix
  4767. */
  4768. getRotationMatrixToRef(result: Matrix): Matrix;
  4769. /**
  4770. * Toggles model matrix from being right handed to left handed in place and vice versa
  4771. */
  4772. toggleModelMatrixHandInPlace(): void;
  4773. /**
  4774. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4775. */
  4776. toggleProjectionMatrixHandInPlace(): void;
  4777. /**
  4778. * Creates a matrix from an array
  4779. * @param array defines the source array
  4780. * @param offset defines an offset in the source array
  4781. * @returns a new Matrix set from the starting index of the given array
  4782. */
  4783. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4784. /**
  4785. * Copy the content of an array into a given matrix
  4786. * @param array defines the source array
  4787. * @param offset defines an offset in the source array
  4788. * @param result defines the target matrix
  4789. */
  4790. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4791. /**
  4792. * Stores an array into a matrix after having multiplied each component by a given factor
  4793. * @param array defines the source array
  4794. * @param offset defines the offset in the source array
  4795. * @param scale defines the scaling factor
  4796. * @param result defines the target matrix
  4797. */
  4798. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4799. /**
  4800. * Gets an identity matrix that must not be updated
  4801. */
  4802. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4803. /**
  4804. * Stores a list of values (16) inside a given matrix
  4805. * @param initialM11 defines 1st value of 1st row
  4806. * @param initialM12 defines 2nd value of 1st row
  4807. * @param initialM13 defines 3rd value of 1st row
  4808. * @param initialM14 defines 4th value of 1st row
  4809. * @param initialM21 defines 1st value of 2nd row
  4810. * @param initialM22 defines 2nd value of 2nd row
  4811. * @param initialM23 defines 3rd value of 2nd row
  4812. * @param initialM24 defines 4th value of 2nd row
  4813. * @param initialM31 defines 1st value of 3rd row
  4814. * @param initialM32 defines 2nd value of 3rd row
  4815. * @param initialM33 defines 3rd value of 3rd row
  4816. * @param initialM34 defines 4th value of 3rd row
  4817. * @param initialM41 defines 1st value of 4th row
  4818. * @param initialM42 defines 2nd value of 4th row
  4819. * @param initialM43 defines 3rd value of 4th row
  4820. * @param initialM44 defines 4th value of 4th row
  4821. * @param result defines the target matrix
  4822. */
  4823. 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;
  4824. /**
  4825. * Creates new matrix from a list of values (16)
  4826. * @param initialM11 defines 1st value of 1st row
  4827. * @param initialM12 defines 2nd value of 1st row
  4828. * @param initialM13 defines 3rd value of 1st row
  4829. * @param initialM14 defines 4th value of 1st row
  4830. * @param initialM21 defines 1st value of 2nd row
  4831. * @param initialM22 defines 2nd value of 2nd row
  4832. * @param initialM23 defines 3rd value of 2nd row
  4833. * @param initialM24 defines 4th value of 2nd row
  4834. * @param initialM31 defines 1st value of 3rd row
  4835. * @param initialM32 defines 2nd value of 3rd row
  4836. * @param initialM33 defines 3rd value of 3rd row
  4837. * @param initialM34 defines 4th value of 3rd row
  4838. * @param initialM41 defines 1st value of 4th row
  4839. * @param initialM42 defines 2nd value of 4th row
  4840. * @param initialM43 defines 3rd value of 4th row
  4841. * @param initialM44 defines 4th value of 4th row
  4842. * @returns the new matrix
  4843. */
  4844. 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;
  4845. /**
  4846. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4847. * @param scale defines the scale vector3
  4848. * @param rotation defines the rotation quaternion
  4849. * @param translation defines the translation vector3
  4850. * @returns a new matrix
  4851. */
  4852. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4853. /**
  4854. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4855. * @param scale defines the scale vector3
  4856. * @param rotation defines the rotation quaternion
  4857. * @param translation defines the translation vector3
  4858. * @param result defines the target matrix
  4859. */
  4860. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4861. /**
  4862. * Creates a new identity matrix
  4863. * @returns a new identity matrix
  4864. */
  4865. static Identity(): Matrix;
  4866. /**
  4867. * Creates a new identity matrix and stores the result in a given matrix
  4868. * @param result defines the target matrix
  4869. */
  4870. static IdentityToRef(result: Matrix): void;
  4871. /**
  4872. * Creates a new zero matrix
  4873. * @returns a new zero matrix
  4874. */
  4875. static Zero(): Matrix;
  4876. /**
  4877. * Creates a new rotation matrix for "angle" radians around the X axis
  4878. * @param angle defines the angle (in radians) to use
  4879. * @return the new matrix
  4880. */
  4881. static RotationX(angle: number): Matrix;
  4882. /**
  4883. * Creates a new matrix as the invert of a given matrix
  4884. * @param source defines the source matrix
  4885. * @returns the new matrix
  4886. */
  4887. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4888. /**
  4889. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4890. * @param angle defines the angle (in radians) to use
  4891. * @param result defines the target matrix
  4892. */
  4893. static RotationXToRef(angle: number, result: Matrix): void;
  4894. /**
  4895. * Creates a new rotation matrix for "angle" radians around the Y axis
  4896. * @param angle defines the angle (in radians) to use
  4897. * @return the new matrix
  4898. */
  4899. static RotationY(angle: number): Matrix;
  4900. /**
  4901. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4902. * @param angle defines the angle (in radians) to use
  4903. * @param result defines the target matrix
  4904. */
  4905. static RotationYToRef(angle: number, result: Matrix): void;
  4906. /**
  4907. * Creates a new rotation matrix for "angle" radians around the Z axis
  4908. * @param angle defines the angle (in radians) to use
  4909. * @return the new matrix
  4910. */
  4911. static RotationZ(angle: number): Matrix;
  4912. /**
  4913. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4914. * @param angle defines the angle (in radians) to use
  4915. * @param result defines the target matrix
  4916. */
  4917. static RotationZToRef(angle: number, result: Matrix): void;
  4918. /**
  4919. * Creates a new rotation matrix for "angle" radians around the given axis
  4920. * @param axis defines the axis to use
  4921. * @param angle defines the angle (in radians) to use
  4922. * @return the new matrix
  4923. */
  4924. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4925. /**
  4926. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4927. * @param axis defines the axis to use
  4928. * @param angle defines the angle (in radians) to use
  4929. * @param result defines the target matrix
  4930. */
  4931. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4932. /**
  4933. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4934. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4935. * @param from defines the vector to align
  4936. * @param to defines the vector to align to
  4937. * @param result defines the target matrix
  4938. */
  4939. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4940. /**
  4941. * Creates a rotation matrix
  4942. * @param yaw defines the yaw angle in radians (Y axis)
  4943. * @param pitch defines the pitch angle in radians (X axis)
  4944. * @param roll defines the roll angle in radians (Z axis)
  4945. * @returns the new rotation matrix
  4946. */
  4947. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4948. /**
  4949. * Creates a rotation matrix and stores it in a given matrix
  4950. * @param yaw defines the yaw angle in radians (Y axis)
  4951. * @param pitch defines the pitch angle in radians (X axis)
  4952. * @param roll defines the roll angle in radians (Z axis)
  4953. * @param result defines the target matrix
  4954. */
  4955. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4956. /**
  4957. * Creates a scaling matrix
  4958. * @param x defines the scale factor on X axis
  4959. * @param y defines the scale factor on Y axis
  4960. * @param z defines the scale factor on Z axis
  4961. * @returns the new matrix
  4962. */
  4963. static Scaling(x: number, y: number, z: number): Matrix;
  4964. /**
  4965. * Creates a scaling matrix and stores it in a given matrix
  4966. * @param x defines the scale factor on X axis
  4967. * @param y defines the scale factor on Y axis
  4968. * @param z defines the scale factor on Z axis
  4969. * @param result defines the target matrix
  4970. */
  4971. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4972. /**
  4973. * Creates a translation matrix
  4974. * @param x defines the translation on X axis
  4975. * @param y defines the translation on Y axis
  4976. * @param z defines the translationon Z axis
  4977. * @returns the new matrix
  4978. */
  4979. static Translation(x: number, y: number, z: number): Matrix;
  4980. /**
  4981. * Creates a translation matrix and stores it in a given matrix
  4982. * @param x defines the translation on X axis
  4983. * @param y defines the translation on Y axis
  4984. * @param z defines the translationon Z axis
  4985. * @param result defines the target matrix
  4986. */
  4987. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4988. /**
  4989. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4990. * @param startValue defines the start value
  4991. * @param endValue defines the end value
  4992. * @param gradient defines the gradient factor
  4993. * @returns the new matrix
  4994. */
  4995. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4996. /**
  4997. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4998. * @param startValue defines the start value
  4999. * @param endValue defines the end value
  5000. * @param gradient defines the gradient factor
  5001. * @param result defines the Matrix object where to store data
  5002. */
  5003. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5004. /**
  5005. * Builds a new matrix whose values are computed by:
  5006. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5007. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5008. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5009. * @param startValue defines the first matrix
  5010. * @param endValue defines the second matrix
  5011. * @param gradient defines the gradient between the two matrices
  5012. * @returns the new matrix
  5013. */
  5014. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5015. /**
  5016. * Update a matrix to values which are computed by:
  5017. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5018. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5019. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5020. * @param startValue defines the first matrix
  5021. * @param endValue defines the second matrix
  5022. * @param gradient defines the gradient between the two matrices
  5023. * @param result defines the target matrix
  5024. */
  5025. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5026. /**
  5027. * 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"
  5028. * This function works in left handed mode
  5029. * @param eye defines the final position of the entity
  5030. * @param target defines where the entity should look at
  5031. * @param up defines the up vector for the entity
  5032. * @returns the new matrix
  5033. */
  5034. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5035. /**
  5036. * 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".
  5037. * This function works in left handed mode
  5038. * @param eye defines the final position of the entity
  5039. * @param target defines where the entity should look at
  5040. * @param up defines the up vector for the entity
  5041. * @param result defines the target matrix
  5042. */
  5043. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5044. /**
  5045. * 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"
  5046. * This function works in right handed mode
  5047. * @param eye defines the final position of the entity
  5048. * @param target defines where the entity should look at
  5049. * @param up defines the up vector for the entity
  5050. * @returns the new matrix
  5051. */
  5052. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5053. /**
  5054. * 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".
  5055. * This function works in right handed mode
  5056. * @param eye defines the final position of the entity
  5057. * @param target defines where the entity should look at
  5058. * @param up defines the up vector for the entity
  5059. * @param result defines the target matrix
  5060. */
  5061. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5062. /**
  5063. * Create a left-handed orthographic projection matrix
  5064. * @param width defines the viewport width
  5065. * @param height defines the viewport height
  5066. * @param znear defines the near clip plane
  5067. * @param zfar defines the far clip plane
  5068. * @returns a new matrix as a left-handed orthographic projection matrix
  5069. */
  5070. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5071. /**
  5072. * Store a left-handed orthographic projection to a given matrix
  5073. * @param width defines the viewport width
  5074. * @param height defines the viewport height
  5075. * @param znear defines the near clip plane
  5076. * @param zfar defines the far clip plane
  5077. * @param result defines the target matrix
  5078. */
  5079. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5080. /**
  5081. * Create a left-handed orthographic projection matrix
  5082. * @param left defines the viewport left coordinate
  5083. * @param right defines the viewport right coordinate
  5084. * @param bottom defines the viewport bottom coordinate
  5085. * @param top defines the viewport top coordinate
  5086. * @param znear defines the near clip plane
  5087. * @param zfar defines the far clip plane
  5088. * @returns a new matrix as a left-handed orthographic projection matrix
  5089. */
  5090. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5091. /**
  5092. * Stores a left-handed orthographic projection into a given matrix
  5093. * @param left defines the viewport left coordinate
  5094. * @param right defines the viewport right coordinate
  5095. * @param bottom defines the viewport bottom coordinate
  5096. * @param top defines the viewport top coordinate
  5097. * @param znear defines the near clip plane
  5098. * @param zfar defines the far clip plane
  5099. * @param result defines the target matrix
  5100. */
  5101. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5102. /**
  5103. * Creates a right-handed orthographic projection matrix
  5104. * @param left defines the viewport left coordinate
  5105. * @param right defines the viewport right coordinate
  5106. * @param bottom defines the viewport bottom coordinate
  5107. * @param top defines the viewport top coordinate
  5108. * @param znear defines the near clip plane
  5109. * @param zfar defines the far clip plane
  5110. * @returns a new matrix as a right-handed orthographic projection matrix
  5111. */
  5112. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5113. /**
  5114. * Stores a right-handed orthographic projection into a given matrix
  5115. * @param left defines the viewport left coordinate
  5116. * @param right defines the viewport right coordinate
  5117. * @param bottom defines the viewport bottom coordinate
  5118. * @param top defines the viewport top coordinate
  5119. * @param znear defines the near clip plane
  5120. * @param zfar defines the far clip plane
  5121. * @param result defines the target matrix
  5122. */
  5123. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5124. /**
  5125. * Creates a left-handed perspective projection matrix
  5126. * @param width defines the viewport width
  5127. * @param height defines the viewport height
  5128. * @param znear defines the near clip plane
  5129. * @param zfar defines the far clip plane
  5130. * @returns a new matrix as a left-handed perspective projection matrix
  5131. */
  5132. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5133. /**
  5134. * Creates a left-handed perspective projection matrix
  5135. * @param fov defines the horizontal field of view
  5136. * @param aspect defines the aspect ratio
  5137. * @param znear defines the near clip plane
  5138. * @param zfar defines the far clip plane
  5139. * @returns a new matrix as a left-handed perspective projection matrix
  5140. */
  5141. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5142. /**
  5143. * Stores a left-handed perspective projection into a given matrix
  5144. * @param fov defines the horizontal field of view
  5145. * @param aspect defines the aspect ratio
  5146. * @param znear defines the near clip plane
  5147. * @param zfar defines the far clip plane
  5148. * @param result defines the target matrix
  5149. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5150. */
  5151. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5152. /**
  5153. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5154. * @param fov defines the horizontal field of view
  5155. * @param aspect defines the aspect ratio
  5156. * @param znear defines the near clip plane
  5157. * @param zfar not used as infinity is used as far clip
  5158. * @param result defines the target matrix
  5159. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5160. */
  5161. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5162. /**
  5163. * Creates a right-handed perspective projection matrix
  5164. * @param fov defines the horizontal field of view
  5165. * @param aspect defines the aspect ratio
  5166. * @param znear defines the near clip plane
  5167. * @param zfar defines the far clip plane
  5168. * @returns a new matrix as a right-handed perspective projection matrix
  5169. */
  5170. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5171. /**
  5172. * Stores a right-handed perspective projection into a given matrix
  5173. * @param fov defines the horizontal field of view
  5174. * @param aspect defines the aspect ratio
  5175. * @param znear defines the near clip plane
  5176. * @param zfar defines the far clip plane
  5177. * @param result defines the target matrix
  5178. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5179. */
  5180. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5181. /**
  5182. * Stores a right-handed perspective projection into a given matrix
  5183. * @param fov defines the horizontal field of view
  5184. * @param aspect defines the aspect ratio
  5185. * @param znear defines the near clip plane
  5186. * @param zfar not used as infinity is used as far clip
  5187. * @param result defines the target matrix
  5188. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5189. */
  5190. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5191. /**
  5192. * Stores a perspective projection for WebVR info a given matrix
  5193. * @param fov defines the field of view
  5194. * @param znear defines the near clip plane
  5195. * @param zfar defines the far clip plane
  5196. * @param result defines the target matrix
  5197. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5198. */
  5199. static PerspectiveFovWebVRToRef(fov: {
  5200. upDegrees: number;
  5201. downDegrees: number;
  5202. leftDegrees: number;
  5203. rightDegrees: number;
  5204. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5205. /**
  5206. * Computes a complete transformation matrix
  5207. * @param viewport defines the viewport to use
  5208. * @param world defines the world matrix
  5209. * @param view defines the view matrix
  5210. * @param projection defines the projection matrix
  5211. * @param zmin defines the near clip plane
  5212. * @param zmax defines the far clip plane
  5213. * @returns the transformation matrix
  5214. */
  5215. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5216. /**
  5217. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5218. * @param matrix defines the matrix to use
  5219. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5220. */
  5221. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5222. /**
  5223. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5224. * @param matrix defines the matrix to use
  5225. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5226. */
  5227. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5228. /**
  5229. * Compute the transpose of a given matrix
  5230. * @param matrix defines the matrix to transpose
  5231. * @returns the new matrix
  5232. */
  5233. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5234. /**
  5235. * Compute the transpose of a matrix and store it in a target matrix
  5236. * @param matrix defines the matrix to transpose
  5237. * @param result defines the target matrix
  5238. */
  5239. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5240. /**
  5241. * Computes a reflection matrix from a plane
  5242. * @param plane defines the reflection plane
  5243. * @returns a new matrix
  5244. */
  5245. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5246. /**
  5247. * Computes a reflection matrix from a plane
  5248. * @param plane defines the reflection plane
  5249. * @param result defines the target matrix
  5250. */
  5251. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5252. /**
  5253. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5254. * @param xaxis defines the value of the 1st axis
  5255. * @param yaxis defines the value of the 2nd axis
  5256. * @param zaxis defines the value of the 3rd axis
  5257. * @param result defines the target matrix
  5258. */
  5259. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5260. /**
  5261. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5262. * @param quat defines the quaternion to use
  5263. * @param result defines the target matrix
  5264. */
  5265. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5266. }
  5267. /**
  5268. * @hidden
  5269. */
  5270. export class TmpVectors {
  5271. static Vector2: Vector2[];
  5272. static Vector3: Vector3[];
  5273. static Vector4: Vector4[];
  5274. static Quaternion: Quaternion[];
  5275. static Matrix: Matrix[];
  5276. }
  5277. }
  5278. declare module "babylonjs/Maths/math.path" {
  5279. import { DeepImmutable, Nullable } from "babylonjs/types";
  5280. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5281. /**
  5282. * Defines potential orientation for back face culling
  5283. */
  5284. export enum Orientation {
  5285. /**
  5286. * Clockwise
  5287. */
  5288. CW = 0,
  5289. /** Counter clockwise */
  5290. CCW = 1
  5291. }
  5292. /** Class used to represent a Bezier curve */
  5293. export class BezierCurve {
  5294. /**
  5295. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5296. * @param t defines the time
  5297. * @param x1 defines the left coordinate on X axis
  5298. * @param y1 defines the left coordinate on Y axis
  5299. * @param x2 defines the right coordinate on X axis
  5300. * @param y2 defines the right coordinate on Y axis
  5301. * @returns the interpolated value
  5302. */
  5303. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5304. }
  5305. /**
  5306. * Defines angle representation
  5307. */
  5308. export class Angle {
  5309. private _radians;
  5310. /**
  5311. * Creates an Angle object of "radians" radians (float).
  5312. * @param radians the angle in radians
  5313. */
  5314. constructor(radians: number);
  5315. /**
  5316. * Get value in degrees
  5317. * @returns the Angle value in degrees (float)
  5318. */
  5319. degrees(): number;
  5320. /**
  5321. * Get value in radians
  5322. * @returns the Angle value in radians (float)
  5323. */
  5324. radians(): number;
  5325. /**
  5326. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5327. * @param a defines first point as the origin
  5328. * @param b defines point
  5329. * @returns a new Angle
  5330. */
  5331. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5332. /**
  5333. * Gets a new Angle object from the given float in radians
  5334. * @param radians defines the angle value in radians
  5335. * @returns a new Angle
  5336. */
  5337. static FromRadians(radians: number): Angle;
  5338. /**
  5339. * Gets a new Angle object from the given float in degrees
  5340. * @param degrees defines the angle value in degrees
  5341. * @returns a new Angle
  5342. */
  5343. static FromDegrees(degrees: number): Angle;
  5344. }
  5345. /**
  5346. * This represents an arc in a 2d space.
  5347. */
  5348. export class Arc2 {
  5349. /** Defines the start point of the arc */
  5350. startPoint: Vector2;
  5351. /** Defines the mid point of the arc */
  5352. midPoint: Vector2;
  5353. /** Defines the end point of the arc */
  5354. endPoint: Vector2;
  5355. /**
  5356. * Defines the center point of the arc.
  5357. */
  5358. centerPoint: Vector2;
  5359. /**
  5360. * Defines the radius of the arc.
  5361. */
  5362. radius: number;
  5363. /**
  5364. * Defines the angle of the arc (from mid point to end point).
  5365. */
  5366. angle: Angle;
  5367. /**
  5368. * Defines the start angle of the arc (from start point to middle point).
  5369. */
  5370. startAngle: Angle;
  5371. /**
  5372. * Defines the orientation of the arc (clock wise/counter clock wise).
  5373. */
  5374. orientation: Orientation;
  5375. /**
  5376. * Creates an Arc object from the three given points : start, middle and end.
  5377. * @param startPoint Defines the start point of the arc
  5378. * @param midPoint Defines the midlle point of the arc
  5379. * @param endPoint Defines the end point of the arc
  5380. */
  5381. constructor(
  5382. /** Defines the start point of the arc */
  5383. startPoint: Vector2,
  5384. /** Defines the mid point of the arc */
  5385. midPoint: Vector2,
  5386. /** Defines the end point of the arc */
  5387. endPoint: Vector2);
  5388. }
  5389. /**
  5390. * Represents a 2D path made up of multiple 2D points
  5391. */
  5392. export class Path2 {
  5393. private _points;
  5394. private _length;
  5395. /**
  5396. * If the path start and end point are the same
  5397. */
  5398. closed: boolean;
  5399. /**
  5400. * Creates a Path2 object from the starting 2D coordinates x and y.
  5401. * @param x the starting points x value
  5402. * @param y the starting points y value
  5403. */
  5404. constructor(x: number, y: number);
  5405. /**
  5406. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5407. * @param x the added points x value
  5408. * @param y the added points y value
  5409. * @returns the updated Path2.
  5410. */
  5411. addLineTo(x: number, y: number): Path2;
  5412. /**
  5413. * 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.
  5414. * @param midX middle point x value
  5415. * @param midY middle point y value
  5416. * @param endX end point x value
  5417. * @param endY end point y value
  5418. * @param numberOfSegments (default: 36)
  5419. * @returns the updated Path2.
  5420. */
  5421. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5422. /**
  5423. * Closes the Path2.
  5424. * @returns the Path2.
  5425. */
  5426. close(): Path2;
  5427. /**
  5428. * Gets the sum of the distance between each sequential point in the path
  5429. * @returns the Path2 total length (float).
  5430. */
  5431. length(): number;
  5432. /**
  5433. * Gets the points which construct the path
  5434. * @returns the Path2 internal array of points.
  5435. */
  5436. getPoints(): Vector2[];
  5437. /**
  5438. * Retreives the point at the distance aways from the starting point
  5439. * @param normalizedLengthPosition the length along the path to retreive the point from
  5440. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5441. */
  5442. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5443. /**
  5444. * Creates a new path starting from an x and y position
  5445. * @param x starting x value
  5446. * @param y starting y value
  5447. * @returns a new Path2 starting at the coordinates (x, y).
  5448. */
  5449. static StartingAt(x: number, y: number): Path2;
  5450. }
  5451. /**
  5452. * Represents a 3D path made up of multiple 3D points
  5453. */
  5454. export class Path3D {
  5455. /**
  5456. * an array of Vector3, the curve axis of the Path3D
  5457. */
  5458. path: Vector3[];
  5459. private _curve;
  5460. private _distances;
  5461. private _tangents;
  5462. private _normals;
  5463. private _binormals;
  5464. private _raw;
  5465. private _alignTangentsWithPath;
  5466. private readonly _pointAtData;
  5467. /**
  5468. * new Path3D(path, normal, raw)
  5469. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5470. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5471. * @param path an array of Vector3, the curve axis of the Path3D
  5472. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5473. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5474. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5475. */
  5476. constructor(
  5477. /**
  5478. * an array of Vector3, the curve axis of the Path3D
  5479. */
  5480. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5481. /**
  5482. * Returns the Path3D array of successive Vector3 designing its curve.
  5483. * @returns the Path3D array of successive Vector3 designing its curve.
  5484. */
  5485. getCurve(): Vector3[];
  5486. /**
  5487. * Returns the Path3D array of successive Vector3 designing its curve.
  5488. * @returns the Path3D array of successive Vector3 designing its curve.
  5489. */
  5490. getPoints(): Vector3[];
  5491. /**
  5492. * @returns the computed length (float) of the path.
  5493. */
  5494. length(): number;
  5495. /**
  5496. * Returns an array populated with tangent vectors on each Path3D curve point.
  5497. * @returns an array populated with tangent vectors on each Path3D curve point.
  5498. */
  5499. getTangents(): Vector3[];
  5500. /**
  5501. * Returns an array populated with normal vectors on each Path3D curve point.
  5502. * @returns an array populated with normal vectors on each Path3D curve point.
  5503. */
  5504. getNormals(): Vector3[];
  5505. /**
  5506. * Returns an array populated with binormal vectors on each Path3D curve point.
  5507. * @returns an array populated with binormal vectors on each Path3D curve point.
  5508. */
  5509. getBinormals(): Vector3[];
  5510. /**
  5511. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5512. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5513. */
  5514. getDistances(): number[];
  5515. /**
  5516. * Returns an interpolated point along this path
  5517. * @param position the position of the point along this path, from 0.0 to 1.0
  5518. * @returns a new Vector3 as the point
  5519. */
  5520. getPointAt(position: number): Vector3;
  5521. /**
  5522. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5523. * @param position the position of the point along this path, from 0.0 to 1.0
  5524. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5525. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5526. */
  5527. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5528. /**
  5529. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5530. * @param position the position of the point along this path, from 0.0 to 1.0
  5531. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5532. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5533. */
  5534. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5535. /**
  5536. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5537. * @param position the position of the point along this path, from 0.0 to 1.0
  5538. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5539. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5540. */
  5541. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5542. /**
  5543. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5544. * @param position the position of the point along this path, from 0.0 to 1.0
  5545. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5546. */
  5547. getDistanceAt(position: number): number;
  5548. /**
  5549. * Returns the array index of the previous point of an interpolated point along this path
  5550. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5551. * @returns the array index
  5552. */
  5553. getPreviousPointIndexAt(position: number): number;
  5554. /**
  5555. * 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)
  5556. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5557. * @returns the sub position
  5558. */
  5559. getSubPositionAt(position: number): number;
  5560. /**
  5561. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5562. * @param target the vector of which to get the closest position to
  5563. * @returns the position of the closest virtual point on this path to the target vector
  5564. */
  5565. getClosestPositionTo(target: Vector3): number;
  5566. /**
  5567. * Returns a sub path (slice) of this path
  5568. * @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
  5569. * @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
  5570. * @returns a sub path (slice) of this path
  5571. */
  5572. slice(start?: number, end?: number): Path3D;
  5573. /**
  5574. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5575. * @param path path which all values are copied into the curves points
  5576. * @param firstNormal which should be projected onto the curve
  5577. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5578. * @returns the same object updated.
  5579. */
  5580. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5581. private _compute;
  5582. private _getFirstNonNullVector;
  5583. private _getLastNonNullVector;
  5584. private _normalVector;
  5585. /**
  5586. * Updates the point at data for an interpolated point along this curve
  5587. * @param position the position of the point along this curve, from 0.0 to 1.0
  5588. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5589. * @returns the (updated) point at data
  5590. */
  5591. private _updatePointAtData;
  5592. /**
  5593. * Updates the point at data from the specified parameters
  5594. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5595. * @param point the interpolated point
  5596. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5597. */
  5598. private _setPointAtData;
  5599. /**
  5600. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5601. */
  5602. private _updateInterpolationMatrix;
  5603. }
  5604. /**
  5605. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5606. * A Curve3 is designed from a series of successive Vector3.
  5607. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5608. */
  5609. export class Curve3 {
  5610. private _points;
  5611. private _length;
  5612. /**
  5613. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5614. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5615. * @param v1 (Vector3) the control point
  5616. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5617. * @param nbPoints (integer) the wanted number of points in the curve
  5618. * @returns the created Curve3
  5619. */
  5620. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5621. /**
  5622. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5623. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5624. * @param v1 (Vector3) the first control point
  5625. * @param v2 (Vector3) the second control point
  5626. * @param v3 (Vector3) the end point of the Cubic Bezier
  5627. * @param nbPoints (integer) the wanted number of points in the curve
  5628. * @returns the created Curve3
  5629. */
  5630. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5631. /**
  5632. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5633. * @param p1 (Vector3) the origin point of the Hermite Spline
  5634. * @param t1 (Vector3) the tangent vector at the origin point
  5635. * @param p2 (Vector3) the end point of the Hermite Spline
  5636. * @param t2 (Vector3) the tangent vector at the end point
  5637. * @param nbPoints (integer) the wanted number of points in the curve
  5638. * @returns the created Curve3
  5639. */
  5640. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5641. /**
  5642. * Returns a Curve3 object along a CatmullRom Spline curve :
  5643. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5644. * @param nbPoints (integer) the wanted number of points between each curve control points
  5645. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5646. * @returns the created Curve3
  5647. */
  5648. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5649. /**
  5650. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5651. * A Curve3 is designed from a series of successive Vector3.
  5652. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5653. * @param points points which make up the curve
  5654. */
  5655. constructor(points: Vector3[]);
  5656. /**
  5657. * @returns the Curve3 stored array of successive Vector3
  5658. */
  5659. getPoints(): Vector3[];
  5660. /**
  5661. * @returns the computed length (float) of the curve.
  5662. */
  5663. length(): number;
  5664. /**
  5665. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5666. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5667. * curveA and curveB keep unchanged.
  5668. * @param curve the curve to continue from this curve
  5669. * @returns the newly constructed curve
  5670. */
  5671. continue(curve: DeepImmutable<Curve3>): Curve3;
  5672. private _computeLength;
  5673. }
  5674. }
  5675. declare module "babylonjs/Animations/easing" {
  5676. /**
  5677. * This represents the main contract an easing function should follow.
  5678. * Easing functions are used throughout the animation system.
  5679. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5680. */
  5681. export interface IEasingFunction {
  5682. /**
  5683. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5684. * of the easing function.
  5685. * The link below provides some of the most common examples of easing functions.
  5686. * @see https://easings.net/
  5687. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5688. * @returns the corresponding value on the curve defined by the easing function
  5689. */
  5690. ease(gradient: number): number;
  5691. }
  5692. /**
  5693. * Base class used for every default easing function.
  5694. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5695. */
  5696. export class EasingFunction implements IEasingFunction {
  5697. /**
  5698. * Interpolation follows the mathematical formula associated with the easing function.
  5699. */
  5700. static readonly EASINGMODE_EASEIN: number;
  5701. /**
  5702. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5703. */
  5704. static readonly EASINGMODE_EASEOUT: number;
  5705. /**
  5706. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5707. */
  5708. static readonly EASINGMODE_EASEINOUT: number;
  5709. private _easingMode;
  5710. /**
  5711. * Sets the easing mode of the current function.
  5712. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5713. */
  5714. setEasingMode(easingMode: number): void;
  5715. /**
  5716. * Gets the current easing mode.
  5717. * @returns the easing mode
  5718. */
  5719. getEasingMode(): number;
  5720. /**
  5721. * @hidden
  5722. */
  5723. easeInCore(gradient: number): number;
  5724. /**
  5725. * Given an input gradient between 0 and 1, this returns the corresponding value
  5726. * of the easing function.
  5727. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5728. * @returns the corresponding value on the curve defined by the easing function
  5729. */
  5730. ease(gradient: number): number;
  5731. }
  5732. /**
  5733. * Easing function with a circle shape (see link below).
  5734. * @see https://easings.net/#easeInCirc
  5735. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5736. */
  5737. export class CircleEase extends EasingFunction implements IEasingFunction {
  5738. /** @hidden */
  5739. easeInCore(gradient: number): number;
  5740. }
  5741. /**
  5742. * Easing function with a ease back shape (see link below).
  5743. * @see https://easings.net/#easeInBack
  5744. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5745. */
  5746. export class BackEase extends EasingFunction implements IEasingFunction {
  5747. /** Defines the amplitude of the function */
  5748. amplitude: number;
  5749. /**
  5750. * Instantiates a back ease easing
  5751. * @see https://easings.net/#easeInBack
  5752. * @param amplitude Defines the amplitude of the function
  5753. */
  5754. constructor(
  5755. /** Defines the amplitude of the function */
  5756. amplitude?: number);
  5757. /** @hidden */
  5758. easeInCore(gradient: number): number;
  5759. }
  5760. /**
  5761. * Easing function with a bouncing shape (see link below).
  5762. * @see https://easings.net/#easeInBounce
  5763. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5764. */
  5765. export class BounceEase extends EasingFunction implements IEasingFunction {
  5766. /** Defines the number of bounces */
  5767. bounces: number;
  5768. /** Defines the amplitude of the bounce */
  5769. bounciness: number;
  5770. /**
  5771. * Instantiates a bounce easing
  5772. * @see https://easings.net/#easeInBounce
  5773. * @param bounces Defines the number of bounces
  5774. * @param bounciness Defines the amplitude of the bounce
  5775. */
  5776. constructor(
  5777. /** Defines the number of bounces */
  5778. bounces?: number,
  5779. /** Defines the amplitude of the bounce */
  5780. bounciness?: number);
  5781. /** @hidden */
  5782. easeInCore(gradient: number): number;
  5783. }
  5784. /**
  5785. * Easing function with a power of 3 shape (see link below).
  5786. * @see https://easings.net/#easeInCubic
  5787. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5788. */
  5789. export class CubicEase extends EasingFunction implements IEasingFunction {
  5790. /** @hidden */
  5791. easeInCore(gradient: number): number;
  5792. }
  5793. /**
  5794. * Easing function with an elastic shape (see link below).
  5795. * @see https://easings.net/#easeInElastic
  5796. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5797. */
  5798. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5799. /** Defines the number of oscillations*/
  5800. oscillations: number;
  5801. /** Defines the amplitude of the oscillations*/
  5802. springiness: number;
  5803. /**
  5804. * Instantiates an elastic easing function
  5805. * @see https://easings.net/#easeInElastic
  5806. * @param oscillations Defines the number of oscillations
  5807. * @param springiness Defines the amplitude of the oscillations
  5808. */
  5809. constructor(
  5810. /** Defines the number of oscillations*/
  5811. oscillations?: number,
  5812. /** Defines the amplitude of the oscillations*/
  5813. springiness?: number);
  5814. /** @hidden */
  5815. easeInCore(gradient: number): number;
  5816. }
  5817. /**
  5818. * Easing function with an exponential shape (see link below).
  5819. * @see https://easings.net/#easeInExpo
  5820. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5821. */
  5822. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5823. /** Defines the exponent of the function */
  5824. exponent: number;
  5825. /**
  5826. * Instantiates an exponential easing function
  5827. * @see https://easings.net/#easeInExpo
  5828. * @param exponent Defines the exponent of the function
  5829. */
  5830. constructor(
  5831. /** Defines the exponent of the function */
  5832. exponent?: number);
  5833. /** @hidden */
  5834. easeInCore(gradient: number): number;
  5835. }
  5836. /**
  5837. * Easing function with a power shape (see link below).
  5838. * @see https://easings.net/#easeInQuad
  5839. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5840. */
  5841. export class PowerEase extends EasingFunction implements IEasingFunction {
  5842. /** Defines the power of the function */
  5843. power: number;
  5844. /**
  5845. * Instantiates an power base easing function
  5846. * @see https://easings.net/#easeInQuad
  5847. * @param power Defines the power of the function
  5848. */
  5849. constructor(
  5850. /** Defines the power of the function */
  5851. power?: number);
  5852. /** @hidden */
  5853. easeInCore(gradient: number): number;
  5854. }
  5855. /**
  5856. * Easing function with a power of 2 shape (see link below).
  5857. * @see https://easings.net/#easeInQuad
  5858. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5859. */
  5860. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5861. /** @hidden */
  5862. easeInCore(gradient: number): number;
  5863. }
  5864. /**
  5865. * Easing function with a power of 4 shape (see link below).
  5866. * @see https://easings.net/#easeInQuart
  5867. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5868. */
  5869. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5870. /** @hidden */
  5871. easeInCore(gradient: number): number;
  5872. }
  5873. /**
  5874. * Easing function with a power of 5 shape (see link below).
  5875. * @see https://easings.net/#easeInQuint
  5876. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5877. */
  5878. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5879. /** @hidden */
  5880. easeInCore(gradient: number): number;
  5881. }
  5882. /**
  5883. * Easing function with a sin shape (see link below).
  5884. * @see https://easings.net/#easeInSine
  5885. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5886. */
  5887. export class SineEase extends EasingFunction implements IEasingFunction {
  5888. /** @hidden */
  5889. easeInCore(gradient: number): number;
  5890. }
  5891. /**
  5892. * Easing function with a bezier shape (see link below).
  5893. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5894. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5895. */
  5896. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5897. /** Defines the x component of the start tangent in the bezier curve */
  5898. x1: number;
  5899. /** Defines the y component of the start tangent in the bezier curve */
  5900. y1: number;
  5901. /** Defines the x component of the end tangent in the bezier curve */
  5902. x2: number;
  5903. /** Defines the y component of the end tangent in the bezier curve */
  5904. y2: number;
  5905. /**
  5906. * Instantiates a bezier function
  5907. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5908. * @param x1 Defines the x component of the start tangent in the bezier curve
  5909. * @param y1 Defines the y component of the start tangent in the bezier curve
  5910. * @param x2 Defines the x component of the end tangent in the bezier curve
  5911. * @param y2 Defines the y component of the end tangent in the bezier curve
  5912. */
  5913. constructor(
  5914. /** Defines the x component of the start tangent in the bezier curve */
  5915. x1?: number,
  5916. /** Defines the y component of the start tangent in the bezier curve */
  5917. y1?: number,
  5918. /** Defines the x component of the end tangent in the bezier curve */
  5919. x2?: number,
  5920. /** Defines the y component of the end tangent in the bezier curve */
  5921. y2?: number);
  5922. /** @hidden */
  5923. easeInCore(gradient: number): number;
  5924. }
  5925. }
  5926. declare module "babylonjs/Maths/math.color" {
  5927. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5928. /**
  5929. * Class used to hold a RBG color
  5930. */
  5931. export class Color3 {
  5932. /**
  5933. * Defines the red component (between 0 and 1, default is 0)
  5934. */
  5935. r: number;
  5936. /**
  5937. * Defines the green component (between 0 and 1, default is 0)
  5938. */
  5939. g: number;
  5940. /**
  5941. * Defines the blue component (between 0 and 1, default is 0)
  5942. */
  5943. b: number;
  5944. /**
  5945. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5946. * @param r defines the red component (between 0 and 1, default is 0)
  5947. * @param g defines the green component (between 0 and 1, default is 0)
  5948. * @param b defines the blue component (between 0 and 1, default is 0)
  5949. */
  5950. constructor(
  5951. /**
  5952. * Defines the red component (between 0 and 1, default is 0)
  5953. */
  5954. r?: number,
  5955. /**
  5956. * Defines the green component (between 0 and 1, default is 0)
  5957. */
  5958. g?: number,
  5959. /**
  5960. * Defines the blue component (between 0 and 1, default is 0)
  5961. */
  5962. b?: number);
  5963. /**
  5964. * Creates a string with the Color3 current values
  5965. * @returns the string representation of the Color3 object
  5966. */
  5967. toString(): string;
  5968. /**
  5969. * Returns the string "Color3"
  5970. * @returns "Color3"
  5971. */
  5972. getClassName(): string;
  5973. /**
  5974. * Compute the Color3 hash code
  5975. * @returns an unique number that can be used to hash Color3 objects
  5976. */
  5977. getHashCode(): number;
  5978. /**
  5979. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5980. * @param array defines the array where to store the r,g,b components
  5981. * @param index defines an optional index in the target array to define where to start storing values
  5982. * @returns the current Color3 object
  5983. */
  5984. toArray(array: FloatArray, index?: number): Color3;
  5985. /**
  5986. * Update the current color with values stored in an array from the starting index of the given array
  5987. * @param array defines the source array
  5988. * @param offset defines an offset in the source array
  5989. * @returns the current Color3 object
  5990. */
  5991. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5992. /**
  5993. * Returns a new Color4 object from the current Color3 and the given alpha
  5994. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5995. * @returns a new Color4 object
  5996. */
  5997. toColor4(alpha?: number): Color4;
  5998. /**
  5999. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6000. * @returns the new array
  6001. */
  6002. asArray(): number[];
  6003. /**
  6004. * Returns the luminance value
  6005. * @returns a float value
  6006. */
  6007. toLuminance(): number;
  6008. /**
  6009. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6010. * @param otherColor defines the second operand
  6011. * @returns the new Color3 object
  6012. */
  6013. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6014. /**
  6015. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6016. * @param otherColor defines the second operand
  6017. * @param result defines the Color3 object where to store the result
  6018. * @returns the current Color3
  6019. */
  6020. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6021. /**
  6022. * Determines equality between Color3 objects
  6023. * @param otherColor defines the second operand
  6024. * @returns true if the rgb values are equal to the given ones
  6025. */
  6026. equals(otherColor: DeepImmutable<Color3>): boolean;
  6027. /**
  6028. * Determines equality between the current Color3 object and a set of r,b,g values
  6029. * @param r defines the red component to check
  6030. * @param g defines the green component to check
  6031. * @param b defines the blue component to check
  6032. * @returns true if the rgb values are equal to the given ones
  6033. */
  6034. equalsFloats(r: number, g: number, b: number): boolean;
  6035. /**
  6036. * Multiplies in place each rgb value by scale
  6037. * @param scale defines the scaling factor
  6038. * @returns the updated Color3
  6039. */
  6040. scale(scale: number): Color3;
  6041. /**
  6042. * Multiplies the rgb values by scale and stores the result into "result"
  6043. * @param scale defines the scaling factor
  6044. * @param result defines the Color3 object where to store the result
  6045. * @returns the unmodified current Color3
  6046. */
  6047. scaleToRef(scale: number, result: Color3): Color3;
  6048. /**
  6049. * Scale the current Color3 values by a factor and add the result to a given Color3
  6050. * @param scale defines the scale factor
  6051. * @param result defines color to store the result into
  6052. * @returns the unmodified current Color3
  6053. */
  6054. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6055. /**
  6056. * Clamps the rgb values by the min and max values and stores the result into "result"
  6057. * @param min defines minimum clamping value (default is 0)
  6058. * @param max defines maximum clamping value (default is 1)
  6059. * @param result defines color to store the result into
  6060. * @returns the original Color3
  6061. */
  6062. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6063. /**
  6064. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6065. * @param otherColor defines the second operand
  6066. * @returns the new Color3
  6067. */
  6068. add(otherColor: DeepImmutable<Color3>): Color3;
  6069. /**
  6070. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6071. * @param otherColor defines the second operand
  6072. * @param result defines Color3 object to store the result into
  6073. * @returns the unmodified current Color3
  6074. */
  6075. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6076. /**
  6077. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6078. * @param otherColor defines the second operand
  6079. * @returns the new Color3
  6080. */
  6081. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6082. /**
  6083. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6084. * @param otherColor defines the second operand
  6085. * @param result defines Color3 object to store the result into
  6086. * @returns the unmodified current Color3
  6087. */
  6088. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6089. /**
  6090. * Copy the current object
  6091. * @returns a new Color3 copied the current one
  6092. */
  6093. clone(): Color3;
  6094. /**
  6095. * Copies the rgb values from the source in the current Color3
  6096. * @param source defines the source Color3 object
  6097. * @returns the updated Color3 object
  6098. */
  6099. copyFrom(source: DeepImmutable<Color3>): Color3;
  6100. /**
  6101. * Updates the Color3 rgb values from the given floats
  6102. * @param r defines the red component to read from
  6103. * @param g defines the green component to read from
  6104. * @param b defines the blue component to read from
  6105. * @returns the current Color3 object
  6106. */
  6107. copyFromFloats(r: number, g: number, b: number): Color3;
  6108. /**
  6109. * Updates the Color3 rgb values from the given floats
  6110. * @param r defines the red component to read from
  6111. * @param g defines the green component to read from
  6112. * @param b defines the blue component to read from
  6113. * @returns the current Color3 object
  6114. */
  6115. set(r: number, g: number, b: number): Color3;
  6116. /**
  6117. * Compute the Color3 hexadecimal code as a string
  6118. * @returns a string containing the hexadecimal representation of the Color3 object
  6119. */
  6120. toHexString(): string;
  6121. /**
  6122. * Computes a new Color3 converted from the current one to linear space
  6123. * @returns a new Color3 object
  6124. */
  6125. toLinearSpace(): Color3;
  6126. /**
  6127. * Converts current color in rgb space to HSV values
  6128. * @returns a new color3 representing the HSV values
  6129. */
  6130. toHSV(): Color3;
  6131. /**
  6132. * Converts current color in rgb space to HSV values
  6133. * @param result defines the Color3 where to store the HSV values
  6134. */
  6135. toHSVToRef(result: Color3): void;
  6136. /**
  6137. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6138. * @param convertedColor defines the Color3 object where to store the linear space version
  6139. * @returns the unmodified Color3
  6140. */
  6141. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6142. /**
  6143. * Computes a new Color3 converted from the current one to gamma space
  6144. * @returns a new Color3 object
  6145. */
  6146. toGammaSpace(): Color3;
  6147. /**
  6148. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6149. * @param convertedColor defines the Color3 object where to store the gamma space version
  6150. * @returns the unmodified Color3
  6151. */
  6152. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6153. private static _BlackReadOnly;
  6154. /**
  6155. * Convert Hue, saturation and value to a Color3 (RGB)
  6156. * @param hue defines the hue
  6157. * @param saturation defines the saturation
  6158. * @param value defines the value
  6159. * @param result defines the Color3 where to store the RGB values
  6160. */
  6161. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6162. /**
  6163. * Creates a new Color3 from the string containing valid hexadecimal values
  6164. * @param hex defines a string containing valid hexadecimal values
  6165. * @returns a new Color3 object
  6166. */
  6167. static FromHexString(hex: string): Color3;
  6168. /**
  6169. * Creates a new Color3 from the starting index of the given array
  6170. * @param array defines the source array
  6171. * @param offset defines an offset in the source array
  6172. * @returns a new Color3 object
  6173. */
  6174. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6175. /**
  6176. * Creates a new Color3 from the starting index element of the given array
  6177. * @param array defines the source array to read from
  6178. * @param offset defines the offset in the source array
  6179. * @param result defines the target Color3 object
  6180. */
  6181. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6182. /**
  6183. * Creates a new Color3 from integer values (< 256)
  6184. * @param r defines the red component to read from (value between 0 and 255)
  6185. * @param g defines the green component to read from (value between 0 and 255)
  6186. * @param b defines the blue component to read from (value between 0 and 255)
  6187. * @returns a new Color3 object
  6188. */
  6189. static FromInts(r: number, g: number, b: number): Color3;
  6190. /**
  6191. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6192. * @param start defines the start Color3 value
  6193. * @param end defines the end Color3 value
  6194. * @param amount defines the gradient value between start and end
  6195. * @returns a new Color3 object
  6196. */
  6197. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6198. /**
  6199. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6200. * @param left defines the start value
  6201. * @param right defines the end value
  6202. * @param amount defines the gradient factor
  6203. * @param result defines the Color3 object where to store the result
  6204. */
  6205. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6206. /**
  6207. * Returns a Color3 value containing a red color
  6208. * @returns a new Color3 object
  6209. */
  6210. static Red(): Color3;
  6211. /**
  6212. * Returns a Color3 value containing a green color
  6213. * @returns a new Color3 object
  6214. */
  6215. static Green(): Color3;
  6216. /**
  6217. * Returns a Color3 value containing a blue color
  6218. * @returns a new Color3 object
  6219. */
  6220. static Blue(): Color3;
  6221. /**
  6222. * Returns a Color3 value containing a black color
  6223. * @returns a new Color3 object
  6224. */
  6225. static Black(): Color3;
  6226. /**
  6227. * Gets a Color3 value containing a black color that must not be updated
  6228. */
  6229. static get BlackReadOnly(): DeepImmutable<Color3>;
  6230. /**
  6231. * Returns a Color3 value containing a white color
  6232. * @returns a new Color3 object
  6233. */
  6234. static White(): Color3;
  6235. /**
  6236. * Returns a Color3 value containing a purple color
  6237. * @returns a new Color3 object
  6238. */
  6239. static Purple(): Color3;
  6240. /**
  6241. * Returns a Color3 value containing a magenta color
  6242. * @returns a new Color3 object
  6243. */
  6244. static Magenta(): Color3;
  6245. /**
  6246. * Returns a Color3 value containing a yellow color
  6247. * @returns a new Color3 object
  6248. */
  6249. static Yellow(): Color3;
  6250. /**
  6251. * Returns a Color3 value containing a gray color
  6252. * @returns a new Color3 object
  6253. */
  6254. static Gray(): Color3;
  6255. /**
  6256. * Returns a Color3 value containing a teal color
  6257. * @returns a new Color3 object
  6258. */
  6259. static Teal(): Color3;
  6260. /**
  6261. * Returns a Color3 value containing a random color
  6262. * @returns a new Color3 object
  6263. */
  6264. static Random(): Color3;
  6265. }
  6266. /**
  6267. * Class used to hold a RBGA color
  6268. */
  6269. export class Color4 {
  6270. /**
  6271. * Defines the red component (between 0 and 1, default is 0)
  6272. */
  6273. r: number;
  6274. /**
  6275. * Defines the green component (between 0 and 1, default is 0)
  6276. */
  6277. g: number;
  6278. /**
  6279. * Defines the blue component (between 0 and 1, default is 0)
  6280. */
  6281. b: number;
  6282. /**
  6283. * Defines the alpha component (between 0 and 1, default is 1)
  6284. */
  6285. a: number;
  6286. /**
  6287. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6288. * @param r defines the red component (between 0 and 1, default is 0)
  6289. * @param g defines the green component (between 0 and 1, default is 0)
  6290. * @param b defines the blue component (between 0 and 1, default is 0)
  6291. * @param a defines the alpha component (between 0 and 1, default is 1)
  6292. */
  6293. constructor(
  6294. /**
  6295. * Defines the red component (between 0 and 1, default is 0)
  6296. */
  6297. r?: number,
  6298. /**
  6299. * Defines the green component (between 0 and 1, default is 0)
  6300. */
  6301. g?: number,
  6302. /**
  6303. * Defines the blue component (between 0 and 1, default is 0)
  6304. */
  6305. b?: number,
  6306. /**
  6307. * Defines the alpha component (between 0 and 1, default is 1)
  6308. */
  6309. a?: number);
  6310. /**
  6311. * Adds in place the given Color4 values to the current Color4 object
  6312. * @param right defines the second operand
  6313. * @returns the current updated Color4 object
  6314. */
  6315. addInPlace(right: DeepImmutable<Color4>): Color4;
  6316. /**
  6317. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6318. * @returns the new array
  6319. */
  6320. asArray(): number[];
  6321. /**
  6322. * Stores from the starting index in the given array the Color4 successive values
  6323. * @param array defines the array where to store the r,g,b components
  6324. * @param index defines an optional index in the target array to define where to start storing values
  6325. * @returns the current Color4 object
  6326. */
  6327. toArray(array: number[], index?: number): Color4;
  6328. /**
  6329. * Update the current color with values stored in an array from the starting index of the given array
  6330. * @param array defines the source array
  6331. * @param offset defines an offset in the source array
  6332. * @returns the current Color4 object
  6333. */
  6334. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6335. /**
  6336. * Determines equality between Color4 objects
  6337. * @param otherColor defines the second operand
  6338. * @returns true if the rgba values are equal to the given ones
  6339. */
  6340. equals(otherColor: DeepImmutable<Color4>): boolean;
  6341. /**
  6342. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6343. * @param right defines the second operand
  6344. * @returns a new Color4 object
  6345. */
  6346. add(right: DeepImmutable<Color4>): Color4;
  6347. /**
  6348. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6349. * @param right defines the second operand
  6350. * @returns a new Color4 object
  6351. */
  6352. subtract(right: DeepImmutable<Color4>): Color4;
  6353. /**
  6354. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6355. * @param right defines the second operand
  6356. * @param result defines the Color4 object where to store the result
  6357. * @returns the current Color4 object
  6358. */
  6359. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6360. /**
  6361. * Creates a new Color4 with the current Color4 values multiplied by scale
  6362. * @param scale defines the scaling factor to apply
  6363. * @returns a new Color4 object
  6364. */
  6365. scale(scale: number): Color4;
  6366. /**
  6367. * Multiplies the current Color4 values by scale and stores the result in "result"
  6368. * @param scale defines the scaling factor to apply
  6369. * @param result defines the Color4 object where to store the result
  6370. * @returns the current unmodified Color4
  6371. */
  6372. scaleToRef(scale: number, result: Color4): Color4;
  6373. /**
  6374. * Scale the current Color4 values by a factor and add the result to a given Color4
  6375. * @param scale defines the scale factor
  6376. * @param result defines the Color4 object where to store the result
  6377. * @returns the unmodified current Color4
  6378. */
  6379. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6380. /**
  6381. * Clamps the rgb values by the min and max values and stores the result into "result"
  6382. * @param min defines minimum clamping value (default is 0)
  6383. * @param max defines maximum clamping value (default is 1)
  6384. * @param result defines color to store the result into.
  6385. * @returns the cuurent Color4
  6386. */
  6387. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6388. /**
  6389. * Multipy an Color4 value by another and return a new Color4 object
  6390. * @param color defines the Color4 value to multiply by
  6391. * @returns a new Color4 object
  6392. */
  6393. multiply(color: Color4): Color4;
  6394. /**
  6395. * Multipy a Color4 value by another and push the result in a reference value
  6396. * @param color defines the Color4 value to multiply by
  6397. * @param result defines the Color4 to fill the result in
  6398. * @returns the result Color4
  6399. */
  6400. multiplyToRef(color: Color4, result: Color4): Color4;
  6401. /**
  6402. * Creates a string with the Color4 current values
  6403. * @returns the string representation of the Color4 object
  6404. */
  6405. toString(): string;
  6406. /**
  6407. * Returns the string "Color4"
  6408. * @returns "Color4"
  6409. */
  6410. getClassName(): string;
  6411. /**
  6412. * Compute the Color4 hash code
  6413. * @returns an unique number that can be used to hash Color4 objects
  6414. */
  6415. getHashCode(): number;
  6416. /**
  6417. * Creates a new Color4 copied from the current one
  6418. * @returns a new Color4 object
  6419. */
  6420. clone(): Color4;
  6421. /**
  6422. * Copies the given Color4 values into the current one
  6423. * @param source defines the source Color4 object
  6424. * @returns the current updated Color4 object
  6425. */
  6426. copyFrom(source: Color4): Color4;
  6427. /**
  6428. * Copies the given float values into the current one
  6429. * @param r defines the red component to read from
  6430. * @param g defines the green component to read from
  6431. * @param b defines the blue component to read from
  6432. * @param a defines the alpha component to read from
  6433. * @returns the current updated Color4 object
  6434. */
  6435. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6436. /**
  6437. * Copies the given float values into the current one
  6438. * @param r defines the red component to read from
  6439. * @param g defines the green component to read from
  6440. * @param b defines the blue component to read from
  6441. * @param a defines the alpha component to read from
  6442. * @returns the current updated Color4 object
  6443. */
  6444. set(r: number, g: number, b: number, a: number): Color4;
  6445. /**
  6446. * Compute the Color4 hexadecimal code as a string
  6447. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6448. * @returns a string containing the hexadecimal representation of the Color4 object
  6449. */
  6450. toHexString(returnAsColor3?: boolean): string;
  6451. /**
  6452. * Computes a new Color4 converted from the current one to linear space
  6453. * @returns a new Color4 object
  6454. */
  6455. toLinearSpace(): Color4;
  6456. /**
  6457. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6458. * @param convertedColor defines the Color4 object where to store the linear space version
  6459. * @returns the unmodified Color4
  6460. */
  6461. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6462. /**
  6463. * Computes a new Color4 converted from the current one to gamma space
  6464. * @returns a new Color4 object
  6465. */
  6466. toGammaSpace(): Color4;
  6467. /**
  6468. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6469. * @param convertedColor defines the Color4 object where to store the gamma space version
  6470. * @returns the unmodified Color4
  6471. */
  6472. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6473. /**
  6474. * Creates a new Color4 from the string containing valid hexadecimal values
  6475. * @param hex defines a string containing valid hexadecimal values
  6476. * @returns a new Color4 object
  6477. */
  6478. static FromHexString(hex: string): Color4;
  6479. /**
  6480. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6481. * @param left defines the start value
  6482. * @param right defines the end value
  6483. * @param amount defines the gradient factor
  6484. * @returns a new Color4 object
  6485. */
  6486. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6487. /**
  6488. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6489. * @param left defines the start value
  6490. * @param right defines the end value
  6491. * @param amount defines the gradient factor
  6492. * @param result defines the Color4 object where to store data
  6493. */
  6494. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6495. /**
  6496. * Creates a new Color4 from a Color3 and an alpha value
  6497. * @param color3 defines the source Color3 to read from
  6498. * @param alpha defines the alpha component (1.0 by default)
  6499. * @returns a new Color4 object
  6500. */
  6501. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6502. /**
  6503. * Creates a new Color4 from the starting index element of the given array
  6504. * @param array defines the source array to read from
  6505. * @param offset defines the offset in the source array
  6506. * @returns a new Color4 object
  6507. */
  6508. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6509. /**
  6510. * Creates a new Color4 from the starting index element of the given array
  6511. * @param array defines the source array to read from
  6512. * @param offset defines the offset in the source array
  6513. * @param result defines the target Color4 object
  6514. */
  6515. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6516. /**
  6517. * Creates a new Color3 from integer values (< 256)
  6518. * @param r defines the red component to read from (value between 0 and 255)
  6519. * @param g defines the green component to read from (value between 0 and 255)
  6520. * @param b defines the blue component to read from (value between 0 and 255)
  6521. * @param a defines the alpha component to read from (value between 0 and 255)
  6522. * @returns a new Color3 object
  6523. */
  6524. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6525. /**
  6526. * Check the content of a given array and convert it to an array containing RGBA data
  6527. * If the original array was already containing count * 4 values then it is returned directly
  6528. * @param colors defines the array to check
  6529. * @param count defines the number of RGBA data to expect
  6530. * @returns an array containing count * 4 values (RGBA)
  6531. */
  6532. static CheckColors4(colors: number[], count: number): number[];
  6533. }
  6534. /**
  6535. * @hidden
  6536. */
  6537. export class TmpColors {
  6538. static Color3: Color3[];
  6539. static Color4: Color4[];
  6540. }
  6541. }
  6542. declare module "babylonjs/Animations/animationKey" {
  6543. /**
  6544. * Defines an interface which represents an animation key frame
  6545. */
  6546. export interface IAnimationKey {
  6547. /**
  6548. * Frame of the key frame
  6549. */
  6550. frame: number;
  6551. /**
  6552. * Value at the specifies key frame
  6553. */
  6554. value: any;
  6555. /**
  6556. * The input tangent for the cubic hermite spline
  6557. */
  6558. inTangent?: any;
  6559. /**
  6560. * The output tangent for the cubic hermite spline
  6561. */
  6562. outTangent?: any;
  6563. /**
  6564. * The animation interpolation type
  6565. */
  6566. interpolation?: AnimationKeyInterpolation;
  6567. }
  6568. /**
  6569. * Enum for the animation key frame interpolation type
  6570. */
  6571. export enum AnimationKeyInterpolation {
  6572. /**
  6573. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6574. */
  6575. STEP = 1
  6576. }
  6577. }
  6578. declare module "babylonjs/Animations/animationRange" {
  6579. /**
  6580. * Represents the range of an animation
  6581. */
  6582. export class AnimationRange {
  6583. /**The name of the animation range**/
  6584. name: string;
  6585. /**The starting frame of the animation */
  6586. from: number;
  6587. /**The ending frame of the animation*/
  6588. to: number;
  6589. /**
  6590. * Initializes the range of an animation
  6591. * @param name The name of the animation range
  6592. * @param from The starting frame of the animation
  6593. * @param to The ending frame of the animation
  6594. */
  6595. constructor(
  6596. /**The name of the animation range**/
  6597. name: string,
  6598. /**The starting frame of the animation */
  6599. from: number,
  6600. /**The ending frame of the animation*/
  6601. to: number);
  6602. /**
  6603. * Makes a copy of the animation range
  6604. * @returns A copy of the animation range
  6605. */
  6606. clone(): AnimationRange;
  6607. }
  6608. }
  6609. declare module "babylonjs/Animations/animationEvent" {
  6610. /**
  6611. * Composed of a frame, and an action function
  6612. */
  6613. export class AnimationEvent {
  6614. /** The frame for which the event is triggered **/
  6615. frame: number;
  6616. /** The event to perform when triggered **/
  6617. action: (currentFrame: number) => void;
  6618. /** Specifies if the event should be triggered only once**/
  6619. onlyOnce?: boolean | undefined;
  6620. /**
  6621. * Specifies if the animation event is done
  6622. */
  6623. isDone: boolean;
  6624. /**
  6625. * Initializes the animation event
  6626. * @param frame The frame for which the event is triggered
  6627. * @param action The event to perform when triggered
  6628. * @param onlyOnce Specifies if the event should be triggered only once
  6629. */
  6630. constructor(
  6631. /** The frame for which the event is triggered **/
  6632. frame: number,
  6633. /** The event to perform when triggered **/
  6634. action: (currentFrame: number) => void,
  6635. /** Specifies if the event should be triggered only once**/
  6636. onlyOnce?: boolean | undefined);
  6637. /** @hidden */
  6638. _clone(): AnimationEvent;
  6639. }
  6640. }
  6641. declare module "babylonjs/Behaviors/behavior" {
  6642. import { Nullable } from "babylonjs/types";
  6643. /**
  6644. * Interface used to define a behavior
  6645. */
  6646. export interface Behavior<T> {
  6647. /** gets or sets behavior's name */
  6648. name: string;
  6649. /**
  6650. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6651. */
  6652. init(): void;
  6653. /**
  6654. * Called when the behavior is attached to a target
  6655. * @param target defines the target where the behavior is attached to
  6656. */
  6657. attach(target: T): void;
  6658. /**
  6659. * Called when the behavior is detached from its target
  6660. */
  6661. detach(): void;
  6662. }
  6663. /**
  6664. * Interface implemented by classes supporting behaviors
  6665. */
  6666. export interface IBehaviorAware<T> {
  6667. /**
  6668. * Attach a behavior
  6669. * @param behavior defines the behavior to attach
  6670. * @returns the current host
  6671. */
  6672. addBehavior(behavior: Behavior<T>): T;
  6673. /**
  6674. * Remove a behavior from the current object
  6675. * @param behavior defines the behavior to detach
  6676. * @returns the current host
  6677. */
  6678. removeBehavior(behavior: Behavior<T>): T;
  6679. /**
  6680. * Gets a behavior using its name to search
  6681. * @param name defines the name to search
  6682. * @returns the behavior or null if not found
  6683. */
  6684. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6685. }
  6686. }
  6687. declare module "babylonjs/Meshes/buffer" {
  6688. import { Nullable, DataArray } from "babylonjs/types";
  6689. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6690. /**
  6691. * Class used to store data that will be store in GPU memory
  6692. */
  6693. export class Buffer {
  6694. private _engine;
  6695. private _buffer;
  6696. /** @hidden */
  6697. _data: Nullable<DataArray>;
  6698. private _updatable;
  6699. private _instanced;
  6700. private _divisor;
  6701. private _isAlreadyOwned;
  6702. /**
  6703. * Gets the byte stride.
  6704. */
  6705. readonly byteStride: number;
  6706. /**
  6707. * Constructor
  6708. * @param engine the engine
  6709. * @param data the data to use for this buffer
  6710. * @param updatable whether the data is updatable
  6711. * @param stride the stride (optional)
  6712. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6713. * @param instanced whether the buffer is instanced (optional)
  6714. * @param useBytes set to true if the stride in in bytes (optional)
  6715. * @param divisor sets an optional divisor for instances (1 by default)
  6716. */
  6717. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6718. /**
  6719. * Create a new VertexBuffer based on the current buffer
  6720. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6721. * @param offset defines offset in the buffer (0 by default)
  6722. * @param size defines the size in floats of attributes (position is 3 for instance)
  6723. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6724. * @param instanced defines if the vertex buffer contains indexed data
  6725. * @param useBytes defines if the offset and stride are in bytes *
  6726. * @param divisor sets an optional divisor for instances (1 by default)
  6727. * @returns the new vertex buffer
  6728. */
  6729. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6730. /**
  6731. * Gets a boolean indicating if the Buffer is updatable?
  6732. * @returns true if the buffer is updatable
  6733. */
  6734. isUpdatable(): boolean;
  6735. /**
  6736. * Gets current buffer's data
  6737. * @returns a DataArray or null
  6738. */
  6739. getData(): Nullable<DataArray>;
  6740. /**
  6741. * Gets underlying native buffer
  6742. * @returns underlying native buffer
  6743. */
  6744. getBuffer(): Nullable<DataBuffer>;
  6745. /**
  6746. * Gets the stride in float32 units (i.e. byte stride / 4).
  6747. * May not be an integer if the byte stride is not divisible by 4.
  6748. * @returns the stride in float32 units
  6749. * @deprecated Please use byteStride instead.
  6750. */
  6751. getStrideSize(): number;
  6752. /**
  6753. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6754. * @param data defines the data to store
  6755. */
  6756. create(data?: Nullable<DataArray>): void;
  6757. /** @hidden */
  6758. _rebuild(): void;
  6759. /**
  6760. * Update current buffer data
  6761. * @param data defines the data to store
  6762. */
  6763. update(data: DataArray): void;
  6764. /**
  6765. * Updates the data directly.
  6766. * @param data the new data
  6767. * @param offset the new offset
  6768. * @param vertexCount the vertex count (optional)
  6769. * @param useBytes set to true if the offset is in bytes
  6770. */
  6771. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6772. /** @hidden */
  6773. _increaseReferences(): void;
  6774. /**
  6775. * Release all resources
  6776. */
  6777. dispose(): void;
  6778. }
  6779. /**
  6780. * Specialized buffer used to store vertex data
  6781. */
  6782. export class VertexBuffer {
  6783. /** @hidden */
  6784. _buffer: Buffer;
  6785. private _kind;
  6786. private _size;
  6787. private _ownsBuffer;
  6788. private _instanced;
  6789. private _instanceDivisor;
  6790. /**
  6791. * The byte type.
  6792. */
  6793. static readonly BYTE: number;
  6794. /**
  6795. * The unsigned byte type.
  6796. */
  6797. static readonly UNSIGNED_BYTE: number;
  6798. /**
  6799. * The short type.
  6800. */
  6801. static readonly SHORT: number;
  6802. /**
  6803. * The unsigned short type.
  6804. */
  6805. static readonly UNSIGNED_SHORT: number;
  6806. /**
  6807. * The integer type.
  6808. */
  6809. static readonly INT: number;
  6810. /**
  6811. * The unsigned integer type.
  6812. */
  6813. static readonly UNSIGNED_INT: number;
  6814. /**
  6815. * The float type.
  6816. */
  6817. static readonly FLOAT: number;
  6818. /**
  6819. * Gets or sets the instance divisor when in instanced mode
  6820. */
  6821. get instanceDivisor(): number;
  6822. set instanceDivisor(value: number);
  6823. /**
  6824. * Gets the byte stride.
  6825. */
  6826. readonly byteStride: number;
  6827. /**
  6828. * Gets the byte offset.
  6829. */
  6830. readonly byteOffset: number;
  6831. /**
  6832. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6833. */
  6834. readonly normalized: boolean;
  6835. /**
  6836. * Gets the data type of each component in the array.
  6837. */
  6838. readonly type: number;
  6839. /**
  6840. * Constructor
  6841. * @param engine the engine
  6842. * @param data the data to use for this vertex buffer
  6843. * @param kind the vertex buffer kind
  6844. * @param updatable whether the data is updatable
  6845. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6846. * @param stride the stride (optional)
  6847. * @param instanced whether the buffer is instanced (optional)
  6848. * @param offset the offset of the data (optional)
  6849. * @param size the number of components (optional)
  6850. * @param type the type of the component (optional)
  6851. * @param normalized whether the data contains normalized data (optional)
  6852. * @param useBytes set to true if stride and offset are in bytes (optional)
  6853. * @param divisor defines the instance divisor to use (1 by default)
  6854. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  6855. */
  6856. 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, takeBufferOwnership?: boolean);
  6857. /** @hidden */
  6858. _rebuild(): void;
  6859. /**
  6860. * Returns the kind of the VertexBuffer (string)
  6861. * @returns a string
  6862. */
  6863. getKind(): string;
  6864. /**
  6865. * Gets a boolean indicating if the VertexBuffer is updatable?
  6866. * @returns true if the buffer is updatable
  6867. */
  6868. isUpdatable(): boolean;
  6869. /**
  6870. * Gets current buffer's data
  6871. * @returns a DataArray or null
  6872. */
  6873. getData(): Nullable<DataArray>;
  6874. /**
  6875. * Gets underlying native buffer
  6876. * @returns underlying native buffer
  6877. */
  6878. getBuffer(): Nullable<DataBuffer>;
  6879. /**
  6880. * Gets the stride in float32 units (i.e. byte stride / 4).
  6881. * May not be an integer if the byte stride is not divisible by 4.
  6882. * @returns the stride in float32 units
  6883. * @deprecated Please use byteStride instead.
  6884. */
  6885. getStrideSize(): number;
  6886. /**
  6887. * Returns the offset as a multiple of the type byte length.
  6888. * @returns the offset in bytes
  6889. * @deprecated Please use byteOffset instead.
  6890. */
  6891. getOffset(): number;
  6892. /**
  6893. * Returns the number of components per vertex attribute (integer)
  6894. * @returns the size in float
  6895. */
  6896. getSize(): number;
  6897. /**
  6898. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6899. * @returns true if this buffer is instanced
  6900. */
  6901. getIsInstanced(): boolean;
  6902. /**
  6903. * Returns the instancing divisor, zero for non-instanced (integer).
  6904. * @returns a number
  6905. */
  6906. getInstanceDivisor(): number;
  6907. /**
  6908. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6909. * @param data defines the data to store
  6910. */
  6911. create(data?: DataArray): void;
  6912. /**
  6913. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6914. * This function will create a new buffer if the current one is not updatable
  6915. * @param data defines the data to store
  6916. */
  6917. update(data: DataArray): void;
  6918. /**
  6919. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6920. * Returns the directly updated WebGLBuffer.
  6921. * @param data the new data
  6922. * @param offset the new offset
  6923. * @param useBytes set to true if the offset is in bytes
  6924. */
  6925. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6926. /**
  6927. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6928. */
  6929. dispose(): void;
  6930. /**
  6931. * Enumerates each value of this vertex buffer as numbers.
  6932. * @param count the number of values to enumerate
  6933. * @param callback the callback function called for each value
  6934. */
  6935. forEach(count: number, callback: (value: number, index: number) => void): void;
  6936. /**
  6937. * Positions
  6938. */
  6939. static readonly PositionKind: string;
  6940. /**
  6941. * Normals
  6942. */
  6943. static readonly NormalKind: string;
  6944. /**
  6945. * Tangents
  6946. */
  6947. static readonly TangentKind: string;
  6948. /**
  6949. * Texture coordinates
  6950. */
  6951. static readonly UVKind: string;
  6952. /**
  6953. * Texture coordinates 2
  6954. */
  6955. static readonly UV2Kind: string;
  6956. /**
  6957. * Texture coordinates 3
  6958. */
  6959. static readonly UV3Kind: string;
  6960. /**
  6961. * Texture coordinates 4
  6962. */
  6963. static readonly UV4Kind: string;
  6964. /**
  6965. * Texture coordinates 5
  6966. */
  6967. static readonly UV5Kind: string;
  6968. /**
  6969. * Texture coordinates 6
  6970. */
  6971. static readonly UV6Kind: string;
  6972. /**
  6973. * Colors
  6974. */
  6975. static readonly ColorKind: string;
  6976. /**
  6977. * Matrix indices (for bones)
  6978. */
  6979. static readonly MatricesIndicesKind: string;
  6980. /**
  6981. * Matrix weights (for bones)
  6982. */
  6983. static readonly MatricesWeightsKind: string;
  6984. /**
  6985. * Additional matrix indices (for bones)
  6986. */
  6987. static readonly MatricesIndicesExtraKind: string;
  6988. /**
  6989. * Additional matrix weights (for bones)
  6990. */
  6991. static readonly MatricesWeightsExtraKind: string;
  6992. /**
  6993. * Deduces the stride given a kind.
  6994. * @param kind The kind string to deduce
  6995. * @returns The deduced stride
  6996. */
  6997. static DeduceStride(kind: string): number;
  6998. /**
  6999. * Gets the byte length of the given type.
  7000. * @param type the type
  7001. * @returns the number of bytes
  7002. */
  7003. static GetTypeByteLength(type: number): number;
  7004. /**
  7005. * Enumerates each value of the given parameters as numbers.
  7006. * @param data the data to enumerate
  7007. * @param byteOffset the byte offset of the data
  7008. * @param byteStride the byte stride of the data
  7009. * @param componentCount the number of components per element
  7010. * @param componentType the type of the component
  7011. * @param count the number of values to enumerate
  7012. * @param normalized whether the data is normalized
  7013. * @param callback the callback function called for each value
  7014. */
  7015. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7016. private static _GetFloatValue;
  7017. }
  7018. }
  7019. declare module "babylonjs/Collisions/intersectionInfo" {
  7020. import { Nullable } from "babylonjs/types";
  7021. /**
  7022. * @hidden
  7023. */
  7024. export class IntersectionInfo {
  7025. bu: Nullable<number>;
  7026. bv: Nullable<number>;
  7027. distance: number;
  7028. faceId: number;
  7029. subMeshId: number;
  7030. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7031. }
  7032. }
  7033. declare module "babylonjs/Culling/boundingSphere" {
  7034. import { DeepImmutable } from "babylonjs/types";
  7035. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7036. import { Plane } from "babylonjs/Maths/math.plane";
  7037. /**
  7038. * Class used to store bounding sphere information
  7039. */
  7040. export class BoundingSphere {
  7041. /**
  7042. * Gets the center of the bounding sphere in local space
  7043. */
  7044. readonly center: Vector3;
  7045. /**
  7046. * Radius of the bounding sphere in local space
  7047. */
  7048. radius: number;
  7049. /**
  7050. * Gets the center of the bounding sphere in world space
  7051. */
  7052. readonly centerWorld: Vector3;
  7053. /**
  7054. * Radius of the bounding sphere in world space
  7055. */
  7056. radiusWorld: number;
  7057. /**
  7058. * Gets the minimum vector in local space
  7059. */
  7060. readonly minimum: Vector3;
  7061. /**
  7062. * Gets the maximum vector in local space
  7063. */
  7064. readonly maximum: Vector3;
  7065. private _worldMatrix;
  7066. private static readonly TmpVector3;
  7067. /**
  7068. * Creates a new bounding sphere
  7069. * @param min defines the minimum vector (in local space)
  7070. * @param max defines the maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7074. /**
  7075. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7076. * @param min defines the new minimum vector (in local space)
  7077. * @param max defines the new maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7081. /**
  7082. * Scale the current bounding sphere by applying a scale factor
  7083. * @param factor defines the scale factor to apply
  7084. * @returns the current bounding box
  7085. */
  7086. scale(factor: number): BoundingSphere;
  7087. /**
  7088. * Gets the world matrix of the bounding box
  7089. * @returns a matrix
  7090. */
  7091. getWorldMatrix(): DeepImmutable<Matrix>;
  7092. /** @hidden */
  7093. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7094. /**
  7095. * Tests if the bounding sphere is intersecting the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if the bounding sphere center is in between the frustum planes.
  7102. * Used for optimistic fast inclusion.
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @returns true if the sphere center is in between the frustum planes
  7105. */
  7106. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if a point is inside the bounding sphere
  7109. * @param point defines the point to test
  7110. * @returns true if the point is inside the bounding sphere
  7111. */
  7112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7113. /**
  7114. * Checks if two sphere intersct
  7115. * @param sphere0 sphere 0
  7116. * @param sphere1 sphere 1
  7117. * @returns true if the speres intersect
  7118. */
  7119. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7120. }
  7121. }
  7122. declare module "babylonjs/Culling/boundingBox" {
  7123. import { DeepImmutable } from "babylonjs/types";
  7124. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7125. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7126. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7127. import { Plane } from "babylonjs/Maths/math.plane";
  7128. /**
  7129. * Class used to store bounding box information
  7130. */
  7131. export class BoundingBox implements ICullable {
  7132. /**
  7133. * Gets the 8 vectors representing the bounding box in local space
  7134. */
  7135. readonly vectors: Vector3[];
  7136. /**
  7137. * Gets the center of the bounding box in local space
  7138. */
  7139. readonly center: Vector3;
  7140. /**
  7141. * Gets the center of the bounding box in world space
  7142. */
  7143. readonly centerWorld: Vector3;
  7144. /**
  7145. * Gets the extend size in local space
  7146. */
  7147. readonly extendSize: Vector3;
  7148. /**
  7149. * Gets the extend size in world space
  7150. */
  7151. readonly extendSizeWorld: Vector3;
  7152. /**
  7153. * Gets the OBB (object bounding box) directions
  7154. */
  7155. readonly directions: Vector3[];
  7156. /**
  7157. * Gets the 8 vectors representing the bounding box in world space
  7158. */
  7159. readonly vectorsWorld: Vector3[];
  7160. /**
  7161. * Gets the minimum vector in world space
  7162. */
  7163. readonly minimumWorld: Vector3;
  7164. /**
  7165. * Gets the maximum vector in world space
  7166. */
  7167. readonly maximumWorld: Vector3;
  7168. /**
  7169. * Gets the minimum vector in local space
  7170. */
  7171. readonly minimum: Vector3;
  7172. /**
  7173. * Gets the maximum vector in local space
  7174. */
  7175. readonly maximum: Vector3;
  7176. private _worldMatrix;
  7177. private static readonly TmpVector3;
  7178. /**
  7179. * @hidden
  7180. */
  7181. _tag: number;
  7182. /**
  7183. * Creates a new bounding box
  7184. * @param min defines the minimum vector (in local space)
  7185. * @param max defines the maximum vector (in local space)
  7186. * @param worldMatrix defines the new world matrix
  7187. */
  7188. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7189. /**
  7190. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7191. * @param min defines the new minimum vector (in local space)
  7192. * @param max defines the new maximum vector (in local space)
  7193. * @param worldMatrix defines the new world matrix
  7194. */
  7195. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7196. /**
  7197. * Scale the current bounding box by applying a scale factor
  7198. * @param factor defines the scale factor to apply
  7199. * @returns the current bounding box
  7200. */
  7201. scale(factor: number): BoundingBox;
  7202. /**
  7203. * Gets the world matrix of the bounding box
  7204. * @returns a matrix
  7205. */
  7206. getWorldMatrix(): DeepImmutable<Matrix>;
  7207. /** @hidden */
  7208. _update(world: DeepImmutable<Matrix>): void;
  7209. /**
  7210. * Tests if the bounding box is intersecting the frustum planes
  7211. * @param frustumPlanes defines the frustum planes to test
  7212. * @returns true if there is an intersection
  7213. */
  7214. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7215. /**
  7216. * Tests if the bounding box is entirely inside the frustum planes
  7217. * @param frustumPlanes defines the frustum planes to test
  7218. * @returns true if there is an inclusion
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /**
  7222. * Tests if a point is inside the bounding box
  7223. * @param point defines the point to test
  7224. * @returns true if the point is inside the bounding box
  7225. */
  7226. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7227. /**
  7228. * Tests if the bounding box intersects with a bounding sphere
  7229. * @param sphere defines the sphere to test
  7230. * @returns true if there is an intersection
  7231. */
  7232. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7233. /**
  7234. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7235. * @param min defines the min vector to use
  7236. * @param max defines the max vector to use
  7237. * @returns true if there is an intersection
  7238. */
  7239. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7240. /**
  7241. * Tests if two bounding boxes are intersections
  7242. * @param box0 defines the first box to test
  7243. * @param box1 defines the second box to test
  7244. * @returns true if there is an intersection
  7245. */
  7246. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7247. /**
  7248. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7249. * @param minPoint defines the minimum vector of the bounding box
  7250. * @param maxPoint defines the maximum vector of the bounding box
  7251. * @param sphereCenter defines the sphere center
  7252. * @param sphereRadius defines the sphere radius
  7253. * @returns true if there is an intersection
  7254. */
  7255. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7256. /**
  7257. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7258. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7259. * @param frustumPlanes defines the frustum planes to test
  7260. * @return true if there is an inclusion
  7261. */
  7262. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7263. /**
  7264. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7265. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7266. * @param frustumPlanes defines the frustum planes to test
  7267. * @return true if there is an intersection
  7268. */
  7269. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7270. }
  7271. }
  7272. declare module "babylonjs/Collisions/collider" {
  7273. import { Nullable, IndicesArray } from "babylonjs/types";
  7274. import { Vector3 } from "babylonjs/Maths/math.vector";
  7275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7276. import { Plane } from "babylonjs/Maths/math.plane";
  7277. /** @hidden */
  7278. export class Collider {
  7279. /** Define if a collision was found */
  7280. collisionFound: boolean;
  7281. /**
  7282. * Define last intersection point in local space
  7283. */
  7284. intersectionPoint: Vector3;
  7285. /**
  7286. * Define last collided mesh
  7287. */
  7288. collidedMesh: Nullable<AbstractMesh>;
  7289. private _collisionPoint;
  7290. private _planeIntersectionPoint;
  7291. private _tempVector;
  7292. private _tempVector2;
  7293. private _tempVector3;
  7294. private _tempVector4;
  7295. private _edge;
  7296. private _baseToVertex;
  7297. private _destinationPoint;
  7298. private _slidePlaneNormal;
  7299. private _displacementVector;
  7300. /** @hidden */
  7301. _radius: Vector3;
  7302. /** @hidden */
  7303. _retry: number;
  7304. private _velocity;
  7305. private _basePoint;
  7306. private _epsilon;
  7307. /** @hidden */
  7308. _velocityWorldLength: number;
  7309. /** @hidden */
  7310. _basePointWorld: Vector3;
  7311. private _velocityWorld;
  7312. private _normalizedVelocity;
  7313. /** @hidden */
  7314. _initialVelocity: Vector3;
  7315. /** @hidden */
  7316. _initialPosition: Vector3;
  7317. private _nearestDistance;
  7318. private _collisionMask;
  7319. get collisionMask(): number;
  7320. set collisionMask(mask: number);
  7321. /**
  7322. * Gets the plane normal used to compute the sliding response (in local space)
  7323. */
  7324. get slidePlaneNormal(): Vector3;
  7325. /** @hidden */
  7326. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7327. /** @hidden */
  7328. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7329. /** @hidden */
  7330. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7331. /** @hidden */
  7332. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7333. /** @hidden */
  7334. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7335. /** @hidden */
  7336. _getResponse(pos: Vector3, vel: Vector3): void;
  7337. }
  7338. }
  7339. declare module "babylonjs/Culling/boundingInfo" {
  7340. import { DeepImmutable } from "babylonjs/types";
  7341. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7342. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7343. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7344. import { Plane } from "babylonjs/Maths/math.plane";
  7345. import { Collider } from "babylonjs/Collisions/collider";
  7346. /**
  7347. * Interface for cullable objects
  7348. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7349. */
  7350. export interface ICullable {
  7351. /**
  7352. * Checks if the object or part of the object is in the frustum
  7353. * @param frustumPlanes Camera near/planes
  7354. * @returns true if the object is in frustum otherwise false
  7355. */
  7356. isInFrustum(frustumPlanes: Plane[]): boolean;
  7357. /**
  7358. * Checks if a cullable object (mesh...) is in the camera frustum
  7359. * Unlike isInFrustum this cheks the full bounding box
  7360. * @param frustumPlanes Camera near/planes
  7361. * @returns true if the object is in frustum otherwise false
  7362. */
  7363. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7364. }
  7365. /**
  7366. * Info for a bounding data of a mesh
  7367. */
  7368. export class BoundingInfo implements ICullable {
  7369. /**
  7370. * Bounding box for the mesh
  7371. */
  7372. readonly boundingBox: BoundingBox;
  7373. /**
  7374. * Bounding sphere for the mesh
  7375. */
  7376. readonly boundingSphere: BoundingSphere;
  7377. private _isLocked;
  7378. private static readonly TmpVector3;
  7379. /**
  7380. * Constructs bounding info
  7381. * @param minimum min vector of the bounding box/sphere
  7382. * @param maximum max vector of the bounding box/sphere
  7383. * @param worldMatrix defines the new world matrix
  7384. */
  7385. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7386. /**
  7387. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7388. * @param min defines the new minimum vector (in local space)
  7389. * @param max defines the new maximum vector (in local space)
  7390. * @param worldMatrix defines the new world matrix
  7391. */
  7392. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7393. /**
  7394. * min vector of the bounding box/sphere
  7395. */
  7396. get minimum(): Vector3;
  7397. /**
  7398. * max vector of the bounding box/sphere
  7399. */
  7400. get maximum(): Vector3;
  7401. /**
  7402. * If the info is locked and won't be updated to avoid perf overhead
  7403. */
  7404. get isLocked(): boolean;
  7405. set isLocked(value: boolean);
  7406. /**
  7407. * Updates the bounding sphere and box
  7408. * @param world world matrix to be used to update
  7409. */
  7410. update(world: DeepImmutable<Matrix>): void;
  7411. /**
  7412. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7413. * @param center New center of the bounding info
  7414. * @param extend New extend of the bounding info
  7415. * @returns the current bounding info
  7416. */
  7417. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7418. /**
  7419. * Scale the current bounding info by applying a scale factor
  7420. * @param factor defines the scale factor to apply
  7421. * @returns the current bounding info
  7422. */
  7423. scale(factor: number): BoundingInfo;
  7424. /**
  7425. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7426. * @param frustumPlanes defines the frustum to test
  7427. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7428. * @returns true if the bounding info is in the frustum planes
  7429. */
  7430. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7431. /**
  7432. * Gets the world distance between the min and max points of the bounding box
  7433. */
  7434. get diagonalLength(): number;
  7435. /**
  7436. * Checks if a cullable object (mesh...) is in the camera frustum
  7437. * Unlike isInFrustum this cheks the full bounding box
  7438. * @param frustumPlanes Camera near/planes
  7439. * @returns true if the object is in frustum otherwise false
  7440. */
  7441. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7442. /** @hidden */
  7443. _checkCollision(collider: Collider): boolean;
  7444. /**
  7445. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7446. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7447. * @param point the point to check intersection with
  7448. * @returns if the point intersects
  7449. */
  7450. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7451. /**
  7452. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7453. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7454. * @param boundingInfo the bounding info to check intersection with
  7455. * @param precise if the intersection should be done using OBB
  7456. * @returns if the bounding info intersects
  7457. */
  7458. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7459. }
  7460. }
  7461. declare module "babylonjs/Maths/math.functions" {
  7462. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7463. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7464. /**
  7465. * Extracts minimum and maximum values from a list of indexed positions
  7466. * @param positions defines the positions to use
  7467. * @param indices defines the indices to the positions
  7468. * @param indexStart defines the start index
  7469. * @param indexCount defines the end index
  7470. * @param bias defines bias value to add to the result
  7471. * @return minimum and maximum values
  7472. */
  7473. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7474. minimum: Vector3;
  7475. maximum: Vector3;
  7476. };
  7477. /**
  7478. * Extracts minimum and maximum values from a list of positions
  7479. * @param positions defines the positions to use
  7480. * @param start defines the start index in the positions array
  7481. * @param count defines the number of positions to handle
  7482. * @param bias defines bias value to add to the result
  7483. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7484. * @return minimum and maximum values
  7485. */
  7486. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7487. minimum: Vector3;
  7488. maximum: Vector3;
  7489. };
  7490. }
  7491. declare module "babylonjs/Misc/guid" {
  7492. /**
  7493. * Class used to manipulate GUIDs
  7494. */
  7495. export class GUID {
  7496. /**
  7497. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7498. * Be aware Math.random() could cause collisions, but:
  7499. * "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"
  7500. * @returns a pseudo random id
  7501. */
  7502. static RandomId(): string;
  7503. }
  7504. }
  7505. declare module "babylonjs/Materials/Textures/baseTexture" {
  7506. import { Observable } from "babylonjs/Misc/observable";
  7507. import { Nullable } from "babylonjs/types";
  7508. import { Scene } from "babylonjs/scene";
  7509. import { Matrix } from "babylonjs/Maths/math.vector";
  7510. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7511. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  7512. import "babylonjs/Misc/fileTools";
  7513. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7514. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  7515. /**
  7516. * Base class of all the textures in babylon.
  7517. * It groups all the common properties the materials, post process, lights... might need
  7518. * in order to make a correct use of the texture.
  7519. */
  7520. export class BaseTexture extends ThinTexture implements IAnimatable {
  7521. /**
  7522. * Default anisotropic filtering level for the application.
  7523. * It is set to 4 as a good tradeoff between perf and quality.
  7524. */
  7525. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7526. /**
  7527. * Gets or sets the unique id of the texture
  7528. */
  7529. uniqueId: number;
  7530. /**
  7531. * Define the name of the texture.
  7532. */
  7533. name: string;
  7534. /**
  7535. * Gets or sets an object used to store user defined information.
  7536. */
  7537. metadata: any;
  7538. /**
  7539. * For internal use only. Please do not use.
  7540. */
  7541. reservedDataStore: any;
  7542. private _hasAlpha;
  7543. /**
  7544. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7545. */
  7546. set hasAlpha(value: boolean);
  7547. get hasAlpha(): boolean;
  7548. /**
  7549. * Defines if the alpha value should be determined via the rgb values.
  7550. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7551. */
  7552. getAlphaFromRGB: boolean;
  7553. /**
  7554. * Intensity or strength of the texture.
  7555. * It is commonly used by materials to fine tune the intensity of the texture
  7556. */
  7557. level: number;
  7558. /**
  7559. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7560. * This is part of the texture as textures usually maps to one uv set.
  7561. */
  7562. coordinatesIndex: number;
  7563. protected _coordinatesMode: number;
  7564. /**
  7565. * How a texture is mapped.
  7566. *
  7567. * | Value | Type | Description |
  7568. * | ----- | ----------------------------------- | ----------- |
  7569. * | 0 | EXPLICIT_MODE | |
  7570. * | 1 | SPHERICAL_MODE | |
  7571. * | 2 | PLANAR_MODE | |
  7572. * | 3 | CUBIC_MODE | |
  7573. * | 4 | PROJECTION_MODE | |
  7574. * | 5 | SKYBOX_MODE | |
  7575. * | 6 | INVCUBIC_MODE | |
  7576. * | 7 | EQUIRECTANGULAR_MODE | |
  7577. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7578. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7579. */
  7580. set coordinatesMode(value: number);
  7581. get coordinatesMode(): number;
  7582. /**
  7583. * | Value | Type | Description |
  7584. * | ----- | ------------------ | ----------- |
  7585. * | 0 | CLAMP_ADDRESSMODE | |
  7586. * | 1 | WRAP_ADDRESSMODE | |
  7587. * | 2 | MIRROR_ADDRESSMODE | |
  7588. */
  7589. get wrapU(): number;
  7590. set wrapU(value: number);
  7591. /**
  7592. * | Value | Type | Description |
  7593. * | ----- | ------------------ | ----------- |
  7594. * | 0 | CLAMP_ADDRESSMODE | |
  7595. * | 1 | WRAP_ADDRESSMODE | |
  7596. * | 2 | MIRROR_ADDRESSMODE | |
  7597. */
  7598. get wrapV(): number;
  7599. set wrapV(value: number);
  7600. /**
  7601. * | Value | Type | Description |
  7602. * | ----- | ------------------ | ----------- |
  7603. * | 0 | CLAMP_ADDRESSMODE | |
  7604. * | 1 | WRAP_ADDRESSMODE | |
  7605. * | 2 | MIRROR_ADDRESSMODE | |
  7606. */
  7607. wrapR: number;
  7608. /**
  7609. * With compliant hardware and browser (supporting anisotropic filtering)
  7610. * this defines the level of anisotropic filtering in the texture.
  7611. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7612. */
  7613. anisotropicFilteringLevel: number;
  7614. private _isCube;
  7615. /**
  7616. * Define if the texture is a cube texture or if false a 2d texture.
  7617. */
  7618. get isCube(): boolean;
  7619. set isCube(value: boolean);
  7620. /**
  7621. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7622. */
  7623. get is3D(): boolean;
  7624. set is3D(value: boolean);
  7625. /**
  7626. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7627. */
  7628. get is2DArray(): boolean;
  7629. set is2DArray(value: boolean);
  7630. private _gammaSpace;
  7631. /**
  7632. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7633. * HDR texture are usually stored in linear space.
  7634. * This only impacts the PBR and Background materials
  7635. */
  7636. get gammaSpace(): boolean;
  7637. set gammaSpace(gamma: boolean);
  7638. /**
  7639. * Gets or sets whether or not the texture contains RGBD data.
  7640. */
  7641. get isRGBD(): boolean;
  7642. set isRGBD(value: boolean);
  7643. /**
  7644. * Is Z inverted in the texture (useful in a cube texture).
  7645. */
  7646. invertZ: boolean;
  7647. /**
  7648. * Are mip maps generated for this texture or not.
  7649. */
  7650. get noMipmap(): boolean;
  7651. /**
  7652. * @hidden
  7653. */
  7654. lodLevelInAlpha: boolean;
  7655. /**
  7656. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7657. */
  7658. get lodGenerationOffset(): number;
  7659. set lodGenerationOffset(value: number);
  7660. /**
  7661. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7662. */
  7663. get lodGenerationScale(): number;
  7664. set lodGenerationScale(value: number);
  7665. /**
  7666. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7667. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7668. * average roughness values.
  7669. */
  7670. get linearSpecularLOD(): boolean;
  7671. set linearSpecularLOD(value: boolean);
  7672. /**
  7673. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7674. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7675. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7676. */
  7677. get irradianceTexture(): Nullable<BaseTexture>;
  7678. set irradianceTexture(value: Nullable<BaseTexture>);
  7679. /**
  7680. * Define if the texture is a render target.
  7681. */
  7682. isRenderTarget: boolean;
  7683. /**
  7684. * Define the unique id of the texture in the scene.
  7685. */
  7686. get uid(): string;
  7687. /** @hidden */
  7688. _prefiltered: boolean;
  7689. /**
  7690. * Return a string representation of the texture.
  7691. * @returns the texture as a string
  7692. */
  7693. toString(): string;
  7694. /**
  7695. * Get the class name of the texture.
  7696. * @returns "BaseTexture"
  7697. */
  7698. getClassName(): string;
  7699. /**
  7700. * Define the list of animation attached to the texture.
  7701. */
  7702. animations: import("babylonjs/Animations/animation").Animation[];
  7703. /**
  7704. * An event triggered when the texture is disposed.
  7705. */
  7706. onDisposeObservable: Observable<BaseTexture>;
  7707. private _onDisposeObserver;
  7708. /**
  7709. * Callback triggered when the texture has been disposed.
  7710. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7711. */
  7712. set onDispose(callback: () => void);
  7713. protected _scene: Nullable<Scene>;
  7714. /** @hidden */
  7715. _texture: Nullable<InternalTexture>;
  7716. private _uid;
  7717. /**
  7718. * Define if the texture is preventinga material to render or not.
  7719. * If not and the texture is not ready, the engine will use a default black texture instead.
  7720. */
  7721. get isBlocking(): boolean;
  7722. /**
  7723. * Instantiates a new BaseTexture.
  7724. * Base class of all the textures in babylon.
  7725. * It groups all the common properties the materials, post process, lights... might need
  7726. * in order to make a correct use of the texture.
  7727. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7728. */
  7729. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7730. /**
  7731. * Get the scene the texture belongs to.
  7732. * @returns the scene or null if undefined
  7733. */
  7734. getScene(): Nullable<Scene>;
  7735. /** @hidden */
  7736. protected _getEngine(): Nullable<ThinEngine>;
  7737. /**
  7738. * Checks if the texture has the same transform matrix than another texture
  7739. * @param texture texture to check against
  7740. * @returns true if the transforms are the same, else false
  7741. */
  7742. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7743. /**
  7744. * Get the texture transform matrix used to offset tile the texture for istance.
  7745. * @returns the transformation matrix
  7746. */
  7747. getTextureMatrix(): Matrix;
  7748. /**
  7749. * Get the texture reflection matrix used to rotate/transform the reflection.
  7750. * @returns the reflection matrix
  7751. */
  7752. getReflectionTextureMatrix(): Matrix;
  7753. /**
  7754. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7755. * @returns true if ready or not blocking
  7756. */
  7757. isReadyOrNotBlocking(): boolean;
  7758. /**
  7759. * Scales the texture if is `canRescale()`
  7760. * @param ratio the resize factor we want to use to rescale
  7761. */
  7762. scale(ratio: number): void;
  7763. /**
  7764. * Get if the texture can rescale.
  7765. */
  7766. get canRescale(): boolean;
  7767. /** @hidden */
  7768. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7769. /** @hidden */
  7770. _rebuild(): void;
  7771. /**
  7772. * Clones the texture.
  7773. * @returns the cloned texture
  7774. */
  7775. clone(): Nullable<BaseTexture>;
  7776. /**
  7777. * Get the texture underlying type (INT, FLOAT...)
  7778. */
  7779. get textureType(): number;
  7780. /**
  7781. * Get the texture underlying format (RGB, RGBA...)
  7782. */
  7783. get textureFormat(): number;
  7784. /**
  7785. * Indicates that textures need to be re-calculated for all materials
  7786. */
  7787. protected _markAllSubMeshesAsTexturesDirty(): void;
  7788. /**
  7789. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7790. * This will returns an RGBA array buffer containing either in values (0-255) or
  7791. * float values (0-1) depending of the underlying buffer type.
  7792. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7793. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7794. * @param buffer defines a user defined buffer to fill with data (can be null)
  7795. * @returns The Array buffer containing the pixels data.
  7796. */
  7797. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  7798. /** @hidden */
  7799. get _lodTextureHigh(): Nullable<BaseTexture>;
  7800. /** @hidden */
  7801. get _lodTextureMid(): Nullable<BaseTexture>;
  7802. /** @hidden */
  7803. get _lodTextureLow(): Nullable<BaseTexture>;
  7804. /**
  7805. * Dispose the texture and release its associated resources.
  7806. */
  7807. dispose(): void;
  7808. /**
  7809. * Serialize the texture into a JSON representation that can be parsed later on.
  7810. * @returns the JSON representation of the texture
  7811. */
  7812. serialize(): any;
  7813. /**
  7814. * Helper function to be called back once a list of texture contains only ready textures.
  7815. * @param textures Define the list of textures to wait for
  7816. * @param callback Define the callback triggered once the entire list will be ready
  7817. */
  7818. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  7819. private static _isScene;
  7820. }
  7821. }
  7822. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7823. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7824. /** @hidden */
  7825. export class WebGLDataBuffer extends DataBuffer {
  7826. private _buffer;
  7827. constructor(resource: WebGLBuffer);
  7828. get underlyingResource(): any;
  7829. }
  7830. }
  7831. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7832. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7833. import { Nullable } from "babylonjs/types";
  7834. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7835. /** @hidden */
  7836. export class WebGLPipelineContext implements IPipelineContext {
  7837. engine: ThinEngine;
  7838. program: Nullable<WebGLProgram>;
  7839. context?: WebGLRenderingContext;
  7840. vertexShader?: WebGLShader;
  7841. fragmentShader?: WebGLShader;
  7842. isParallelCompiled: boolean;
  7843. onCompiled?: () => void;
  7844. transformFeedback?: WebGLTransformFeedback | null;
  7845. vertexCompilationError: Nullable<string>;
  7846. fragmentCompilationError: Nullable<string>;
  7847. programLinkError: Nullable<string>;
  7848. programValidationError: Nullable<string>;
  7849. get isAsync(): boolean;
  7850. get isReady(): boolean;
  7851. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7852. _getVertexShaderCode(): string | null;
  7853. _getFragmentShaderCode(): string | null;
  7854. }
  7855. }
  7856. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7857. import { FloatArray, Nullable } from "babylonjs/types";
  7858. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7859. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7860. module "babylonjs/Engines/thinEngine" {
  7861. interface ThinEngine {
  7862. /**
  7863. * Create an uniform buffer
  7864. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7865. * @param elements defines the content of the uniform buffer
  7866. * @returns the webGL uniform buffer
  7867. */
  7868. createUniformBuffer(elements: FloatArray): DataBuffer;
  7869. /**
  7870. * Create a dynamic uniform buffer
  7871. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7872. * @param elements defines the content of the uniform buffer
  7873. * @returns the webGL uniform buffer
  7874. */
  7875. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7876. /**
  7877. * Update an existing uniform buffer
  7878. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7879. * @param uniformBuffer defines the target uniform buffer
  7880. * @param elements defines the content to update
  7881. * @param offset defines the offset in the uniform buffer where update should start
  7882. * @param count defines the size of the data to update
  7883. */
  7884. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7885. /**
  7886. * Bind an uniform buffer to the current webGL context
  7887. * @param buffer defines the buffer to bind
  7888. */
  7889. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7890. /**
  7891. * Bind a buffer to the current webGL context at a given location
  7892. * @param buffer defines the buffer to bind
  7893. * @param location defines the index where to bind the buffer
  7894. */
  7895. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7896. /**
  7897. * Bind a specific block at a given index in a specific shader program
  7898. * @param pipelineContext defines the pipeline context to use
  7899. * @param blockName defines the block name
  7900. * @param index defines the index where to bind the block
  7901. */
  7902. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7903. }
  7904. }
  7905. }
  7906. declare module "babylonjs/Materials/uniformBuffer" {
  7907. import { Nullable, FloatArray } from "babylonjs/types";
  7908. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7909. import { Engine } from "babylonjs/Engines/engine";
  7910. import { Effect } from "babylonjs/Materials/effect";
  7911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7912. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7913. import { Color3 } from "babylonjs/Maths/math.color";
  7914. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7915. /**
  7916. * Uniform buffer objects.
  7917. *
  7918. * Handles blocks of uniform on the GPU.
  7919. *
  7920. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7921. *
  7922. * For more information, please refer to :
  7923. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7924. */
  7925. export class UniformBuffer {
  7926. private _engine;
  7927. private _buffer;
  7928. private _data;
  7929. private _bufferData;
  7930. private _dynamic?;
  7931. private _uniformLocations;
  7932. private _uniformSizes;
  7933. private _uniformLocationPointer;
  7934. private _needSync;
  7935. private _noUBO;
  7936. private _currentEffect;
  7937. /** @hidden */
  7938. _alreadyBound: boolean;
  7939. private static _MAX_UNIFORM_SIZE;
  7940. private static _tempBuffer;
  7941. /**
  7942. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7943. * This is dynamic to allow compat with webgl 1 and 2.
  7944. * You will need to pass the name of the uniform as well as the value.
  7945. */
  7946. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7947. /**
  7948. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7949. * This is dynamic to allow compat with webgl 1 and 2.
  7950. * You will need to pass the name of the uniform as well as the value.
  7951. */
  7952. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7953. /**
  7954. * Lambda to Update a single float in a uniform buffer.
  7955. * This is dynamic to allow compat with webgl 1 and 2.
  7956. * You will need to pass the name of the uniform as well as the value.
  7957. */
  7958. updateFloat: (name: string, x: number) => void;
  7959. /**
  7960. * Lambda to Update a vec2 of float in a uniform buffer.
  7961. * This is dynamic to allow compat with webgl 1 and 2.
  7962. * You will need to pass the name of the uniform as well as the value.
  7963. */
  7964. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7965. /**
  7966. * Lambda to Update a vec3 of float in a uniform buffer.
  7967. * This is dynamic to allow compat with webgl 1 and 2.
  7968. * You will need to pass the name of the uniform as well as the value.
  7969. */
  7970. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7971. /**
  7972. * Lambda to Update a vec4 of float in a uniform buffer.
  7973. * This is dynamic to allow compat with webgl 1 and 2.
  7974. * You will need to pass the name of the uniform as well as the value.
  7975. */
  7976. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7977. /**
  7978. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7979. * This is dynamic to allow compat with webgl 1 and 2.
  7980. * You will need to pass the name of the uniform as well as the value.
  7981. */
  7982. updateMatrix: (name: string, mat: Matrix) => void;
  7983. /**
  7984. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7985. * This is dynamic to allow compat with webgl 1 and 2.
  7986. * You will need to pass the name of the uniform as well as the value.
  7987. */
  7988. updateVector3: (name: string, vector: Vector3) => void;
  7989. /**
  7990. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7991. * This is dynamic to allow compat with webgl 1 and 2.
  7992. * You will need to pass the name of the uniform as well as the value.
  7993. */
  7994. updateVector4: (name: string, vector: Vector4) => void;
  7995. /**
  7996. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7997. * This is dynamic to allow compat with webgl 1 and 2.
  7998. * You will need to pass the name of the uniform as well as the value.
  7999. */
  8000. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8001. /**
  8002. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8003. * This is dynamic to allow compat with webgl 1 and 2.
  8004. * You will need to pass the name of the uniform as well as the value.
  8005. */
  8006. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8007. /**
  8008. * Instantiates a new Uniform buffer objects.
  8009. *
  8010. * Handles blocks of uniform on the GPU.
  8011. *
  8012. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8013. *
  8014. * For more information, please refer to :
  8015. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8016. * @param engine Define the engine the buffer is associated with
  8017. * @param data Define the data contained in the buffer
  8018. * @param dynamic Define if the buffer is updatable
  8019. */
  8020. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  8021. /**
  8022. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8023. * or just falling back on setUniformXXX calls.
  8024. */
  8025. get useUbo(): boolean;
  8026. /**
  8027. * Indicates if the WebGL underlying uniform buffer is in sync
  8028. * with the javascript cache data.
  8029. */
  8030. get isSync(): boolean;
  8031. /**
  8032. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8033. * Also, a dynamic UniformBuffer will disable cache verification and always
  8034. * update the underlying WebGL uniform buffer to the GPU.
  8035. * @returns if Dynamic, otherwise false
  8036. */
  8037. isDynamic(): boolean;
  8038. /**
  8039. * The data cache on JS side.
  8040. * @returns the underlying data as a float array
  8041. */
  8042. getData(): Float32Array;
  8043. /**
  8044. * The underlying WebGL Uniform buffer.
  8045. * @returns the webgl buffer
  8046. */
  8047. getBuffer(): Nullable<DataBuffer>;
  8048. /**
  8049. * std140 layout specifies how to align data within an UBO structure.
  8050. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8051. * for specs.
  8052. */
  8053. private _fillAlignment;
  8054. /**
  8055. * Adds an uniform in the buffer.
  8056. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8057. * for the layout to be correct !
  8058. * @param name Name of the uniform, as used in the uniform block in the shader.
  8059. * @param size Data size, or data directly.
  8060. */
  8061. addUniform(name: string, size: number | number[]): void;
  8062. /**
  8063. * Adds a Matrix 4x4 to the uniform buffer.
  8064. * @param name Name of the uniform, as used in the uniform block in the shader.
  8065. * @param mat A 4x4 matrix.
  8066. */
  8067. addMatrix(name: string, mat: Matrix): void;
  8068. /**
  8069. * Adds a vec2 to the uniform buffer.
  8070. * @param name Name of the uniform, as used in the uniform block in the shader.
  8071. * @param x Define the x component value of the vec2
  8072. * @param y Define the y component value of the vec2
  8073. */
  8074. addFloat2(name: string, x: number, y: number): void;
  8075. /**
  8076. * Adds a vec3 to the uniform buffer.
  8077. * @param name Name of the uniform, as used in the uniform block in the shader.
  8078. * @param x Define the x component value of the vec3
  8079. * @param y Define the y component value of the vec3
  8080. * @param z Define the z component value of the vec3
  8081. */
  8082. addFloat3(name: string, x: number, y: number, z: number): void;
  8083. /**
  8084. * Adds a vec3 to the uniform buffer.
  8085. * @param name Name of the uniform, as used in the uniform block in the shader.
  8086. * @param color Define the vec3 from a Color
  8087. */
  8088. addColor3(name: string, color: Color3): void;
  8089. /**
  8090. * Adds a vec4 to the uniform buffer.
  8091. * @param name Name of the uniform, as used in the uniform block in the shader.
  8092. * @param color Define the rgb components from a Color
  8093. * @param alpha Define the a component of the vec4
  8094. */
  8095. addColor4(name: string, color: Color3, alpha: number): void;
  8096. /**
  8097. * Adds a vec3 to the uniform buffer.
  8098. * @param name Name of the uniform, as used in the uniform block in the shader.
  8099. * @param vector Define the vec3 components from a Vector
  8100. */
  8101. addVector3(name: string, vector: Vector3): void;
  8102. /**
  8103. * Adds a Matrix 3x3 to the uniform buffer.
  8104. * @param name Name of the uniform, as used in the uniform block in the shader.
  8105. */
  8106. addMatrix3x3(name: string): void;
  8107. /**
  8108. * Adds a Matrix 2x2 to the uniform buffer.
  8109. * @param name Name of the uniform, as used in the uniform block in the shader.
  8110. */
  8111. addMatrix2x2(name: string): void;
  8112. /**
  8113. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8114. */
  8115. create(): void;
  8116. /** @hidden */
  8117. _rebuild(): void;
  8118. /**
  8119. * Updates the WebGL Uniform Buffer on the GPU.
  8120. * If the `dynamic` flag is set to true, no cache comparison is done.
  8121. * Otherwise, the buffer will be updated only if the cache differs.
  8122. */
  8123. update(): void;
  8124. /**
  8125. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8126. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8127. * @param data Define the flattened data
  8128. * @param size Define the size of the data.
  8129. */
  8130. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8131. private _valueCache;
  8132. private _cacheMatrix;
  8133. private _updateMatrix3x3ForUniform;
  8134. private _updateMatrix3x3ForEffect;
  8135. private _updateMatrix2x2ForEffect;
  8136. private _updateMatrix2x2ForUniform;
  8137. private _updateFloatForEffect;
  8138. private _updateFloatForUniform;
  8139. private _updateFloat2ForEffect;
  8140. private _updateFloat2ForUniform;
  8141. private _updateFloat3ForEffect;
  8142. private _updateFloat3ForUniform;
  8143. private _updateFloat4ForEffect;
  8144. private _updateFloat4ForUniform;
  8145. private _updateMatrixForEffect;
  8146. private _updateMatrixForUniform;
  8147. private _updateVector3ForEffect;
  8148. private _updateVector3ForUniform;
  8149. private _updateVector4ForEffect;
  8150. private _updateVector4ForUniform;
  8151. private _updateColor3ForEffect;
  8152. private _updateColor3ForUniform;
  8153. private _updateColor4ForEffect;
  8154. private _updateColor4ForUniform;
  8155. /**
  8156. * Sets a sampler uniform on the effect.
  8157. * @param name Define the name of the sampler.
  8158. * @param texture Define the texture to set in the sampler
  8159. */
  8160. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8161. /**
  8162. * Directly updates the value of the uniform in the cache AND on the GPU.
  8163. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8164. * @param data Define the flattened data
  8165. */
  8166. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8167. /**
  8168. * Binds this uniform buffer to an effect.
  8169. * @param effect Define the effect to bind the buffer to
  8170. * @param name Name of the uniform block in the shader.
  8171. */
  8172. bindToEffect(effect: Effect, name: string): void;
  8173. /**
  8174. * Disposes the uniform buffer.
  8175. */
  8176. dispose(): void;
  8177. }
  8178. }
  8179. declare module "babylonjs/Materials/materialDefines" {
  8180. /**
  8181. * Manages the defines for the Material
  8182. */
  8183. export class MaterialDefines {
  8184. /** @hidden */
  8185. protected _keys: string[];
  8186. private _isDirty;
  8187. /** @hidden */
  8188. _renderId: number;
  8189. /** @hidden */
  8190. _areLightsDirty: boolean;
  8191. /** @hidden */
  8192. _areLightsDisposed: boolean;
  8193. /** @hidden */
  8194. _areAttributesDirty: boolean;
  8195. /** @hidden */
  8196. _areTexturesDirty: boolean;
  8197. /** @hidden */
  8198. _areFresnelDirty: boolean;
  8199. /** @hidden */
  8200. _areMiscDirty: boolean;
  8201. /** @hidden */
  8202. _arePrePassDirty: boolean;
  8203. /** @hidden */
  8204. _areImageProcessingDirty: boolean;
  8205. /** @hidden */
  8206. _normals: boolean;
  8207. /** @hidden */
  8208. _uvs: boolean;
  8209. /** @hidden */
  8210. _needNormals: boolean;
  8211. /** @hidden */
  8212. _needUVs: boolean;
  8213. [id: string]: any;
  8214. /**
  8215. * Specifies if the material needs to be re-calculated
  8216. */
  8217. get isDirty(): boolean;
  8218. /**
  8219. * Marks the material to indicate that it has been re-calculated
  8220. */
  8221. markAsProcessed(): void;
  8222. /**
  8223. * Marks the material to indicate that it needs to be re-calculated
  8224. */
  8225. markAsUnprocessed(): void;
  8226. /**
  8227. * Marks the material to indicate all of its defines need to be re-calculated
  8228. */
  8229. markAllAsDirty(): void;
  8230. /**
  8231. * Marks the material to indicate that image processing needs to be re-calculated
  8232. */
  8233. markAsImageProcessingDirty(): void;
  8234. /**
  8235. * Marks the material to indicate the lights need to be re-calculated
  8236. * @param disposed Defines whether the light is dirty due to dispose or not
  8237. */
  8238. markAsLightDirty(disposed?: boolean): void;
  8239. /**
  8240. * Marks the attribute state as changed
  8241. */
  8242. markAsAttributesDirty(): void;
  8243. /**
  8244. * Marks the texture state as changed
  8245. */
  8246. markAsTexturesDirty(): void;
  8247. /**
  8248. * Marks the fresnel state as changed
  8249. */
  8250. markAsFresnelDirty(): void;
  8251. /**
  8252. * Marks the misc state as changed
  8253. */
  8254. markAsMiscDirty(): void;
  8255. /**
  8256. * Marks the prepass state as changed
  8257. */
  8258. markAsPrePassDirty(): void;
  8259. /**
  8260. * Rebuilds the material defines
  8261. */
  8262. rebuild(): void;
  8263. /**
  8264. * Specifies if two material defines are equal
  8265. * @param other - A material define instance to compare to
  8266. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8267. */
  8268. isEqual(other: MaterialDefines): boolean;
  8269. /**
  8270. * Clones this instance's defines to another instance
  8271. * @param other - material defines to clone values to
  8272. */
  8273. cloneTo(other: MaterialDefines): void;
  8274. /**
  8275. * Resets the material define values
  8276. */
  8277. reset(): void;
  8278. /**
  8279. * Converts the material define values to a string
  8280. * @returns - String of material define information
  8281. */
  8282. toString(): string;
  8283. }
  8284. }
  8285. declare module "babylonjs/Misc/iInspectable" {
  8286. /**
  8287. * Enum that determines the text-wrapping mode to use.
  8288. */
  8289. export enum InspectableType {
  8290. /**
  8291. * Checkbox for booleans
  8292. */
  8293. Checkbox = 0,
  8294. /**
  8295. * Sliders for numbers
  8296. */
  8297. Slider = 1,
  8298. /**
  8299. * Vector3
  8300. */
  8301. Vector3 = 2,
  8302. /**
  8303. * Quaternions
  8304. */
  8305. Quaternion = 3,
  8306. /**
  8307. * Color3
  8308. */
  8309. Color3 = 4,
  8310. /**
  8311. * String
  8312. */
  8313. String = 5
  8314. }
  8315. /**
  8316. * Interface used to define custom inspectable properties.
  8317. * This interface is used by the inspector to display custom property grids
  8318. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8319. */
  8320. export interface IInspectable {
  8321. /**
  8322. * Gets the label to display
  8323. */
  8324. label: string;
  8325. /**
  8326. * Gets the name of the property to edit
  8327. */
  8328. propertyName: string;
  8329. /**
  8330. * Gets the type of the editor to use
  8331. */
  8332. type: InspectableType;
  8333. /**
  8334. * Gets the minimum value of the property when using in "slider" mode
  8335. */
  8336. min?: number;
  8337. /**
  8338. * Gets the maximum value of the property when using in "slider" mode
  8339. */
  8340. max?: number;
  8341. /**
  8342. * Gets the setp to use when using in "slider" mode
  8343. */
  8344. step?: number;
  8345. }
  8346. }
  8347. declare module "babylonjs/Lights/light" {
  8348. import { Nullable } from "babylonjs/types";
  8349. import { Scene } from "babylonjs/scene";
  8350. import { Vector3 } from "babylonjs/Maths/math.vector";
  8351. import { Color3 } from "babylonjs/Maths/math.color";
  8352. import { Node } from "babylonjs/node";
  8353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8354. import { Effect } from "babylonjs/Materials/effect";
  8355. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8356. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  8357. /**
  8358. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8359. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8360. * 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.
  8361. */
  8362. export abstract class Light extends Node {
  8363. /**
  8364. * Falloff Default: light is falling off following the material specification:
  8365. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8366. */
  8367. static readonly FALLOFF_DEFAULT: number;
  8368. /**
  8369. * Falloff Physical: light is falling off following the inverse squared distance law.
  8370. */
  8371. static readonly FALLOFF_PHYSICAL: number;
  8372. /**
  8373. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8374. * to enhance interoperability with other engines.
  8375. */
  8376. static readonly FALLOFF_GLTF: number;
  8377. /**
  8378. * Falloff Standard: light is falling off like in the standard material
  8379. * to enhance interoperability with other materials.
  8380. */
  8381. static readonly FALLOFF_STANDARD: number;
  8382. /**
  8383. * If every light affecting the material is in this lightmapMode,
  8384. * material.lightmapTexture adds or multiplies
  8385. * (depends on material.useLightmapAsShadowmap)
  8386. * after every other light calculations.
  8387. */
  8388. static readonly LIGHTMAP_DEFAULT: number;
  8389. /**
  8390. * material.lightmapTexture as only diffuse lighting from this light
  8391. * adds only specular lighting from this light
  8392. * adds dynamic shadows
  8393. */
  8394. static readonly LIGHTMAP_SPECULAR: number;
  8395. /**
  8396. * material.lightmapTexture as only lighting
  8397. * no light calculation from this light
  8398. * only adds dynamic shadows from this light
  8399. */
  8400. static readonly LIGHTMAP_SHADOWSONLY: number;
  8401. /**
  8402. * Each light type uses the default quantity according to its type:
  8403. * point/spot lights use luminous intensity
  8404. * directional lights use illuminance
  8405. */
  8406. static readonly INTENSITYMODE_AUTOMATIC: number;
  8407. /**
  8408. * lumen (lm)
  8409. */
  8410. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8411. /**
  8412. * candela (lm/sr)
  8413. */
  8414. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8415. /**
  8416. * lux (lm/m^2)
  8417. */
  8418. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8419. /**
  8420. * nit (cd/m^2)
  8421. */
  8422. static readonly INTENSITYMODE_LUMINANCE: number;
  8423. /**
  8424. * Light type const id of the point light.
  8425. */
  8426. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8427. /**
  8428. * Light type const id of the directional light.
  8429. */
  8430. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8431. /**
  8432. * Light type const id of the spot light.
  8433. */
  8434. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8435. /**
  8436. * Light type const id of the hemispheric light.
  8437. */
  8438. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8439. /**
  8440. * Diffuse gives the basic color to an object.
  8441. */
  8442. diffuse: Color3;
  8443. /**
  8444. * Specular produces a highlight color on an object.
  8445. * Note: This is note affecting PBR materials.
  8446. */
  8447. specular: Color3;
  8448. /**
  8449. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8450. * falling off base on range or angle.
  8451. * This can be set to any values in Light.FALLOFF_x.
  8452. *
  8453. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8454. * other types of materials.
  8455. */
  8456. falloffType: number;
  8457. /**
  8458. * Strength of the light.
  8459. * Note: By default it is define in the framework own unit.
  8460. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8461. */
  8462. intensity: number;
  8463. private _range;
  8464. protected _inverseSquaredRange: number;
  8465. /**
  8466. * Defines how far from the source the light is impacting in scene units.
  8467. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8468. */
  8469. get range(): number;
  8470. /**
  8471. * Defines how far from the source the light is impacting in scene units.
  8472. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8473. */
  8474. set range(value: number);
  8475. /**
  8476. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8477. * of light.
  8478. */
  8479. private _photometricScale;
  8480. private _intensityMode;
  8481. /**
  8482. * Gets the photometric scale used to interpret the intensity.
  8483. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8484. */
  8485. get intensityMode(): number;
  8486. /**
  8487. * Sets the photometric scale used to interpret the intensity.
  8488. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8489. */
  8490. set intensityMode(value: number);
  8491. private _radius;
  8492. /**
  8493. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8494. */
  8495. get radius(): number;
  8496. /**
  8497. * sets the light radius used by PBR Materials to simulate soft area lights.
  8498. */
  8499. set radius(value: number);
  8500. private _renderPriority;
  8501. /**
  8502. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8503. * exceeding the number allowed of the materials.
  8504. */
  8505. renderPriority: number;
  8506. private _shadowEnabled;
  8507. /**
  8508. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8509. * the current shadow generator.
  8510. */
  8511. get shadowEnabled(): boolean;
  8512. /**
  8513. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8514. * the current shadow generator.
  8515. */
  8516. set shadowEnabled(value: boolean);
  8517. private _includedOnlyMeshes;
  8518. /**
  8519. * Gets the only meshes impacted by this light.
  8520. */
  8521. get includedOnlyMeshes(): AbstractMesh[];
  8522. /**
  8523. * Sets the only meshes impacted by this light.
  8524. */
  8525. set includedOnlyMeshes(value: AbstractMesh[]);
  8526. private _excludedMeshes;
  8527. /**
  8528. * Gets the meshes not impacted by this light.
  8529. */
  8530. get excludedMeshes(): AbstractMesh[];
  8531. /**
  8532. * Sets the meshes not impacted by this light.
  8533. */
  8534. set excludedMeshes(value: AbstractMesh[]);
  8535. private _excludeWithLayerMask;
  8536. /**
  8537. * Gets the layer id use to find what meshes are not impacted by the light.
  8538. * Inactive if 0
  8539. */
  8540. get excludeWithLayerMask(): number;
  8541. /**
  8542. * Sets the layer id use to find what meshes are not impacted by the light.
  8543. * Inactive if 0
  8544. */
  8545. set excludeWithLayerMask(value: number);
  8546. private _includeOnlyWithLayerMask;
  8547. /**
  8548. * Gets the layer id use to find what meshes are impacted by the light.
  8549. * Inactive if 0
  8550. */
  8551. get includeOnlyWithLayerMask(): number;
  8552. /**
  8553. * Sets the layer id use to find what meshes are impacted by the light.
  8554. * Inactive if 0
  8555. */
  8556. set includeOnlyWithLayerMask(value: number);
  8557. private _lightmapMode;
  8558. /**
  8559. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8560. */
  8561. get lightmapMode(): number;
  8562. /**
  8563. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  8564. */
  8565. set lightmapMode(value: number);
  8566. /**
  8567. * Shadow generator associted to the light.
  8568. * @hidden Internal use only.
  8569. */
  8570. _shadowGenerator: Nullable<IShadowGenerator>;
  8571. /**
  8572. * @hidden Internal use only.
  8573. */
  8574. _excludedMeshesIds: string[];
  8575. /**
  8576. * @hidden Internal use only.
  8577. */
  8578. _includedOnlyMeshesIds: string[];
  8579. /**
  8580. * The current light unifom buffer.
  8581. * @hidden Internal use only.
  8582. */
  8583. _uniformBuffer: UniformBuffer;
  8584. /** @hidden */
  8585. _renderId: number;
  8586. /**
  8587. * Creates a Light object in the scene.
  8588. * Documentation : https://doc.babylonjs.com/babylon101/lights
  8589. * @param name The firendly name of the light
  8590. * @param scene The scene the light belongs too
  8591. */
  8592. constructor(name: string, scene: Scene);
  8593. protected abstract _buildUniformLayout(): void;
  8594. /**
  8595. * Sets the passed Effect "effect" with the Light information.
  8596. * @param effect The effect to update
  8597. * @param lightIndex The index of the light in the effect to update
  8598. * @returns The light
  8599. */
  8600. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  8601. /**
  8602. * Sets the passed Effect "effect" with the Light textures.
  8603. * @param effect The effect to update
  8604. * @param lightIndex The index of the light in the effect to update
  8605. * @returns The light
  8606. */
  8607. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  8608. /**
  8609. * Binds the lights information from the scene to the effect for the given mesh.
  8610. * @param lightIndex Light index
  8611. * @param scene The scene where the light belongs to
  8612. * @param effect The effect we are binding the data to
  8613. * @param useSpecular Defines if specular is supported
  8614. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  8615. */
  8616. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  8617. /**
  8618. * Sets the passed Effect "effect" with the Light information.
  8619. * @param effect The effect to update
  8620. * @param lightDataUniformName The uniform used to store light data (position or direction)
  8621. * @returns The light
  8622. */
  8623. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  8624. /**
  8625. * Returns the string "Light".
  8626. * @returns the class name
  8627. */
  8628. getClassName(): string;
  8629. /** @hidden */
  8630. readonly _isLight: boolean;
  8631. /**
  8632. * Converts the light information to a readable string for debug purpose.
  8633. * @param fullDetails Supports for multiple levels of logging within scene loading
  8634. * @returns the human readable light info
  8635. */
  8636. toString(fullDetails?: boolean): string;
  8637. /** @hidden */
  8638. protected _syncParentEnabledState(): void;
  8639. /**
  8640. * Set the enabled state of this node.
  8641. * @param value - the new enabled state
  8642. */
  8643. setEnabled(value: boolean): void;
  8644. /**
  8645. * Returns the Light associated shadow generator if any.
  8646. * @return the associated shadow generator.
  8647. */
  8648. getShadowGenerator(): Nullable<IShadowGenerator>;
  8649. /**
  8650. * Returns a Vector3, the absolute light position in the World.
  8651. * @returns the world space position of the light
  8652. */
  8653. getAbsolutePosition(): Vector3;
  8654. /**
  8655. * Specifies if the light will affect the passed mesh.
  8656. * @param mesh The mesh to test against the light
  8657. * @return true the mesh is affected otherwise, false.
  8658. */
  8659. canAffectMesh(mesh: AbstractMesh): boolean;
  8660. /**
  8661. * Sort function to order lights for rendering.
  8662. * @param a First Light object to compare to second.
  8663. * @param b Second Light object to compare first.
  8664. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  8665. */
  8666. static CompareLightsPriority(a: Light, b: Light): number;
  8667. /**
  8668. * Releases resources associated with this node.
  8669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8671. */
  8672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8673. /**
  8674. * Returns the light type ID (integer).
  8675. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  8676. */
  8677. getTypeID(): number;
  8678. /**
  8679. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  8680. * @returns the scaled intensity in intensity mode unit
  8681. */
  8682. getScaledIntensity(): number;
  8683. /**
  8684. * Returns a new Light object, named "name", from the current one.
  8685. * @param name The name of the cloned light
  8686. * @param newParent The parent of this light, if it has one
  8687. * @returns the new created light
  8688. */
  8689. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  8690. /**
  8691. * Serializes the current light into a Serialization object.
  8692. * @returns the serialized object.
  8693. */
  8694. serialize(): any;
  8695. /**
  8696. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  8697. * This new light is named "name" and added to the passed scene.
  8698. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  8699. * @param name The friendly name of the light
  8700. * @param scene The scene the new light will belong to
  8701. * @returns the constructor function
  8702. */
  8703. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  8704. /**
  8705. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  8706. * @param parsedLight The JSON representation of the light
  8707. * @param scene The scene to create the parsed light in
  8708. * @returns the created light after parsing
  8709. */
  8710. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  8711. private _hookArrayForExcluded;
  8712. private _hookArrayForIncludedOnly;
  8713. private _resyncMeshes;
  8714. /**
  8715. * Forces the meshes to update their light related information in their rendering used effects
  8716. * @hidden Internal Use Only
  8717. */
  8718. _markMeshesAsLightDirty(): void;
  8719. /**
  8720. * Recomputes the cached photometric scale if needed.
  8721. */
  8722. private _computePhotometricScale;
  8723. /**
  8724. * Returns the Photometric Scale according to the light type and intensity mode.
  8725. */
  8726. private _getPhotometricScale;
  8727. /**
  8728. * Reorder the light in the scene according to their defined priority.
  8729. * @hidden Internal Use Only
  8730. */
  8731. _reorderLightsInScene(): void;
  8732. /**
  8733. * Prepares the list of defines specific to the light type.
  8734. * @param defines the list of defines
  8735. * @param lightIndex defines the index of the light for the effect
  8736. */
  8737. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  8738. }
  8739. }
  8740. declare module "babylonjs/Maths/math.axis" {
  8741. import { Vector3 } from "babylonjs/Maths/math.vector";
  8742. /** Defines supported spaces */
  8743. export enum Space {
  8744. /** Local (object) space */
  8745. LOCAL = 0,
  8746. /** World space */
  8747. WORLD = 1,
  8748. /** Bone space */
  8749. BONE = 2
  8750. }
  8751. /** Defines the 3 main axes */
  8752. export class Axis {
  8753. /** X axis */
  8754. static X: Vector3;
  8755. /** Y axis */
  8756. static Y: Vector3;
  8757. /** Z axis */
  8758. static Z: Vector3;
  8759. }
  8760. /**
  8761. * Defines cartesian components.
  8762. */
  8763. export enum Coordinate {
  8764. /** X axis */
  8765. X = 0,
  8766. /** Y axis */
  8767. Y = 1,
  8768. /** Z axis */
  8769. Z = 2
  8770. }
  8771. }
  8772. declare module "babylonjs/Lights/shadowLight" {
  8773. import { Camera } from "babylonjs/Cameras/camera";
  8774. import { Scene } from "babylonjs/scene";
  8775. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8777. import { Light } from "babylonjs/Lights/light";
  8778. /**
  8779. * Interface describing all the common properties and methods a shadow light needs to implement.
  8780. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8781. * as well as binding the different shadow properties to the effects.
  8782. */
  8783. export interface IShadowLight extends Light {
  8784. /**
  8785. * The light id in the scene (used in scene.findLighById for instance)
  8786. */
  8787. id: string;
  8788. /**
  8789. * The position the shdow will be casted from.
  8790. */
  8791. position: Vector3;
  8792. /**
  8793. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8794. */
  8795. direction: Vector3;
  8796. /**
  8797. * The transformed position. Position of the light in world space taking parenting in account.
  8798. */
  8799. transformedPosition: Vector3;
  8800. /**
  8801. * The transformed direction. Direction of the light in world space taking parenting in account.
  8802. */
  8803. transformedDirection: Vector3;
  8804. /**
  8805. * The friendly name of the light in the scene.
  8806. */
  8807. name: string;
  8808. /**
  8809. * Defines the shadow projection clipping minimum z value.
  8810. */
  8811. shadowMinZ: number;
  8812. /**
  8813. * Defines the shadow projection clipping maximum z value.
  8814. */
  8815. shadowMaxZ: number;
  8816. /**
  8817. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8818. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8819. */
  8820. computeTransformedInformation(): boolean;
  8821. /**
  8822. * Gets the scene the light belongs to.
  8823. * @returns The scene
  8824. */
  8825. getScene(): Scene;
  8826. /**
  8827. * Callback defining a custom Projection Matrix Builder.
  8828. * This can be used to override the default projection matrix computation.
  8829. */
  8830. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8831. /**
  8832. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8833. * @param matrix The materix to updated with the projection information
  8834. * @param viewMatrix The transform matrix of the light
  8835. * @param renderList The list of mesh to render in the map
  8836. * @returns The current light
  8837. */
  8838. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8839. /**
  8840. * Gets the current depth scale used in ESM.
  8841. * @returns The scale
  8842. */
  8843. getDepthScale(): number;
  8844. /**
  8845. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8846. * @returns true if a cube texture needs to be use
  8847. */
  8848. needCube(): boolean;
  8849. /**
  8850. * Detects if the projection matrix requires to be recomputed this frame.
  8851. * @returns true if it requires to be recomputed otherwise, false.
  8852. */
  8853. needProjectionMatrixCompute(): boolean;
  8854. /**
  8855. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8856. */
  8857. forceProjectionMatrixCompute(): void;
  8858. /**
  8859. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8860. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8861. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8862. */
  8863. getShadowDirection(faceIndex?: number): Vector3;
  8864. /**
  8865. * Gets the minZ used for shadow according to both the scene and the light.
  8866. * @param activeCamera The camera we are returning the min for
  8867. * @returns the depth min z
  8868. */
  8869. getDepthMinZ(activeCamera: Camera): number;
  8870. /**
  8871. * Gets the maxZ used for shadow according to both the scene and the light.
  8872. * @param activeCamera The camera we are returning the max for
  8873. * @returns the depth max z
  8874. */
  8875. getDepthMaxZ(activeCamera: Camera): number;
  8876. }
  8877. /**
  8878. * Base implementation IShadowLight
  8879. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8880. */
  8881. export abstract class ShadowLight extends Light implements IShadowLight {
  8882. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8883. protected _position: Vector3;
  8884. protected _setPosition(value: Vector3): void;
  8885. /**
  8886. * Sets the position the shadow will be casted from. Also use as the light position for both
  8887. * point and spot lights.
  8888. */
  8889. get position(): Vector3;
  8890. /**
  8891. * Sets the position the shadow will be casted from. Also use as the light position for both
  8892. * point and spot lights.
  8893. */
  8894. set position(value: Vector3);
  8895. protected _direction: Vector3;
  8896. protected _setDirection(value: Vector3): void;
  8897. /**
  8898. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8899. * Also use as the light direction on spot and directional lights.
  8900. */
  8901. get direction(): Vector3;
  8902. /**
  8903. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8904. * Also use as the light direction on spot and directional lights.
  8905. */
  8906. set direction(value: Vector3);
  8907. protected _shadowMinZ: number;
  8908. /**
  8909. * Gets the shadow projection clipping minimum z value.
  8910. */
  8911. get shadowMinZ(): number;
  8912. /**
  8913. * Sets the shadow projection clipping minimum z value.
  8914. */
  8915. set shadowMinZ(value: number);
  8916. protected _shadowMaxZ: number;
  8917. /**
  8918. * Sets the shadow projection clipping maximum z value.
  8919. */
  8920. get shadowMaxZ(): number;
  8921. /**
  8922. * Gets the shadow projection clipping maximum z value.
  8923. */
  8924. set shadowMaxZ(value: number);
  8925. /**
  8926. * Callback defining a custom Projection Matrix Builder.
  8927. * This can be used to override the default projection matrix computation.
  8928. */
  8929. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8930. /**
  8931. * The transformed position. Position of the light in world space taking parenting in account.
  8932. */
  8933. transformedPosition: Vector3;
  8934. /**
  8935. * The transformed direction. Direction of the light in world space taking parenting in account.
  8936. */
  8937. transformedDirection: Vector3;
  8938. private _needProjectionMatrixCompute;
  8939. /**
  8940. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8941. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8942. */
  8943. computeTransformedInformation(): boolean;
  8944. /**
  8945. * Return the depth scale used for the shadow map.
  8946. * @returns the depth scale.
  8947. */
  8948. getDepthScale(): number;
  8949. /**
  8950. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8951. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8952. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8953. */
  8954. getShadowDirection(faceIndex?: number): Vector3;
  8955. /**
  8956. * Returns the ShadowLight absolute position in the World.
  8957. * @returns the position vector in world space
  8958. */
  8959. getAbsolutePosition(): Vector3;
  8960. /**
  8961. * Sets the ShadowLight direction toward the passed target.
  8962. * @param target The point to target in local space
  8963. * @returns the updated ShadowLight direction
  8964. */
  8965. setDirectionToTarget(target: Vector3): Vector3;
  8966. /**
  8967. * Returns the light rotation in euler definition.
  8968. * @returns the x y z rotation in local space.
  8969. */
  8970. getRotation(): Vector3;
  8971. /**
  8972. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8973. * @returns true if a cube texture needs to be use
  8974. */
  8975. needCube(): boolean;
  8976. /**
  8977. * Detects if the projection matrix requires to be recomputed this frame.
  8978. * @returns true if it requires to be recomputed otherwise, false.
  8979. */
  8980. needProjectionMatrixCompute(): boolean;
  8981. /**
  8982. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8983. */
  8984. forceProjectionMatrixCompute(): void;
  8985. /** @hidden */
  8986. _initCache(): void;
  8987. /** @hidden */
  8988. _isSynchronized(): boolean;
  8989. /**
  8990. * Computes the world matrix of the node
  8991. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8992. * @returns the world matrix
  8993. */
  8994. computeWorldMatrix(force?: boolean): Matrix;
  8995. /**
  8996. * Gets the minZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the min for
  8998. * @returns the depth min z
  8999. */
  9000. getDepthMinZ(activeCamera: Camera): number;
  9001. /**
  9002. * Gets the maxZ used for shadow according to both the scene and the light.
  9003. * @param activeCamera The camera we are returning the max for
  9004. * @returns the depth max z
  9005. */
  9006. getDepthMaxZ(activeCamera: Camera): number;
  9007. /**
  9008. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9009. * @param matrix The materix to updated with the projection information
  9010. * @param viewMatrix The transform matrix of the light
  9011. * @param renderList The list of mesh to render in the map
  9012. * @returns The current light
  9013. */
  9014. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9015. }
  9016. }
  9017. declare module "babylonjs/Materials/prePassConfiguration" {
  9018. import { Matrix } from "babylonjs/Maths/math.vector";
  9019. import { Mesh } from "babylonjs/Meshes/mesh";
  9020. import { Scene } from "babylonjs/scene";
  9021. import { Effect } from "babylonjs/Materials/effect";
  9022. /**
  9023. * Configuration needed for prepass-capable materials
  9024. */
  9025. export class PrePassConfiguration {
  9026. /**
  9027. * Previous world matrices of meshes carrying this material
  9028. * Used for computing velocity
  9029. */
  9030. previousWorldMatrices: {
  9031. [index: number]: Matrix;
  9032. };
  9033. /**
  9034. * Previous view project matrix
  9035. * Used for computing velocity
  9036. */
  9037. previousViewProjection: Matrix;
  9038. /**
  9039. * Previous bones of meshes carrying this material
  9040. * Used for computing velocity
  9041. */
  9042. previousBones: {
  9043. [index: number]: Float32Array;
  9044. };
  9045. /**
  9046. * Add the required uniforms to the current list.
  9047. * @param uniforms defines the current uniform list.
  9048. */
  9049. static AddUniforms(uniforms: string[]): void;
  9050. /**
  9051. * Add the required samplers to the current list.
  9052. * @param samplers defines the current sampler list.
  9053. */
  9054. static AddSamplers(samplers: string[]): void;
  9055. /**
  9056. * Binds the material data.
  9057. * @param effect defines the effect to update
  9058. * @param scene defines the scene the material belongs to.
  9059. * @param mesh The mesh
  9060. * @param world World matrix of this mesh
  9061. * @param isFrozen Is the material frozen
  9062. */
  9063. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9064. }
  9065. }
  9066. declare module "babylonjs/Cameras/targetCamera" {
  9067. import { Nullable } from "babylonjs/types";
  9068. import { Camera } from "babylonjs/Cameras/camera";
  9069. import { Scene } from "babylonjs/scene";
  9070. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9071. /**
  9072. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9073. * This is the base of the follow, arc rotate cameras and Free camera
  9074. * @see https://doc.babylonjs.com/features/cameras
  9075. */
  9076. export class TargetCamera extends Camera {
  9077. private static _RigCamTransformMatrix;
  9078. private static _TargetTransformMatrix;
  9079. private static _TargetFocalPoint;
  9080. private _tmpUpVector;
  9081. private _tmpTargetVector;
  9082. /**
  9083. * Define the current direction the camera is moving to
  9084. */
  9085. cameraDirection: Vector3;
  9086. /**
  9087. * Define the current rotation the camera is rotating to
  9088. */
  9089. cameraRotation: Vector2;
  9090. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9091. ignoreParentScaling: boolean;
  9092. /**
  9093. * When set, the up vector of the camera will be updated by the rotation of the camera
  9094. */
  9095. updateUpVectorFromRotation: boolean;
  9096. private _tmpQuaternion;
  9097. /**
  9098. * Define the current rotation of the camera
  9099. */
  9100. rotation: Vector3;
  9101. /**
  9102. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9103. */
  9104. rotationQuaternion: Quaternion;
  9105. /**
  9106. * Define the current speed of the camera
  9107. */
  9108. speed: number;
  9109. /**
  9110. * Add constraint to the camera to prevent it to move freely in all directions and
  9111. * around all axis.
  9112. */
  9113. noRotationConstraint: boolean;
  9114. /**
  9115. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9116. * panning
  9117. */
  9118. invertRotation: boolean;
  9119. /**
  9120. * Speed multiplier for inverse camera panning
  9121. */
  9122. inverseRotationSpeed: number;
  9123. /**
  9124. * Define the current target of the camera as an object or a position.
  9125. */
  9126. lockedTarget: any;
  9127. /** @hidden */
  9128. _currentTarget: Vector3;
  9129. /** @hidden */
  9130. _initialFocalDistance: number;
  9131. /** @hidden */
  9132. _viewMatrix: Matrix;
  9133. /** @hidden */
  9134. _camMatrix: Matrix;
  9135. /** @hidden */
  9136. _cameraTransformMatrix: Matrix;
  9137. /** @hidden */
  9138. _cameraRotationMatrix: Matrix;
  9139. /** @hidden */
  9140. _referencePoint: Vector3;
  9141. /** @hidden */
  9142. _transformedReferencePoint: Vector3;
  9143. /** @hidden */
  9144. _reset: () => void;
  9145. private _defaultUp;
  9146. /**
  9147. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9148. * This is the base of the follow, arc rotate cameras and Free camera
  9149. * @see https://doc.babylonjs.com/features/cameras
  9150. * @param name Defines the name of the camera in the scene
  9151. * @param position Defines the start position of the camera in the scene
  9152. * @param scene Defines the scene the camera belongs to
  9153. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9154. */
  9155. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9156. /**
  9157. * Gets the position in front of the camera at a given distance.
  9158. * @param distance The distance from the camera we want the position to be
  9159. * @returns the position
  9160. */
  9161. getFrontPosition(distance: number): Vector3;
  9162. /** @hidden */
  9163. _getLockedTargetPosition(): Nullable<Vector3>;
  9164. private _storedPosition;
  9165. private _storedRotation;
  9166. private _storedRotationQuaternion;
  9167. /**
  9168. * Store current camera state of the camera (fov, position, rotation, etc..)
  9169. * @returns the camera
  9170. */
  9171. storeState(): Camera;
  9172. /**
  9173. * Restored camera state. You must call storeState() first
  9174. * @returns whether it was successful or not
  9175. * @hidden
  9176. */
  9177. _restoreStateValues(): boolean;
  9178. /** @hidden */
  9179. _initCache(): void;
  9180. /** @hidden */
  9181. _updateCache(ignoreParentClass?: boolean): void;
  9182. /** @hidden */
  9183. _isSynchronizedViewMatrix(): boolean;
  9184. /** @hidden */
  9185. _computeLocalCameraSpeed(): number;
  9186. /**
  9187. * Defines the target the camera should look at.
  9188. * @param target Defines the new target as a Vector or a mesh
  9189. */
  9190. setTarget(target: Vector3): void;
  9191. /**
  9192. * Defines the target point of the camera.
  9193. * The camera looks towards it form the radius distance.
  9194. */
  9195. get target(): Vector3;
  9196. set target(value: Vector3);
  9197. /**
  9198. * Return the current target position of the camera. This value is expressed in local space.
  9199. * @returns the target position
  9200. */
  9201. getTarget(): Vector3;
  9202. /** @hidden */
  9203. _decideIfNeedsToMove(): boolean;
  9204. /** @hidden */
  9205. _updatePosition(): void;
  9206. /** @hidden */
  9207. _checkInputs(): void;
  9208. protected _updateCameraRotationMatrix(): void;
  9209. /**
  9210. * 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)
  9211. * @returns the current camera
  9212. */
  9213. private _rotateUpVectorWithCameraRotationMatrix;
  9214. private _cachedRotationZ;
  9215. private _cachedQuaternionRotationZ;
  9216. /** @hidden */
  9217. _getViewMatrix(): Matrix;
  9218. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9219. /**
  9220. * @hidden
  9221. */
  9222. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9223. /**
  9224. * @hidden
  9225. */
  9226. _updateRigCameras(): void;
  9227. private _getRigCamPositionAndTarget;
  9228. /**
  9229. * Gets the current object class name.
  9230. * @return the class name
  9231. */
  9232. getClassName(): string;
  9233. }
  9234. }
  9235. declare module "babylonjs/Cameras/cameraInputsManager" {
  9236. import { Nullable } from "babylonjs/types";
  9237. import { Camera } from "babylonjs/Cameras/camera";
  9238. /**
  9239. * @ignore
  9240. * This is a list of all the different input types that are available in the application.
  9241. * Fo instance: ArcRotateCameraGamepadInput...
  9242. */
  9243. export var CameraInputTypes: {};
  9244. /**
  9245. * This is the contract to implement in order to create a new input class.
  9246. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9247. */
  9248. export interface ICameraInput<TCamera extends Camera> {
  9249. /**
  9250. * Defines the camera the input is attached to.
  9251. */
  9252. camera: Nullable<TCamera>;
  9253. /**
  9254. * Gets the class name of the current intput.
  9255. * @returns the class name
  9256. */
  9257. getClassName(): string;
  9258. /**
  9259. * Get the friendly name associated with the input class.
  9260. * @returns the input friendly name
  9261. */
  9262. getSimpleName(): string;
  9263. /**
  9264. * Attach the input controls to a specific dom element to get the input from.
  9265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9266. */
  9267. attachControl(noPreventDefault?: boolean): void;
  9268. /**
  9269. * Detach the current controls from the specified dom element.
  9270. */
  9271. detachControl(): void;
  9272. /**
  9273. * Update the current camera state depending on the inputs that have been used this frame.
  9274. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9275. */
  9276. checkInputs?: () => void;
  9277. }
  9278. /**
  9279. * Represents a map of input types to input instance or input index to input instance.
  9280. */
  9281. export interface CameraInputsMap<TCamera extends Camera> {
  9282. /**
  9283. * Accessor to the input by input type.
  9284. */
  9285. [name: string]: ICameraInput<TCamera>;
  9286. /**
  9287. * Accessor to the input by input index.
  9288. */
  9289. [idx: number]: ICameraInput<TCamera>;
  9290. }
  9291. /**
  9292. * This represents the input manager used within a camera.
  9293. * It helps dealing with all the different kind of input attached to a camera.
  9294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9295. */
  9296. export class CameraInputsManager<TCamera extends Camera> {
  9297. /**
  9298. * Defines the list of inputs attahed to the camera.
  9299. */
  9300. attached: CameraInputsMap<TCamera>;
  9301. /**
  9302. * Defines the dom element the camera is collecting inputs from.
  9303. * This is null if the controls have not been attached.
  9304. */
  9305. attachedToElement: boolean;
  9306. /**
  9307. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9308. */
  9309. noPreventDefault: boolean;
  9310. /**
  9311. * Defined the camera the input manager belongs to.
  9312. */
  9313. camera: TCamera;
  9314. /**
  9315. * Update the current camera state depending on the inputs that have been used this frame.
  9316. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9317. */
  9318. checkInputs: () => void;
  9319. /**
  9320. * Instantiate a new Camera Input Manager.
  9321. * @param camera Defines the camera the input manager blongs to
  9322. */
  9323. constructor(camera: TCamera);
  9324. /**
  9325. * Add an input method to a camera
  9326. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9327. * @param input camera input method
  9328. */
  9329. add(input: ICameraInput<TCamera>): void;
  9330. /**
  9331. * Remove a specific input method from a camera
  9332. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9333. * @param inputToRemove camera input method
  9334. */
  9335. remove(inputToRemove: ICameraInput<TCamera>): void;
  9336. /**
  9337. * Remove a specific input type from a camera
  9338. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9339. * @param inputType the type of the input to remove
  9340. */
  9341. removeByType(inputType: string): void;
  9342. private _addCheckInputs;
  9343. /**
  9344. * Attach the input controls to the currently attached dom element to listen the events from.
  9345. * @param input Defines the input to attach
  9346. */
  9347. attachInput(input: ICameraInput<TCamera>): void;
  9348. /**
  9349. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9350. * @param element Defines the dom element to collect the events from
  9351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9352. */
  9353. attachElement(noPreventDefault?: boolean): void;
  9354. /**
  9355. * Detach the current manager inputs controls from a specific dom element.
  9356. * @param element Defines the dom element to collect the events from
  9357. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9358. */
  9359. detachElement(disconnect?: boolean): void;
  9360. /**
  9361. * Rebuild the dynamic inputCheck function from the current list of
  9362. * defined inputs in the manager.
  9363. */
  9364. rebuildInputCheck(): void;
  9365. /**
  9366. * Remove all attached input methods from a camera
  9367. */
  9368. clear(): void;
  9369. /**
  9370. * Serialize the current input manager attached to a camera.
  9371. * This ensures than once parsed,
  9372. * the input associated to the camera will be identical to the current ones
  9373. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9374. */
  9375. serialize(serializedCamera: any): void;
  9376. /**
  9377. * Parses an input manager serialized JSON to restore the previous list of inputs
  9378. * and states associated to a camera.
  9379. * @param parsedCamera Defines the JSON to parse
  9380. */
  9381. parse(parsedCamera: any): void;
  9382. }
  9383. }
  9384. declare module "babylonjs/Events/keyboardEvents" {
  9385. /**
  9386. * Gather the list of keyboard event types as constants.
  9387. */
  9388. export class KeyboardEventTypes {
  9389. /**
  9390. * The keydown event is fired when a key becomes active (pressed).
  9391. */
  9392. static readonly KEYDOWN: number;
  9393. /**
  9394. * The keyup event is fired when a key has been released.
  9395. */
  9396. static readonly KEYUP: number;
  9397. }
  9398. /**
  9399. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9400. */
  9401. export class KeyboardInfo {
  9402. /**
  9403. * Defines the type of event (KeyboardEventTypes)
  9404. */
  9405. type: number;
  9406. /**
  9407. * Defines the related dom event
  9408. */
  9409. event: KeyboardEvent;
  9410. /**
  9411. * Instantiates a new keyboard info.
  9412. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9413. * @param type Defines the type of event (KeyboardEventTypes)
  9414. * @param event Defines the related dom event
  9415. */
  9416. constructor(
  9417. /**
  9418. * Defines the type of event (KeyboardEventTypes)
  9419. */
  9420. type: number,
  9421. /**
  9422. * Defines the related dom event
  9423. */
  9424. event: KeyboardEvent);
  9425. }
  9426. /**
  9427. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9428. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9429. */
  9430. export class KeyboardInfoPre extends KeyboardInfo {
  9431. /**
  9432. * Defines the type of event (KeyboardEventTypes)
  9433. */
  9434. type: number;
  9435. /**
  9436. * Defines the related dom event
  9437. */
  9438. event: KeyboardEvent;
  9439. /**
  9440. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9441. */
  9442. skipOnPointerObservable: boolean;
  9443. /**
  9444. * Instantiates a new keyboard pre info.
  9445. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9446. * @param type Defines the type of event (KeyboardEventTypes)
  9447. * @param event Defines the related dom event
  9448. */
  9449. constructor(
  9450. /**
  9451. * Defines the type of event (KeyboardEventTypes)
  9452. */
  9453. type: number,
  9454. /**
  9455. * Defines the related dom event
  9456. */
  9457. event: KeyboardEvent);
  9458. }
  9459. }
  9460. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9461. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9462. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9463. /**
  9464. * Manage the keyboard inputs to control the movement of a free camera.
  9465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9466. */
  9467. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9468. /**
  9469. * Defines the camera the input is attached to.
  9470. */
  9471. camera: FreeCamera;
  9472. /**
  9473. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9474. */
  9475. keysUp: number[];
  9476. /**
  9477. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9478. */
  9479. keysUpward: number[];
  9480. /**
  9481. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9482. */
  9483. keysDown: number[];
  9484. /**
  9485. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9486. */
  9487. keysDownward: number[];
  9488. /**
  9489. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9490. */
  9491. keysLeft: number[];
  9492. /**
  9493. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9494. */
  9495. keysRight: number[];
  9496. private _keys;
  9497. private _onCanvasBlurObserver;
  9498. private _onKeyboardObserver;
  9499. private _engine;
  9500. private _scene;
  9501. /**
  9502. * Attach the input controls to a specific dom element to get the input from.
  9503. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9504. */
  9505. attachControl(noPreventDefault?: boolean): void;
  9506. /**
  9507. * Detach the current controls from the specified dom element.
  9508. */
  9509. detachControl(): void;
  9510. /**
  9511. * Update the current camera state depending on the inputs that have been used this frame.
  9512. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9513. */
  9514. checkInputs(): void;
  9515. /**
  9516. * Gets the class name of the current intput.
  9517. * @returns the class name
  9518. */
  9519. getClassName(): string;
  9520. /** @hidden */
  9521. _onLostFocus(): void;
  9522. /**
  9523. * Get the friendly name associated with the input class.
  9524. * @returns the input friendly name
  9525. */
  9526. getSimpleName(): string;
  9527. }
  9528. }
  9529. declare module "babylonjs/Actions/action" {
  9530. import { Observable } from "babylonjs/Misc/observable";
  9531. import { Condition } from "babylonjs/Actions/condition";
  9532. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9533. import { Nullable } from "babylonjs/types";
  9534. import { Scene } from "babylonjs/scene";
  9535. import { ActionManager } from "babylonjs/Actions/actionManager";
  9536. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9537. import { Node } from "babylonjs/node";
  9538. /**
  9539. * Interface used to define Action
  9540. */
  9541. export interface IAction {
  9542. /**
  9543. * Trigger for the action
  9544. */
  9545. trigger: number;
  9546. /** Options of the trigger */
  9547. triggerOptions: any;
  9548. /**
  9549. * Gets the trigger parameters
  9550. * @returns the trigger parameters
  9551. */
  9552. getTriggerParameter(): any;
  9553. /**
  9554. * Internal only - executes current action event
  9555. * @hidden
  9556. */
  9557. _executeCurrent(evt?: ActionEvent): void;
  9558. /**
  9559. * Serialize placeholder for child classes
  9560. * @param parent of child
  9561. * @returns the serialized object
  9562. */
  9563. serialize(parent: any): any;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _prepare(): void;
  9569. /**
  9570. * Internal only - manager for action
  9571. * @hidden
  9572. */
  9573. _actionManager: Nullable<AbstractActionManager>;
  9574. /**
  9575. * Adds action to chain of actions, may be a DoNothingAction
  9576. * @param action defines the next action to execute
  9577. * @returns The action passed in
  9578. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9579. */
  9580. then(action: IAction): IAction;
  9581. }
  9582. /**
  9583. * The action to be carried out following a trigger
  9584. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9585. */
  9586. export class Action implements IAction {
  9587. /** the trigger, with or without parameters, for the action */
  9588. triggerOptions: any;
  9589. /**
  9590. * Trigger for the action
  9591. */
  9592. trigger: number;
  9593. /**
  9594. * Internal only - manager for action
  9595. * @hidden
  9596. */
  9597. _actionManager: ActionManager;
  9598. private _nextActiveAction;
  9599. private _child;
  9600. private _condition?;
  9601. private _triggerParameter;
  9602. /**
  9603. * An event triggered prior to action being executed.
  9604. */
  9605. onBeforeExecuteObservable: Observable<Action>;
  9606. /**
  9607. * Creates a new Action
  9608. * @param triggerOptions the trigger, with or without parameters, for the action
  9609. * @param condition an optional determinant of action
  9610. */
  9611. constructor(
  9612. /** the trigger, with or without parameters, for the action */
  9613. triggerOptions: any, condition?: Condition);
  9614. /**
  9615. * Internal only
  9616. * @hidden
  9617. */
  9618. _prepare(): void;
  9619. /**
  9620. * Gets the trigger parameters
  9621. * @returns the trigger parameters
  9622. */
  9623. getTriggerParameter(): any;
  9624. /**
  9625. * Internal only - executes current action event
  9626. * @hidden
  9627. */
  9628. _executeCurrent(evt?: ActionEvent): void;
  9629. /**
  9630. * Execute placeholder for child classes
  9631. * @param evt optional action event
  9632. */
  9633. execute(evt?: ActionEvent): void;
  9634. /**
  9635. * Skips to next active action
  9636. */
  9637. skipToNextActiveAction(): void;
  9638. /**
  9639. * Adds action to chain of actions, may be a DoNothingAction
  9640. * @param action defines the next action to execute
  9641. * @returns The action passed in
  9642. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9643. */
  9644. then(action: Action): Action;
  9645. /**
  9646. * Internal only
  9647. * @hidden
  9648. */
  9649. _getProperty(propertyPath: string): string;
  9650. /**
  9651. * Internal only
  9652. * @hidden
  9653. */
  9654. _getEffectiveTarget(target: any, propertyPath: string): any;
  9655. /**
  9656. * Serialize placeholder for child classes
  9657. * @param parent of child
  9658. * @returns the serialized object
  9659. */
  9660. serialize(parent: any): any;
  9661. /**
  9662. * Internal only called by serialize
  9663. * @hidden
  9664. */
  9665. protected _serialize(serializedAction: any, parent?: any): any;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. static _SerializeValueAsString: (value: any) => string;
  9671. /**
  9672. * Internal only
  9673. * @hidden
  9674. */
  9675. static _GetTargetProperty: (target: Scene | Node) => {
  9676. name: string;
  9677. targetType: string;
  9678. value: string;
  9679. };
  9680. }
  9681. }
  9682. declare module "babylonjs/Actions/condition" {
  9683. import { ActionManager } from "babylonjs/Actions/actionManager";
  9684. /**
  9685. * A Condition applied to an Action
  9686. */
  9687. export class Condition {
  9688. /**
  9689. * Internal only - manager for action
  9690. * @hidden
  9691. */
  9692. _actionManager: ActionManager;
  9693. /**
  9694. * Internal only
  9695. * @hidden
  9696. */
  9697. _evaluationId: number;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. _currentResult: boolean;
  9703. /**
  9704. * Creates a new Condition
  9705. * @param actionManager the manager of the action the condition is applied to
  9706. */
  9707. constructor(actionManager: ActionManager);
  9708. /**
  9709. * Check if the current condition is valid
  9710. * @returns a boolean
  9711. */
  9712. isValid(): boolean;
  9713. /**
  9714. * Internal only
  9715. * @hidden
  9716. */
  9717. _getProperty(propertyPath: string): string;
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. _getEffectiveTarget(target: any, propertyPath: string): any;
  9723. /**
  9724. * Serialize placeholder for child classes
  9725. * @returns the serialized object
  9726. */
  9727. serialize(): any;
  9728. /**
  9729. * Internal only
  9730. * @hidden
  9731. */
  9732. protected _serialize(serializedCondition: any): any;
  9733. }
  9734. /**
  9735. * Defines specific conditional operators as extensions of Condition
  9736. */
  9737. export class ValueCondition extends Condition {
  9738. /** path to specify the property of the target the conditional operator uses */
  9739. propertyPath: string;
  9740. /** the value compared by the conditional operator against the current value of the property */
  9741. value: any;
  9742. /** the conditional operator, default ValueCondition.IsEqual */
  9743. operator: number;
  9744. /**
  9745. * Internal only
  9746. * @hidden
  9747. */
  9748. private static _IsEqual;
  9749. /**
  9750. * Internal only
  9751. * @hidden
  9752. */
  9753. private static _IsDifferent;
  9754. /**
  9755. * Internal only
  9756. * @hidden
  9757. */
  9758. private static _IsGreater;
  9759. /**
  9760. * Internal only
  9761. * @hidden
  9762. */
  9763. private static _IsLesser;
  9764. /**
  9765. * returns the number for IsEqual
  9766. */
  9767. static get IsEqual(): number;
  9768. /**
  9769. * Returns the number for IsDifferent
  9770. */
  9771. static get IsDifferent(): number;
  9772. /**
  9773. * Returns the number for IsGreater
  9774. */
  9775. static get IsGreater(): number;
  9776. /**
  9777. * Returns the number for IsLesser
  9778. */
  9779. static get IsLesser(): number;
  9780. /**
  9781. * Internal only The action manager for the condition
  9782. * @hidden
  9783. */
  9784. _actionManager: ActionManager;
  9785. /**
  9786. * Internal only
  9787. * @hidden
  9788. */
  9789. private _target;
  9790. /**
  9791. * Internal only
  9792. * @hidden
  9793. */
  9794. private _effectiveTarget;
  9795. /**
  9796. * Internal only
  9797. * @hidden
  9798. */
  9799. private _property;
  9800. /**
  9801. * Creates a new ValueCondition
  9802. * @param actionManager manager for the action the condition applies to
  9803. * @param target for the action
  9804. * @param propertyPath path to specify the property of the target the conditional operator uses
  9805. * @param value the value compared by the conditional operator against the current value of the property
  9806. * @param operator the conditional operator, default ValueCondition.IsEqual
  9807. */
  9808. constructor(actionManager: ActionManager, target: any,
  9809. /** path to specify the property of the target the conditional operator uses */
  9810. propertyPath: string,
  9811. /** the value compared by the conditional operator against the current value of the property */
  9812. value: any,
  9813. /** the conditional operator, default ValueCondition.IsEqual */
  9814. operator?: number);
  9815. /**
  9816. * Compares the given value with the property value for the specified conditional operator
  9817. * @returns the result of the comparison
  9818. */
  9819. isValid(): boolean;
  9820. /**
  9821. * Serialize the ValueCondition into a JSON compatible object
  9822. * @returns serialization object
  9823. */
  9824. serialize(): any;
  9825. /**
  9826. * Gets the name of the conditional operator for the ValueCondition
  9827. * @param operator the conditional operator
  9828. * @returns the name
  9829. */
  9830. static GetOperatorName(operator: number): string;
  9831. }
  9832. /**
  9833. * Defines a predicate condition as an extension of Condition
  9834. */
  9835. export class PredicateCondition extends Condition {
  9836. /** defines the predicate function used to validate the condition */
  9837. predicate: () => boolean;
  9838. /**
  9839. * Internal only - manager for action
  9840. * @hidden
  9841. */
  9842. _actionManager: ActionManager;
  9843. /**
  9844. * Creates a new PredicateCondition
  9845. * @param actionManager manager for the action the condition applies to
  9846. * @param predicate defines the predicate function used to validate the condition
  9847. */
  9848. constructor(actionManager: ActionManager,
  9849. /** defines the predicate function used to validate the condition */
  9850. predicate: () => boolean);
  9851. /**
  9852. * @returns the validity of the predicate condition
  9853. */
  9854. isValid(): boolean;
  9855. }
  9856. /**
  9857. * Defines a state condition as an extension of Condition
  9858. */
  9859. export class StateCondition extends Condition {
  9860. /** Value to compare with target state */
  9861. value: string;
  9862. /**
  9863. * Internal only - manager for action
  9864. * @hidden
  9865. */
  9866. _actionManager: ActionManager;
  9867. /**
  9868. * Internal only
  9869. * @hidden
  9870. */
  9871. private _target;
  9872. /**
  9873. * Creates a new StateCondition
  9874. * @param actionManager manager for the action the condition applies to
  9875. * @param target of the condition
  9876. * @param value to compare with target state
  9877. */
  9878. constructor(actionManager: ActionManager, target: any,
  9879. /** Value to compare with target state */
  9880. value: string);
  9881. /**
  9882. * Gets a boolean indicating if the current condition is met
  9883. * @returns the validity of the state
  9884. */
  9885. isValid(): boolean;
  9886. /**
  9887. * Serialize the StateCondition into a JSON compatible object
  9888. * @returns serialization object
  9889. */
  9890. serialize(): any;
  9891. }
  9892. }
  9893. declare module "babylonjs/Actions/directActions" {
  9894. import { Action } from "babylonjs/Actions/action";
  9895. import { Condition } from "babylonjs/Actions/condition";
  9896. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9897. /**
  9898. * This defines an action responsible to toggle a boolean once triggered.
  9899. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9900. */
  9901. export class SwitchBooleanAction extends Action {
  9902. /**
  9903. * The path to the boolean property in the target object
  9904. */
  9905. propertyPath: string;
  9906. private _target;
  9907. private _effectiveTarget;
  9908. private _property;
  9909. /**
  9910. * Instantiate the action
  9911. * @param triggerOptions defines the trigger options
  9912. * @param target defines the object containing the boolean
  9913. * @param propertyPath defines the path to the boolean property in the target object
  9914. * @param condition defines the trigger related conditions
  9915. */
  9916. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9917. /** @hidden */
  9918. _prepare(): void;
  9919. /**
  9920. * Execute the action toggle the boolean value.
  9921. */
  9922. execute(): void;
  9923. /**
  9924. * Serializes the actions and its related information.
  9925. * @param parent defines the object to serialize in
  9926. * @returns the serialized object
  9927. */
  9928. serialize(parent: any): any;
  9929. }
  9930. /**
  9931. * This defines an action responsible to set a the state field of the target
  9932. * to a desired value once triggered.
  9933. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9934. */
  9935. export class SetStateAction extends Action {
  9936. /**
  9937. * The value to store in the state field.
  9938. */
  9939. value: string;
  9940. private _target;
  9941. /**
  9942. * Instantiate the action
  9943. * @param triggerOptions defines the trigger options
  9944. * @param target defines the object containing the state property
  9945. * @param value defines the value to store in the state field
  9946. * @param condition defines the trigger related conditions
  9947. */
  9948. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9949. /**
  9950. * Execute the action and store the value on the target state property.
  9951. */
  9952. execute(): void;
  9953. /**
  9954. * Serializes the actions and its related information.
  9955. * @param parent defines the object to serialize in
  9956. * @returns the serialized object
  9957. */
  9958. serialize(parent: any): any;
  9959. }
  9960. /**
  9961. * This defines an action responsible to set a property of the target
  9962. * to a desired value once triggered.
  9963. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9964. */
  9965. export class SetValueAction extends Action {
  9966. /**
  9967. * The path of the property to set in the target.
  9968. */
  9969. propertyPath: string;
  9970. /**
  9971. * The value to set in the property
  9972. */
  9973. value: any;
  9974. private _target;
  9975. private _effectiveTarget;
  9976. private _property;
  9977. /**
  9978. * Instantiate the action
  9979. * @param triggerOptions defines the trigger options
  9980. * @param target defines the object containing the property
  9981. * @param propertyPath defines the path of the property to set in the target
  9982. * @param value defines the value to set in the property
  9983. * @param condition defines the trigger related conditions
  9984. */
  9985. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9986. /** @hidden */
  9987. _prepare(): void;
  9988. /**
  9989. * Execute the action and set the targetted property to the desired value.
  9990. */
  9991. execute(): void;
  9992. /**
  9993. * Serializes the actions and its related information.
  9994. * @param parent defines the object to serialize in
  9995. * @returns the serialized object
  9996. */
  9997. serialize(parent: any): any;
  9998. }
  9999. /**
  10000. * This defines an action responsible to increment the target value
  10001. * to a desired value once triggered.
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10003. */
  10004. export class IncrementValueAction extends Action {
  10005. /**
  10006. * The path of the property to increment in the target.
  10007. */
  10008. propertyPath: string;
  10009. /**
  10010. * The value we should increment the property by.
  10011. */
  10012. value: any;
  10013. private _target;
  10014. private _effectiveTarget;
  10015. private _property;
  10016. /**
  10017. * Instantiate the action
  10018. * @param triggerOptions defines the trigger options
  10019. * @param target defines the object containing the property
  10020. * @param propertyPath defines the path of the property to increment in the target
  10021. * @param value defines the value value we should increment the property by
  10022. * @param condition defines the trigger related conditions
  10023. */
  10024. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10025. /** @hidden */
  10026. _prepare(): void;
  10027. /**
  10028. * Execute the action and increment the target of the value amount.
  10029. */
  10030. execute(): void;
  10031. /**
  10032. * Serializes the actions and its related information.
  10033. * @param parent defines the object to serialize in
  10034. * @returns the serialized object
  10035. */
  10036. serialize(parent: any): any;
  10037. }
  10038. /**
  10039. * This defines an action responsible to start an animation once triggered.
  10040. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10041. */
  10042. export class PlayAnimationAction extends Action {
  10043. /**
  10044. * Where the animation should start (animation frame)
  10045. */
  10046. from: number;
  10047. /**
  10048. * Where the animation should stop (animation frame)
  10049. */
  10050. to: number;
  10051. /**
  10052. * Define if the animation should loop or stop after the first play.
  10053. */
  10054. loop?: boolean;
  10055. private _target;
  10056. /**
  10057. * Instantiate the action
  10058. * @param triggerOptions defines the trigger options
  10059. * @param target defines the target animation or animation name
  10060. * @param from defines from where the animation should start (animation frame)
  10061. * @param end defines where the animation should stop (animation frame)
  10062. * @param loop defines if the animation should loop or stop after the first play
  10063. * @param condition defines the trigger related conditions
  10064. */
  10065. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10066. /** @hidden */
  10067. _prepare(): void;
  10068. /**
  10069. * Execute the action and play the animation.
  10070. */
  10071. execute(): void;
  10072. /**
  10073. * Serializes the actions and its related information.
  10074. * @param parent defines the object to serialize in
  10075. * @returns the serialized object
  10076. */
  10077. serialize(parent: any): any;
  10078. }
  10079. /**
  10080. * This defines an action responsible to stop an animation once triggered.
  10081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10082. */
  10083. export class StopAnimationAction extends Action {
  10084. private _target;
  10085. /**
  10086. * Instantiate the action
  10087. * @param triggerOptions defines the trigger options
  10088. * @param target defines the target animation or animation name
  10089. * @param condition defines the trigger related conditions
  10090. */
  10091. constructor(triggerOptions: any, target: any, condition?: Condition);
  10092. /** @hidden */
  10093. _prepare(): void;
  10094. /**
  10095. * Execute the action and stop the animation.
  10096. */
  10097. execute(): void;
  10098. /**
  10099. * Serializes the actions and its related information.
  10100. * @param parent defines the object to serialize in
  10101. * @returns the serialized object
  10102. */
  10103. serialize(parent: any): any;
  10104. }
  10105. /**
  10106. * This defines an action responsible that does nothing once triggered.
  10107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10108. */
  10109. export class DoNothingAction extends Action {
  10110. /**
  10111. * Instantiate the action
  10112. * @param triggerOptions defines the trigger options
  10113. * @param condition defines the trigger related conditions
  10114. */
  10115. constructor(triggerOptions?: any, condition?: Condition);
  10116. /**
  10117. * Execute the action and do nothing.
  10118. */
  10119. execute(): void;
  10120. /**
  10121. * Serializes the actions and its related information.
  10122. * @param parent defines the object to serialize in
  10123. * @returns the serialized object
  10124. */
  10125. serialize(parent: any): any;
  10126. }
  10127. /**
  10128. * This defines an action responsible to trigger several actions once triggered.
  10129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10130. */
  10131. export class CombineAction extends Action {
  10132. /**
  10133. * The list of aggregated animations to run.
  10134. */
  10135. children: Action[];
  10136. /**
  10137. * Instantiate the action
  10138. * @param triggerOptions defines the trigger options
  10139. * @param children defines the list of aggregated animations to run
  10140. * @param condition defines the trigger related conditions
  10141. */
  10142. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10143. /** @hidden */
  10144. _prepare(): void;
  10145. /**
  10146. * Execute the action and executes all the aggregated actions.
  10147. */
  10148. execute(evt: ActionEvent): void;
  10149. /**
  10150. * Serializes the actions and its related information.
  10151. * @param parent defines the object to serialize in
  10152. * @returns the serialized object
  10153. */
  10154. serialize(parent: any): any;
  10155. }
  10156. /**
  10157. * This defines an action responsible to run code (external event) once triggered.
  10158. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10159. */
  10160. export class ExecuteCodeAction extends Action {
  10161. /**
  10162. * The callback function to run.
  10163. */
  10164. func: (evt: ActionEvent) => void;
  10165. /**
  10166. * Instantiate the action
  10167. * @param triggerOptions defines the trigger options
  10168. * @param func defines the callback function to run
  10169. * @param condition defines the trigger related conditions
  10170. */
  10171. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10172. /**
  10173. * Execute the action and run the attached code.
  10174. */
  10175. execute(evt: ActionEvent): void;
  10176. }
  10177. /**
  10178. * This defines an action responsible to set the parent property of the target once triggered.
  10179. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10180. */
  10181. export class SetParentAction extends Action {
  10182. private _parent;
  10183. private _target;
  10184. /**
  10185. * Instantiate the action
  10186. * @param triggerOptions defines the trigger options
  10187. * @param target defines the target containing the parent property
  10188. * @param parent defines from where the animation should start (animation frame)
  10189. * @param condition defines the trigger related conditions
  10190. */
  10191. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10192. /** @hidden */
  10193. _prepare(): void;
  10194. /**
  10195. * Execute the action and set the parent property.
  10196. */
  10197. execute(): void;
  10198. /**
  10199. * Serializes the actions and its related information.
  10200. * @param parent defines the object to serialize in
  10201. * @returns the serialized object
  10202. */
  10203. serialize(parent: any): any;
  10204. }
  10205. }
  10206. declare module "babylonjs/Actions/actionManager" {
  10207. import { Nullable } from "babylonjs/types";
  10208. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10209. import { Scene } from "babylonjs/scene";
  10210. import { IAction } from "babylonjs/Actions/action";
  10211. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10212. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10213. /**
  10214. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10215. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10217. */
  10218. export class ActionManager extends AbstractActionManager {
  10219. /**
  10220. * Nothing
  10221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10222. */
  10223. static readonly NothingTrigger: number;
  10224. /**
  10225. * On pick
  10226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10227. */
  10228. static readonly OnPickTrigger: number;
  10229. /**
  10230. * On left pick
  10231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10232. */
  10233. static readonly OnLeftPickTrigger: number;
  10234. /**
  10235. * On right pick
  10236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10237. */
  10238. static readonly OnRightPickTrigger: number;
  10239. /**
  10240. * On center pick
  10241. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10242. */
  10243. static readonly OnCenterPickTrigger: number;
  10244. /**
  10245. * On pick down
  10246. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10247. */
  10248. static readonly OnPickDownTrigger: number;
  10249. /**
  10250. * On double pick
  10251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10252. */
  10253. static readonly OnDoublePickTrigger: number;
  10254. /**
  10255. * On pick up
  10256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10257. */
  10258. static readonly OnPickUpTrigger: number;
  10259. /**
  10260. * On pick out.
  10261. * This trigger will only be raised if you also declared a OnPickDown
  10262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10263. */
  10264. static readonly OnPickOutTrigger: number;
  10265. /**
  10266. * On long press
  10267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10268. */
  10269. static readonly OnLongPressTrigger: number;
  10270. /**
  10271. * On pointer over
  10272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10273. */
  10274. static readonly OnPointerOverTrigger: number;
  10275. /**
  10276. * On pointer out
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10278. */
  10279. static readonly OnPointerOutTrigger: number;
  10280. /**
  10281. * On every frame
  10282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10283. */
  10284. static readonly OnEveryFrameTrigger: number;
  10285. /**
  10286. * On intersection enter
  10287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10288. */
  10289. static readonly OnIntersectionEnterTrigger: number;
  10290. /**
  10291. * On intersection exit
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10293. */
  10294. static readonly OnIntersectionExitTrigger: number;
  10295. /**
  10296. * On key down
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly OnKeyDownTrigger: number;
  10300. /**
  10301. * On key up
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnKeyUpTrigger: number;
  10305. private _scene;
  10306. /**
  10307. * Creates a new action manager
  10308. * @param scene defines the hosting scene
  10309. */
  10310. constructor(scene: Scene);
  10311. /**
  10312. * Releases all associated resources
  10313. */
  10314. dispose(): void;
  10315. /**
  10316. * Gets hosting scene
  10317. * @returns the hosting scene
  10318. */
  10319. getScene(): Scene;
  10320. /**
  10321. * Does this action manager handles actions of any of the given triggers
  10322. * @param triggers defines the triggers to be tested
  10323. * @return a boolean indicating whether one (or more) of the triggers is handled
  10324. */
  10325. hasSpecificTriggers(triggers: number[]): boolean;
  10326. /**
  10327. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10328. * speed.
  10329. * @param triggerA defines the trigger to be tested
  10330. * @param triggerB defines the trigger to be tested
  10331. * @return a boolean indicating whether one (or more) of the triggers is handled
  10332. */
  10333. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10334. /**
  10335. * Does this action manager handles actions of a given trigger
  10336. * @param trigger defines the trigger to be tested
  10337. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10338. * @return whether the trigger is handled
  10339. */
  10340. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10341. /**
  10342. * Does this action manager has pointer triggers
  10343. */
  10344. get hasPointerTriggers(): boolean;
  10345. /**
  10346. * Does this action manager has pick triggers
  10347. */
  10348. get hasPickTriggers(): boolean;
  10349. /**
  10350. * Registers an action to this action manager
  10351. * @param action defines the action to be registered
  10352. * @return the action amended (prepared) after registration
  10353. */
  10354. registerAction(action: IAction): Nullable<IAction>;
  10355. /**
  10356. * Unregisters an action to this action manager
  10357. * @param action defines the action to be unregistered
  10358. * @return a boolean indicating whether the action has been unregistered
  10359. */
  10360. unregisterAction(action: IAction): Boolean;
  10361. /**
  10362. * Process a specific trigger
  10363. * @param trigger defines the trigger to process
  10364. * @param evt defines the event details to be processed
  10365. */
  10366. processTrigger(trigger: number, evt?: IActionEvent): void;
  10367. /** @hidden */
  10368. _getEffectiveTarget(target: any, propertyPath: string): any;
  10369. /** @hidden */
  10370. _getProperty(propertyPath: string): string;
  10371. /**
  10372. * Serialize this manager to a JSON object
  10373. * @param name defines the property name to store this manager
  10374. * @returns a JSON representation of this manager
  10375. */
  10376. serialize(name: string): any;
  10377. /**
  10378. * Creates a new ActionManager from a JSON data
  10379. * @param parsedActions defines the JSON data to read from
  10380. * @param object defines the hosting mesh
  10381. * @param scene defines the hosting scene
  10382. */
  10383. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10384. /**
  10385. * Get a trigger name by index
  10386. * @param trigger defines the trigger index
  10387. * @returns a trigger name
  10388. */
  10389. static GetTriggerName(trigger: number): string;
  10390. }
  10391. }
  10392. declare module "babylonjs/Culling/ray" {
  10393. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10394. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10395. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10397. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10398. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10399. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10400. import { Plane } from "babylonjs/Maths/math.plane";
  10401. /**
  10402. * Class representing a ray with position and direction
  10403. */
  10404. export class Ray {
  10405. /** origin point */
  10406. origin: Vector3;
  10407. /** direction */
  10408. direction: Vector3;
  10409. /** length of the ray */
  10410. length: number;
  10411. private static readonly _TmpVector3;
  10412. private _tmpRay;
  10413. /**
  10414. * Creates a new ray
  10415. * @param origin origin point
  10416. * @param direction direction
  10417. * @param length length of the ray
  10418. */
  10419. constructor(
  10420. /** origin point */
  10421. origin: Vector3,
  10422. /** direction */
  10423. direction: Vector3,
  10424. /** length of the ray */
  10425. length?: number);
  10426. /**
  10427. * Checks if the ray intersects a box
  10428. * This does not account for the ray lenght by design to improve perfs.
  10429. * @param minimum bound of the box
  10430. * @param maximum bound of the box
  10431. * @param intersectionTreshold extra extend to be added to the box in all direction
  10432. * @returns if the box was hit
  10433. */
  10434. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10435. /**
  10436. * Checks if the ray intersects a box
  10437. * This does not account for the ray lenght by design to improve perfs.
  10438. * @param box the bounding box to check
  10439. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10440. * @returns if the box was hit
  10441. */
  10442. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10443. /**
  10444. * If the ray hits a sphere
  10445. * @param sphere the bounding sphere to check
  10446. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10447. * @returns true if it hits the sphere
  10448. */
  10449. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10450. /**
  10451. * If the ray hits a triange
  10452. * @param vertex0 triangle vertex
  10453. * @param vertex1 triangle vertex
  10454. * @param vertex2 triangle vertex
  10455. * @returns intersection information if hit
  10456. */
  10457. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10458. /**
  10459. * Checks if ray intersects a plane
  10460. * @param plane the plane to check
  10461. * @returns the distance away it was hit
  10462. */
  10463. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10464. /**
  10465. * Calculate the intercept of a ray on a given axis
  10466. * @param axis to check 'x' | 'y' | 'z'
  10467. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10468. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10469. */
  10470. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10471. /**
  10472. * Checks if ray intersects a mesh
  10473. * @param mesh the mesh to check
  10474. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10475. * @returns picking info of the intersecton
  10476. */
  10477. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10478. /**
  10479. * Checks if ray intersects a mesh
  10480. * @param meshes the meshes to check
  10481. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10482. * @param results array to store result in
  10483. * @returns Array of picking infos
  10484. */
  10485. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10486. private _comparePickingInfo;
  10487. private static smallnum;
  10488. private static rayl;
  10489. /**
  10490. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10491. * @param sega the first point of the segment to test the intersection against
  10492. * @param segb the second point of the segment to test the intersection against
  10493. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10494. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10495. */
  10496. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10497. /**
  10498. * Update the ray from viewport position
  10499. * @param x position
  10500. * @param y y position
  10501. * @param viewportWidth viewport width
  10502. * @param viewportHeight viewport height
  10503. * @param world world matrix
  10504. * @param view view matrix
  10505. * @param projection projection matrix
  10506. * @returns this ray updated
  10507. */
  10508. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10509. /**
  10510. * Creates a ray with origin and direction of 0,0,0
  10511. * @returns the new ray
  10512. */
  10513. static Zero(): Ray;
  10514. /**
  10515. * Creates a new ray from screen space and viewport
  10516. * @param x position
  10517. * @param y y position
  10518. * @param viewportWidth viewport width
  10519. * @param viewportHeight viewport height
  10520. * @param world world matrix
  10521. * @param view view matrix
  10522. * @param projection projection matrix
  10523. * @returns new ray
  10524. */
  10525. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10526. /**
  10527. * 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
  10528. * transformed to the given world matrix.
  10529. * @param origin The origin point
  10530. * @param end The end point
  10531. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10532. * @returns the new ray
  10533. */
  10534. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10535. /**
  10536. * Transforms a ray by a matrix
  10537. * @param ray ray to transform
  10538. * @param matrix matrix to apply
  10539. * @returns the resulting new ray
  10540. */
  10541. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10542. /**
  10543. * Transforms a ray by a matrix
  10544. * @param ray ray to transform
  10545. * @param matrix matrix to apply
  10546. * @param result ray to store result in
  10547. */
  10548. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10549. /**
  10550. * Unproject a ray from screen space to object space
  10551. * @param sourceX defines the screen space x coordinate to use
  10552. * @param sourceY defines the screen space y coordinate to use
  10553. * @param viewportWidth defines the current width of the viewport
  10554. * @param viewportHeight defines the current height of the viewport
  10555. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10556. * @param view defines the view matrix to use
  10557. * @param projection defines the projection matrix to use
  10558. */
  10559. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10560. }
  10561. /**
  10562. * Type used to define predicate used to select faces when a mesh intersection is detected
  10563. */
  10564. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10565. module "babylonjs/scene" {
  10566. interface Scene {
  10567. /** @hidden */
  10568. _tempPickingRay: Nullable<Ray>;
  10569. /** @hidden */
  10570. _cachedRayForTransform: Ray;
  10571. /** @hidden */
  10572. _pickWithRayInverseMatrix: Matrix;
  10573. /** @hidden */
  10574. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10575. /** @hidden */
  10576. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10577. /** @hidden */
  10578. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  10579. }
  10580. }
  10581. }
  10582. declare module "babylonjs/sceneComponent" {
  10583. import { Scene } from "babylonjs/scene";
  10584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10586. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10587. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10588. import { Nullable } from "babylonjs/types";
  10589. import { Camera } from "babylonjs/Cameras/camera";
  10590. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10591. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10592. import { AbstractScene } from "babylonjs/abstractScene";
  10593. import { Mesh } from "babylonjs/Meshes/mesh";
  10594. import { Effect } from "babylonjs/Materials/effect";
  10595. /**
  10596. * Groups all the scene component constants in one place to ease maintenance.
  10597. * @hidden
  10598. */
  10599. export class SceneComponentConstants {
  10600. static readonly NAME_EFFECTLAYER: string;
  10601. static readonly NAME_LAYER: string;
  10602. static readonly NAME_LENSFLARESYSTEM: string;
  10603. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10604. static readonly NAME_PARTICLESYSTEM: string;
  10605. static readonly NAME_GAMEPAD: string;
  10606. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10607. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10608. static readonly NAME_PREPASSRENDERER: string;
  10609. static readonly NAME_DEPTHRENDERER: string;
  10610. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10611. static readonly NAME_SPRITE: string;
  10612. static readonly NAME_SUBSURFACE: string;
  10613. static readonly NAME_OUTLINERENDERER: string;
  10614. static readonly NAME_PROCEDURALTEXTURE: string;
  10615. static readonly NAME_SHADOWGENERATOR: string;
  10616. static readonly NAME_OCTREE: string;
  10617. static readonly NAME_PHYSICSENGINE: string;
  10618. static readonly NAME_AUDIO: string;
  10619. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10620. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10622. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10623. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10624. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10625. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10626. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10627. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10628. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  10629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10630. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  10631. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10632. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10633. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10634. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10635. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10636. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10637. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10638. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10639. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10640. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10641. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10643. static readonly STEP_AFTERRENDER_AUDIO: number;
  10644. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10645. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10646. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10648. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10649. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10650. static readonly STEP_POINTERMOVE_SPRITE: number;
  10651. static readonly STEP_POINTERDOWN_SPRITE: number;
  10652. static readonly STEP_POINTERUP_SPRITE: number;
  10653. }
  10654. /**
  10655. * This represents a scene component.
  10656. *
  10657. * This is used to decouple the dependency the scene is having on the different workloads like
  10658. * layers, post processes...
  10659. */
  10660. export interface ISceneComponent {
  10661. /**
  10662. * The name of the component. Each component must have a unique name.
  10663. */
  10664. name: string;
  10665. /**
  10666. * The scene the component belongs to.
  10667. */
  10668. scene: Scene;
  10669. /**
  10670. * Register the component to one instance of a scene.
  10671. */
  10672. register(): void;
  10673. /**
  10674. * Rebuilds the elements related to this component in case of
  10675. * context lost for instance.
  10676. */
  10677. rebuild(): void;
  10678. /**
  10679. * Disposes the component and the associated ressources.
  10680. */
  10681. dispose(): void;
  10682. }
  10683. /**
  10684. * This represents a SERIALIZABLE scene component.
  10685. *
  10686. * This extends Scene Component to add Serialization methods on top.
  10687. */
  10688. export interface ISceneSerializableComponent extends ISceneComponent {
  10689. /**
  10690. * Adds all the elements from the container to the scene
  10691. * @param container the container holding the elements
  10692. */
  10693. addFromContainer(container: AbstractScene): void;
  10694. /**
  10695. * Removes all the elements in the container from the scene
  10696. * @param container contains the elements to remove
  10697. * @param dispose if the removed element should be disposed (default: false)
  10698. */
  10699. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10700. /**
  10701. * Serializes the component data to the specified json object
  10702. * @param serializationObject The object to serialize to
  10703. */
  10704. serialize(serializationObject: any): void;
  10705. }
  10706. /**
  10707. * Strong typing of a Mesh related stage step action
  10708. */
  10709. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10710. /**
  10711. * Strong typing of a Evaluate Sub Mesh related stage step action
  10712. */
  10713. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10714. /**
  10715. * Strong typing of a pre active Mesh related stage step action
  10716. */
  10717. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  10718. /**
  10719. * Strong typing of a Camera related stage step action
  10720. */
  10721. export type CameraStageAction = (camera: Camera) => void;
  10722. /**
  10723. * Strong typing of a Camera Frame buffer related stage step action
  10724. */
  10725. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10726. /**
  10727. * Strong typing of a Render Target related stage step action
  10728. */
  10729. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10730. /**
  10731. * Strong typing of a RenderingGroup related stage step action
  10732. */
  10733. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10734. /**
  10735. * Strong typing of a Mesh Render related stage step action
  10736. */
  10737. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  10738. /**
  10739. * Strong typing of a simple stage step action
  10740. */
  10741. export type SimpleStageAction = () => void;
  10742. /**
  10743. * Strong typing of a render target action.
  10744. */
  10745. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10746. /**
  10747. * Strong typing of a pointer move action.
  10748. */
  10749. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10750. /**
  10751. * Strong typing of a pointer up/down action.
  10752. */
  10753. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10754. /**
  10755. * Representation of a stage in the scene (Basically a list of ordered steps)
  10756. * @hidden
  10757. */
  10758. export class Stage<T extends Function> extends Array<{
  10759. index: number;
  10760. component: ISceneComponent;
  10761. action: T;
  10762. }> {
  10763. /**
  10764. * Hide ctor from the rest of the world.
  10765. * @param items The items to add.
  10766. */
  10767. private constructor();
  10768. /**
  10769. * Creates a new Stage.
  10770. * @returns A new instance of a Stage
  10771. */
  10772. static Create<T extends Function>(): Stage<T>;
  10773. /**
  10774. * Registers a step in an ordered way in the targeted stage.
  10775. * @param index Defines the position to register the step in
  10776. * @param component Defines the component attached to the step
  10777. * @param action Defines the action to launch during the step
  10778. */
  10779. registerStep(index: number, component: ISceneComponent, action: T): void;
  10780. /**
  10781. * Clears all the steps from the stage.
  10782. */
  10783. clear(): void;
  10784. }
  10785. }
  10786. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10787. import { Nullable } from "babylonjs/types";
  10788. import { Observable } from "babylonjs/Misc/observable";
  10789. import { Scene } from "babylonjs/scene";
  10790. import { Sprite } from "babylonjs/Sprites/sprite";
  10791. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10792. import { Ray } from "babylonjs/Culling/ray";
  10793. import { Camera } from "babylonjs/Cameras/camera";
  10794. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10795. import { ISceneComponent } from "babylonjs/sceneComponent";
  10796. module "babylonjs/scene" {
  10797. interface Scene {
  10798. /** @hidden */
  10799. _pointerOverSprite: Nullable<Sprite>;
  10800. /** @hidden */
  10801. _pickedDownSprite: Nullable<Sprite>;
  10802. /** @hidden */
  10803. _tempSpritePickingRay: Nullable<Ray>;
  10804. /**
  10805. * All of the sprite managers added to this scene
  10806. * @see https://doc.babylonjs.com/babylon101/sprites
  10807. */
  10808. spriteManagers: Array<ISpriteManager>;
  10809. /**
  10810. * An event triggered when sprites rendering is about to start
  10811. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10812. */
  10813. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10814. /**
  10815. * An event triggered when sprites rendering is done
  10816. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10817. */
  10818. onAfterSpritesRenderingObservable: Observable<Scene>;
  10819. /** @hidden */
  10820. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10821. /** Launch a ray to try to pick a sprite in the scene
  10822. * @param x position on screen
  10823. * @param y position on screen
  10824. * @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
  10825. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10826. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10827. * @returns a PickingInfo
  10828. */
  10829. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10830. /** Use the given ray to pick a sprite in the scene
  10831. * @param ray The ray (in world space) to use to pick meshes
  10832. * @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
  10833. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10834. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10835. * @returns a PickingInfo
  10836. */
  10837. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10838. /** @hidden */
  10839. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10840. /** Launch a ray to try to pick sprites in the scene
  10841. * @param x position on screen
  10842. * @param y position on screen
  10843. * @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
  10844. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /** Use the given ray to pick sprites in the scene
  10849. * @param ray The ray (in world space) to use to pick meshes
  10850. * @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
  10851. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10852. * @returns a PickingInfo array
  10853. */
  10854. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10855. /**
  10856. * Force the sprite under the pointer
  10857. * @param sprite defines the sprite to use
  10858. */
  10859. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10860. /**
  10861. * Gets the sprite under the pointer
  10862. * @returns a Sprite or null if no sprite is under the pointer
  10863. */
  10864. getPointerOverSprite(): Nullable<Sprite>;
  10865. }
  10866. }
  10867. /**
  10868. * Defines the sprite scene component responsible to manage sprites
  10869. * in a given scene.
  10870. */
  10871. export class SpriteSceneComponent implements ISceneComponent {
  10872. /**
  10873. * The component name helpfull to identify the component in the list of scene components.
  10874. */
  10875. readonly name: string;
  10876. /**
  10877. * The scene the component belongs to.
  10878. */
  10879. scene: Scene;
  10880. /** @hidden */
  10881. private _spritePredicate;
  10882. /**
  10883. * Creates a new instance of the component for the given scene
  10884. * @param scene Defines the scene to register the component in
  10885. */
  10886. constructor(scene: Scene);
  10887. /**
  10888. * Registers the component in a given scene
  10889. */
  10890. register(): void;
  10891. /**
  10892. * Rebuilds the elements related to this component in case of
  10893. * context lost for instance.
  10894. */
  10895. rebuild(): void;
  10896. /**
  10897. * Disposes the component and the associated ressources.
  10898. */
  10899. dispose(): void;
  10900. private _pickSpriteButKeepRay;
  10901. private _pointerMove;
  10902. private _pointerDown;
  10903. private _pointerUp;
  10904. }
  10905. }
  10906. declare module "babylonjs/Misc/timingTools" {
  10907. /**
  10908. * Class used to provide helper for timing
  10909. */
  10910. export class TimingTools {
  10911. /**
  10912. * Polyfill for setImmediate
  10913. * @param action defines the action to execute after the current execution block
  10914. */
  10915. static SetImmediate(action: () => void): void;
  10916. }
  10917. }
  10918. declare module "babylonjs/Misc/instantiationTools" {
  10919. /**
  10920. * Class used to enable instatition of objects by class name
  10921. */
  10922. export class InstantiationTools {
  10923. /**
  10924. * Use this object to register external classes like custom textures or material
  10925. * to allow the laoders to instantiate them
  10926. */
  10927. static RegisteredExternalClasses: {
  10928. [key: string]: Object;
  10929. };
  10930. /**
  10931. * Tries to instantiate a new object from a given class name
  10932. * @param className defines the class name to instantiate
  10933. * @returns the new object or null if the system was not able to do the instantiation
  10934. */
  10935. static Instantiate(className: string): any;
  10936. }
  10937. }
  10938. declare module "babylonjs/Misc/copyTools" {
  10939. import { Nullable } from "babylonjs/types";
  10940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10941. /**
  10942. * Class used to host copy specific utilities
  10943. */
  10944. export class CopyTools {
  10945. /**
  10946. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  10947. * @param texture defines the texture to read pixels from
  10948. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  10949. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  10950. * @returns The base64 encoded string or null
  10951. */
  10952. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  10953. }
  10954. }
  10955. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  10956. /**
  10957. * Define options used to create a depth texture
  10958. */
  10959. export class DepthTextureCreationOptions {
  10960. /** Specifies whether or not a stencil should be allocated in the texture */
  10961. generateStencil?: boolean;
  10962. /** Specifies whether or not bilinear filtering is enable on the texture */
  10963. bilinearFiltering?: boolean;
  10964. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  10965. comparisonFunction?: number;
  10966. /** Specifies if the created texture is a cube texture */
  10967. isCube?: boolean;
  10968. }
  10969. }
  10970. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  10971. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10972. import { Nullable } from "babylonjs/types";
  10973. import { Scene } from "babylonjs/scene";
  10974. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  10975. module "babylonjs/Engines/thinEngine" {
  10976. interface ThinEngine {
  10977. /**
  10978. * Creates a depth stencil cube texture.
  10979. * This is only available in WebGL 2.
  10980. * @param size The size of face edge in the cube texture.
  10981. * @param options The options defining the cube texture.
  10982. * @returns The cube texture
  10983. */
  10984. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  10985. /**
  10986. * Creates a cube texture
  10987. * @param rootUrl defines the url where the files to load is located
  10988. * @param scene defines the current scene
  10989. * @param files defines the list of files to load (1 per face)
  10990. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  10991. * @param onLoad defines an optional callback raised when the texture is loaded
  10992. * @param onError defines an optional callback raised if there is an issue to load the texture
  10993. * @param format defines the format of the data
  10994. * @param forcedExtension defines the extension to use to pick the right loader
  10995. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  10996. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  10997. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  10998. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  10999. * @param loaderOptions options to be passed to the loader
  11000. * @returns the cube texture as an InternalTexture
  11001. */
  11002. 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>, loaderOptions: any): InternalTexture;
  11003. /**
  11004. * Creates a cube texture
  11005. * @param rootUrl defines the url where the files to load is located
  11006. * @param scene defines the current scene
  11007. * @param files defines the list of files to load (1 per face)
  11008. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11009. * @param onLoad defines an optional callback raised when the texture is loaded
  11010. * @param onError defines an optional callback raised if there is an issue to load the texture
  11011. * @param format defines the format of the data
  11012. * @param forcedExtension defines the extension to use to pick the right loader
  11013. * @returns the cube texture as an InternalTexture
  11014. */
  11015. 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;
  11016. /**
  11017. * Creates a cube texture
  11018. * @param rootUrl defines the url where the files to load is located
  11019. * @param scene defines the current scene
  11020. * @param files defines the list of files to load (1 per face)
  11021. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11022. * @param onLoad defines an optional callback raised when the texture is loaded
  11023. * @param onError defines an optional callback raised if there is an issue to load the texture
  11024. * @param format defines the format of the data
  11025. * @param forcedExtension defines the extension to use to pick the right loader
  11026. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11027. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11028. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11029. * @returns the cube texture as an InternalTexture
  11030. */
  11031. 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;
  11032. /** @hidden */
  11033. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11034. /** @hidden */
  11035. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11036. /** @hidden */
  11037. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11038. /** @hidden */
  11039. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11040. /**
  11041. * @hidden
  11042. */
  11043. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11044. }
  11045. }
  11046. }
  11047. declare module "babylonjs/Materials/Textures/cubeTexture" {
  11048. import { Nullable } from "babylonjs/types";
  11049. import { Scene } from "babylonjs/scene";
  11050. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11051. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11052. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11053. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  11054. import { Observable } from "babylonjs/Misc/observable";
  11055. /**
  11056. * Class for creating a cube texture
  11057. */
  11058. export class CubeTexture extends BaseTexture {
  11059. private _delayedOnLoad;
  11060. /**
  11061. * Observable triggered once the texture has been loaded.
  11062. */
  11063. onLoadObservable: Observable<CubeTexture>;
  11064. /**
  11065. * The url of the texture
  11066. */
  11067. url: string;
  11068. /**
  11069. * Gets or sets the center of the bounding box associated with the cube texture.
  11070. * It must define where the camera used to render the texture was set
  11071. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11072. */
  11073. boundingBoxPosition: Vector3;
  11074. private _boundingBoxSize;
  11075. /**
  11076. * Gets or sets the size of the bounding box associated with the cube texture
  11077. * When defined, the cubemap will switch to local mode
  11078. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11079. * @example https://www.babylonjs-playground.com/#RNASML
  11080. */
  11081. set boundingBoxSize(value: Vector3);
  11082. /**
  11083. * Returns the bounding box size
  11084. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11085. */
  11086. get boundingBoxSize(): Vector3;
  11087. protected _rotationY: number;
  11088. /**
  11089. * Sets texture matrix rotation angle around Y axis in radians.
  11090. */
  11091. set rotationY(value: number);
  11092. /**
  11093. * Gets texture matrix rotation angle around Y axis radians.
  11094. */
  11095. get rotationY(): number;
  11096. /**
  11097. * Are mip maps generated for this texture or not.
  11098. */
  11099. get noMipmap(): boolean;
  11100. private _noMipmap;
  11101. private _files;
  11102. protected _forcedExtension: Nullable<string>;
  11103. private _extensions;
  11104. private _textureMatrix;
  11105. private _format;
  11106. private _createPolynomials;
  11107. private _loaderOptions;
  11108. /**
  11109. * Creates a cube texture from an array of image urls
  11110. * @param files defines an array of image urls
  11111. * @param scene defines the hosting scene
  11112. * @param noMipmap specifies if mip maps are not used
  11113. * @returns a cube texture
  11114. */
  11115. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11116. /**
  11117. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11118. * @param url defines the url of the prefiltered texture
  11119. * @param scene defines the scene the texture is attached to
  11120. * @param forcedExtension defines the extension of the file if different from the url
  11121. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11122. * @return the prefiltered texture
  11123. */
  11124. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11125. /**
  11126. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11127. * as prefiltered data.
  11128. * @param rootUrl defines the url of the texture or the root name of the six images
  11129. * @param null defines the scene or engine the texture is attached to
  11130. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11131. * @param noMipmap defines if mipmaps should be created or not
  11132. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11133. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11134. * @param onError defines a callback triggered in case of error during load
  11135. * @param format defines the internal format to use for the texture once loaded
  11136. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11137. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11138. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11139. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11140. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11141. * @param loaderOptions options to be passed to the loader
  11142. * @return the cube texture
  11143. */
  11144. 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, loaderOptions?: any);
  11145. /**
  11146. * Get the current class name of the texture useful for serialization or dynamic coding.
  11147. * @returns "CubeTexture"
  11148. */
  11149. getClassName(): string;
  11150. /**
  11151. * Update the url (and optional buffer) of this texture if url was null during construction.
  11152. * @param url the url of the texture
  11153. * @param forcedExtension defines the extension to use
  11154. * @param onLoad callback called when the texture is loaded (defaults to null)
  11155. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11156. */
  11157. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11158. /**
  11159. * Delays loading of the cube texture
  11160. * @param forcedExtension defines the extension to use
  11161. */
  11162. delayLoad(forcedExtension?: string): void;
  11163. /**
  11164. * Returns the reflection texture matrix
  11165. * @returns the reflection texture matrix
  11166. */
  11167. getReflectionTextureMatrix(): Matrix;
  11168. /**
  11169. * Sets the reflection texture matrix
  11170. * @param value Reflection texture matrix
  11171. */
  11172. setReflectionTextureMatrix(value: Matrix): void;
  11173. /**
  11174. * Parses text to create a cube texture
  11175. * @param parsedTexture define the serialized text to read from
  11176. * @param scene defines the hosting scene
  11177. * @param rootUrl defines the root url of the cube texture
  11178. * @returns a cube texture
  11179. */
  11180. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11181. /**
  11182. * Makes a clone, or deep copy, of the cube texture
  11183. * @returns a new cube texture
  11184. */
  11185. clone(): CubeTexture;
  11186. }
  11187. }
  11188. declare module "babylonjs/Materials/colorCurves" {
  11189. import { Effect } from "babylonjs/Materials/effect";
  11190. /**
  11191. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11192. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11193. * 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;
  11194. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11195. */
  11196. export class ColorCurves {
  11197. private _dirty;
  11198. private _tempColor;
  11199. private _globalCurve;
  11200. private _highlightsCurve;
  11201. private _midtonesCurve;
  11202. private _shadowsCurve;
  11203. private _positiveCurve;
  11204. private _negativeCurve;
  11205. private _globalHue;
  11206. private _globalDensity;
  11207. private _globalSaturation;
  11208. private _globalExposure;
  11209. /**
  11210. * Gets the global Hue value.
  11211. * 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).
  11212. */
  11213. get globalHue(): number;
  11214. /**
  11215. * Sets the global Hue value.
  11216. * 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).
  11217. */
  11218. set globalHue(value: number);
  11219. /**
  11220. * Gets the global Density value.
  11221. * 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.
  11222. * Values less than zero provide a filter of opposite hue.
  11223. */
  11224. get globalDensity(): number;
  11225. /**
  11226. * Sets the global Density value.
  11227. * 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.
  11228. * Values less than zero provide a filter of opposite hue.
  11229. */
  11230. set globalDensity(value: number);
  11231. /**
  11232. * Gets the global Saturation value.
  11233. * 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.
  11234. */
  11235. get globalSaturation(): number;
  11236. /**
  11237. * Sets the global Saturation value.
  11238. * 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.
  11239. */
  11240. set globalSaturation(value: number);
  11241. /**
  11242. * Gets the global Exposure value.
  11243. * 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.
  11244. */
  11245. get globalExposure(): number;
  11246. /**
  11247. * Sets the global Exposure value.
  11248. * 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.
  11249. */
  11250. set globalExposure(value: number);
  11251. private _highlightsHue;
  11252. private _highlightsDensity;
  11253. private _highlightsSaturation;
  11254. private _highlightsExposure;
  11255. /**
  11256. * Gets the highlights Hue value.
  11257. * 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).
  11258. */
  11259. get highlightsHue(): number;
  11260. /**
  11261. * Sets the highlights Hue value.
  11262. * 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).
  11263. */
  11264. set highlightsHue(value: number);
  11265. /**
  11266. * Gets the highlights Density value.
  11267. * 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.
  11268. * Values less than zero provide a filter of opposite hue.
  11269. */
  11270. get highlightsDensity(): number;
  11271. /**
  11272. * Sets the highlights Density value.
  11273. * 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.
  11274. * Values less than zero provide a filter of opposite hue.
  11275. */
  11276. set highlightsDensity(value: number);
  11277. /**
  11278. * Gets the highlights Saturation value.
  11279. * 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.
  11280. */
  11281. get highlightsSaturation(): number;
  11282. /**
  11283. * Sets the highlights Saturation value.
  11284. * 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.
  11285. */
  11286. set highlightsSaturation(value: number);
  11287. /**
  11288. * Gets the highlights Exposure value.
  11289. * 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.
  11290. */
  11291. get highlightsExposure(): number;
  11292. /**
  11293. * Sets the highlights Exposure value.
  11294. * 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.
  11295. */
  11296. set highlightsExposure(value: number);
  11297. private _midtonesHue;
  11298. private _midtonesDensity;
  11299. private _midtonesSaturation;
  11300. private _midtonesExposure;
  11301. /**
  11302. * Gets the midtones Hue value.
  11303. * 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).
  11304. */
  11305. get midtonesHue(): number;
  11306. /**
  11307. * Sets the midtones Hue value.
  11308. * 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).
  11309. */
  11310. set midtonesHue(value: number);
  11311. /**
  11312. * Gets the midtones Density value.
  11313. * 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.
  11314. * Values less than zero provide a filter of opposite hue.
  11315. */
  11316. get midtonesDensity(): number;
  11317. /**
  11318. * Sets the midtones Density value.
  11319. * 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.
  11320. * Values less than zero provide a filter of opposite hue.
  11321. */
  11322. set midtonesDensity(value: number);
  11323. /**
  11324. * Gets the midtones Saturation value.
  11325. * 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.
  11326. */
  11327. get midtonesSaturation(): number;
  11328. /**
  11329. * Sets the midtones Saturation value.
  11330. * 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.
  11331. */
  11332. set midtonesSaturation(value: number);
  11333. /**
  11334. * Gets the midtones Exposure value.
  11335. * 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.
  11336. */
  11337. get midtonesExposure(): number;
  11338. /**
  11339. * Sets the midtones Exposure value.
  11340. * 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.
  11341. */
  11342. set midtonesExposure(value: number);
  11343. private _shadowsHue;
  11344. private _shadowsDensity;
  11345. private _shadowsSaturation;
  11346. private _shadowsExposure;
  11347. /**
  11348. * Gets the shadows Hue value.
  11349. * 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).
  11350. */
  11351. get shadowsHue(): number;
  11352. /**
  11353. * Sets the shadows Hue value.
  11354. * 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).
  11355. */
  11356. set shadowsHue(value: number);
  11357. /**
  11358. * Gets the shadows Density value.
  11359. * 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.
  11360. * Values less than zero provide a filter of opposite hue.
  11361. */
  11362. get shadowsDensity(): number;
  11363. /**
  11364. * Sets the shadows Density value.
  11365. * 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.
  11366. * Values less than zero provide a filter of opposite hue.
  11367. */
  11368. set shadowsDensity(value: number);
  11369. /**
  11370. * Gets the shadows Saturation value.
  11371. * 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.
  11372. */
  11373. get shadowsSaturation(): number;
  11374. /**
  11375. * Sets the shadows Saturation value.
  11376. * 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.
  11377. */
  11378. set shadowsSaturation(value: number);
  11379. /**
  11380. * Gets the shadows Exposure value.
  11381. * 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.
  11382. */
  11383. get shadowsExposure(): number;
  11384. /**
  11385. * Sets the shadows Exposure value.
  11386. * 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.
  11387. */
  11388. set shadowsExposure(value: number);
  11389. /**
  11390. * Returns the class name
  11391. * @returns The class name
  11392. */
  11393. getClassName(): string;
  11394. /**
  11395. * Binds the color curves to the shader.
  11396. * @param colorCurves The color curve to bind
  11397. * @param effect The effect to bind to
  11398. * @param positiveUniform The positive uniform shader parameter
  11399. * @param neutralUniform The neutral uniform shader parameter
  11400. * @param negativeUniform The negative uniform shader parameter
  11401. */
  11402. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11403. /**
  11404. * Prepare the list of uniforms associated with the ColorCurves effects.
  11405. * @param uniformsList The list of uniforms used in the effect
  11406. */
  11407. static PrepareUniforms(uniformsList: string[]): void;
  11408. /**
  11409. * Returns color grading data based on a hue, density, saturation and exposure value.
  11410. * @param filterHue The hue of the color filter.
  11411. * @param filterDensity The density of the color filter.
  11412. * @param saturation The saturation.
  11413. * @param exposure The exposure.
  11414. * @param result The result data container.
  11415. */
  11416. private getColorGradingDataToRef;
  11417. /**
  11418. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11419. * @param value The input slider value in range [-100,100].
  11420. * @returns Adjusted value.
  11421. */
  11422. private static applyColorGradingSliderNonlinear;
  11423. /**
  11424. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11425. * @param hue The hue (H) input.
  11426. * @param saturation The saturation (S) input.
  11427. * @param brightness The brightness (B) input.
  11428. * @result An RGBA color represented as Vector4.
  11429. */
  11430. private static fromHSBToRef;
  11431. /**
  11432. * Returns a value clamped between min and max
  11433. * @param value The value to clamp
  11434. * @param min The minimum of value
  11435. * @param max The maximum of value
  11436. * @returns The clamped value.
  11437. */
  11438. private static clamp;
  11439. /**
  11440. * Clones the current color curve instance.
  11441. * @return The cloned curves
  11442. */
  11443. clone(): ColorCurves;
  11444. /**
  11445. * Serializes the current color curve instance to a json representation.
  11446. * @return a JSON representation
  11447. */
  11448. serialize(): any;
  11449. /**
  11450. * Parses the color curve from a json representation.
  11451. * @param source the JSON source to parse
  11452. * @return The parsed curves
  11453. */
  11454. static Parse(source: any): ColorCurves;
  11455. }
  11456. }
  11457. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  11458. import { Observable } from "babylonjs/Misc/observable";
  11459. import { Nullable } from "babylonjs/types";
  11460. import { Color4 } from "babylonjs/Maths/math.color";
  11461. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11462. import { Effect } from "babylonjs/Materials/effect";
  11463. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11464. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  11465. /**
  11466. * Interface to follow in your material defines to integrate easily the
  11467. * Image proccessing functions.
  11468. * @hidden
  11469. */
  11470. export interface IImageProcessingConfigurationDefines {
  11471. IMAGEPROCESSING: boolean;
  11472. VIGNETTE: boolean;
  11473. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11474. VIGNETTEBLENDMODEOPAQUE: boolean;
  11475. TONEMAPPING: boolean;
  11476. TONEMAPPING_ACES: boolean;
  11477. CONTRAST: boolean;
  11478. EXPOSURE: boolean;
  11479. COLORCURVES: boolean;
  11480. COLORGRADING: boolean;
  11481. COLORGRADING3D: boolean;
  11482. SAMPLER3DGREENDEPTH: boolean;
  11483. SAMPLER3DBGRMAP: boolean;
  11484. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11485. }
  11486. /**
  11487. * @hidden
  11488. */
  11489. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11490. IMAGEPROCESSING: boolean;
  11491. VIGNETTE: boolean;
  11492. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11493. VIGNETTEBLENDMODEOPAQUE: boolean;
  11494. TONEMAPPING: boolean;
  11495. TONEMAPPING_ACES: boolean;
  11496. CONTRAST: boolean;
  11497. COLORCURVES: boolean;
  11498. COLORGRADING: boolean;
  11499. COLORGRADING3D: boolean;
  11500. SAMPLER3DGREENDEPTH: boolean;
  11501. SAMPLER3DBGRMAP: boolean;
  11502. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11503. EXPOSURE: boolean;
  11504. constructor();
  11505. }
  11506. /**
  11507. * This groups together the common properties used for image processing either in direct forward pass
  11508. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11509. * or not.
  11510. */
  11511. export class ImageProcessingConfiguration {
  11512. /**
  11513. * Default tone mapping applied in BabylonJS.
  11514. */
  11515. static readonly TONEMAPPING_STANDARD: number;
  11516. /**
  11517. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11518. * to other engines rendering to increase portability.
  11519. */
  11520. static readonly TONEMAPPING_ACES: number;
  11521. /**
  11522. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11523. */
  11524. colorCurves: Nullable<ColorCurves>;
  11525. private _colorCurvesEnabled;
  11526. /**
  11527. * Gets wether the color curves effect is enabled.
  11528. */
  11529. get colorCurvesEnabled(): boolean;
  11530. /**
  11531. * Sets wether the color curves effect is enabled.
  11532. */
  11533. set colorCurvesEnabled(value: boolean);
  11534. private _colorGradingTexture;
  11535. /**
  11536. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11537. */
  11538. get colorGradingTexture(): Nullable<BaseTexture>;
  11539. /**
  11540. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11541. */
  11542. set colorGradingTexture(value: Nullable<BaseTexture>);
  11543. private _colorGradingEnabled;
  11544. /**
  11545. * Gets wether the color grading effect is enabled.
  11546. */
  11547. get colorGradingEnabled(): boolean;
  11548. /**
  11549. * Sets wether the color grading effect is enabled.
  11550. */
  11551. set colorGradingEnabled(value: boolean);
  11552. private _colorGradingWithGreenDepth;
  11553. /**
  11554. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11555. */
  11556. get colorGradingWithGreenDepth(): boolean;
  11557. /**
  11558. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11559. */
  11560. set colorGradingWithGreenDepth(value: boolean);
  11561. private _colorGradingBGR;
  11562. /**
  11563. * Gets wether the color grading texture contains BGR values.
  11564. */
  11565. get colorGradingBGR(): boolean;
  11566. /**
  11567. * Sets wether the color grading texture contains BGR values.
  11568. */
  11569. set colorGradingBGR(value: boolean);
  11570. /** @hidden */
  11571. _exposure: number;
  11572. /**
  11573. * Gets the Exposure used in the effect.
  11574. */
  11575. get exposure(): number;
  11576. /**
  11577. * Sets the Exposure used in the effect.
  11578. */
  11579. set exposure(value: number);
  11580. private _toneMappingEnabled;
  11581. /**
  11582. * Gets wether the tone mapping effect is enabled.
  11583. */
  11584. get toneMappingEnabled(): boolean;
  11585. /**
  11586. * Sets wether the tone mapping effect is enabled.
  11587. */
  11588. set toneMappingEnabled(value: boolean);
  11589. private _toneMappingType;
  11590. /**
  11591. * Gets the type of tone mapping effect.
  11592. */
  11593. get toneMappingType(): number;
  11594. /**
  11595. * Sets the type of tone mapping effect used in BabylonJS.
  11596. */
  11597. set toneMappingType(value: number);
  11598. protected _contrast: number;
  11599. /**
  11600. * Gets the contrast used in the effect.
  11601. */
  11602. get contrast(): number;
  11603. /**
  11604. * Sets the contrast used in the effect.
  11605. */
  11606. set contrast(value: number);
  11607. /**
  11608. * Vignette stretch size.
  11609. */
  11610. vignetteStretch: number;
  11611. /**
  11612. * Vignette centre X Offset.
  11613. */
  11614. vignetteCentreX: number;
  11615. /**
  11616. * Vignette centre Y Offset.
  11617. */
  11618. vignetteCentreY: number;
  11619. /**
  11620. * Vignette weight or intensity of the vignette effect.
  11621. */
  11622. vignetteWeight: number;
  11623. /**
  11624. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  11625. * if vignetteEnabled is set to true.
  11626. */
  11627. vignetteColor: Color4;
  11628. /**
  11629. * Camera field of view used by the Vignette effect.
  11630. */
  11631. vignetteCameraFov: number;
  11632. private _vignetteBlendMode;
  11633. /**
  11634. * Gets the vignette blend mode allowing different kind of effect.
  11635. */
  11636. get vignetteBlendMode(): number;
  11637. /**
  11638. * Sets the vignette blend mode allowing different kind of effect.
  11639. */
  11640. set vignetteBlendMode(value: number);
  11641. private _vignetteEnabled;
  11642. /**
  11643. * Gets wether the vignette effect is enabled.
  11644. */
  11645. get vignetteEnabled(): boolean;
  11646. /**
  11647. * Sets wether the vignette effect is enabled.
  11648. */
  11649. set vignetteEnabled(value: boolean);
  11650. private _applyByPostProcess;
  11651. /**
  11652. * Gets wether the image processing is applied through a post process or not.
  11653. */
  11654. get applyByPostProcess(): boolean;
  11655. /**
  11656. * Sets wether the image processing is applied through a post process or not.
  11657. */
  11658. set applyByPostProcess(value: boolean);
  11659. private _isEnabled;
  11660. /**
  11661. * Gets wether the image processing is enabled or not.
  11662. */
  11663. get isEnabled(): boolean;
  11664. /**
  11665. * Sets wether the image processing is enabled or not.
  11666. */
  11667. set isEnabled(value: boolean);
  11668. /**
  11669. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  11670. */
  11671. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  11672. /**
  11673. * Method called each time the image processing information changes requires to recompile the effect.
  11674. */
  11675. protected _updateParameters(): void;
  11676. /**
  11677. * Gets the current class name.
  11678. * @return "ImageProcessingConfiguration"
  11679. */
  11680. getClassName(): string;
  11681. /**
  11682. * Prepare the list of uniforms associated with the Image Processing effects.
  11683. * @param uniforms The list of uniforms used in the effect
  11684. * @param defines the list of defines currently in use
  11685. */
  11686. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  11687. /**
  11688. * Prepare the list of samplers associated with the Image Processing effects.
  11689. * @param samplersList The list of uniforms used in the effect
  11690. * @param defines the list of defines currently in use
  11691. */
  11692. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  11693. /**
  11694. * Prepare the list of defines associated to the shader.
  11695. * @param defines the list of defines to complete
  11696. * @param forPostProcess Define if we are currently in post process mode or not
  11697. */
  11698. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  11699. /**
  11700. * Returns true if all the image processing information are ready.
  11701. * @returns True if ready, otherwise, false
  11702. */
  11703. isReady(): boolean;
  11704. /**
  11705. * Binds the image processing to the shader.
  11706. * @param effect The effect to bind to
  11707. * @param overrideAspectRatio Override the aspect ratio of the effect
  11708. */
  11709. bind(effect: Effect, overrideAspectRatio?: number): void;
  11710. /**
  11711. * Clones the current image processing instance.
  11712. * @return The cloned image processing
  11713. */
  11714. clone(): ImageProcessingConfiguration;
  11715. /**
  11716. * Serializes the current image processing instance to a json representation.
  11717. * @return a JSON representation
  11718. */
  11719. serialize(): any;
  11720. /**
  11721. * Parses the image processing from a json representation.
  11722. * @param source the JSON source to parse
  11723. * @return The parsed image processing
  11724. */
  11725. static Parse(source: any): ImageProcessingConfiguration;
  11726. private static _VIGNETTEMODE_MULTIPLY;
  11727. private static _VIGNETTEMODE_OPAQUE;
  11728. /**
  11729. * Used to apply the vignette as a mix with the pixel color.
  11730. */
  11731. static get VIGNETTEMODE_MULTIPLY(): number;
  11732. /**
  11733. * Used to apply the vignette as a replacement of the pixel color.
  11734. */
  11735. static get VIGNETTEMODE_OPAQUE(): number;
  11736. }
  11737. }
  11738. declare module "babylonjs/Shaders/postprocess.vertex" {
  11739. /** @hidden */
  11740. export var postprocessVertexShader: {
  11741. name: string;
  11742. shader: string;
  11743. };
  11744. }
  11745. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  11746. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11747. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11748. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  11749. /**
  11750. * Type used to define a render target texture size (either with a number or with a rect width and height)
  11751. */
  11752. export type RenderTargetTextureSize = number | {
  11753. width: number;
  11754. height: number;
  11755. layers?: number;
  11756. };
  11757. module "babylonjs/Engines/thinEngine" {
  11758. interface ThinEngine {
  11759. /**
  11760. * Creates a new render target texture
  11761. * @param size defines the size of the texture
  11762. * @param options defines the options used to create the texture
  11763. * @returns a new render target texture stored in an InternalTexture
  11764. */
  11765. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11766. /**
  11767. * Creates a depth stencil texture.
  11768. * This is only available in WebGL 2 or with the depth texture extension available.
  11769. * @param size The size of face edge in the texture.
  11770. * @param options The options defining the texture.
  11771. * @returns The texture
  11772. */
  11773. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11774. /** @hidden */
  11775. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  11776. }
  11777. }
  11778. }
  11779. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  11780. /**
  11781. * Defines the kind of connection point for node based material
  11782. */
  11783. export enum NodeMaterialBlockConnectionPointTypes {
  11784. /** Float */
  11785. Float = 1,
  11786. /** Int */
  11787. Int = 2,
  11788. /** Vector2 */
  11789. Vector2 = 4,
  11790. /** Vector3 */
  11791. Vector3 = 8,
  11792. /** Vector4 */
  11793. Vector4 = 16,
  11794. /** Color3 */
  11795. Color3 = 32,
  11796. /** Color4 */
  11797. Color4 = 64,
  11798. /** Matrix */
  11799. Matrix = 128,
  11800. /** Custom object */
  11801. Object = 256,
  11802. /** Detect type based on connection */
  11803. AutoDetect = 1024,
  11804. /** Output type that will be defined by input type */
  11805. BasedOnInput = 2048
  11806. }
  11807. }
  11808. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  11809. /**
  11810. * Enum used to define the target of a block
  11811. */
  11812. export enum NodeMaterialBlockTargets {
  11813. /** Vertex shader */
  11814. Vertex = 1,
  11815. /** Fragment shader */
  11816. Fragment = 2,
  11817. /** Neutral */
  11818. Neutral = 4,
  11819. /** Vertex and Fragment */
  11820. VertexAndFragment = 3
  11821. }
  11822. }
  11823. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  11824. /**
  11825. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  11826. */
  11827. export enum NodeMaterialBlockConnectionPointMode {
  11828. /** Value is an uniform */
  11829. Uniform = 0,
  11830. /** Value is a mesh attribute */
  11831. Attribute = 1,
  11832. /** Value is a varying between vertex and fragment shaders */
  11833. Varying = 2,
  11834. /** Mode is undefined */
  11835. Undefined = 3
  11836. }
  11837. }
  11838. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  11839. /**
  11840. * Enum used to define system values e.g. values automatically provided by the system
  11841. */
  11842. export enum NodeMaterialSystemValues {
  11843. /** World */
  11844. World = 1,
  11845. /** View */
  11846. View = 2,
  11847. /** Projection */
  11848. Projection = 3,
  11849. /** ViewProjection */
  11850. ViewProjection = 4,
  11851. /** WorldView */
  11852. WorldView = 5,
  11853. /** WorldViewProjection */
  11854. WorldViewProjection = 6,
  11855. /** CameraPosition */
  11856. CameraPosition = 7,
  11857. /** Fog Color */
  11858. FogColor = 8,
  11859. /** Delta time */
  11860. DeltaTime = 9
  11861. }
  11862. }
  11863. declare module "babylonjs/Maths/math.frustum" {
  11864. import { Matrix } from "babylonjs/Maths/math.vector";
  11865. import { DeepImmutable } from "babylonjs/types";
  11866. import { Plane } from "babylonjs/Maths/math.plane";
  11867. /**
  11868. * Represents a camera frustum
  11869. */
  11870. export class Frustum {
  11871. /**
  11872. * Gets the planes representing the frustum
  11873. * @param transform matrix to be applied to the returned planes
  11874. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  11875. */
  11876. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  11877. /**
  11878. * Gets the near frustum plane transformed by the transform matrix
  11879. * @param transform transformation matrix to be applied to the resulting frustum plane
  11880. * @param frustumPlane the resuling frustum plane
  11881. */
  11882. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11883. /**
  11884. * Gets the far frustum plane transformed by the transform matrix
  11885. * @param transform transformation matrix to be applied to the resulting frustum plane
  11886. * @param frustumPlane the resuling frustum plane
  11887. */
  11888. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11889. /**
  11890. * Gets the left frustum plane transformed by the transform matrix
  11891. * @param transform transformation matrix to be applied to the resulting frustum plane
  11892. * @param frustumPlane the resuling frustum plane
  11893. */
  11894. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11895. /**
  11896. * Gets the right frustum plane transformed by the transform matrix
  11897. * @param transform transformation matrix to be applied to the resulting frustum plane
  11898. * @param frustumPlane the resuling frustum plane
  11899. */
  11900. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11901. /**
  11902. * Gets the top frustum plane transformed by the transform matrix
  11903. * @param transform transformation matrix to be applied to the resulting frustum plane
  11904. * @param frustumPlane the resuling frustum plane
  11905. */
  11906. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11907. /**
  11908. * Gets the bottom frustum plane transformed by the transform matrix
  11909. * @param transform transformation matrix to be applied to the resulting frustum plane
  11910. * @param frustumPlane the resuling frustum plane
  11911. */
  11912. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  11913. /**
  11914. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  11915. * @param transform transformation matrix to be applied to the resulting frustum planes
  11916. * @param frustumPlanes the resuling frustum planes
  11917. */
  11918. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  11919. }
  11920. }
  11921. declare module "babylonjs/Maths/math.vertexFormat" {
  11922. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11923. /**
  11924. * Contains position and normal vectors for a vertex
  11925. */
  11926. export class PositionNormalVertex {
  11927. /** the position of the vertex (defaut: 0,0,0) */
  11928. position: Vector3;
  11929. /** the normal of the vertex (defaut: 0,1,0) */
  11930. normal: Vector3;
  11931. /**
  11932. * Creates a PositionNormalVertex
  11933. * @param position the position of the vertex (defaut: 0,0,0)
  11934. * @param normal the normal of the vertex (defaut: 0,1,0)
  11935. */
  11936. constructor(
  11937. /** the position of the vertex (defaut: 0,0,0) */
  11938. position?: Vector3,
  11939. /** the normal of the vertex (defaut: 0,1,0) */
  11940. normal?: Vector3);
  11941. /**
  11942. * Clones the PositionNormalVertex
  11943. * @returns the cloned PositionNormalVertex
  11944. */
  11945. clone(): PositionNormalVertex;
  11946. }
  11947. /**
  11948. * Contains position, normal and uv vectors for a vertex
  11949. */
  11950. export class PositionNormalTextureVertex {
  11951. /** the position of the vertex (defaut: 0,0,0) */
  11952. position: Vector3;
  11953. /** the normal of the vertex (defaut: 0,1,0) */
  11954. normal: Vector3;
  11955. /** the uv of the vertex (default: 0,0) */
  11956. uv: Vector2;
  11957. /**
  11958. * Creates a PositionNormalTextureVertex
  11959. * @param position the position of the vertex (defaut: 0,0,0)
  11960. * @param normal the normal of the vertex (defaut: 0,1,0)
  11961. * @param uv the uv of the vertex (default: 0,0)
  11962. */
  11963. constructor(
  11964. /** the position of the vertex (defaut: 0,0,0) */
  11965. position?: Vector3,
  11966. /** the normal of the vertex (defaut: 0,1,0) */
  11967. normal?: Vector3,
  11968. /** the uv of the vertex (default: 0,0) */
  11969. uv?: Vector2);
  11970. /**
  11971. * Clones the PositionNormalTextureVertex
  11972. * @returns the cloned PositionNormalTextureVertex
  11973. */
  11974. clone(): PositionNormalTextureVertex;
  11975. }
  11976. }
  11977. declare module "babylonjs/Maths/math" {
  11978. export * from "babylonjs/Maths/math.axis";
  11979. export * from "babylonjs/Maths/math.color";
  11980. export * from "babylonjs/Maths/math.constants";
  11981. export * from "babylonjs/Maths/math.frustum";
  11982. export * from "babylonjs/Maths/math.path";
  11983. export * from "babylonjs/Maths/math.plane";
  11984. export * from "babylonjs/Maths/math.size";
  11985. export * from "babylonjs/Maths/math.vector";
  11986. export * from "babylonjs/Maths/math.vertexFormat";
  11987. export * from "babylonjs/Maths/math.viewport";
  11988. }
  11989. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  11990. /**
  11991. * Enum defining the type of animations supported by InputBlock
  11992. */
  11993. export enum AnimatedInputBlockTypes {
  11994. /** No animation */
  11995. None = 0,
  11996. /** Time based animation. Will only work for floats */
  11997. Time = 1
  11998. }
  11999. }
  12000. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  12001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12002. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12003. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  12004. import { Nullable } from "babylonjs/types";
  12005. import { Effect } from "babylonjs/Materials/effect";
  12006. import { Matrix } from "babylonjs/Maths/math.vector";
  12007. import { Scene } from "babylonjs/scene";
  12008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12010. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12011. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  12012. import { Observable } from "babylonjs/Misc/observable";
  12013. /**
  12014. * Block used to expose an input value
  12015. */
  12016. export class InputBlock extends NodeMaterialBlock {
  12017. private _mode;
  12018. private _associatedVariableName;
  12019. private _storedValue;
  12020. private _valueCallback;
  12021. private _type;
  12022. private _animationType;
  12023. /** Gets or set a value used to limit the range of float values */
  12024. min: number;
  12025. /** Gets or set a value used to limit the range of float values */
  12026. max: number;
  12027. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12028. isBoolean: boolean;
  12029. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12030. matrixMode: number;
  12031. /** @hidden */
  12032. _systemValue: Nullable<NodeMaterialSystemValues>;
  12033. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12034. isConstant: boolean;
  12035. /** Gets or sets the group to use to display this block in the Inspector */
  12036. groupInInspector: string;
  12037. /** Gets an observable raised when the value is changed */
  12038. onValueChangedObservable: Observable<InputBlock>;
  12039. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12040. convertToGammaSpace: boolean;
  12041. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12042. convertToLinearSpace: boolean;
  12043. /**
  12044. * Gets or sets the connection point type (default is float)
  12045. */
  12046. get type(): NodeMaterialBlockConnectionPointTypes;
  12047. /**
  12048. * Creates a new InputBlock
  12049. * @param name defines the block name
  12050. * @param target defines the target of that block (Vertex by default)
  12051. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12052. */
  12053. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12054. /**
  12055. * Validates if a name is a reserve word.
  12056. * @param newName the new name to be given to the node.
  12057. * @returns false if the name is a reserve word, else true.
  12058. */
  12059. validateBlockName(newName: string): boolean;
  12060. /**
  12061. * Gets the output component
  12062. */
  12063. get output(): NodeMaterialConnectionPoint;
  12064. /**
  12065. * Set the source of this connection point to a vertex attribute
  12066. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12067. * @returns the current connection point
  12068. */
  12069. setAsAttribute(attributeName?: string): InputBlock;
  12070. /**
  12071. * Set the source of this connection point to a system value
  12072. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12073. * @returns the current connection point
  12074. */
  12075. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12076. /**
  12077. * Gets or sets the value of that point.
  12078. * Please note that this value will be ignored if valueCallback is defined
  12079. */
  12080. get value(): any;
  12081. set value(value: any);
  12082. /**
  12083. * Gets or sets a callback used to get the value of that point.
  12084. * Please note that setting this value will force the connection point to ignore the value property
  12085. */
  12086. get valueCallback(): () => any;
  12087. set valueCallback(value: () => any);
  12088. /**
  12089. * Gets or sets the associated variable name in the shader
  12090. */
  12091. get associatedVariableName(): string;
  12092. set associatedVariableName(value: string);
  12093. /** Gets or sets the type of animation applied to the input */
  12094. get animationType(): AnimatedInputBlockTypes;
  12095. set animationType(value: AnimatedInputBlockTypes);
  12096. /**
  12097. * Gets a boolean indicating that this connection point not defined yet
  12098. */
  12099. get isUndefined(): boolean;
  12100. /**
  12101. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12102. * In this case the connection point name must be the name of the uniform to use.
  12103. * Can only be set on inputs
  12104. */
  12105. get isUniform(): boolean;
  12106. set isUniform(value: boolean);
  12107. /**
  12108. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12109. * In this case the connection point name must be the name of the attribute to use
  12110. * Can only be set on inputs
  12111. */
  12112. get isAttribute(): boolean;
  12113. set isAttribute(value: boolean);
  12114. /**
  12115. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12116. * Can only be set on exit points
  12117. */
  12118. get isVarying(): boolean;
  12119. set isVarying(value: boolean);
  12120. /**
  12121. * Gets a boolean indicating that the current connection point is a system value
  12122. */
  12123. get isSystemValue(): boolean;
  12124. /**
  12125. * Gets or sets the current well known value or null if not defined as a system value
  12126. */
  12127. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12128. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12129. /**
  12130. * Gets the current class name
  12131. * @returns the class name
  12132. */
  12133. getClassName(): string;
  12134. /**
  12135. * Animate the input if animationType !== None
  12136. * @param scene defines the rendering scene
  12137. */
  12138. animate(scene: Scene): void;
  12139. private _emitDefine;
  12140. initialize(state: NodeMaterialBuildState): void;
  12141. /**
  12142. * Set the input block to its default value (based on its type)
  12143. */
  12144. setDefaultValue(): void;
  12145. private _emitConstant;
  12146. /** @hidden */
  12147. get _noContextSwitch(): boolean;
  12148. private _emit;
  12149. /** @hidden */
  12150. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12151. /** @hidden */
  12152. _transmit(effect: Effect, scene: Scene): void;
  12153. protected _buildBlock(state: NodeMaterialBuildState): void;
  12154. protected _dumpPropertiesCode(): string;
  12155. dispose(): void;
  12156. serialize(): any;
  12157. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12158. }
  12159. }
  12160. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  12161. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  12162. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12163. import { Nullable } from "babylonjs/types";
  12164. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12165. import { Observable } from "babylonjs/Misc/observable";
  12166. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12167. /**
  12168. * Enum used to define the compatibility state between two connection points
  12169. */
  12170. export enum NodeMaterialConnectionPointCompatibilityStates {
  12171. /** Points are compatibles */
  12172. Compatible = 0,
  12173. /** Points are incompatible because of their types */
  12174. TypeIncompatible = 1,
  12175. /** Points are incompatible because of their targets (vertex vs fragment) */
  12176. TargetIncompatible = 2
  12177. }
  12178. /**
  12179. * Defines the direction of a connection point
  12180. */
  12181. export enum NodeMaterialConnectionPointDirection {
  12182. /** Input */
  12183. Input = 0,
  12184. /** Output */
  12185. Output = 1
  12186. }
  12187. /**
  12188. * Defines a connection point for a block
  12189. */
  12190. export class NodeMaterialConnectionPoint {
  12191. /**
  12192. * Checks if two types are equivalent
  12193. * @param type1 type 1 to check
  12194. * @param type2 type 2 to check
  12195. * @returns true if both types are equivalent, else false
  12196. */
  12197. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12198. /** @hidden */
  12199. _ownerBlock: NodeMaterialBlock;
  12200. /** @hidden */
  12201. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12202. private _endpoints;
  12203. private _associatedVariableName;
  12204. private _direction;
  12205. /** @hidden */
  12206. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12207. /** @hidden */
  12208. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12209. /** @hidden */
  12210. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12211. private _type;
  12212. /** @hidden */
  12213. _enforceAssociatedVariableName: boolean;
  12214. /** Gets the direction of the point */
  12215. get direction(): NodeMaterialConnectionPointDirection;
  12216. /** Indicates that this connection point needs dual validation before being connected to another point */
  12217. needDualDirectionValidation: boolean;
  12218. /**
  12219. * Gets or sets the additional types supported by this connection point
  12220. */
  12221. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12222. /**
  12223. * Gets or sets the additional types excluded by this connection point
  12224. */
  12225. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12226. /**
  12227. * Observable triggered when this point is connected
  12228. */
  12229. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12230. /**
  12231. * Gets or sets the associated variable name in the shader
  12232. */
  12233. get associatedVariableName(): string;
  12234. set associatedVariableName(value: string);
  12235. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12236. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12237. /**
  12238. * Gets or sets the connection point type (default is float)
  12239. */
  12240. get type(): NodeMaterialBlockConnectionPointTypes;
  12241. set type(value: NodeMaterialBlockConnectionPointTypes);
  12242. /**
  12243. * Gets or sets the connection point name
  12244. */
  12245. name: string;
  12246. /**
  12247. * Gets or sets the connection point name
  12248. */
  12249. displayName: string;
  12250. /**
  12251. * Gets or sets a boolean indicating that this connection point can be omitted
  12252. */
  12253. isOptional: boolean;
  12254. /**
  12255. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12256. */
  12257. isExposedOnFrame: boolean;
  12258. /**
  12259. * Gets or sets number indicating the position that the port is exposed to on a frame
  12260. */
  12261. exposedPortPosition: number;
  12262. /**
  12263. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12264. */
  12265. define: string;
  12266. /** @hidden */
  12267. _prioritizeVertex: boolean;
  12268. private _target;
  12269. /** Gets or sets the target of that connection point */
  12270. get target(): NodeMaterialBlockTargets;
  12271. set target(value: NodeMaterialBlockTargets);
  12272. /**
  12273. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12274. */
  12275. get isConnected(): boolean;
  12276. /**
  12277. * Gets a boolean indicating that the current point is connected to an input block
  12278. */
  12279. get isConnectedToInputBlock(): boolean;
  12280. /**
  12281. * Gets a the connected input block (if any)
  12282. */
  12283. get connectInputBlock(): Nullable<InputBlock>;
  12284. /** Get the other side of the connection (if any) */
  12285. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12286. /** Get the block that owns this connection point */
  12287. get ownerBlock(): NodeMaterialBlock;
  12288. /** Get the block connected on the other side of this connection (if any) */
  12289. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12290. /** Get the block connected on the endpoints of this connection (if any) */
  12291. get connectedBlocks(): Array<NodeMaterialBlock>;
  12292. /** Gets the list of connected endpoints */
  12293. get endpoints(): NodeMaterialConnectionPoint[];
  12294. /** Gets a boolean indicating if that output point is connected to at least one input */
  12295. get hasEndpoints(): boolean;
  12296. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12297. get isConnectedInVertexShader(): boolean;
  12298. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12299. get isConnectedInFragmentShader(): boolean;
  12300. /**
  12301. * Creates a block suitable to be used as an input for this input point.
  12302. * If null is returned, a block based on the point type will be created.
  12303. * @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
  12304. */
  12305. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12306. /**
  12307. * Creates a new connection point
  12308. * @param name defines the connection point name
  12309. * @param ownerBlock defines the block hosting this connection point
  12310. * @param direction defines the direction of the connection point
  12311. */
  12312. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12313. /**
  12314. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12315. * @returns the class name
  12316. */
  12317. getClassName(): string;
  12318. /**
  12319. * Gets a boolean indicating if the current point can be connected to another point
  12320. * @param connectionPoint defines the other connection point
  12321. * @returns a boolean
  12322. */
  12323. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12324. /**
  12325. * Gets a number indicating if the current point can be connected to another point
  12326. * @param connectionPoint defines the other connection point
  12327. * @returns a number defining the compatibility state
  12328. */
  12329. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12330. /**
  12331. * Connect this point to another connection point
  12332. * @param connectionPoint defines the other connection point
  12333. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12334. * @returns the current connection point
  12335. */
  12336. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12337. /**
  12338. * Disconnect this point from one of his endpoint
  12339. * @param endpoint defines the other connection point
  12340. * @returns the current connection point
  12341. */
  12342. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12343. /**
  12344. * Serializes this point in a JSON representation
  12345. * @param isInput defines if the connection point is an input (default is true)
  12346. * @returns the serialized point object
  12347. */
  12348. serialize(isInput?: boolean): any;
  12349. /**
  12350. * Release resources
  12351. */
  12352. dispose(): void;
  12353. }
  12354. }
  12355. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  12356. /**
  12357. * Enum used to define the material modes
  12358. */
  12359. export enum NodeMaterialModes {
  12360. /** Regular material */
  12361. Material = 0,
  12362. /** For post process */
  12363. PostProcess = 1,
  12364. /** For particle system */
  12365. Particle = 2,
  12366. /** For procedural texture */
  12367. ProceduralTexture = 3
  12368. }
  12369. }
  12370. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  12371. /** @hidden */
  12372. export var helperFunctions: {
  12373. name: string;
  12374. shader: string;
  12375. };
  12376. }
  12377. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  12378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12380. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12381. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12383. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12384. import { Effect } from "babylonjs/Materials/effect";
  12385. import { Mesh } from "babylonjs/Meshes/mesh";
  12386. import { Nullable } from "babylonjs/types";
  12387. import { Texture } from "babylonjs/Materials/Textures/texture";
  12388. import { Scene } from "babylonjs/scene";
  12389. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12390. /**
  12391. * Block used to read a texture from a sampler
  12392. */
  12393. export class TextureBlock extends NodeMaterialBlock {
  12394. private _defineName;
  12395. private _linearDefineName;
  12396. private _gammaDefineName;
  12397. private _tempTextureRead;
  12398. private _samplerName;
  12399. private _transformedUVName;
  12400. private _textureTransformName;
  12401. private _textureInfoName;
  12402. private _mainUVName;
  12403. private _mainUVDefineName;
  12404. private _fragmentOnly;
  12405. /**
  12406. * Gets or sets the texture associated with the node
  12407. */
  12408. texture: Nullable<Texture>;
  12409. /**
  12410. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12411. */
  12412. convertToGammaSpace: boolean;
  12413. /**
  12414. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12415. */
  12416. convertToLinearSpace: boolean;
  12417. /**
  12418. * Create a new TextureBlock
  12419. * @param name defines the block name
  12420. */
  12421. constructor(name: string, fragmentOnly?: boolean);
  12422. /**
  12423. * Gets the current class name
  12424. * @returns the class name
  12425. */
  12426. getClassName(): string;
  12427. /**
  12428. * Gets the uv input component
  12429. */
  12430. get uv(): NodeMaterialConnectionPoint;
  12431. /**
  12432. * Gets the rgba output component
  12433. */
  12434. get rgba(): NodeMaterialConnectionPoint;
  12435. /**
  12436. * Gets the rgb output component
  12437. */
  12438. get rgb(): NodeMaterialConnectionPoint;
  12439. /**
  12440. * Gets the r output component
  12441. */
  12442. get r(): NodeMaterialConnectionPoint;
  12443. /**
  12444. * Gets the g output component
  12445. */
  12446. get g(): NodeMaterialConnectionPoint;
  12447. /**
  12448. * Gets the b output component
  12449. */
  12450. get b(): NodeMaterialConnectionPoint;
  12451. /**
  12452. * Gets the a output component
  12453. */
  12454. get a(): NodeMaterialConnectionPoint;
  12455. get target(): NodeMaterialBlockTargets;
  12456. autoConfigure(material: NodeMaterial): void;
  12457. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12459. isReady(): boolean;
  12460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12461. private get _isMixed();
  12462. private _injectVertexCode;
  12463. private _writeTextureRead;
  12464. private _writeOutput;
  12465. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12466. protected _dumpPropertiesCode(): string;
  12467. serialize(): any;
  12468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12469. }
  12470. }
  12471. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  12472. /** @hidden */
  12473. export var reflectionFunction: {
  12474. name: string;
  12475. shader: string;
  12476. };
  12477. }
  12478. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  12479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12484. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12485. import { Effect } from "babylonjs/Materials/effect";
  12486. import { Mesh } from "babylonjs/Meshes/mesh";
  12487. import { Nullable } from "babylonjs/types";
  12488. import { Scene } from "babylonjs/scene";
  12489. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  12490. /**
  12491. * Base block used to read a reflection texture from a sampler
  12492. */
  12493. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12494. /** @hidden */
  12495. _define3DName: string;
  12496. /** @hidden */
  12497. _defineCubicName: string;
  12498. /** @hidden */
  12499. _defineExplicitName: string;
  12500. /** @hidden */
  12501. _defineProjectionName: string;
  12502. /** @hidden */
  12503. _defineLocalCubicName: string;
  12504. /** @hidden */
  12505. _defineSphericalName: string;
  12506. /** @hidden */
  12507. _definePlanarName: string;
  12508. /** @hidden */
  12509. _defineEquirectangularName: string;
  12510. /** @hidden */
  12511. _defineMirroredEquirectangularFixedName: string;
  12512. /** @hidden */
  12513. _defineEquirectangularFixedName: string;
  12514. /** @hidden */
  12515. _defineSkyboxName: string;
  12516. /** @hidden */
  12517. _defineOppositeZ: string;
  12518. /** @hidden */
  12519. _cubeSamplerName: string;
  12520. /** @hidden */
  12521. _2DSamplerName: string;
  12522. protected _positionUVWName: string;
  12523. protected _directionWName: string;
  12524. protected _reflectionVectorName: string;
  12525. /** @hidden */
  12526. _reflectionCoordsName: string;
  12527. /** @hidden */
  12528. _reflectionMatrixName: string;
  12529. protected _reflectionColorName: string;
  12530. /**
  12531. * Gets or sets the texture associated with the node
  12532. */
  12533. texture: Nullable<BaseTexture>;
  12534. /**
  12535. * Create a new ReflectionTextureBaseBlock
  12536. * @param name defines the block name
  12537. */
  12538. constructor(name: string);
  12539. /**
  12540. * Gets the current class name
  12541. * @returns the class name
  12542. */
  12543. getClassName(): string;
  12544. /**
  12545. * Gets the world position input component
  12546. */
  12547. abstract get position(): NodeMaterialConnectionPoint;
  12548. /**
  12549. * Gets the world position input component
  12550. */
  12551. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12552. /**
  12553. * Gets the world normal input component
  12554. */
  12555. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12556. /**
  12557. * Gets the world input component
  12558. */
  12559. abstract get world(): NodeMaterialConnectionPoint;
  12560. /**
  12561. * Gets the camera (or eye) position component
  12562. */
  12563. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12564. /**
  12565. * Gets the view input component
  12566. */
  12567. abstract get view(): NodeMaterialConnectionPoint;
  12568. protected _getTexture(): Nullable<BaseTexture>;
  12569. autoConfigure(material: NodeMaterial): void;
  12570. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12571. isReady(): boolean;
  12572. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12573. /**
  12574. * Gets the code to inject in the vertex shader
  12575. * @param state current state of the node material building
  12576. * @returns the shader code
  12577. */
  12578. handleVertexSide(state: NodeMaterialBuildState): string;
  12579. /**
  12580. * Handles the inits for the fragment code path
  12581. * @param state node material build state
  12582. */
  12583. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12584. /**
  12585. * Generates the reflection coords code for the fragment code path
  12586. * @param worldNormalVarName name of the world normal variable
  12587. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12588. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12589. * @returns the shader code
  12590. */
  12591. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12592. /**
  12593. * Generates the reflection color code for the fragment code path
  12594. * @param lodVarName name of the lod variable
  12595. * @param swizzleLookupTexture swizzle to use for the final color variable
  12596. * @returns the shader code
  12597. */
  12598. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12599. /**
  12600. * Generates the code corresponding to the connected output points
  12601. * @param state node material build state
  12602. * @param varName name of the variable to output
  12603. * @returns the shader code
  12604. */
  12605. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12606. protected _buildBlock(state: NodeMaterialBuildState): this;
  12607. protected _dumpPropertiesCode(): string;
  12608. serialize(): any;
  12609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12610. }
  12611. }
  12612. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  12613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12614. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12615. import { Nullable } from "babylonjs/types";
  12616. /**
  12617. * Defines a connection point to be used for points with a custom object type
  12618. */
  12619. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12620. private _blockType;
  12621. private _blockName;
  12622. private _nameForCheking?;
  12623. /**
  12624. * Creates a new connection point
  12625. * @param name defines the connection point name
  12626. * @param ownerBlock defines the block hosting this connection point
  12627. * @param direction defines the direction of the connection point
  12628. */
  12629. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12630. /**
  12631. * Gets a number indicating if the current point can be connected to another point
  12632. * @param connectionPoint defines the other connection point
  12633. * @returns a number defining the compatibility state
  12634. */
  12635. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12636. /**
  12637. * Creates a block suitable to be used as an input for this input point.
  12638. * If null is returned, a block based on the point type will be created.
  12639. * @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
  12640. */
  12641. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12642. }
  12643. }
  12644. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  12645. /**
  12646. * Enum defining the type of properties that can be edited in the property pages in the NME
  12647. */
  12648. export enum PropertyTypeForEdition {
  12649. /** property is a boolean */
  12650. Boolean = 0,
  12651. /** property is a float */
  12652. Float = 1,
  12653. /** property is a Vector2 */
  12654. Vector2 = 2,
  12655. /** property is a list of values */
  12656. List = 3
  12657. }
  12658. /**
  12659. * Interface that defines an option in a variable of type list
  12660. */
  12661. export interface IEditablePropertyListOption {
  12662. /** label of the option */
  12663. "label": string;
  12664. /** value of the option */
  12665. "value": number;
  12666. }
  12667. /**
  12668. * Interface that defines the options available for an editable property
  12669. */
  12670. export interface IEditablePropertyOption {
  12671. /** min value */
  12672. "min"?: number;
  12673. /** max value */
  12674. "max"?: number;
  12675. /** notifiers: indicates which actions to take when the property is changed */
  12676. "notifiers"?: {
  12677. /** the material should be rebuilt */
  12678. "rebuild"?: boolean;
  12679. /** the preview should be updated */
  12680. "update"?: boolean;
  12681. };
  12682. /** list of the options for a variable of type list */
  12683. "options"?: IEditablePropertyListOption[];
  12684. }
  12685. /**
  12686. * Interface that describes an editable property
  12687. */
  12688. export interface IPropertyDescriptionForEdition {
  12689. /** name of the property */
  12690. "propertyName": string;
  12691. /** display name of the property */
  12692. "displayName": string;
  12693. /** type of the property */
  12694. "type": PropertyTypeForEdition;
  12695. /** group of the property - all properties with the same group value will be displayed in a specific section */
  12696. "groupName": string;
  12697. /** options for the property */
  12698. "options": IEditablePropertyOption;
  12699. }
  12700. /**
  12701. * Decorator that flags a property in a node material block as being editable
  12702. */
  12703. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  12704. }
  12705. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  12706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12708. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12710. import { Nullable } from "babylonjs/types";
  12711. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12712. import { Mesh } from "babylonjs/Meshes/mesh";
  12713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12714. import { Effect } from "babylonjs/Materials/effect";
  12715. import { Scene } from "babylonjs/scene";
  12716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12717. /**
  12718. * Block used to implement the refraction part of the sub surface module of the PBR material
  12719. */
  12720. export class RefractionBlock extends NodeMaterialBlock {
  12721. /** @hidden */
  12722. _define3DName: string;
  12723. /** @hidden */
  12724. _refractionMatrixName: string;
  12725. /** @hidden */
  12726. _defineLODRefractionAlpha: string;
  12727. /** @hidden */
  12728. _defineLinearSpecularRefraction: string;
  12729. /** @hidden */
  12730. _defineOppositeZ: string;
  12731. /** @hidden */
  12732. _cubeSamplerName: string;
  12733. /** @hidden */
  12734. _2DSamplerName: string;
  12735. /** @hidden */
  12736. _vRefractionMicrosurfaceInfosName: string;
  12737. /** @hidden */
  12738. _vRefractionInfosName: string;
  12739. /** @hidden */
  12740. _vRefractionFilteringInfoName: string;
  12741. private _scene;
  12742. /**
  12743. * The properties below are set by the main PBR block prior to calling methods of this class.
  12744. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  12745. * It's less burden on the user side in the editor part.
  12746. */
  12747. /** @hidden */
  12748. viewConnectionPoint: NodeMaterialConnectionPoint;
  12749. /** @hidden */
  12750. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  12751. /**
  12752. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  12753. * Materials half opaque for instance using refraction could benefit from this control.
  12754. */
  12755. linkRefractionWithTransparency: boolean;
  12756. /**
  12757. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  12758. */
  12759. invertRefractionY: boolean;
  12760. /**
  12761. * Gets or sets the texture associated with the node
  12762. */
  12763. texture: Nullable<BaseTexture>;
  12764. /**
  12765. * Create a new RefractionBlock
  12766. * @param name defines the block name
  12767. */
  12768. constructor(name: string);
  12769. /**
  12770. * Gets the current class name
  12771. * @returns the class name
  12772. */
  12773. getClassName(): string;
  12774. /**
  12775. * Gets the intensity input component
  12776. */
  12777. get intensity(): NodeMaterialConnectionPoint;
  12778. /**
  12779. * Gets the tint at distance input component
  12780. */
  12781. get tintAtDistance(): NodeMaterialConnectionPoint;
  12782. /**
  12783. * Gets the view input component
  12784. */
  12785. get view(): NodeMaterialConnectionPoint;
  12786. /**
  12787. * Gets the refraction object output component
  12788. */
  12789. get refraction(): NodeMaterialConnectionPoint;
  12790. /**
  12791. * Returns true if the block has a texture
  12792. */
  12793. get hasTexture(): boolean;
  12794. protected _getTexture(): Nullable<BaseTexture>;
  12795. autoConfigure(material: NodeMaterial): void;
  12796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12797. isReady(): boolean;
  12798. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  12799. /**
  12800. * Gets the main code of the block (fragment side)
  12801. * @param state current state of the node material building
  12802. * @returns the shader code
  12803. */
  12804. getCode(state: NodeMaterialBuildState): string;
  12805. protected _buildBlock(state: NodeMaterialBuildState): this;
  12806. protected _dumpPropertiesCode(): string;
  12807. serialize(): any;
  12808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12809. }
  12810. }
  12811. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  12812. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12813. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12814. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  12815. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12817. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12818. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12819. import { Nullable } from "babylonjs/types";
  12820. import { Scene } from "babylonjs/scene";
  12821. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12822. /**
  12823. * Base block used as input for post process
  12824. */
  12825. export class CurrentScreenBlock extends NodeMaterialBlock {
  12826. private _samplerName;
  12827. private _linearDefineName;
  12828. private _gammaDefineName;
  12829. private _mainUVName;
  12830. private _tempTextureRead;
  12831. /**
  12832. * Gets or sets the texture associated with the node
  12833. */
  12834. texture: Nullable<BaseTexture>;
  12835. /**
  12836. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12837. */
  12838. convertToGammaSpace: boolean;
  12839. /**
  12840. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12841. */
  12842. convertToLinearSpace: boolean;
  12843. /**
  12844. * Create a new CurrentScreenBlock
  12845. * @param name defines the block name
  12846. */
  12847. constructor(name: string);
  12848. /**
  12849. * Gets the current class name
  12850. * @returns the class name
  12851. */
  12852. getClassName(): string;
  12853. /**
  12854. * Gets the uv input component
  12855. */
  12856. get uv(): NodeMaterialConnectionPoint;
  12857. /**
  12858. * Gets the rgba output component
  12859. */
  12860. get rgba(): NodeMaterialConnectionPoint;
  12861. /**
  12862. * Gets the rgb output component
  12863. */
  12864. get rgb(): NodeMaterialConnectionPoint;
  12865. /**
  12866. * Gets the r output component
  12867. */
  12868. get r(): NodeMaterialConnectionPoint;
  12869. /**
  12870. * Gets the g output component
  12871. */
  12872. get g(): NodeMaterialConnectionPoint;
  12873. /**
  12874. * Gets the b output component
  12875. */
  12876. get b(): NodeMaterialConnectionPoint;
  12877. /**
  12878. * Gets the a output component
  12879. */
  12880. get a(): NodeMaterialConnectionPoint;
  12881. /**
  12882. * Initialize the block and prepare the context for build
  12883. * @param state defines the state that will be used for the build
  12884. */
  12885. initialize(state: NodeMaterialBuildState): void;
  12886. get target(): NodeMaterialBlockTargets;
  12887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12888. isReady(): boolean;
  12889. private _injectVertexCode;
  12890. private _writeTextureRead;
  12891. private _writeOutput;
  12892. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12893. serialize(): any;
  12894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12895. }
  12896. }
  12897. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  12898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  12900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12902. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  12903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12904. import { Nullable } from "babylonjs/types";
  12905. import { Scene } from "babylonjs/scene";
  12906. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12907. /**
  12908. * Base block used for the particle texture
  12909. */
  12910. export class ParticleTextureBlock extends NodeMaterialBlock {
  12911. private _samplerName;
  12912. private _linearDefineName;
  12913. private _gammaDefineName;
  12914. private _tempTextureRead;
  12915. /**
  12916. * Gets or sets the texture associated with the node
  12917. */
  12918. texture: Nullable<BaseTexture>;
  12919. /**
  12920. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12921. */
  12922. convertToGammaSpace: boolean;
  12923. /**
  12924. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12925. */
  12926. convertToLinearSpace: boolean;
  12927. /**
  12928. * Create a new ParticleTextureBlock
  12929. * @param name defines the block name
  12930. */
  12931. constructor(name: string);
  12932. /**
  12933. * Gets the current class name
  12934. * @returns the class name
  12935. */
  12936. getClassName(): string;
  12937. /**
  12938. * Gets the uv input component
  12939. */
  12940. get uv(): NodeMaterialConnectionPoint;
  12941. /**
  12942. * Gets the rgba output component
  12943. */
  12944. get rgba(): NodeMaterialConnectionPoint;
  12945. /**
  12946. * Gets the rgb output component
  12947. */
  12948. get rgb(): NodeMaterialConnectionPoint;
  12949. /**
  12950. * Gets the r output component
  12951. */
  12952. get r(): NodeMaterialConnectionPoint;
  12953. /**
  12954. * Gets the g output component
  12955. */
  12956. get g(): NodeMaterialConnectionPoint;
  12957. /**
  12958. * Gets the b output component
  12959. */
  12960. get b(): NodeMaterialConnectionPoint;
  12961. /**
  12962. * Gets the a output component
  12963. */
  12964. get a(): NodeMaterialConnectionPoint;
  12965. /**
  12966. * Initialize the block and prepare the context for build
  12967. * @param state defines the state that will be used for the build
  12968. */
  12969. initialize(state: NodeMaterialBuildState): void;
  12970. autoConfigure(material: NodeMaterial): void;
  12971. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12972. isReady(): boolean;
  12973. private _writeOutput;
  12974. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12975. serialize(): any;
  12976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12977. }
  12978. }
  12979. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  12980. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  12981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  12982. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  12983. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  12984. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  12985. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  12986. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  12987. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  12988. import { Scene } from "babylonjs/scene";
  12989. /**
  12990. * Class used to store shared data between 2 NodeMaterialBuildState
  12991. */
  12992. export class NodeMaterialBuildStateSharedData {
  12993. /**
  12994. * Gets the list of emitted varyings
  12995. */
  12996. temps: string[];
  12997. /**
  12998. * Gets the list of emitted varyings
  12999. */
  13000. varyings: string[];
  13001. /**
  13002. * Gets the varying declaration string
  13003. */
  13004. varyingDeclaration: string;
  13005. /**
  13006. * Input blocks
  13007. */
  13008. inputBlocks: InputBlock[];
  13009. /**
  13010. * Input blocks
  13011. */
  13012. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13013. /**
  13014. * Bindable blocks (Blocks that need to set data to the effect)
  13015. */
  13016. bindableBlocks: NodeMaterialBlock[];
  13017. /**
  13018. * List of blocks that can provide a compilation fallback
  13019. */
  13020. blocksWithFallbacks: NodeMaterialBlock[];
  13021. /**
  13022. * List of blocks that can provide a define update
  13023. */
  13024. blocksWithDefines: NodeMaterialBlock[];
  13025. /**
  13026. * List of blocks that can provide a repeatable content
  13027. */
  13028. repeatableContentBlocks: NodeMaterialBlock[];
  13029. /**
  13030. * List of blocks that can provide a dynamic list of uniforms
  13031. */
  13032. dynamicUniformBlocks: NodeMaterialBlock[];
  13033. /**
  13034. * List of blocks that can block the isReady function for the material
  13035. */
  13036. blockingBlocks: NodeMaterialBlock[];
  13037. /**
  13038. * Gets the list of animated inputs
  13039. */
  13040. animatedInputs: InputBlock[];
  13041. /**
  13042. * Build Id used to avoid multiple recompilations
  13043. */
  13044. buildId: number;
  13045. /** List of emitted variables */
  13046. variableNames: {
  13047. [key: string]: number;
  13048. };
  13049. /** List of emitted defines */
  13050. defineNames: {
  13051. [key: string]: number;
  13052. };
  13053. /** Should emit comments? */
  13054. emitComments: boolean;
  13055. /** Emit build activity */
  13056. verbose: boolean;
  13057. /** Gets or sets the hosting scene */
  13058. scene: Scene;
  13059. /**
  13060. * Gets the compilation hints emitted at compilation time
  13061. */
  13062. hints: {
  13063. needWorldViewMatrix: boolean;
  13064. needWorldViewProjectionMatrix: boolean;
  13065. needAlphaBlending: boolean;
  13066. needAlphaTesting: boolean;
  13067. };
  13068. /**
  13069. * List of compilation checks
  13070. */
  13071. checks: {
  13072. emitVertex: boolean;
  13073. emitFragment: boolean;
  13074. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13075. };
  13076. /**
  13077. * Is vertex program allowed to be empty?
  13078. */
  13079. allowEmptyVertexProgram: boolean;
  13080. /** Creates a new shared data */
  13081. constructor();
  13082. /**
  13083. * Emits console errors and exceptions if there is a failing check
  13084. */
  13085. emitErrors(): void;
  13086. }
  13087. }
  13088. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  13089. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13090. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13091. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  13092. /**
  13093. * Class used to store node based material build state
  13094. */
  13095. export class NodeMaterialBuildState {
  13096. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13097. supportUniformBuffers: boolean;
  13098. /**
  13099. * Gets the list of emitted attributes
  13100. */
  13101. attributes: string[];
  13102. /**
  13103. * Gets the list of emitted uniforms
  13104. */
  13105. uniforms: string[];
  13106. /**
  13107. * Gets the list of emitted constants
  13108. */
  13109. constants: string[];
  13110. /**
  13111. * Gets the list of emitted samplers
  13112. */
  13113. samplers: string[];
  13114. /**
  13115. * Gets the list of emitted functions
  13116. */
  13117. functions: {
  13118. [key: string]: string;
  13119. };
  13120. /**
  13121. * Gets the list of emitted extensions
  13122. */
  13123. extensions: {
  13124. [key: string]: string;
  13125. };
  13126. /**
  13127. * Gets the target of the compilation state
  13128. */
  13129. target: NodeMaterialBlockTargets;
  13130. /**
  13131. * Gets the list of emitted counters
  13132. */
  13133. counters: {
  13134. [key: string]: number;
  13135. };
  13136. /**
  13137. * Shared data between multiple NodeMaterialBuildState instances
  13138. */
  13139. sharedData: NodeMaterialBuildStateSharedData;
  13140. /** @hidden */
  13141. _vertexState: NodeMaterialBuildState;
  13142. /** @hidden */
  13143. _attributeDeclaration: string;
  13144. /** @hidden */
  13145. _uniformDeclaration: string;
  13146. /** @hidden */
  13147. _constantDeclaration: string;
  13148. /** @hidden */
  13149. _samplerDeclaration: string;
  13150. /** @hidden */
  13151. _varyingTransfer: string;
  13152. /** @hidden */
  13153. _injectAtEnd: string;
  13154. private _repeatableContentAnchorIndex;
  13155. /** @hidden */
  13156. _builtCompilationString: string;
  13157. /**
  13158. * Gets the emitted compilation strings
  13159. */
  13160. compilationString: string;
  13161. /**
  13162. * Finalize the compilation strings
  13163. * @param state defines the current compilation state
  13164. */
  13165. finalize(state: NodeMaterialBuildState): void;
  13166. /** @hidden */
  13167. get _repeatableContentAnchor(): string;
  13168. /** @hidden */
  13169. _getFreeVariableName(prefix: string): string;
  13170. /** @hidden */
  13171. _getFreeDefineName(prefix: string): string;
  13172. /** @hidden */
  13173. _excludeVariableName(name: string): void;
  13174. /** @hidden */
  13175. _emit2DSampler(name: string): void;
  13176. /** @hidden */
  13177. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13178. /** @hidden */
  13179. _emitExtension(name: string, extension: string, define?: string): void;
  13180. /** @hidden */
  13181. _emitFunction(name: string, code: string, comments: string): void;
  13182. /** @hidden */
  13183. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13184. replaceStrings?: {
  13185. search: RegExp;
  13186. replace: string;
  13187. }[];
  13188. repeatKey?: string;
  13189. }): string;
  13190. /** @hidden */
  13191. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13192. repeatKey?: string;
  13193. removeAttributes?: boolean;
  13194. removeUniforms?: boolean;
  13195. removeVaryings?: boolean;
  13196. removeIfDef?: boolean;
  13197. replaceStrings?: {
  13198. search: RegExp;
  13199. replace: string;
  13200. }[];
  13201. }, storeKey?: string): void;
  13202. /** @hidden */
  13203. _registerTempVariable(name: string): boolean;
  13204. /** @hidden */
  13205. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13206. /** @hidden */
  13207. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13208. /** @hidden */
  13209. _emitFloat(value: number): string;
  13210. }
  13211. }
  13212. declare module "babylonjs/Misc/uniqueIdGenerator" {
  13213. /**
  13214. * Helper class used to generate session unique ID
  13215. */
  13216. export class UniqueIdGenerator {
  13217. private static _UniqueIdCounter;
  13218. /**
  13219. * Gets an unique (relatively to the current scene) Id
  13220. */
  13221. static get UniqueId(): number;
  13222. }
  13223. }
  13224. declare module "babylonjs/Materials/effectFallbacks" {
  13225. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  13226. import { Effect } from "babylonjs/Materials/effect";
  13227. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13228. /**
  13229. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13230. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13231. */
  13232. export class EffectFallbacks implements IEffectFallbacks {
  13233. private _defines;
  13234. private _currentRank;
  13235. private _maxRank;
  13236. private _mesh;
  13237. /**
  13238. * Removes the fallback from the bound mesh.
  13239. */
  13240. unBindMesh(): void;
  13241. /**
  13242. * Adds a fallback on the specified property.
  13243. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13244. * @param define The name of the define in the shader
  13245. */
  13246. addFallback(rank: number, define: string): void;
  13247. /**
  13248. * Sets the mesh to use CPU skinning when needing to fallback.
  13249. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13250. * @param mesh The mesh to use the fallbacks.
  13251. */
  13252. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13253. /**
  13254. * Checks to see if more fallbacks are still availible.
  13255. */
  13256. get hasMoreFallbacks(): boolean;
  13257. /**
  13258. * Removes the defines that should be removed when falling back.
  13259. * @param currentDefines defines the current define statements for the shader.
  13260. * @param effect defines the current effect we try to compile
  13261. * @returns The resulting defines with defines of the current rank removed.
  13262. */
  13263. reduce(currentDefines: string, effect: Effect): string;
  13264. }
  13265. }
  13266. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  13267. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  13268. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13269. import { Nullable } from "babylonjs/types";
  13270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13271. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  13272. import { Effect } from "babylonjs/Materials/effect";
  13273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13274. import { Mesh } from "babylonjs/Meshes/mesh";
  13275. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13276. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13277. import { Scene } from "babylonjs/scene";
  13278. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  13279. /**
  13280. * Defines a block that can be used inside a node based material
  13281. */
  13282. export class NodeMaterialBlock {
  13283. private _buildId;
  13284. private _buildTarget;
  13285. private _target;
  13286. private _isFinalMerger;
  13287. private _isInput;
  13288. private _name;
  13289. protected _isUnique: boolean;
  13290. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13291. inputsAreExclusive: boolean;
  13292. /** @hidden */
  13293. _codeVariableName: string;
  13294. /** @hidden */
  13295. _inputs: NodeMaterialConnectionPoint[];
  13296. /** @hidden */
  13297. _outputs: NodeMaterialConnectionPoint[];
  13298. /** @hidden */
  13299. _preparationId: number;
  13300. /**
  13301. * Gets the name of the block
  13302. */
  13303. get name(): string;
  13304. /**
  13305. * Sets the name of the block. Will check if the name is valid.
  13306. */
  13307. set name(newName: string);
  13308. /**
  13309. * Gets or sets the unique id of the node
  13310. */
  13311. uniqueId: number;
  13312. /**
  13313. * Gets or sets the comments associated with this block
  13314. */
  13315. comments: string;
  13316. /**
  13317. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13318. */
  13319. get isUnique(): boolean;
  13320. /**
  13321. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13322. */
  13323. get isFinalMerger(): boolean;
  13324. /**
  13325. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13326. */
  13327. get isInput(): boolean;
  13328. /**
  13329. * Gets or sets the build Id
  13330. */
  13331. get buildId(): number;
  13332. set buildId(value: number);
  13333. /**
  13334. * Gets or sets the target of the block
  13335. */
  13336. get target(): NodeMaterialBlockTargets;
  13337. set target(value: NodeMaterialBlockTargets);
  13338. /**
  13339. * Gets the list of input points
  13340. */
  13341. get inputs(): NodeMaterialConnectionPoint[];
  13342. /** Gets the list of output points */
  13343. get outputs(): NodeMaterialConnectionPoint[];
  13344. /**
  13345. * Find an input by its name
  13346. * @param name defines the name of the input to look for
  13347. * @returns the input or null if not found
  13348. */
  13349. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13350. /**
  13351. * Find an output by its name
  13352. * @param name defines the name of the outputto look for
  13353. * @returns the output or null if not found
  13354. */
  13355. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13356. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13357. visibleInInspector: boolean;
  13358. /**
  13359. * Creates a new NodeMaterialBlock
  13360. * @param name defines the block name
  13361. * @param target defines the target of that block (Vertex by default)
  13362. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13363. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13364. */
  13365. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13366. /**
  13367. * Initialize the block and prepare the context for build
  13368. * @param state defines the state that will be used for the build
  13369. */
  13370. initialize(state: NodeMaterialBuildState): void;
  13371. /**
  13372. * Bind data to effect. Will only be called for blocks with isBindable === true
  13373. * @param effect defines the effect to bind data to
  13374. * @param nodeMaterial defines the hosting NodeMaterial
  13375. * @param mesh defines the mesh that will be rendered
  13376. * @param subMesh defines the submesh that will be rendered
  13377. */
  13378. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13379. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13380. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13381. protected _writeFloat(value: number): string;
  13382. /**
  13383. * Gets the current class name e.g. "NodeMaterialBlock"
  13384. * @returns the class name
  13385. */
  13386. getClassName(): string;
  13387. /**
  13388. * Register a new input. Must be called inside a block constructor
  13389. * @param name defines the connection point name
  13390. * @param type defines the connection point type
  13391. * @param isOptional defines a boolean indicating that this input can be omitted
  13392. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13393. * @param point an already created connection point. If not provided, create a new one
  13394. * @returns the current block
  13395. */
  13396. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13397. /**
  13398. * Register a new output. Must be called inside a block constructor
  13399. * @param name defines the connection point name
  13400. * @param type defines the connection point type
  13401. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13402. * @param point an already created connection point. If not provided, create a new one
  13403. * @returns the current block
  13404. */
  13405. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13406. /**
  13407. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13408. * @param forOutput defines an optional connection point to check compatibility with
  13409. * @returns the first available input or null
  13410. */
  13411. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13412. /**
  13413. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13414. * @param forBlock defines an optional block to check compatibility with
  13415. * @returns the first available input or null
  13416. */
  13417. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13418. /**
  13419. * Gets the sibling of the given output
  13420. * @param current defines the current output
  13421. * @returns the next output in the list or null
  13422. */
  13423. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13424. /**
  13425. * Connect current block with another block
  13426. * @param other defines the block to connect with
  13427. * @param options define the various options to help pick the right connections
  13428. * @returns the current block
  13429. */
  13430. connectTo(other: NodeMaterialBlock, options?: {
  13431. input?: string;
  13432. output?: string;
  13433. outputSwizzle?: string;
  13434. }): this | undefined;
  13435. protected _buildBlock(state: NodeMaterialBuildState): void;
  13436. /**
  13437. * Add uniforms, samplers and uniform buffers at compilation time
  13438. * @param state defines the state to update
  13439. * @param nodeMaterial defines the node material requesting the update
  13440. * @param defines defines the material defines to update
  13441. * @param uniformBuffers defines the list of uniform buffer names
  13442. */
  13443. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13444. /**
  13445. * Add potential fallbacks if shader compilation fails
  13446. * @param mesh defines the mesh to be rendered
  13447. * @param fallbacks defines the current prioritized list of fallbacks
  13448. */
  13449. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13450. /**
  13451. * Initialize defines for shader compilation
  13452. * @param mesh defines the mesh to be rendered
  13453. * @param nodeMaterial defines the node material requesting the update
  13454. * @param defines defines the material defines to update
  13455. * @param useInstances specifies that instances should be used
  13456. */
  13457. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13458. /**
  13459. * Update defines for shader compilation
  13460. * @param mesh defines the mesh to be rendered
  13461. * @param nodeMaterial defines the node material requesting the update
  13462. * @param defines defines the material defines to update
  13463. * @param useInstances specifies that instances should be used
  13464. * @param subMesh defines which submesh to render
  13465. */
  13466. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13467. /**
  13468. * Lets the block try to connect some inputs automatically
  13469. * @param material defines the hosting NodeMaterial
  13470. */
  13471. autoConfigure(material: NodeMaterial): void;
  13472. /**
  13473. * Function called when a block is declared as repeatable content generator
  13474. * @param vertexShaderState defines the current compilation state for the vertex shader
  13475. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13476. * @param mesh defines the mesh to be rendered
  13477. * @param defines defines the material defines to update
  13478. */
  13479. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13480. /**
  13481. * Checks if the block is ready
  13482. * @param mesh defines the mesh to be rendered
  13483. * @param nodeMaterial defines the node material requesting the update
  13484. * @param defines defines the material defines to update
  13485. * @param useInstances specifies that instances should be used
  13486. * @returns true if the block is ready
  13487. */
  13488. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13489. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13490. private _processBuild;
  13491. /**
  13492. * Validates the new name for the block node.
  13493. * @param newName the new name to be given to the node.
  13494. * @returns false if the name is a reserve word, else true.
  13495. */
  13496. validateBlockName(newName: string): boolean;
  13497. /**
  13498. * Compile the current node and generate the shader code
  13499. * @param state defines the current compilation state (uniforms, samplers, current string)
  13500. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13501. * @returns true if already built
  13502. */
  13503. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13504. protected _inputRename(name: string): string;
  13505. protected _outputRename(name: string): string;
  13506. protected _dumpPropertiesCode(): string;
  13507. /** @hidden */
  13508. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13509. /** @hidden */
  13510. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13511. /**
  13512. * Clone the current block to a new identical block
  13513. * @param scene defines the hosting scene
  13514. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13515. * @returns a copy of the current block
  13516. */
  13517. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13518. /**
  13519. * Serializes this block in a JSON representation
  13520. * @returns the serialized block object
  13521. */
  13522. serialize(): any;
  13523. /** @hidden */
  13524. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13525. private _deserializePortDisplayNamesAndExposedOnFrame;
  13526. /**
  13527. * Release resources
  13528. */
  13529. dispose(): void;
  13530. }
  13531. }
  13532. declare module "babylonjs/Materials/pushMaterial" {
  13533. import { Nullable } from "babylonjs/types";
  13534. import { Scene } from "babylonjs/scene";
  13535. import { Matrix } from "babylonjs/Maths/math.vector";
  13536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13537. import { Mesh } from "babylonjs/Meshes/mesh";
  13538. import { Material } from "babylonjs/Materials/material";
  13539. import { Effect } from "babylonjs/Materials/effect";
  13540. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13541. /**
  13542. * Base class of materials working in push mode in babylon JS
  13543. * @hidden
  13544. */
  13545. export class PushMaterial extends Material {
  13546. protected _activeEffect: Effect;
  13547. protected _normalMatrix: Matrix;
  13548. constructor(name: string, scene: Scene);
  13549. getEffect(): Effect;
  13550. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13551. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13552. /**
  13553. * Binds the given world matrix to the active effect
  13554. *
  13555. * @param world the matrix to bind
  13556. */
  13557. bindOnlyWorldMatrix(world: Matrix): void;
  13558. /**
  13559. * Binds the given normal matrix to the active effect
  13560. *
  13561. * @param normalMatrix the matrix to bind
  13562. */
  13563. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13564. bind(world: Matrix, mesh?: Mesh): void;
  13565. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13566. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13567. }
  13568. }
  13569. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  13570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13571. /**
  13572. * Root class for all node material optimizers
  13573. */
  13574. export class NodeMaterialOptimizer {
  13575. /**
  13576. * Function used to optimize a NodeMaterial graph
  13577. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13578. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13579. */
  13580. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13581. }
  13582. }
  13583. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  13584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13587. import { Scene } from "babylonjs/scene";
  13588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13589. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  13590. import { SubMesh } from "babylonjs/Meshes/subMesh";
  13591. /**
  13592. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13593. */
  13594. export class TransformBlock extends NodeMaterialBlock {
  13595. /**
  13596. * Defines the value to use to complement W value to transform it to a Vector4
  13597. */
  13598. complementW: number;
  13599. /**
  13600. * Defines the value to use to complement z value to transform it to a Vector4
  13601. */
  13602. complementZ: number;
  13603. /**
  13604. * Creates a new TransformBlock
  13605. * @param name defines the block name
  13606. */
  13607. constructor(name: string);
  13608. /**
  13609. * Gets the current class name
  13610. * @returns the class name
  13611. */
  13612. getClassName(): string;
  13613. /**
  13614. * Gets the vector input
  13615. */
  13616. get vector(): NodeMaterialConnectionPoint;
  13617. /**
  13618. * Gets the output component
  13619. */
  13620. get output(): NodeMaterialConnectionPoint;
  13621. /**
  13622. * Gets the xyz output component
  13623. */
  13624. get xyz(): NodeMaterialConnectionPoint;
  13625. /**
  13626. * Gets the matrix transform input
  13627. */
  13628. get transform(): NodeMaterialConnectionPoint;
  13629. protected _buildBlock(state: NodeMaterialBuildState): this;
  13630. /**
  13631. * Update defines for shader compilation
  13632. * @param mesh defines the mesh to be rendered
  13633. * @param nodeMaterial defines the node material requesting the update
  13634. * @param defines defines the material defines to update
  13635. * @param useInstances specifies that instances should be used
  13636. * @param subMesh defines which submesh to render
  13637. */
  13638. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13639. serialize(): any;
  13640. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13641. protected _dumpPropertiesCode(): string;
  13642. }
  13643. }
  13644. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  13645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13648. /**
  13649. * Block used to output the vertex position
  13650. */
  13651. export class VertexOutputBlock extends NodeMaterialBlock {
  13652. /**
  13653. * Creates a new VertexOutputBlock
  13654. * @param name defines the block name
  13655. */
  13656. constructor(name: string);
  13657. /**
  13658. * Gets the current class name
  13659. * @returns the class name
  13660. */
  13661. getClassName(): string;
  13662. /**
  13663. * Gets the vector input component
  13664. */
  13665. get vector(): NodeMaterialConnectionPoint;
  13666. protected _buildBlock(state: NodeMaterialBuildState): this;
  13667. }
  13668. }
  13669. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  13670. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13672. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13673. /**
  13674. * Block used to output the final color
  13675. */
  13676. export class FragmentOutputBlock extends NodeMaterialBlock {
  13677. /**
  13678. * Create a new FragmentOutputBlock
  13679. * @param name defines the block name
  13680. */
  13681. constructor(name: string);
  13682. /**
  13683. * Gets the current class name
  13684. * @returns the class name
  13685. */
  13686. getClassName(): string;
  13687. /**
  13688. * Gets the rgba input component
  13689. */
  13690. get rgba(): NodeMaterialConnectionPoint;
  13691. /**
  13692. * Gets the rgb input component
  13693. */
  13694. get rgb(): NodeMaterialConnectionPoint;
  13695. /**
  13696. * Gets the a input component
  13697. */
  13698. get a(): NodeMaterialConnectionPoint;
  13699. protected _buildBlock(state: NodeMaterialBuildState): this;
  13700. }
  13701. }
  13702. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  13703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13704. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13705. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13706. /**
  13707. * Block used for the particle ramp gradient section
  13708. */
  13709. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13710. /**
  13711. * Create a new ParticleRampGradientBlock
  13712. * @param name defines the block name
  13713. */
  13714. constructor(name: string);
  13715. /**
  13716. * Gets the current class name
  13717. * @returns the class name
  13718. */
  13719. getClassName(): string;
  13720. /**
  13721. * Gets the color input component
  13722. */
  13723. get color(): NodeMaterialConnectionPoint;
  13724. /**
  13725. * Gets the rampColor output component
  13726. */
  13727. get rampColor(): NodeMaterialConnectionPoint;
  13728. /**
  13729. * Initialize the block and prepare the context for build
  13730. * @param state defines the state that will be used for the build
  13731. */
  13732. initialize(state: NodeMaterialBuildState): void;
  13733. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13734. }
  13735. }
  13736. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  13737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13740. /**
  13741. * Block used for the particle blend multiply section
  13742. */
  13743. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13744. /**
  13745. * Create a new ParticleBlendMultiplyBlock
  13746. * @param name defines the block name
  13747. */
  13748. constructor(name: string);
  13749. /**
  13750. * Gets the current class name
  13751. * @returns the class name
  13752. */
  13753. getClassName(): string;
  13754. /**
  13755. * Gets the color input component
  13756. */
  13757. get color(): NodeMaterialConnectionPoint;
  13758. /**
  13759. * Gets the alphaTexture input component
  13760. */
  13761. get alphaTexture(): NodeMaterialConnectionPoint;
  13762. /**
  13763. * Gets the alphaColor input component
  13764. */
  13765. get alphaColor(): NodeMaterialConnectionPoint;
  13766. /**
  13767. * Gets the blendColor output component
  13768. */
  13769. get blendColor(): NodeMaterialConnectionPoint;
  13770. /**
  13771. * Initialize the block and prepare the context for build
  13772. * @param state defines the state that will be used for the build
  13773. */
  13774. initialize(state: NodeMaterialBuildState): void;
  13775. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13776. }
  13777. }
  13778. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  13779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13782. /**
  13783. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13784. */
  13785. export class VectorMergerBlock extends NodeMaterialBlock {
  13786. /**
  13787. * Create a new VectorMergerBlock
  13788. * @param name defines the block name
  13789. */
  13790. constructor(name: string);
  13791. /**
  13792. * Gets the current class name
  13793. * @returns the class name
  13794. */
  13795. getClassName(): string;
  13796. /**
  13797. * Gets the xyz component (input)
  13798. */
  13799. get xyzIn(): NodeMaterialConnectionPoint;
  13800. /**
  13801. * Gets the xy component (input)
  13802. */
  13803. get xyIn(): NodeMaterialConnectionPoint;
  13804. /**
  13805. * Gets the x component (input)
  13806. */
  13807. get x(): NodeMaterialConnectionPoint;
  13808. /**
  13809. * Gets the y component (input)
  13810. */
  13811. get y(): NodeMaterialConnectionPoint;
  13812. /**
  13813. * Gets the z component (input)
  13814. */
  13815. get z(): NodeMaterialConnectionPoint;
  13816. /**
  13817. * Gets the w component (input)
  13818. */
  13819. get w(): NodeMaterialConnectionPoint;
  13820. /**
  13821. * Gets the xyzw component (output)
  13822. */
  13823. get xyzw(): NodeMaterialConnectionPoint;
  13824. /**
  13825. * Gets the xyz component (output)
  13826. */
  13827. get xyzOut(): NodeMaterialConnectionPoint;
  13828. /**
  13829. * Gets the xy component (output)
  13830. */
  13831. get xyOut(): NodeMaterialConnectionPoint;
  13832. /**
  13833. * Gets the xy component (output)
  13834. * @deprecated Please use xyOut instead.
  13835. */
  13836. get xy(): NodeMaterialConnectionPoint;
  13837. /**
  13838. * Gets the xyz component (output)
  13839. * @deprecated Please use xyzOut instead.
  13840. */
  13841. get xyz(): NodeMaterialConnectionPoint;
  13842. protected _buildBlock(state: NodeMaterialBuildState): this;
  13843. }
  13844. }
  13845. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  13846. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13847. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13848. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13849. import { Vector2 } from "babylonjs/Maths/math.vector";
  13850. import { Scene } from "babylonjs/scene";
  13851. /**
  13852. * Block used to remap a float from a range to a new one
  13853. */
  13854. export class RemapBlock extends NodeMaterialBlock {
  13855. /**
  13856. * Gets or sets the source range
  13857. */
  13858. sourceRange: Vector2;
  13859. /**
  13860. * Gets or sets the target range
  13861. */
  13862. targetRange: Vector2;
  13863. /**
  13864. * Creates a new RemapBlock
  13865. * @param name defines the block name
  13866. */
  13867. constructor(name: string);
  13868. /**
  13869. * Gets the current class name
  13870. * @returns the class name
  13871. */
  13872. getClassName(): string;
  13873. /**
  13874. * Gets the input component
  13875. */
  13876. get input(): NodeMaterialConnectionPoint;
  13877. /**
  13878. * Gets the source min input component
  13879. */
  13880. get sourceMin(): NodeMaterialConnectionPoint;
  13881. /**
  13882. * Gets the source max input component
  13883. */
  13884. get sourceMax(): NodeMaterialConnectionPoint;
  13885. /**
  13886. * Gets the target min input component
  13887. */
  13888. get targetMin(): NodeMaterialConnectionPoint;
  13889. /**
  13890. * Gets the target max input component
  13891. */
  13892. get targetMax(): NodeMaterialConnectionPoint;
  13893. /**
  13894. * Gets the output component
  13895. */
  13896. get output(): NodeMaterialConnectionPoint;
  13897. protected _buildBlock(state: NodeMaterialBuildState): this;
  13898. protected _dumpPropertiesCode(): string;
  13899. serialize(): any;
  13900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13901. }
  13902. }
  13903. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  13904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  13905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  13906. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  13907. /**
  13908. * Block used to multiply 2 values
  13909. */
  13910. export class MultiplyBlock extends NodeMaterialBlock {
  13911. /**
  13912. * Creates a new MultiplyBlock
  13913. * @param name defines the block name
  13914. */
  13915. constructor(name: string);
  13916. /**
  13917. * Gets the current class name
  13918. * @returns the class name
  13919. */
  13920. getClassName(): string;
  13921. /**
  13922. * Gets the left operand input component
  13923. */
  13924. get left(): NodeMaterialConnectionPoint;
  13925. /**
  13926. * Gets the right operand input component
  13927. */
  13928. get right(): NodeMaterialConnectionPoint;
  13929. /**
  13930. * Gets the output component
  13931. */
  13932. get output(): NodeMaterialConnectionPoint;
  13933. protected _buildBlock(state: NodeMaterialBuildState): this;
  13934. }
  13935. }
  13936. declare module "babylonjs/Misc/gradients" {
  13937. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13938. /** Interface used by value gradients (color, factor, ...) */
  13939. export interface IValueGradient {
  13940. /**
  13941. * Gets or sets the gradient value (between 0 and 1)
  13942. */
  13943. gradient: number;
  13944. }
  13945. /** Class used to store color4 gradient */
  13946. export class ColorGradient implements IValueGradient {
  13947. /**
  13948. * Gets or sets the gradient value (between 0 and 1)
  13949. */
  13950. gradient: number;
  13951. /**
  13952. * Gets or sets first associated color
  13953. */
  13954. color1: Color4;
  13955. /**
  13956. * Gets or sets second associated color
  13957. */
  13958. color2?: Color4 | undefined;
  13959. /**
  13960. * Creates a new color4 gradient
  13961. * @param gradient gets or sets the gradient value (between 0 and 1)
  13962. * @param color1 gets or sets first associated color
  13963. * @param color2 gets or sets first second color
  13964. */
  13965. constructor(
  13966. /**
  13967. * Gets or sets the gradient value (between 0 and 1)
  13968. */
  13969. gradient: number,
  13970. /**
  13971. * Gets or sets first associated color
  13972. */
  13973. color1: Color4,
  13974. /**
  13975. * Gets or sets second associated color
  13976. */
  13977. color2?: Color4 | undefined);
  13978. /**
  13979. * Will get a color picked randomly between color1 and color2.
  13980. * If color2 is undefined then color1 will be used
  13981. * @param result defines the target Color4 to store the result in
  13982. */
  13983. getColorToRef(result: Color4): void;
  13984. }
  13985. /** Class used to store color 3 gradient */
  13986. export class Color3Gradient implements IValueGradient {
  13987. /**
  13988. * Gets or sets the gradient value (between 0 and 1)
  13989. */
  13990. gradient: number;
  13991. /**
  13992. * Gets or sets the associated color
  13993. */
  13994. color: Color3;
  13995. /**
  13996. * Creates a new color3 gradient
  13997. * @param gradient gets or sets the gradient value (between 0 and 1)
  13998. * @param color gets or sets associated color
  13999. */
  14000. constructor(
  14001. /**
  14002. * Gets or sets the gradient value (between 0 and 1)
  14003. */
  14004. gradient: number,
  14005. /**
  14006. * Gets or sets the associated color
  14007. */
  14008. color: Color3);
  14009. }
  14010. /** Class used to store factor gradient */
  14011. export class FactorGradient implements IValueGradient {
  14012. /**
  14013. * Gets or sets the gradient value (between 0 and 1)
  14014. */
  14015. gradient: number;
  14016. /**
  14017. * Gets or sets first associated factor
  14018. */
  14019. factor1: number;
  14020. /**
  14021. * Gets or sets second associated factor
  14022. */
  14023. factor2?: number | undefined;
  14024. /**
  14025. * Creates a new factor gradient
  14026. * @param gradient gets or sets the gradient value (between 0 and 1)
  14027. * @param factor1 gets or sets first associated factor
  14028. * @param factor2 gets or sets second associated factor
  14029. */
  14030. constructor(
  14031. /**
  14032. * Gets or sets the gradient value (between 0 and 1)
  14033. */
  14034. gradient: number,
  14035. /**
  14036. * Gets or sets first associated factor
  14037. */
  14038. factor1: number,
  14039. /**
  14040. * Gets or sets second associated factor
  14041. */
  14042. factor2?: number | undefined);
  14043. /**
  14044. * Will get a number picked randomly between factor1 and factor2.
  14045. * If factor2 is undefined then factor1 will be used
  14046. * @returns the picked number
  14047. */
  14048. getFactor(): number;
  14049. }
  14050. /**
  14051. * Helper used to simplify some generic gradient tasks
  14052. */
  14053. export class GradientHelper {
  14054. /**
  14055. * Gets the current gradient from an array of IValueGradient
  14056. * @param ratio defines the current ratio to get
  14057. * @param gradients defines the array of IValueGradient
  14058. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14059. */
  14060. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14061. }
  14062. }
  14063. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  14064. import { Nullable } from "babylonjs/types";
  14065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14066. import { Scene } from "babylonjs/scene";
  14067. module "babylonjs/Engines/thinEngine" {
  14068. interface ThinEngine {
  14069. /**
  14070. * Creates a raw texture
  14071. * @param data defines the data to store in the texture
  14072. * @param width defines the width of the texture
  14073. * @param height defines the height of the texture
  14074. * @param format defines the format of the data
  14075. * @param generateMipMaps defines if the engine should generate the mip levels
  14076. * @param invertY defines if data must be stored with Y axis inverted
  14077. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14078. * @param compression defines the compression used (null by default)
  14079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14080. * @returns the raw texture inside an InternalTexture
  14081. */
  14082. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14083. /**
  14084. * Update a raw texture
  14085. * @param texture defines the texture to update
  14086. * @param data defines the data to store in the texture
  14087. * @param format defines the format of the data
  14088. * @param invertY defines if data must be stored with Y axis inverted
  14089. */
  14090. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14091. /**
  14092. * Update a raw texture
  14093. * @param texture defines the texture to update
  14094. * @param data defines the data to store in the texture
  14095. * @param format defines the format of the data
  14096. * @param invertY defines if data must be stored with Y axis inverted
  14097. * @param compression defines the compression used (null by default)
  14098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14099. */
  14100. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14101. /**
  14102. * Creates a new raw cube texture
  14103. * @param data defines the array of data to use to create each face
  14104. * @param size defines the size of the textures
  14105. * @param format defines the format of the data
  14106. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14107. * @param generateMipMaps defines if the engine should generate the mip levels
  14108. * @param invertY defines if data must be stored with Y axis inverted
  14109. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14110. * @param compression defines the compression used (null by default)
  14111. * @returns the cube texture as an InternalTexture
  14112. */
  14113. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14114. /**
  14115. * Update a raw cube texture
  14116. * @param texture defines the texture to udpdate
  14117. * @param data defines the data to store
  14118. * @param format defines the data format
  14119. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14120. * @param invertY defines if data must be stored with Y axis inverted
  14121. */
  14122. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14123. /**
  14124. * Update a raw cube texture
  14125. * @param texture defines the texture to udpdate
  14126. * @param data defines the data to store
  14127. * @param format defines the data format
  14128. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14129. * @param invertY defines if data must be stored with Y axis inverted
  14130. * @param compression defines the compression used (null by default)
  14131. */
  14132. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14133. /**
  14134. * Update a raw cube texture
  14135. * @param texture defines the texture to udpdate
  14136. * @param data defines the data to store
  14137. * @param format defines the data format
  14138. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14139. * @param invertY defines if data must be stored with Y axis inverted
  14140. * @param compression defines the compression used (null by default)
  14141. * @param level defines which level of the texture to update
  14142. */
  14143. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14144. /**
  14145. * Creates a new raw cube texture from a specified url
  14146. * @param url defines the url where the data is located
  14147. * @param scene defines the current scene
  14148. * @param size defines the size of the textures
  14149. * @param format defines the format of the data
  14150. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14151. * @param noMipmap defines if the engine should avoid generating the mip levels
  14152. * @param callback defines a callback used to extract texture data from loaded data
  14153. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14154. * @param onLoad defines a callback called when texture is loaded
  14155. * @param onError defines a callback called if there is an error
  14156. * @returns the cube texture as an InternalTexture
  14157. */
  14158. 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;
  14159. /**
  14160. * Creates a new raw cube texture from a specified url
  14161. * @param url defines the url where the data is located
  14162. * @param scene defines the current scene
  14163. * @param size defines the size of the textures
  14164. * @param format defines the format of the data
  14165. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14166. * @param noMipmap defines if the engine should avoid generating the mip levels
  14167. * @param callback defines a callback used to extract texture data from loaded data
  14168. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14169. * @param onLoad defines a callback called when texture is loaded
  14170. * @param onError defines a callback called if there is an error
  14171. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14172. * @param invertY defines if data must be stored with Y axis inverted
  14173. * @returns the cube texture as an InternalTexture
  14174. */
  14175. 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;
  14176. /**
  14177. * Creates a new raw 3D texture
  14178. * @param data defines the data used to create the texture
  14179. * @param width defines the width of the texture
  14180. * @param height defines the height of the texture
  14181. * @param depth defines the depth of the texture
  14182. * @param format defines the format of the texture
  14183. * @param generateMipMaps defines if the engine must generate mip levels
  14184. * @param invertY defines if data must be stored with Y axis inverted
  14185. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14186. * @param compression defines the compressed used (can be null)
  14187. * @param textureType defines the compressed used (can be null)
  14188. * @returns a new raw 3D texture (stored in an InternalTexture)
  14189. */
  14190. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14191. /**
  14192. * Update a raw 3D texture
  14193. * @param texture defines the texture to update
  14194. * @param data defines the data to store
  14195. * @param format defines the data format
  14196. * @param invertY defines if data must be stored with Y axis inverted
  14197. */
  14198. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14199. /**
  14200. * Update a raw 3D texture
  14201. * @param texture defines the texture to update
  14202. * @param data defines the data to store
  14203. * @param format defines the data format
  14204. * @param invertY defines if data must be stored with Y axis inverted
  14205. * @param compression defines the used compression (can be null)
  14206. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14207. */
  14208. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14209. /**
  14210. * Creates a new raw 2D array texture
  14211. * @param data defines the data used to create the texture
  14212. * @param width defines the width of the texture
  14213. * @param height defines the height of the texture
  14214. * @param depth defines the number of layers of the texture
  14215. * @param format defines the format of the texture
  14216. * @param generateMipMaps defines if the engine must generate mip levels
  14217. * @param invertY defines if data must be stored with Y axis inverted
  14218. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14219. * @param compression defines the compressed used (can be null)
  14220. * @param textureType defines the compressed used (can be null)
  14221. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14222. */
  14223. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14224. /**
  14225. * Update a raw 2D array texture
  14226. * @param texture defines the texture to update
  14227. * @param data defines the data to store
  14228. * @param format defines the data format
  14229. * @param invertY defines if data must be stored with Y axis inverted
  14230. */
  14231. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14232. /**
  14233. * Update a raw 2D array texture
  14234. * @param texture defines the texture to update
  14235. * @param data defines the data to store
  14236. * @param format defines the data format
  14237. * @param invertY defines if data must be stored with Y axis inverted
  14238. * @param compression defines the used compression (can be null)
  14239. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14240. */
  14241. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14242. }
  14243. }
  14244. }
  14245. declare module "babylonjs/Materials/Textures/rawTexture" {
  14246. import { Texture } from "babylonjs/Materials/Textures/texture";
  14247. import "babylonjs/Engines/Extensions/engine.rawTexture";
  14248. import { Nullable } from "babylonjs/types";
  14249. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14250. import { Scene } from "babylonjs/scene";
  14251. /**
  14252. * Raw texture can help creating a texture directly from an array of data.
  14253. * This can be super useful if you either get the data from an uncompressed source or
  14254. * if you wish to create your texture pixel by pixel.
  14255. */
  14256. export class RawTexture extends Texture {
  14257. /**
  14258. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14259. */
  14260. format: number;
  14261. /**
  14262. * Instantiates a new RawTexture.
  14263. * Raw texture can help creating a texture directly from an array of data.
  14264. * This can be super useful if you either get the data from an uncompressed source or
  14265. * if you wish to create your texture pixel by pixel.
  14266. * @param data define the array of data to use to create the texture
  14267. * @param width define the width of the texture
  14268. * @param height define the height of the texture
  14269. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14270. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14271. * @param generateMipMaps define whether mip maps should be generated or not
  14272. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14273. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14274. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14275. */
  14276. constructor(data: ArrayBufferView, width: number, height: number,
  14277. /**
  14278. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14279. */
  14280. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14281. /**
  14282. * Updates the texture underlying data.
  14283. * @param data Define the new data of the texture
  14284. */
  14285. update(data: ArrayBufferView): void;
  14286. /**
  14287. * Creates a luminance texture from some data.
  14288. * @param data Define the texture data
  14289. * @param width Define the width of the texture
  14290. * @param height Define the height of the texture
  14291. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14292. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14293. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14294. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14295. * @returns the luminance texture
  14296. */
  14297. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14298. /**
  14299. * Creates a luminance alpha texture from some data.
  14300. * @param data Define the texture data
  14301. * @param width Define the width of the texture
  14302. * @param height Define the height of the texture
  14303. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14304. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14305. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14306. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14307. * @returns the luminance alpha texture
  14308. */
  14309. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14310. /**
  14311. * Creates an alpha texture from some data.
  14312. * @param data Define the texture data
  14313. * @param width Define the width of the texture
  14314. * @param height Define the height of the texture
  14315. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14316. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14317. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14318. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14319. * @returns the alpha texture
  14320. */
  14321. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14322. /**
  14323. * Creates a RGB texture from some data.
  14324. * @param data Define the texture data
  14325. * @param width Define the width of the texture
  14326. * @param height Define the height of the texture
  14327. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14328. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14329. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14330. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14331. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14332. * @returns the RGB alpha texture
  14333. */
  14334. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14335. /**
  14336. * Creates a RGBA texture from some data.
  14337. * @param data Define the texture data
  14338. * @param width Define the width of the texture
  14339. * @param height Define the height of the texture
  14340. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14341. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14342. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14343. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14344. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14345. * @returns the RGBA texture
  14346. */
  14347. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14348. /**
  14349. * Creates a R texture from some data.
  14350. * @param data Define the texture data
  14351. * @param width Define the width of the texture
  14352. * @param height Define the height of the texture
  14353. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14354. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14355. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14356. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14357. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14358. * @returns the R texture
  14359. */
  14360. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14361. }
  14362. }
  14363. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  14364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  14365. import { IndicesArray, DataArray } from "babylonjs/types";
  14366. module "babylonjs/Engines/thinEngine" {
  14367. interface ThinEngine {
  14368. /**
  14369. * Update a dynamic index buffer
  14370. * @param indexBuffer defines the target index buffer
  14371. * @param indices defines the data to update
  14372. * @param offset defines the offset in the target index buffer where update should start
  14373. */
  14374. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14375. /**
  14376. * Updates a dynamic vertex buffer.
  14377. * @param vertexBuffer the vertex buffer to update
  14378. * @param data the data used to update the vertex buffer
  14379. * @param byteOffset the byte offset of the data
  14380. * @param byteLength the byte length of the data
  14381. */
  14382. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14383. }
  14384. }
  14385. }
  14386. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14387. import { Scene } from "babylonjs/scene";
  14388. import { ISceneComponent } from "babylonjs/sceneComponent";
  14389. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14390. module "babylonjs/abstractScene" {
  14391. interface AbstractScene {
  14392. /**
  14393. * The list of procedural textures added to the scene
  14394. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14395. */
  14396. proceduralTextures: Array<ProceduralTexture>;
  14397. }
  14398. }
  14399. /**
  14400. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14401. * in a given scene.
  14402. */
  14403. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14404. /**
  14405. * The component name helpfull to identify the component in the list of scene components.
  14406. */
  14407. readonly name: string;
  14408. /**
  14409. * The scene the component belongs to.
  14410. */
  14411. scene: Scene;
  14412. /**
  14413. * Creates a new instance of the component for the given scene
  14414. * @param scene Defines the scene to register the component in
  14415. */
  14416. constructor(scene: Scene);
  14417. /**
  14418. * Registers the component in a given scene
  14419. */
  14420. register(): void;
  14421. /**
  14422. * Rebuilds the elements related to this component in case of
  14423. * context lost for instance.
  14424. */
  14425. rebuild(): void;
  14426. /**
  14427. * Disposes the component and the associated ressources.
  14428. */
  14429. dispose(): void;
  14430. private _beforeClear;
  14431. }
  14432. }
  14433. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  14434. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14435. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14436. module "babylonjs/Engines/thinEngine" {
  14437. interface ThinEngine {
  14438. /**
  14439. * Creates a new render target cube texture
  14440. * @param size defines the size of the texture
  14441. * @param options defines the options used to create the texture
  14442. * @returns a new render target cube texture stored in an InternalTexture
  14443. */
  14444. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14445. }
  14446. }
  14447. }
  14448. declare module "babylonjs/Shaders/procedural.vertex" {
  14449. /** @hidden */
  14450. export var proceduralVertexShader: {
  14451. name: string;
  14452. shader: string;
  14453. };
  14454. }
  14455. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14456. import { Observable } from "babylonjs/Misc/observable";
  14457. import { Nullable } from "babylonjs/types";
  14458. import { Scene } from "babylonjs/scene";
  14459. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  14460. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  14461. import { Effect } from "babylonjs/Materials/effect";
  14462. import { Texture } from "babylonjs/Materials/Textures/texture";
  14463. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14464. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  14465. import "babylonjs/Shaders/procedural.vertex";
  14466. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  14467. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  14468. /**
  14469. * 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.
  14470. * This is the base class of any Procedural texture and contains most of the shareable code.
  14471. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14472. */
  14473. export class ProceduralTexture extends Texture {
  14474. /**
  14475. * Define if the texture is enabled or not (disabled texture will not render)
  14476. */
  14477. isEnabled: boolean;
  14478. /**
  14479. * Define if the texture must be cleared before rendering (default is true)
  14480. */
  14481. autoClear: boolean;
  14482. /**
  14483. * Callback called when the texture is generated
  14484. */
  14485. onGenerated: () => void;
  14486. /**
  14487. * Event raised when the texture is generated
  14488. */
  14489. onGeneratedObservable: Observable<ProceduralTexture>;
  14490. /**
  14491. * Event raised before the texture is generated
  14492. */
  14493. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14494. /**
  14495. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14496. */
  14497. nodeMaterialSource: Nullable<NodeMaterial>;
  14498. /** @hidden */
  14499. _generateMipMaps: boolean;
  14500. /** @hidden **/
  14501. _effect: Effect;
  14502. /** @hidden */
  14503. _textures: {
  14504. [key: string]: Texture;
  14505. };
  14506. /** @hidden */
  14507. protected _fallbackTexture: Nullable<Texture>;
  14508. private _size;
  14509. private _currentRefreshId;
  14510. private _frameId;
  14511. private _refreshRate;
  14512. private _vertexBuffers;
  14513. private _indexBuffer;
  14514. private _uniforms;
  14515. private _samplers;
  14516. private _fragment;
  14517. private _floats;
  14518. private _ints;
  14519. private _floatsArrays;
  14520. private _colors3;
  14521. private _colors4;
  14522. private _vectors2;
  14523. private _vectors3;
  14524. private _matrices;
  14525. private _fallbackTextureUsed;
  14526. private _fullEngine;
  14527. private _cachedDefines;
  14528. private _contentUpdateId;
  14529. private _contentData;
  14530. /**
  14531. * Instantiates a new procedural texture.
  14532. * 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.
  14533. * This is the base class of any Procedural texture and contains most of the shareable code.
  14534. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14535. * @param name Define the name of the texture
  14536. * @param size Define the size of the texture to create
  14537. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14538. * @param scene Define the scene the texture belongs to
  14539. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14540. * @param generateMipMaps Define if the texture should creates mip maps or not
  14541. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14542. * @param textureType The FBO internal texture type
  14543. */
  14544. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14545. /**
  14546. * The effect that is created when initializing the post process.
  14547. * @returns The created effect corresponding the the postprocess.
  14548. */
  14549. getEffect(): Effect;
  14550. /**
  14551. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14552. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14553. */
  14554. getContent(): Nullable<ArrayBufferView>;
  14555. private _createIndexBuffer;
  14556. /** @hidden */
  14557. _rebuild(): void;
  14558. /**
  14559. * Resets the texture in order to recreate its associated resources.
  14560. * This can be called in case of context loss
  14561. */
  14562. reset(): void;
  14563. protected _getDefines(): string;
  14564. /**
  14565. * Is the texture ready to be used ? (rendered at least once)
  14566. * @returns true if ready, otherwise, false.
  14567. */
  14568. isReady(): boolean;
  14569. /**
  14570. * Resets the refresh counter of the texture and start bak from scratch.
  14571. * Could be useful to regenerate the texture if it is setup to render only once.
  14572. */
  14573. resetRefreshCounter(): void;
  14574. /**
  14575. * Set the fragment shader to use in order to render the texture.
  14576. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14577. */
  14578. setFragment(fragment: any): void;
  14579. /**
  14580. * Define the refresh rate of the texture or the rendering frequency.
  14581. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14582. */
  14583. get refreshRate(): number;
  14584. set refreshRate(value: number);
  14585. /** @hidden */
  14586. _shouldRender(): boolean;
  14587. /**
  14588. * Get the size the texture is rendering at.
  14589. * @returns the size (on cube texture it is always squared)
  14590. */
  14591. getRenderSize(): RenderTargetTextureSize;
  14592. /**
  14593. * Resize the texture to new value.
  14594. * @param size Define the new size the texture should have
  14595. * @param generateMipMaps Define whether the new texture should create mip maps
  14596. */
  14597. resize(size: number, generateMipMaps: boolean): void;
  14598. private _checkUniform;
  14599. /**
  14600. * Set a texture in the shader program used to render.
  14601. * @param name Define the name of the uniform samplers as defined in the shader
  14602. * @param texture Define the texture to bind to this sampler
  14603. * @return the texture itself allowing "fluent" like uniform updates
  14604. */
  14605. setTexture(name: string, texture: Texture): ProceduralTexture;
  14606. /**
  14607. * Set a float in the shader.
  14608. * @param name Define the name of the uniform as defined in the shader
  14609. * @param value Define the value to give to the uniform
  14610. * @return the texture itself allowing "fluent" like uniform updates
  14611. */
  14612. setFloat(name: string, value: number): ProceduralTexture;
  14613. /**
  14614. * Set a int in the shader.
  14615. * @param name Define the name of the uniform as defined in the shader
  14616. * @param value Define the value to give to the uniform
  14617. * @return the texture itself allowing "fluent" like uniform updates
  14618. */
  14619. setInt(name: string, value: number): ProceduralTexture;
  14620. /**
  14621. * Set an array of floats in the shader.
  14622. * @param name Define the name of the uniform as defined in the shader
  14623. * @param value Define the value to give to the uniform
  14624. * @return the texture itself allowing "fluent" like uniform updates
  14625. */
  14626. setFloats(name: string, value: number[]): ProceduralTexture;
  14627. /**
  14628. * Set a vec3 in the shader from a Color3.
  14629. * @param name Define the name of the uniform as defined in the shader
  14630. * @param value Define the value to give to the uniform
  14631. * @return the texture itself allowing "fluent" like uniform updates
  14632. */
  14633. setColor3(name: string, value: Color3): ProceduralTexture;
  14634. /**
  14635. * Set a vec4 in the shader from a Color4.
  14636. * @param name Define the name of the uniform as defined in the shader
  14637. * @param value Define the value to give to the uniform
  14638. * @return the texture itself allowing "fluent" like uniform updates
  14639. */
  14640. setColor4(name: string, value: Color4): ProceduralTexture;
  14641. /**
  14642. * Set a vec2 in the shader from a Vector2.
  14643. * @param name Define the name of the uniform as defined in the shader
  14644. * @param value Define the value to give to the uniform
  14645. * @return the texture itself allowing "fluent" like uniform updates
  14646. */
  14647. setVector2(name: string, value: Vector2): ProceduralTexture;
  14648. /**
  14649. * Set a vec3 in the shader from a Vector3.
  14650. * @param name Define the name of the uniform as defined in the shader
  14651. * @param value Define the value to give to the uniform
  14652. * @return the texture itself allowing "fluent" like uniform updates
  14653. */
  14654. setVector3(name: string, value: Vector3): ProceduralTexture;
  14655. /**
  14656. * Set a mat4 in the shader from a MAtrix.
  14657. * @param name Define the name of the uniform as defined in the shader
  14658. * @param value Define the value to give to the uniform
  14659. * @return the texture itself allowing "fluent" like uniform updates
  14660. */
  14661. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14662. /**
  14663. * Render the texture to its associated render target.
  14664. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14665. */
  14666. render(useCameraPostProcess?: boolean): void;
  14667. /**
  14668. * Clone the texture.
  14669. * @returns the cloned texture
  14670. */
  14671. clone(): ProceduralTexture;
  14672. /**
  14673. * Dispose the texture and release its asoociated resources.
  14674. */
  14675. dispose(): void;
  14676. }
  14677. }
  14678. declare module "babylonjs/Particles/baseParticleSystem" {
  14679. import { Nullable } from "babylonjs/types";
  14680. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14682. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14683. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  14684. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14686. import { Color4 } from "babylonjs/Maths/math.color";
  14687. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  14688. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  14689. import { Animation } from "babylonjs/Animations/animation";
  14690. import { Scene } from "babylonjs/scene";
  14691. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14692. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14693. /**
  14694. * This represents the base class for particle system in Babylon.
  14695. * 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.
  14696. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14697. * @example https://doc.babylonjs.com/babylon101/particles
  14698. */
  14699. export class BaseParticleSystem {
  14700. /**
  14701. * Source color is added to the destination color without alpha affecting the result
  14702. */
  14703. static BLENDMODE_ONEONE: number;
  14704. /**
  14705. * Blend current color and particle color using particle’s alpha
  14706. */
  14707. static BLENDMODE_STANDARD: number;
  14708. /**
  14709. * Add current color and particle color multiplied by particle’s alpha
  14710. */
  14711. static BLENDMODE_ADD: number;
  14712. /**
  14713. * Multiply current color with particle color
  14714. */
  14715. static BLENDMODE_MULTIPLY: number;
  14716. /**
  14717. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14718. */
  14719. static BLENDMODE_MULTIPLYADD: number;
  14720. /**
  14721. * List of animations used by the particle system.
  14722. */
  14723. animations: Animation[];
  14724. /**
  14725. * Gets or sets the unique id of the particle system
  14726. */
  14727. uniqueId: number;
  14728. /**
  14729. * The id of the Particle system.
  14730. */
  14731. id: string;
  14732. /**
  14733. * The friendly name of the Particle system.
  14734. */
  14735. name: string;
  14736. /**
  14737. * Snippet ID if the particle system was created from the snippet server
  14738. */
  14739. snippetId: string;
  14740. /**
  14741. * The rendering group used by the Particle system to chose when to render.
  14742. */
  14743. renderingGroupId: number;
  14744. /**
  14745. * The emitter represents the Mesh or position we are attaching the particle system to.
  14746. */
  14747. emitter: Nullable<AbstractMesh | Vector3>;
  14748. /**
  14749. * The maximum number of particles to emit per frame
  14750. */
  14751. emitRate: number;
  14752. /**
  14753. * If you want to launch only a few particles at once, that can be done, as well.
  14754. */
  14755. manualEmitCount: number;
  14756. /**
  14757. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14758. */
  14759. updateSpeed: number;
  14760. /**
  14761. * The amount of time the particle system is running (depends of the overall update speed).
  14762. */
  14763. targetStopDuration: number;
  14764. /**
  14765. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14766. */
  14767. disposeOnStop: boolean;
  14768. /**
  14769. * Minimum power of emitting particles.
  14770. */
  14771. minEmitPower: number;
  14772. /**
  14773. * Maximum power of emitting particles.
  14774. */
  14775. maxEmitPower: number;
  14776. /**
  14777. * Minimum life time of emitting particles.
  14778. */
  14779. minLifeTime: number;
  14780. /**
  14781. * Maximum life time of emitting particles.
  14782. */
  14783. maxLifeTime: number;
  14784. /**
  14785. * Minimum Size of emitting particles.
  14786. */
  14787. minSize: number;
  14788. /**
  14789. * Maximum Size of emitting particles.
  14790. */
  14791. maxSize: number;
  14792. /**
  14793. * Minimum scale of emitting particles on X axis.
  14794. */
  14795. minScaleX: number;
  14796. /**
  14797. * Maximum scale of emitting particles on X axis.
  14798. */
  14799. maxScaleX: number;
  14800. /**
  14801. * Minimum scale of emitting particles on Y axis.
  14802. */
  14803. minScaleY: number;
  14804. /**
  14805. * Maximum scale of emitting particles on Y axis.
  14806. */
  14807. maxScaleY: number;
  14808. /**
  14809. * Gets or sets the minimal initial rotation in radians.
  14810. */
  14811. minInitialRotation: number;
  14812. /**
  14813. * Gets or sets the maximal initial rotation in radians.
  14814. */
  14815. maxInitialRotation: number;
  14816. /**
  14817. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14818. */
  14819. minAngularSpeed: number;
  14820. /**
  14821. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14822. */
  14823. maxAngularSpeed: number;
  14824. /**
  14825. * The texture used to render each particle. (this can be a spritesheet)
  14826. */
  14827. particleTexture: Nullable<BaseTexture>;
  14828. /**
  14829. * The layer mask we are rendering the particles through.
  14830. */
  14831. layerMask: number;
  14832. /**
  14833. * This can help using your own shader to render the particle system.
  14834. * The according effect will be created
  14835. */
  14836. customShader: any;
  14837. /**
  14838. * By default particle system starts as soon as they are created. This prevents the
  14839. * automatic start to happen and let you decide when to start emitting particles.
  14840. */
  14841. preventAutoStart: boolean;
  14842. private _noiseTexture;
  14843. /**
  14844. * Gets or sets a texture used to add random noise to particle positions
  14845. */
  14846. get noiseTexture(): Nullable<ProceduralTexture>;
  14847. set noiseTexture(value: Nullable<ProceduralTexture>);
  14848. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14849. noiseStrength: Vector3;
  14850. /**
  14851. * Callback triggered when the particle animation is ending.
  14852. */
  14853. onAnimationEnd: Nullable<() => void>;
  14854. /**
  14855. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14856. */
  14857. blendMode: number;
  14858. /**
  14859. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14860. * to override the particles.
  14861. */
  14862. forceDepthWrite: boolean;
  14863. /** 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 */
  14864. preWarmCycles: number;
  14865. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14866. preWarmStepOffset: number;
  14867. /**
  14868. * 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)
  14869. */
  14870. spriteCellChangeSpeed: number;
  14871. /**
  14872. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14873. */
  14874. startSpriteCellID: number;
  14875. /**
  14876. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14877. */
  14878. endSpriteCellID: number;
  14879. /**
  14880. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14881. */
  14882. spriteCellWidth: number;
  14883. /**
  14884. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14885. */
  14886. spriteCellHeight: number;
  14887. /**
  14888. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14889. */
  14890. spriteRandomStartCell: boolean;
  14891. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14892. translationPivot: Vector2;
  14893. /** @hidden */
  14894. protected _isAnimationSheetEnabled: boolean;
  14895. /**
  14896. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14897. */
  14898. beginAnimationOnStart: boolean;
  14899. /**
  14900. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14901. */
  14902. beginAnimationFrom: number;
  14903. /**
  14904. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14905. */
  14906. beginAnimationTo: number;
  14907. /**
  14908. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14909. */
  14910. beginAnimationLoop: boolean;
  14911. /**
  14912. * Gets or sets a world offset applied to all particles
  14913. */
  14914. worldOffset: Vector3;
  14915. /**
  14916. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14917. */
  14918. get isAnimationSheetEnabled(): boolean;
  14919. set isAnimationSheetEnabled(value: boolean);
  14920. /**
  14921. * Get hosting scene
  14922. * @returns the scene
  14923. */
  14924. getScene(): Nullable<Scene>;
  14925. /**
  14926. * You can use gravity if you want to give an orientation to your particles.
  14927. */
  14928. gravity: Vector3;
  14929. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14930. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14931. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14932. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14933. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14934. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14935. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14936. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14937. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14938. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14939. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14940. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14941. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14942. /**
  14943. * Defines the delay in milliseconds before starting the system (0 by default)
  14944. */
  14945. startDelay: number;
  14946. /**
  14947. * Gets the current list of drag gradients.
  14948. * You must use addDragGradient and removeDragGradient to udpate this list
  14949. * @returns the list of drag gradients
  14950. */
  14951. getDragGradients(): Nullable<Array<FactorGradient>>;
  14952. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14953. limitVelocityDamping: number;
  14954. /**
  14955. * Gets the current list of limit velocity gradients.
  14956. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14957. * @returns the list of limit velocity gradients
  14958. */
  14959. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14960. /**
  14961. * Gets the current list of color gradients.
  14962. * You must use addColorGradient and removeColorGradient to udpate this list
  14963. * @returns the list of color gradients
  14964. */
  14965. getColorGradients(): Nullable<Array<ColorGradient>>;
  14966. /**
  14967. * Gets the current list of size gradients.
  14968. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14969. * @returns the list of size gradients
  14970. */
  14971. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14972. /**
  14973. * Gets the current list of color remap gradients.
  14974. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14975. * @returns the list of color remap gradients
  14976. */
  14977. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14978. /**
  14979. * Gets the current list of alpha remap gradients.
  14980. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14981. * @returns the list of alpha remap gradients
  14982. */
  14983. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14984. /**
  14985. * Gets the current list of life time gradients.
  14986. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14987. * @returns the list of life time gradients
  14988. */
  14989. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14990. /**
  14991. * Gets the current list of angular speed gradients.
  14992. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14993. * @returns the list of angular speed gradients
  14994. */
  14995. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14996. /**
  14997. * Gets the current list of velocity gradients.
  14998. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14999. * @returns the list of velocity gradients
  15000. */
  15001. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15002. /**
  15003. * Gets the current list of start size gradients.
  15004. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15005. * @returns the list of start size gradients
  15006. */
  15007. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15008. /**
  15009. * Gets the current list of emit rate gradients.
  15010. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15011. * @returns the list of emit rate gradients
  15012. */
  15013. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15014. /**
  15015. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15016. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15017. */
  15018. get direction1(): Vector3;
  15019. set direction1(value: Vector3);
  15020. /**
  15021. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15022. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15023. */
  15024. get direction2(): Vector3;
  15025. set direction2(value: Vector3);
  15026. /**
  15027. * 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.
  15028. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15029. */
  15030. get minEmitBox(): Vector3;
  15031. set minEmitBox(value: Vector3);
  15032. /**
  15033. * 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.
  15034. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15035. */
  15036. get maxEmitBox(): Vector3;
  15037. set maxEmitBox(value: Vector3);
  15038. /**
  15039. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15040. */
  15041. color1: Color4;
  15042. /**
  15043. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15044. */
  15045. color2: Color4;
  15046. /**
  15047. * Color the particle will have at the end of its lifetime
  15048. */
  15049. colorDead: Color4;
  15050. /**
  15051. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15052. */
  15053. textureMask: Color4;
  15054. /**
  15055. * The particle emitter type defines the emitter used by the particle system.
  15056. * It can be for example box, sphere, or cone...
  15057. */
  15058. particleEmitterType: IParticleEmitterType;
  15059. /** @hidden */
  15060. _isSubEmitter: boolean;
  15061. /**
  15062. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15063. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15064. */
  15065. billboardMode: number;
  15066. protected _isBillboardBased: boolean;
  15067. /**
  15068. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15069. */
  15070. get isBillboardBased(): boolean;
  15071. set isBillboardBased(value: boolean);
  15072. /**
  15073. * The scene the particle system belongs to.
  15074. */
  15075. protected _scene: Nullable<Scene>;
  15076. /**
  15077. * The engine the particle system belongs to.
  15078. */
  15079. protected _engine: ThinEngine;
  15080. /**
  15081. * Local cache of defines for image processing.
  15082. */
  15083. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15084. /**
  15085. * Default configuration related to image processing available in the standard Material.
  15086. */
  15087. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15088. /**
  15089. * Gets the image processing configuration used either in this material.
  15090. */
  15091. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15092. /**
  15093. * Sets the Default image processing configuration used either in the this material.
  15094. *
  15095. * If sets to null, the scene one is in use.
  15096. */
  15097. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15098. /**
  15099. * Attaches a new image processing configuration to the Standard Material.
  15100. * @param configuration
  15101. */
  15102. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15103. /** @hidden */
  15104. protected _reset(): void;
  15105. /** @hidden */
  15106. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15107. /**
  15108. * Instantiates a particle system.
  15109. * 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.
  15110. * @param name The name of the particle system
  15111. */
  15112. constructor(name: string);
  15113. /**
  15114. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15117. * @returns the emitter
  15118. */
  15119. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15120. /**
  15121. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15122. * @param radius The radius of the hemisphere to emit from
  15123. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15124. * @returns the emitter
  15125. */
  15126. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15127. /**
  15128. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15129. * @param radius The radius of the sphere to emit from
  15130. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15131. * @returns the emitter
  15132. */
  15133. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15134. /**
  15135. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15136. * @param radius The radius of the sphere to emit from
  15137. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15138. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15139. * @returns the emitter
  15140. */
  15141. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15142. /**
  15143. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15144. * @param radius The radius of the emission cylinder
  15145. * @param height The height of the emission cylinder
  15146. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15147. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15148. * @returns the emitter
  15149. */
  15150. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15151. /**
  15152. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15153. * @param radius The radius of the cylinder to emit from
  15154. * @param height The height of the emission cylinder
  15155. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15156. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15157. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15158. * @returns the emitter
  15159. */
  15160. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15161. /**
  15162. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15163. * @param radius The radius of the cone to emit from
  15164. * @param angle The base angle of the cone
  15165. * @returns the emitter
  15166. */
  15167. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15168. /**
  15169. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15170. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15171. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15172. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15173. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15174. * @returns the emitter
  15175. */
  15176. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15177. }
  15178. }
  15179. declare module "babylonjs/Particles/subEmitter" {
  15180. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15181. import { Scene } from "babylonjs/scene";
  15182. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15183. /**
  15184. * Type of sub emitter
  15185. */
  15186. export enum SubEmitterType {
  15187. /**
  15188. * Attached to the particle over it's lifetime
  15189. */
  15190. ATTACHED = 0,
  15191. /**
  15192. * Created when the particle dies
  15193. */
  15194. END = 1
  15195. }
  15196. /**
  15197. * Sub emitter class used to emit particles from an existing particle
  15198. */
  15199. export class SubEmitter {
  15200. /**
  15201. * the particle system to be used by the sub emitter
  15202. */
  15203. particleSystem: ParticleSystem;
  15204. /**
  15205. * Type of the submitter (Default: END)
  15206. */
  15207. type: SubEmitterType;
  15208. /**
  15209. * 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)
  15210. * Note: This only is supported when using an emitter of type Mesh
  15211. */
  15212. inheritDirection: boolean;
  15213. /**
  15214. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15215. */
  15216. inheritedVelocityAmount: number;
  15217. /**
  15218. * Creates a sub emitter
  15219. * @param particleSystem the particle system to be used by the sub emitter
  15220. */
  15221. constructor(
  15222. /**
  15223. * the particle system to be used by the sub emitter
  15224. */
  15225. particleSystem: ParticleSystem);
  15226. /**
  15227. * Clones the sub emitter
  15228. * @returns the cloned sub emitter
  15229. */
  15230. clone(): SubEmitter;
  15231. /**
  15232. * Serialize current object to a JSON object
  15233. * @returns the serialized object
  15234. */
  15235. serialize(): any;
  15236. /** @hidden */
  15237. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15238. /**
  15239. * Creates a new SubEmitter from a serialized JSON version
  15240. * @param serializationObject defines the JSON object to read from
  15241. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15242. * @param rootUrl defines the rootUrl for data loading
  15243. * @returns a new SubEmitter
  15244. */
  15245. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15246. /** Release associated resources */
  15247. dispose(): void;
  15248. }
  15249. }
  15250. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15251. /** @hidden */
  15252. export var clipPlaneFragmentDeclaration: {
  15253. name: string;
  15254. shader: string;
  15255. };
  15256. }
  15257. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15258. /** @hidden */
  15259. export var imageProcessingDeclaration: {
  15260. name: string;
  15261. shader: string;
  15262. };
  15263. }
  15264. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15265. /** @hidden */
  15266. export var imageProcessingFunctions: {
  15267. name: string;
  15268. shader: string;
  15269. };
  15270. }
  15271. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15272. /** @hidden */
  15273. export var clipPlaneFragment: {
  15274. name: string;
  15275. shader: string;
  15276. };
  15277. }
  15278. declare module "babylonjs/Shaders/particles.fragment" {
  15279. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15280. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15281. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15282. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15283. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15284. /** @hidden */
  15285. export var particlesPixelShader: {
  15286. name: string;
  15287. shader: string;
  15288. };
  15289. }
  15290. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15291. /** @hidden */
  15292. export var clipPlaneVertexDeclaration: {
  15293. name: string;
  15294. shader: string;
  15295. };
  15296. }
  15297. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15298. /** @hidden */
  15299. export var clipPlaneVertex: {
  15300. name: string;
  15301. shader: string;
  15302. };
  15303. }
  15304. declare module "babylonjs/Shaders/particles.vertex" {
  15305. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15306. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15307. /** @hidden */
  15308. export var particlesVertexShader: {
  15309. name: string;
  15310. shader: string;
  15311. };
  15312. }
  15313. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  15314. import { Nullable } from "babylonjs/types";
  15315. import { Plane } from "babylonjs/Maths/math";
  15316. /**
  15317. * Interface used to define entities containing multiple clip planes
  15318. */
  15319. export interface IClipPlanesHolder {
  15320. /**
  15321. * Gets or sets the active clipplane 1
  15322. */
  15323. clipPlane: Nullable<Plane>;
  15324. /**
  15325. * Gets or sets the active clipplane 2
  15326. */
  15327. clipPlane2: Nullable<Plane>;
  15328. /**
  15329. * Gets or sets the active clipplane 3
  15330. */
  15331. clipPlane3: Nullable<Plane>;
  15332. /**
  15333. * Gets or sets the active clipplane 4
  15334. */
  15335. clipPlane4: Nullable<Plane>;
  15336. /**
  15337. * Gets or sets the active clipplane 5
  15338. */
  15339. clipPlane5: Nullable<Plane>;
  15340. /**
  15341. * Gets or sets the active clipplane 6
  15342. */
  15343. clipPlane6: Nullable<Plane>;
  15344. }
  15345. }
  15346. declare module "babylonjs/Materials/thinMaterialHelper" {
  15347. import { Effect } from "babylonjs/Materials/effect";
  15348. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  15349. /**
  15350. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15351. *
  15352. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15353. *
  15354. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15355. */
  15356. export class ThinMaterialHelper {
  15357. /**
  15358. * Binds the clip plane information from the holder to the effect.
  15359. * @param effect The effect we are binding the data to
  15360. * @param holder The entity containing the clip plane information
  15361. */
  15362. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15363. }
  15364. }
  15365. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  15366. module "babylonjs/Engines/thinEngine" {
  15367. interface ThinEngine {
  15368. /**
  15369. * Sets alpha constants used by some alpha blending modes
  15370. * @param r defines the red component
  15371. * @param g defines the green component
  15372. * @param b defines the blue component
  15373. * @param a defines the alpha component
  15374. */
  15375. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15376. /**
  15377. * Sets the current alpha mode
  15378. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15379. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15381. */
  15382. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15383. /**
  15384. * Gets the current alpha mode
  15385. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15386. * @returns the current alpha mode
  15387. */
  15388. getAlphaMode(): number;
  15389. /**
  15390. * Sets the current alpha equation
  15391. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15392. */
  15393. setAlphaEquation(equation: number): void;
  15394. /**
  15395. * Gets the current alpha equation.
  15396. * @returns the current alpha equation
  15397. */
  15398. getAlphaEquation(): number;
  15399. }
  15400. }
  15401. }
  15402. declare module "babylonjs/Particles/particleSystem" {
  15403. import { Nullable } from "babylonjs/types";
  15404. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  15405. import { Observable } from "babylonjs/Misc/observable";
  15406. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15407. import { Effect } from "babylonjs/Materials/effect";
  15408. import { IDisposable } from "babylonjs/scene";
  15409. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15410. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15411. import { Particle } from "babylonjs/Particles/particle";
  15412. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15414. import "babylonjs/Shaders/particles.fragment";
  15415. import "babylonjs/Shaders/particles.vertex";
  15416. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  15417. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15418. import "babylonjs/Engines/Extensions/engine.alpha";
  15419. import { Scene } from "babylonjs/scene";
  15420. /**
  15421. * This represents a particle system in Babylon.
  15422. * 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.
  15423. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15424. * @example https://doc.babylonjs.com/babylon101/particles
  15425. */
  15426. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15427. /**
  15428. * Billboard mode will only apply to Y axis
  15429. */
  15430. static readonly BILLBOARDMODE_Y: number;
  15431. /**
  15432. * Billboard mode will apply to all axes
  15433. */
  15434. static readonly BILLBOARDMODE_ALL: number;
  15435. /**
  15436. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15437. */
  15438. static readonly BILLBOARDMODE_STRETCHED: number;
  15439. /**
  15440. * This function can be defined to provide custom update for active particles.
  15441. * This function will be called instead of regular update (age, position, color, etc.).
  15442. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15443. */
  15444. updateFunction: (particles: Particle[]) => void;
  15445. private _emitterWorldMatrix;
  15446. /**
  15447. * This function can be defined to specify initial direction for every new particle.
  15448. * It by default use the emitterType defined function
  15449. */
  15450. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15451. /**
  15452. * This function can be defined to specify initial position for every new particle.
  15453. * It by default use the emitterType defined function
  15454. */
  15455. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15456. /**
  15457. * @hidden
  15458. */
  15459. _inheritedVelocityOffset: Vector3;
  15460. /**
  15461. * An event triggered when the system is disposed
  15462. */
  15463. onDisposeObservable: Observable<IParticleSystem>;
  15464. /**
  15465. * An event triggered when the system is stopped
  15466. */
  15467. onStoppedObservable: Observable<IParticleSystem>;
  15468. private _onDisposeObserver;
  15469. /**
  15470. * Sets a callback that will be triggered when the system is disposed
  15471. */
  15472. set onDispose(callback: () => void);
  15473. private _particles;
  15474. private _epsilon;
  15475. private _capacity;
  15476. private _stockParticles;
  15477. private _newPartsExcess;
  15478. private _vertexData;
  15479. private _vertexBuffer;
  15480. private _vertexBuffers;
  15481. private _spriteBuffer;
  15482. private _indexBuffer;
  15483. private _effect;
  15484. private _customEffect;
  15485. private _cachedDefines;
  15486. private _scaledColorStep;
  15487. private _colorDiff;
  15488. private _scaledDirection;
  15489. private _scaledGravity;
  15490. private _currentRenderId;
  15491. private _alive;
  15492. private _useInstancing;
  15493. private _vertexArrayObject;
  15494. private _started;
  15495. private _stopped;
  15496. private _actualFrame;
  15497. private _scaledUpdateSpeed;
  15498. private _vertexBufferSize;
  15499. /** @hidden */
  15500. _currentEmitRateGradient: Nullable<FactorGradient>;
  15501. /** @hidden */
  15502. _currentEmitRate1: number;
  15503. /** @hidden */
  15504. _currentEmitRate2: number;
  15505. /** @hidden */
  15506. _currentStartSizeGradient: Nullable<FactorGradient>;
  15507. /** @hidden */
  15508. _currentStartSize1: number;
  15509. /** @hidden */
  15510. _currentStartSize2: number;
  15511. private readonly _rawTextureWidth;
  15512. private _rampGradientsTexture;
  15513. private _useRampGradients;
  15514. /** Gets or sets a matrix to use to compute projection */
  15515. defaultProjectionMatrix: Matrix;
  15516. /** Gets or sets a matrix to use to compute view */
  15517. defaultViewMatrix: Matrix;
  15518. /** Gets or sets a boolean indicating that ramp gradients must be used
  15519. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15520. */
  15521. get useRampGradients(): boolean;
  15522. set useRampGradients(value: boolean);
  15523. /**
  15524. * 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.
  15525. * 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: [])
  15526. */
  15527. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15528. private _subEmitters;
  15529. /**
  15530. * @hidden
  15531. * If the particle systems emitter should be disposed when the particle system is disposed
  15532. */
  15533. _disposeEmitterOnDispose: boolean;
  15534. /**
  15535. * The current active Sub-systems, this property is used by the root particle system only.
  15536. */
  15537. activeSubSystems: Array<ParticleSystem>;
  15538. /**
  15539. * Specifies if the particles are updated in emitter local space or world space
  15540. */
  15541. isLocal: boolean;
  15542. private _rootParticleSystem;
  15543. /**
  15544. * Gets the current list of active particles
  15545. */
  15546. get particles(): Particle[];
  15547. /**
  15548. * Gets the number of particles active at the same time.
  15549. * @returns The number of active particles.
  15550. */
  15551. getActiveCount(): number;
  15552. /**
  15553. * Returns the string "ParticleSystem"
  15554. * @returns a string containing the class name
  15555. */
  15556. getClassName(): string;
  15557. /**
  15558. * Gets a boolean indicating that the system is stopping
  15559. * @returns true if the system is currently stopping
  15560. */
  15561. isStopping(): boolean;
  15562. /**
  15563. * Gets the custom effect used to render the particles
  15564. * @param blendMode Blend mode for which the effect should be retrieved
  15565. * @returns The effect
  15566. */
  15567. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15568. /**
  15569. * Sets the custom effect used to render the particles
  15570. * @param effect The effect to set
  15571. * @param blendMode Blend mode for which the effect should be set
  15572. */
  15573. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15574. /** @hidden */
  15575. private _onBeforeDrawParticlesObservable;
  15576. /**
  15577. * Observable that will be called just before the particles are drawn
  15578. */
  15579. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15580. /**
  15581. * Gets the name of the particle vertex shader
  15582. */
  15583. get vertexShaderName(): string;
  15584. /**
  15585. * Instantiates a particle system.
  15586. * 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.
  15587. * @param name The name of the particle system
  15588. * @param capacity The max number of particles alive at the same time
  15589. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15590. * @param customEffect a custom effect used to change the way particles are rendered by default
  15591. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15592. * @param epsilon Offset used to render the particles
  15593. */
  15594. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15595. private _addFactorGradient;
  15596. private _removeFactorGradient;
  15597. /**
  15598. * Adds a new life time gradient
  15599. * @param gradient defines the gradient to use (between 0 and 1)
  15600. * @param factor defines the life time factor to affect to the specified gradient
  15601. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15602. * @returns the current particle system
  15603. */
  15604. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15605. /**
  15606. * Remove a specific life time gradient
  15607. * @param gradient defines the gradient to remove
  15608. * @returns the current particle system
  15609. */
  15610. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15611. /**
  15612. * Adds a new size gradient
  15613. * @param gradient defines the gradient to use (between 0 and 1)
  15614. * @param factor defines the size factor to affect to the specified gradient
  15615. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15616. * @returns the current particle system
  15617. */
  15618. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15619. /**
  15620. * Remove a specific size gradient
  15621. * @param gradient defines the gradient to remove
  15622. * @returns the current particle system
  15623. */
  15624. removeSizeGradient(gradient: number): IParticleSystem;
  15625. /**
  15626. * Adds a new color remap gradient
  15627. * @param gradient defines the gradient to use (between 0 and 1)
  15628. * @param min defines the color remap minimal range
  15629. * @param max defines the color remap maximal range
  15630. * @returns the current particle system
  15631. */
  15632. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15633. /**
  15634. * Remove a specific color remap gradient
  15635. * @param gradient defines the gradient to remove
  15636. * @returns the current particle system
  15637. */
  15638. removeColorRemapGradient(gradient: number): IParticleSystem;
  15639. /**
  15640. * Adds a new alpha remap gradient
  15641. * @param gradient defines the gradient to use (between 0 and 1)
  15642. * @param min defines the alpha remap minimal range
  15643. * @param max defines the alpha remap maximal range
  15644. * @returns the current particle system
  15645. */
  15646. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15647. /**
  15648. * Remove a specific alpha remap gradient
  15649. * @param gradient defines the gradient to remove
  15650. * @returns the current particle system
  15651. */
  15652. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15653. /**
  15654. * Adds a new angular speed gradient
  15655. * @param gradient defines the gradient to use (between 0 and 1)
  15656. * @param factor defines the angular speed to affect to the specified gradient
  15657. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15658. * @returns the current particle system
  15659. */
  15660. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15661. /**
  15662. * Remove a specific angular speed gradient
  15663. * @param gradient defines the gradient to remove
  15664. * @returns the current particle system
  15665. */
  15666. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15667. /**
  15668. * Adds a new velocity gradient
  15669. * @param gradient defines the gradient to use (between 0 and 1)
  15670. * @param factor defines the velocity to affect to the specified gradient
  15671. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15672. * @returns the current particle system
  15673. */
  15674. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15675. /**
  15676. * Remove a specific velocity gradient
  15677. * @param gradient defines the gradient to remove
  15678. * @returns the current particle system
  15679. */
  15680. removeVelocityGradient(gradient: number): IParticleSystem;
  15681. /**
  15682. * Adds a new limit velocity gradient
  15683. * @param gradient defines the gradient to use (between 0 and 1)
  15684. * @param factor defines the limit velocity value to affect to the specified gradient
  15685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15686. * @returns the current particle system
  15687. */
  15688. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15689. /**
  15690. * Remove a specific limit velocity gradient
  15691. * @param gradient defines the gradient to remove
  15692. * @returns the current particle system
  15693. */
  15694. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15695. /**
  15696. * Adds a new drag gradient
  15697. * @param gradient defines the gradient to use (between 0 and 1)
  15698. * @param factor defines the drag value to affect to the specified gradient
  15699. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15700. * @returns the current particle system
  15701. */
  15702. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15703. /**
  15704. * Remove a specific drag gradient
  15705. * @param gradient defines the gradient to remove
  15706. * @returns the current particle system
  15707. */
  15708. removeDragGradient(gradient: number): IParticleSystem;
  15709. /**
  15710. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15711. * @param gradient defines the gradient to use (between 0 and 1)
  15712. * @param factor defines the emit rate value to affect to the specified gradient
  15713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15714. * @returns the current particle system
  15715. */
  15716. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15717. /**
  15718. * Remove a specific emit rate gradient
  15719. * @param gradient defines the gradient to remove
  15720. * @returns the current particle system
  15721. */
  15722. removeEmitRateGradient(gradient: number): IParticleSystem;
  15723. /**
  15724. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15725. * @param gradient defines the gradient to use (between 0 and 1)
  15726. * @param factor defines the start size value to affect to the specified gradient
  15727. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15728. * @returns the current particle system
  15729. */
  15730. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15731. /**
  15732. * Remove a specific start size gradient
  15733. * @param gradient defines the gradient to remove
  15734. * @returns the current particle system
  15735. */
  15736. removeStartSizeGradient(gradient: number): IParticleSystem;
  15737. private _createRampGradientTexture;
  15738. /**
  15739. * Gets the current list of ramp gradients.
  15740. * You must use addRampGradient and removeRampGradient to udpate this list
  15741. * @returns the list of ramp gradients
  15742. */
  15743. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15744. /** Force the system to rebuild all gradients that need to be resync */
  15745. forceRefreshGradients(): void;
  15746. private _syncRampGradientTexture;
  15747. /**
  15748. * Adds a new ramp gradient used to remap particle colors
  15749. * @param gradient defines the gradient to use (between 0 and 1)
  15750. * @param color defines the color to affect to the specified gradient
  15751. * @returns the current particle system
  15752. */
  15753. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15754. /**
  15755. * Remove a specific ramp gradient
  15756. * @param gradient defines the gradient to remove
  15757. * @returns the current particle system
  15758. */
  15759. removeRampGradient(gradient: number): ParticleSystem;
  15760. /**
  15761. * Adds a new color gradient
  15762. * @param gradient defines the gradient to use (between 0 and 1)
  15763. * @param color1 defines the color to affect to the specified gradient
  15764. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15765. * @returns this particle system
  15766. */
  15767. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15768. /**
  15769. * Remove a specific color gradient
  15770. * @param gradient defines the gradient to remove
  15771. * @returns this particle system
  15772. */
  15773. removeColorGradient(gradient: number): IParticleSystem;
  15774. private _fetchR;
  15775. protected _reset(): void;
  15776. private _resetEffect;
  15777. private _createVertexBuffers;
  15778. private _createIndexBuffer;
  15779. /**
  15780. * Gets the maximum number of particles active at the same time.
  15781. * @returns The max number of active particles.
  15782. */
  15783. getCapacity(): number;
  15784. /**
  15785. * Gets whether there are still active particles in the system.
  15786. * @returns True if it is alive, otherwise false.
  15787. */
  15788. isAlive(): boolean;
  15789. /**
  15790. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15791. * @returns True if it has been started, otherwise false.
  15792. */
  15793. isStarted(): boolean;
  15794. private _prepareSubEmitterInternalArray;
  15795. /**
  15796. * Starts the particle system and begins to emit
  15797. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15798. */
  15799. start(delay?: number): void;
  15800. /**
  15801. * Stops the particle system.
  15802. * @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.
  15803. */
  15804. stop(stopSubEmitters?: boolean): void;
  15805. /**
  15806. * Remove all active particles
  15807. */
  15808. reset(): void;
  15809. /**
  15810. * @hidden (for internal use only)
  15811. */
  15812. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15813. /**
  15814. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15815. * Its lifetime will start back at 0.
  15816. */
  15817. recycleParticle: (particle: Particle) => void;
  15818. private _stopSubEmitters;
  15819. private _createParticle;
  15820. private _removeFromRoot;
  15821. private _emitFromParticle;
  15822. private _update;
  15823. /** @hidden */
  15824. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15825. /** @hidden */
  15826. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15827. /**
  15828. * Fill the defines array according to the current settings of the particle system
  15829. * @param defines Array to be updated
  15830. * @param blendMode blend mode to take into account when updating the array
  15831. */
  15832. fillDefines(defines: Array<string>, blendMode: number): void;
  15833. /**
  15834. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15835. * @param uniforms Uniforms array to fill
  15836. * @param attributes Attributes array to fill
  15837. * @param samplers Samplers array to fill
  15838. */
  15839. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15840. /** @hidden */
  15841. private _getEffect;
  15842. /**
  15843. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15844. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15845. */
  15846. animate(preWarmOnly?: boolean): void;
  15847. private _appendParticleVertices;
  15848. /**
  15849. * Rebuilds the particle system.
  15850. */
  15851. rebuild(): void;
  15852. /**
  15853. * Is this system ready to be used/rendered
  15854. * @return true if the system is ready
  15855. */
  15856. isReady(): boolean;
  15857. private _render;
  15858. /**
  15859. * Renders the particle system in its current state.
  15860. * @returns the current number of particles
  15861. */
  15862. render(): number;
  15863. /**
  15864. * Disposes the particle system and free the associated resources
  15865. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15866. */
  15867. dispose(disposeTexture?: boolean): void;
  15868. /**
  15869. * Clones the particle system.
  15870. * @param name The name of the cloned object
  15871. * @param newEmitter The new emitter to use
  15872. * @returns the cloned particle system
  15873. */
  15874. clone(name: string, newEmitter: any): ParticleSystem;
  15875. /**
  15876. * Serializes the particle system to a JSON object
  15877. * @param serializeTexture defines if the texture must be serialized as well
  15878. * @returns the JSON object
  15879. */
  15880. serialize(serializeTexture?: boolean): any;
  15881. /** @hidden */
  15882. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15883. /** @hidden */
  15884. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15885. /**
  15886. * Parses a JSON object to create a particle system.
  15887. * @param parsedParticleSystem The JSON object to parse
  15888. * @param sceneOrEngine The scene or the engine to create the particle system in
  15889. * @param rootUrl The root url to use to load external dependencies like texture
  15890. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15891. * @returns the Parsed particle system
  15892. */
  15893. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15894. }
  15895. }
  15896. declare module "babylonjs/Particles/particle" {
  15897. import { Nullable } from "babylonjs/types";
  15898. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  15899. import { Color4 } from "babylonjs/Maths/math.color";
  15900. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15901. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15902. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  15903. /**
  15904. * A particle represents one of the element emitted by a particle system.
  15905. * This is mainly define by its coordinates, direction, velocity and age.
  15906. */
  15907. export class Particle {
  15908. /**
  15909. * The particle system the particle belongs to.
  15910. */
  15911. particleSystem: ParticleSystem;
  15912. private static _Count;
  15913. /**
  15914. * Unique ID of the particle
  15915. */
  15916. id: number;
  15917. /**
  15918. * The world position of the particle in the scene.
  15919. */
  15920. position: Vector3;
  15921. /**
  15922. * The world direction of the particle in the scene.
  15923. */
  15924. direction: Vector3;
  15925. /**
  15926. * The color of the particle.
  15927. */
  15928. color: Color4;
  15929. /**
  15930. * The color change of the particle per step.
  15931. */
  15932. colorStep: Color4;
  15933. /**
  15934. * Defines how long will the life of the particle be.
  15935. */
  15936. lifeTime: number;
  15937. /**
  15938. * The current age of the particle.
  15939. */
  15940. age: number;
  15941. /**
  15942. * The current size of the particle.
  15943. */
  15944. size: number;
  15945. /**
  15946. * The current scale of the particle.
  15947. */
  15948. scale: Vector2;
  15949. /**
  15950. * The current angle of the particle.
  15951. */
  15952. angle: number;
  15953. /**
  15954. * Defines how fast is the angle changing.
  15955. */
  15956. angularSpeed: number;
  15957. /**
  15958. * Defines the cell index used by the particle to be rendered from a sprite.
  15959. */
  15960. cellIndex: number;
  15961. /**
  15962. * The information required to support color remapping
  15963. */
  15964. remapData: Vector4;
  15965. /** @hidden */
  15966. _randomCellOffset?: number;
  15967. /** @hidden */
  15968. _initialDirection: Nullable<Vector3>;
  15969. /** @hidden */
  15970. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15971. /** @hidden */
  15972. _initialStartSpriteCellID: number;
  15973. /** @hidden */
  15974. _initialEndSpriteCellID: number;
  15975. /** @hidden */
  15976. _currentColorGradient: Nullable<ColorGradient>;
  15977. /** @hidden */
  15978. _currentColor1: Color4;
  15979. /** @hidden */
  15980. _currentColor2: Color4;
  15981. /** @hidden */
  15982. _currentSizeGradient: Nullable<FactorGradient>;
  15983. /** @hidden */
  15984. _currentSize1: number;
  15985. /** @hidden */
  15986. _currentSize2: number;
  15987. /** @hidden */
  15988. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15989. /** @hidden */
  15990. _currentAngularSpeed1: number;
  15991. /** @hidden */
  15992. _currentAngularSpeed2: number;
  15993. /** @hidden */
  15994. _currentVelocityGradient: Nullable<FactorGradient>;
  15995. /** @hidden */
  15996. _currentVelocity1: number;
  15997. /** @hidden */
  15998. _currentVelocity2: number;
  15999. /** @hidden */
  16000. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16001. /** @hidden */
  16002. _currentLimitVelocity1: number;
  16003. /** @hidden */
  16004. _currentLimitVelocity2: number;
  16005. /** @hidden */
  16006. _currentDragGradient: Nullable<FactorGradient>;
  16007. /** @hidden */
  16008. _currentDrag1: number;
  16009. /** @hidden */
  16010. _currentDrag2: number;
  16011. /** @hidden */
  16012. _randomNoiseCoordinates1: Vector3;
  16013. /** @hidden */
  16014. _randomNoiseCoordinates2: Vector3;
  16015. /** @hidden */
  16016. _localPosition?: Vector3;
  16017. /**
  16018. * Creates a new instance Particle
  16019. * @param particleSystem the particle system the particle belongs to
  16020. */
  16021. constructor(
  16022. /**
  16023. * The particle system the particle belongs to.
  16024. */
  16025. particleSystem: ParticleSystem);
  16026. private updateCellInfoFromSystem;
  16027. /**
  16028. * Defines how the sprite cell index is updated for the particle
  16029. */
  16030. updateCellIndex(): void;
  16031. /** @hidden */
  16032. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16033. /** @hidden */
  16034. _inheritParticleInfoToSubEmitters(): void;
  16035. /** @hidden */
  16036. _reset(): void;
  16037. /**
  16038. * Copy the properties of particle to another one.
  16039. * @param other the particle to copy the information to.
  16040. */
  16041. copyTo(other: Particle): void;
  16042. }
  16043. }
  16044. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  16045. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16046. import { Effect } from "babylonjs/Materials/effect";
  16047. import { Particle } from "babylonjs/Particles/particle";
  16048. import { Nullable } from "babylonjs/types";
  16049. import { Scene } from "babylonjs/scene";
  16050. /**
  16051. * Particle emitter represents a volume emitting particles.
  16052. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16053. */
  16054. export interface IParticleEmitterType {
  16055. /**
  16056. * Called by the particle System when the direction is computed for the created particle.
  16057. * @param worldMatrix is the world matrix of the particle system
  16058. * @param directionToUpdate is the direction vector to update with the result
  16059. * @param particle is the particle we are computed the direction for
  16060. * @param isLocal defines if the direction should be set in local space
  16061. */
  16062. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16063. /**
  16064. * Called by the particle System when the position is computed for the created particle.
  16065. * @param worldMatrix is the world matrix of the particle system
  16066. * @param positionToUpdate is the position vector to update with the result
  16067. * @param particle is the particle we are computed the position for
  16068. * @param isLocal defines if the position should be set in local space
  16069. */
  16070. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16071. /**
  16072. * Clones the current emitter and returns a copy of it
  16073. * @returns the new emitter
  16074. */
  16075. clone(): IParticleEmitterType;
  16076. /**
  16077. * Called by the GPUParticleSystem to setup the update shader
  16078. * @param effect defines the update shader
  16079. */
  16080. applyToShader(effect: Effect): void;
  16081. /**
  16082. * Returns a string to use to update the GPU particles update shader
  16083. * @returns the effect defines string
  16084. */
  16085. getEffectDefines(): string;
  16086. /**
  16087. * Returns a string representing the class name
  16088. * @returns a string containing the class name
  16089. */
  16090. getClassName(): string;
  16091. /**
  16092. * Serializes the particle system to a JSON object.
  16093. * @returns the JSON object
  16094. */
  16095. serialize(): any;
  16096. /**
  16097. * Parse properties from a JSON object
  16098. * @param serializationObject defines the JSON object
  16099. * @param scene defines the hosting scene
  16100. */
  16101. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16102. }
  16103. }
  16104. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  16105. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16106. import { Effect } from "babylonjs/Materials/effect";
  16107. import { Particle } from "babylonjs/Particles/particle";
  16108. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16109. /**
  16110. * Particle emitter emitting particles from the inside of a box.
  16111. * It emits the particles randomly between 2 given directions.
  16112. */
  16113. export class BoxParticleEmitter implements IParticleEmitterType {
  16114. /**
  16115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16116. */
  16117. direction1: Vector3;
  16118. /**
  16119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16120. */
  16121. direction2: Vector3;
  16122. /**
  16123. * 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.
  16124. */
  16125. minEmitBox: Vector3;
  16126. /**
  16127. * 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.
  16128. */
  16129. maxEmitBox: Vector3;
  16130. /**
  16131. * Creates a new instance BoxParticleEmitter
  16132. */
  16133. constructor();
  16134. /**
  16135. * Called by the particle System when the direction is computed for the created particle.
  16136. * @param worldMatrix is the world matrix of the particle system
  16137. * @param directionToUpdate is the direction vector to update with the result
  16138. * @param particle is the particle we are computed the direction for
  16139. * @param isLocal defines if the direction should be set in local space
  16140. */
  16141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16142. /**
  16143. * Called by the particle System when the position is computed for the created particle.
  16144. * @param worldMatrix is the world matrix of the particle system
  16145. * @param positionToUpdate is the position vector to update with the result
  16146. * @param particle is the particle we are computed the position for
  16147. * @param isLocal defines if the position should be set in local space
  16148. */
  16149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16150. /**
  16151. * Clones the current emitter and returns a copy of it
  16152. * @returns the new emitter
  16153. */
  16154. clone(): BoxParticleEmitter;
  16155. /**
  16156. * Called by the GPUParticleSystem to setup the update shader
  16157. * @param effect defines the update shader
  16158. */
  16159. applyToShader(effect: Effect): void;
  16160. /**
  16161. * Returns a string to use to update the GPU particles update shader
  16162. * @returns a string containng the defines string
  16163. */
  16164. getEffectDefines(): string;
  16165. /**
  16166. * Returns the string "BoxParticleEmitter"
  16167. * @returns a string containing the class name
  16168. */
  16169. getClassName(): string;
  16170. /**
  16171. * Serializes the particle system to a JSON object.
  16172. * @returns the JSON object
  16173. */
  16174. serialize(): any;
  16175. /**
  16176. * Parse properties from a JSON object
  16177. * @param serializationObject defines the JSON object
  16178. */
  16179. parse(serializationObject: any): void;
  16180. }
  16181. }
  16182. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  16183. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16184. import { Effect } from "babylonjs/Materials/effect";
  16185. import { Particle } from "babylonjs/Particles/particle";
  16186. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16187. /**
  16188. * Particle emitter emitting particles from the inside of a cone.
  16189. * It emits the particles alongside the cone volume from the base to the particle.
  16190. * The emission direction might be randomized.
  16191. */
  16192. export class ConeParticleEmitter implements IParticleEmitterType {
  16193. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16194. directionRandomizer: number;
  16195. private _radius;
  16196. private _angle;
  16197. private _height;
  16198. /**
  16199. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16200. */
  16201. radiusRange: number;
  16202. /**
  16203. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16204. */
  16205. heightRange: number;
  16206. /**
  16207. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16208. */
  16209. emitFromSpawnPointOnly: boolean;
  16210. /**
  16211. * Gets or sets the radius of the emission cone
  16212. */
  16213. get radius(): number;
  16214. set radius(value: number);
  16215. /**
  16216. * Gets or sets the angle of the emission cone
  16217. */
  16218. get angle(): number;
  16219. set angle(value: number);
  16220. private _buildHeight;
  16221. /**
  16222. * Creates a new instance ConeParticleEmitter
  16223. * @param radius the radius of the emission cone (1 by default)
  16224. * @param angle the cone base angle (PI by default)
  16225. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16226. */
  16227. constructor(radius?: number, angle?: number,
  16228. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16229. directionRandomizer?: number);
  16230. /**
  16231. * Called by the particle System when the direction is computed for the created particle.
  16232. * @param worldMatrix is the world matrix of the particle system
  16233. * @param directionToUpdate is the direction vector to update with the result
  16234. * @param particle is the particle we are computed the direction for
  16235. * @param isLocal defines if the direction should be set in local space
  16236. */
  16237. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16238. /**
  16239. * Called by the particle System when the position is computed for the created particle.
  16240. * @param worldMatrix is the world matrix of the particle system
  16241. * @param positionToUpdate is the position vector to update with the result
  16242. * @param particle is the particle we are computed the position for
  16243. * @param isLocal defines if the position should be set in local space
  16244. */
  16245. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16246. /**
  16247. * Clones the current emitter and returns a copy of it
  16248. * @returns the new emitter
  16249. */
  16250. clone(): ConeParticleEmitter;
  16251. /**
  16252. * Called by the GPUParticleSystem to setup the update shader
  16253. * @param effect defines the update shader
  16254. */
  16255. applyToShader(effect: Effect): void;
  16256. /**
  16257. * Returns a string to use to update the GPU particles update shader
  16258. * @returns a string containng the defines string
  16259. */
  16260. getEffectDefines(): string;
  16261. /**
  16262. * Returns the string "ConeParticleEmitter"
  16263. * @returns a string containing the class name
  16264. */
  16265. getClassName(): string;
  16266. /**
  16267. * Serializes the particle system to a JSON object.
  16268. * @returns the JSON object
  16269. */
  16270. serialize(): any;
  16271. /**
  16272. * Parse properties from a JSON object
  16273. * @param serializationObject defines the JSON object
  16274. */
  16275. parse(serializationObject: any): void;
  16276. }
  16277. }
  16278. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  16279. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16280. import { Effect } from "babylonjs/Materials/effect";
  16281. import { Particle } from "babylonjs/Particles/particle";
  16282. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16283. /**
  16284. * Particle emitter emitting particles from the inside of a cylinder.
  16285. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16286. */
  16287. export class CylinderParticleEmitter implements IParticleEmitterType {
  16288. /**
  16289. * The radius of the emission cylinder.
  16290. */
  16291. radius: number;
  16292. /**
  16293. * The height of the emission cylinder.
  16294. */
  16295. height: number;
  16296. /**
  16297. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16298. */
  16299. radiusRange: number;
  16300. /**
  16301. * How much to randomize the particle direction [0-1].
  16302. */
  16303. directionRandomizer: number;
  16304. /**
  16305. * Creates a new instance CylinderParticleEmitter
  16306. * @param radius the radius of the emission cylinder (1 by default)
  16307. * @param height the height of the emission cylinder (1 by default)
  16308. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16309. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16310. */
  16311. constructor(
  16312. /**
  16313. * The radius of the emission cylinder.
  16314. */
  16315. radius?: number,
  16316. /**
  16317. * The height of the emission cylinder.
  16318. */
  16319. height?: number,
  16320. /**
  16321. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16322. */
  16323. radiusRange?: number,
  16324. /**
  16325. * How much to randomize the particle direction [0-1].
  16326. */
  16327. directionRandomizer?: number);
  16328. /**
  16329. * Called by the particle System when the direction is computed for the created particle.
  16330. * @param worldMatrix is the world matrix of the particle system
  16331. * @param directionToUpdate is the direction vector to update with the result
  16332. * @param particle is the particle we are computed the direction for
  16333. * @param isLocal defines if the direction should be set in local space
  16334. */
  16335. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16336. /**
  16337. * Called by the particle System when the position is computed for the created particle.
  16338. * @param worldMatrix is the world matrix of the particle system
  16339. * @param positionToUpdate is the position vector to update with the result
  16340. * @param particle is the particle we are computed the position for
  16341. * @param isLocal defines if the position should be set in local space
  16342. */
  16343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16344. /**
  16345. * Clones the current emitter and returns a copy of it
  16346. * @returns the new emitter
  16347. */
  16348. clone(): CylinderParticleEmitter;
  16349. /**
  16350. * Called by the GPUParticleSystem to setup the update shader
  16351. * @param effect defines the update shader
  16352. */
  16353. applyToShader(effect: Effect): void;
  16354. /**
  16355. * Returns a string to use to update the GPU particles update shader
  16356. * @returns a string containng the defines string
  16357. */
  16358. getEffectDefines(): string;
  16359. /**
  16360. * Returns the string "CylinderParticleEmitter"
  16361. * @returns a string containing the class name
  16362. */
  16363. getClassName(): string;
  16364. /**
  16365. * Serializes the particle system to a JSON object.
  16366. * @returns the JSON object
  16367. */
  16368. serialize(): any;
  16369. /**
  16370. * Parse properties from a JSON object
  16371. * @param serializationObject defines the JSON object
  16372. */
  16373. parse(serializationObject: any): void;
  16374. }
  16375. /**
  16376. * Particle emitter emitting particles from the inside of a cylinder.
  16377. * It emits the particles randomly between two vectors.
  16378. */
  16379. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16380. /**
  16381. * The min limit of the emission direction.
  16382. */
  16383. direction1: Vector3;
  16384. /**
  16385. * The max limit of the emission direction.
  16386. */
  16387. direction2: Vector3;
  16388. /**
  16389. * Creates a new instance CylinderDirectedParticleEmitter
  16390. * @param radius the radius of the emission cylinder (1 by default)
  16391. * @param height the height of the emission cylinder (1 by default)
  16392. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16393. * @param direction1 the min limit of the emission direction (up vector by default)
  16394. * @param direction2 the max limit of the emission direction (up vector by default)
  16395. */
  16396. constructor(radius?: number, height?: number, radiusRange?: number,
  16397. /**
  16398. * The min limit of the emission direction.
  16399. */
  16400. direction1?: Vector3,
  16401. /**
  16402. * The max limit of the emission direction.
  16403. */
  16404. direction2?: Vector3);
  16405. /**
  16406. * Called by the particle System when the direction is computed for the created particle.
  16407. * @param worldMatrix is the world matrix of the particle system
  16408. * @param directionToUpdate is the direction vector to update with the result
  16409. * @param particle is the particle we are computed the direction for
  16410. */
  16411. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16412. /**
  16413. * Clones the current emitter and returns a copy of it
  16414. * @returns the new emitter
  16415. */
  16416. clone(): CylinderDirectedParticleEmitter;
  16417. /**
  16418. * Called by the GPUParticleSystem to setup the update shader
  16419. * @param effect defines the update shader
  16420. */
  16421. applyToShader(effect: Effect): void;
  16422. /**
  16423. * Returns a string to use to update the GPU particles update shader
  16424. * @returns a string containng the defines string
  16425. */
  16426. getEffectDefines(): string;
  16427. /**
  16428. * Returns the string "CylinderDirectedParticleEmitter"
  16429. * @returns a string containing the class name
  16430. */
  16431. getClassName(): string;
  16432. /**
  16433. * Serializes the particle system to a JSON object.
  16434. * @returns the JSON object
  16435. */
  16436. serialize(): any;
  16437. /**
  16438. * Parse properties from a JSON object
  16439. * @param serializationObject defines the JSON object
  16440. */
  16441. parse(serializationObject: any): void;
  16442. }
  16443. }
  16444. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16445. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16446. import { Effect } from "babylonjs/Materials/effect";
  16447. import { Particle } from "babylonjs/Particles/particle";
  16448. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16449. /**
  16450. * Particle emitter emitting particles from the inside of a hemisphere.
  16451. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16452. */
  16453. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16454. /**
  16455. * The radius of the emission hemisphere.
  16456. */
  16457. radius: number;
  16458. /**
  16459. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16460. */
  16461. radiusRange: number;
  16462. /**
  16463. * How much to randomize the particle direction [0-1].
  16464. */
  16465. directionRandomizer: number;
  16466. /**
  16467. * Creates a new instance HemisphericParticleEmitter
  16468. * @param radius the radius of the emission hemisphere (1 by default)
  16469. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16470. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16471. */
  16472. constructor(
  16473. /**
  16474. * The radius of the emission hemisphere.
  16475. */
  16476. radius?: number,
  16477. /**
  16478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16479. */
  16480. radiusRange?: number,
  16481. /**
  16482. * How much to randomize the particle direction [0-1].
  16483. */
  16484. directionRandomizer?: number);
  16485. /**
  16486. * Called by the particle System when the direction is computed for the created particle.
  16487. * @param worldMatrix is the world matrix of the particle system
  16488. * @param directionToUpdate is the direction vector to update with the result
  16489. * @param particle is the particle we are computed the direction for
  16490. * @param isLocal defines if the direction should be set in local space
  16491. */
  16492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16493. /**
  16494. * Called by the particle System when the position is computed for the created particle.
  16495. * @param worldMatrix is the world matrix of the particle system
  16496. * @param positionToUpdate is the position vector to update with the result
  16497. * @param particle is the particle we are computed the position for
  16498. * @param isLocal defines if the position should be set in local space
  16499. */
  16500. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16501. /**
  16502. * Clones the current emitter and returns a copy of it
  16503. * @returns the new emitter
  16504. */
  16505. clone(): HemisphericParticleEmitter;
  16506. /**
  16507. * Called by the GPUParticleSystem to setup the update shader
  16508. * @param effect defines the update shader
  16509. */
  16510. applyToShader(effect: Effect): void;
  16511. /**
  16512. * Returns a string to use to update the GPU particles update shader
  16513. * @returns a string containng the defines string
  16514. */
  16515. getEffectDefines(): string;
  16516. /**
  16517. * Returns the string "HemisphericParticleEmitter"
  16518. * @returns a string containing the class name
  16519. */
  16520. getClassName(): string;
  16521. /**
  16522. * Serializes the particle system to a JSON object.
  16523. * @returns the JSON object
  16524. */
  16525. serialize(): any;
  16526. /**
  16527. * Parse properties from a JSON object
  16528. * @param serializationObject defines the JSON object
  16529. */
  16530. parse(serializationObject: any): void;
  16531. }
  16532. }
  16533. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16534. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16535. import { Effect } from "babylonjs/Materials/effect";
  16536. import { Particle } from "babylonjs/Particles/particle";
  16537. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16538. /**
  16539. * Particle emitter emitting particles from a point.
  16540. * It emits the particles randomly between 2 given directions.
  16541. */
  16542. export class PointParticleEmitter implements IParticleEmitterType {
  16543. /**
  16544. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16545. */
  16546. direction1: Vector3;
  16547. /**
  16548. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16549. */
  16550. direction2: Vector3;
  16551. /**
  16552. * Creates a new instance PointParticleEmitter
  16553. */
  16554. constructor();
  16555. /**
  16556. * Called by the particle System when the direction is computed for the created particle.
  16557. * @param worldMatrix is the world matrix of the particle system
  16558. * @param directionToUpdate is the direction vector to update with the result
  16559. * @param particle is the particle we are computed the direction for
  16560. * @param isLocal defines if the direction should be set in local space
  16561. */
  16562. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16563. /**
  16564. * Called by the particle System when the position is computed for the created particle.
  16565. * @param worldMatrix is the world matrix of the particle system
  16566. * @param positionToUpdate is the position vector to update with the result
  16567. * @param particle is the particle we are computed the position for
  16568. * @param isLocal defines if the position should be set in local space
  16569. */
  16570. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16571. /**
  16572. * Clones the current emitter and returns a copy of it
  16573. * @returns the new emitter
  16574. */
  16575. clone(): PointParticleEmitter;
  16576. /**
  16577. * Called by the GPUParticleSystem to setup the update shader
  16578. * @param effect defines the update shader
  16579. */
  16580. applyToShader(effect: Effect): void;
  16581. /**
  16582. * Returns a string to use to update the GPU particles update shader
  16583. * @returns a string containng the defines string
  16584. */
  16585. getEffectDefines(): string;
  16586. /**
  16587. * Returns the string "PointParticleEmitter"
  16588. * @returns a string containing the class name
  16589. */
  16590. getClassName(): string;
  16591. /**
  16592. * Serializes the particle system to a JSON object.
  16593. * @returns the JSON object
  16594. */
  16595. serialize(): any;
  16596. /**
  16597. * Parse properties from a JSON object
  16598. * @param serializationObject defines the JSON object
  16599. */
  16600. parse(serializationObject: any): void;
  16601. }
  16602. }
  16603. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16604. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16605. import { Effect } from "babylonjs/Materials/effect";
  16606. import { Particle } from "babylonjs/Particles/particle";
  16607. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16608. /**
  16609. * Particle emitter emitting particles from the inside of a sphere.
  16610. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16611. */
  16612. export class SphereParticleEmitter implements IParticleEmitterType {
  16613. /**
  16614. * The radius of the emission sphere.
  16615. */
  16616. radius: number;
  16617. /**
  16618. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16619. */
  16620. radiusRange: number;
  16621. /**
  16622. * How much to randomize the particle direction [0-1].
  16623. */
  16624. directionRandomizer: number;
  16625. /**
  16626. * Creates a new instance SphereParticleEmitter
  16627. * @param radius the radius of the emission sphere (1 by default)
  16628. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16629. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16630. */
  16631. constructor(
  16632. /**
  16633. * The radius of the emission sphere.
  16634. */
  16635. radius?: number,
  16636. /**
  16637. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16638. */
  16639. radiusRange?: number,
  16640. /**
  16641. * How much to randomize the particle direction [0-1].
  16642. */
  16643. directionRandomizer?: number);
  16644. /**
  16645. * Called by the particle System when the direction is computed for the created particle.
  16646. * @param worldMatrix is the world matrix of the particle system
  16647. * @param directionToUpdate is the direction vector to update with the result
  16648. * @param particle is the particle we are computed the direction for
  16649. * @param isLocal defines if the direction should be set in local space
  16650. */
  16651. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16652. /**
  16653. * Called by the particle System when the position is computed for the created particle.
  16654. * @param worldMatrix is the world matrix of the particle system
  16655. * @param positionToUpdate is the position vector to update with the result
  16656. * @param particle is the particle we are computed the position for
  16657. * @param isLocal defines if the position should be set in local space
  16658. */
  16659. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16660. /**
  16661. * Clones the current emitter and returns a copy of it
  16662. * @returns the new emitter
  16663. */
  16664. clone(): SphereParticleEmitter;
  16665. /**
  16666. * Called by the GPUParticleSystem to setup the update shader
  16667. * @param effect defines the update shader
  16668. */
  16669. applyToShader(effect: Effect): void;
  16670. /**
  16671. * Returns a string to use to update the GPU particles update shader
  16672. * @returns a string containng the defines string
  16673. */
  16674. getEffectDefines(): string;
  16675. /**
  16676. * Returns the string "SphereParticleEmitter"
  16677. * @returns a string containing the class name
  16678. */
  16679. getClassName(): string;
  16680. /**
  16681. * Serializes the particle system to a JSON object.
  16682. * @returns the JSON object
  16683. */
  16684. serialize(): any;
  16685. /**
  16686. * Parse properties from a JSON object
  16687. * @param serializationObject defines the JSON object
  16688. */
  16689. parse(serializationObject: any): void;
  16690. }
  16691. /**
  16692. * Particle emitter emitting particles from the inside of a sphere.
  16693. * It emits the particles randomly between two vectors.
  16694. */
  16695. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16696. /**
  16697. * The min limit of the emission direction.
  16698. */
  16699. direction1: Vector3;
  16700. /**
  16701. * The max limit of the emission direction.
  16702. */
  16703. direction2: Vector3;
  16704. /**
  16705. * Creates a new instance SphereDirectedParticleEmitter
  16706. * @param radius the radius of the emission sphere (1 by default)
  16707. * @param direction1 the min limit of the emission direction (up vector by default)
  16708. * @param direction2 the max limit of the emission direction (up vector by default)
  16709. */
  16710. constructor(radius?: number,
  16711. /**
  16712. * The min limit of the emission direction.
  16713. */
  16714. direction1?: Vector3,
  16715. /**
  16716. * The max limit of the emission direction.
  16717. */
  16718. direction2?: Vector3);
  16719. /**
  16720. * Called by the particle System when the direction is computed for the created particle.
  16721. * @param worldMatrix is the world matrix of the particle system
  16722. * @param directionToUpdate is the direction vector to update with the result
  16723. * @param particle is the particle we are computed the direction for
  16724. */
  16725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16726. /**
  16727. * Clones the current emitter and returns a copy of it
  16728. * @returns the new emitter
  16729. */
  16730. clone(): SphereDirectedParticleEmitter;
  16731. /**
  16732. * Called by the GPUParticleSystem to setup the update shader
  16733. * @param effect defines the update shader
  16734. */
  16735. applyToShader(effect: Effect): void;
  16736. /**
  16737. * Returns a string to use to update the GPU particles update shader
  16738. * @returns a string containng the defines string
  16739. */
  16740. getEffectDefines(): string;
  16741. /**
  16742. * Returns the string "SphereDirectedParticleEmitter"
  16743. * @returns a string containing the class name
  16744. */
  16745. getClassName(): string;
  16746. /**
  16747. * Serializes the particle system to a JSON object.
  16748. * @returns the JSON object
  16749. */
  16750. serialize(): any;
  16751. /**
  16752. * Parse properties from a JSON object
  16753. * @param serializationObject defines the JSON object
  16754. */
  16755. parse(serializationObject: any): void;
  16756. }
  16757. }
  16758. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  16759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16760. import { Effect } from "babylonjs/Materials/effect";
  16761. import { Particle } from "babylonjs/Particles/particle";
  16762. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16763. import { Nullable } from "babylonjs/types";
  16764. /**
  16765. * Particle emitter emitting particles from a custom list of positions.
  16766. */
  16767. export class CustomParticleEmitter implements IParticleEmitterType {
  16768. /**
  16769. * Gets or sets the position generator that will create the inital position of each particle.
  16770. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16771. */
  16772. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16773. /**
  16774. * Gets or sets the destination generator that will create the final destination of each particle.
  16775. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16776. */
  16777. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16778. /**
  16779. * Creates a new instance CustomParticleEmitter
  16780. */
  16781. constructor();
  16782. /**
  16783. * Called by the particle System when the direction is computed for the created particle.
  16784. * @param worldMatrix is the world matrix of the particle system
  16785. * @param directionToUpdate is the direction vector to update with the result
  16786. * @param particle is the particle we are computed the direction for
  16787. * @param isLocal defines if the direction should be set in local space
  16788. */
  16789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16790. /**
  16791. * Called by the particle System when the position is computed for the created particle.
  16792. * @param worldMatrix is the world matrix of the particle system
  16793. * @param positionToUpdate is the position vector to update with the result
  16794. * @param particle is the particle we are computed the position for
  16795. * @param isLocal defines if the position should be set in local space
  16796. */
  16797. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16798. /**
  16799. * Clones the current emitter and returns a copy of it
  16800. * @returns the new emitter
  16801. */
  16802. clone(): CustomParticleEmitter;
  16803. /**
  16804. * Called by the GPUParticleSystem to setup the update shader
  16805. * @param effect defines the update shader
  16806. */
  16807. applyToShader(effect: Effect): void;
  16808. /**
  16809. * Returns a string to use to update the GPU particles update shader
  16810. * @returns a string containng the defines string
  16811. */
  16812. getEffectDefines(): string;
  16813. /**
  16814. * Returns the string "PointParticleEmitter"
  16815. * @returns a string containing the class name
  16816. */
  16817. getClassName(): string;
  16818. /**
  16819. * Serializes the particle system to a JSON object.
  16820. * @returns the JSON object
  16821. */
  16822. serialize(): any;
  16823. /**
  16824. * Parse properties from a JSON object
  16825. * @param serializationObject defines the JSON object
  16826. */
  16827. parse(serializationObject: any): void;
  16828. }
  16829. }
  16830. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  16831. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16832. import { Effect } from "babylonjs/Materials/effect";
  16833. import { Particle } from "babylonjs/Particles/particle";
  16834. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16835. import { Nullable } from "babylonjs/types";
  16836. import { Scene } from "babylonjs/scene";
  16837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16838. /**
  16839. * Particle emitter emitting particles from the inside of a box.
  16840. * It emits the particles randomly between 2 given directions.
  16841. */
  16842. export class MeshParticleEmitter implements IParticleEmitterType {
  16843. private _indices;
  16844. private _positions;
  16845. private _normals;
  16846. private _storedNormal;
  16847. private _mesh;
  16848. /**
  16849. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16850. */
  16851. direction1: Vector3;
  16852. /**
  16853. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16854. */
  16855. direction2: Vector3;
  16856. /**
  16857. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16858. */
  16859. useMeshNormalsForDirection: boolean;
  16860. /** Defines the mesh to use as source */
  16861. get mesh(): Nullable<AbstractMesh>;
  16862. set mesh(value: Nullable<AbstractMesh>);
  16863. /**
  16864. * Creates a new instance MeshParticleEmitter
  16865. * @param mesh defines the mesh to use as source
  16866. */
  16867. constructor(mesh?: Nullable<AbstractMesh>);
  16868. /**
  16869. * Called by the particle System when the direction is computed for the created particle.
  16870. * @param worldMatrix is the world matrix of the particle system
  16871. * @param directionToUpdate is the direction vector to update with the result
  16872. * @param particle is the particle we are computed the direction for
  16873. * @param isLocal defines if the direction should be set in local space
  16874. */
  16875. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16876. /**
  16877. * Called by the particle System when the position is computed for the created particle.
  16878. * @param worldMatrix is the world matrix of the particle system
  16879. * @param positionToUpdate is the position vector to update with the result
  16880. * @param particle is the particle we are computed the position for
  16881. * @param isLocal defines if the position should be set in local space
  16882. */
  16883. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16884. /**
  16885. * Clones the current emitter and returns a copy of it
  16886. * @returns the new emitter
  16887. */
  16888. clone(): MeshParticleEmitter;
  16889. /**
  16890. * Called by the GPUParticleSystem to setup the update shader
  16891. * @param effect defines the update shader
  16892. */
  16893. applyToShader(effect: Effect): void;
  16894. /**
  16895. * Returns a string to use to update the GPU particles update shader
  16896. * @returns a string containng the defines string
  16897. */
  16898. getEffectDefines(): string;
  16899. /**
  16900. * Returns the string "BoxParticleEmitter"
  16901. * @returns a string containing the class name
  16902. */
  16903. getClassName(): string;
  16904. /**
  16905. * Serializes the particle system to a JSON object.
  16906. * @returns the JSON object
  16907. */
  16908. serialize(): any;
  16909. /**
  16910. * Parse properties from a JSON object
  16911. * @param serializationObject defines the JSON object
  16912. * @param scene defines the hosting scene
  16913. */
  16914. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16915. }
  16916. }
  16917. declare module "babylonjs/Particles/EmitterTypes/index" {
  16918. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16919. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16920. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16921. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16922. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16923. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16924. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16925. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  16926. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  16927. }
  16928. declare module "babylonjs/Particles/IParticleSystem" {
  16929. import { Nullable } from "babylonjs/types";
  16930. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16931. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16933. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16934. import { Scene } from "babylonjs/scene";
  16935. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  16936. import { Effect } from "babylonjs/Materials/effect";
  16937. import { Observable } from "babylonjs/Misc/observable";
  16938. import { Animation } from "babylonjs/Animations/animation";
  16939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16940. /**
  16941. * Interface representing a particle system in Babylon.js.
  16942. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16943. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16944. */
  16945. export interface IParticleSystem {
  16946. /**
  16947. * List of animations used by the particle system.
  16948. */
  16949. animations: Animation[];
  16950. /**
  16951. * The id of the Particle system.
  16952. */
  16953. id: string;
  16954. /**
  16955. * The name of the Particle system.
  16956. */
  16957. name: string;
  16958. /**
  16959. * The emitter represents the Mesh or position we are attaching the particle system to.
  16960. */
  16961. emitter: Nullable<AbstractMesh | Vector3>;
  16962. /**
  16963. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16964. */
  16965. isBillboardBased: boolean;
  16966. /**
  16967. * The rendering group used by the Particle system to chose when to render.
  16968. */
  16969. renderingGroupId: number;
  16970. /**
  16971. * The layer mask we are rendering the particles through.
  16972. */
  16973. layerMask: number;
  16974. /**
  16975. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16976. */
  16977. updateSpeed: number;
  16978. /**
  16979. * The amount of time the particle system is running (depends of the overall update speed).
  16980. */
  16981. targetStopDuration: number;
  16982. /**
  16983. * The texture used to render each particle. (this can be a spritesheet)
  16984. */
  16985. particleTexture: Nullable<BaseTexture>;
  16986. /**
  16987. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16988. */
  16989. blendMode: number;
  16990. /**
  16991. * Minimum life time of emitting particles.
  16992. */
  16993. minLifeTime: number;
  16994. /**
  16995. * Maximum life time of emitting particles.
  16996. */
  16997. maxLifeTime: number;
  16998. /**
  16999. * Minimum Size of emitting particles.
  17000. */
  17001. minSize: number;
  17002. /**
  17003. * Maximum Size of emitting particles.
  17004. */
  17005. maxSize: number;
  17006. /**
  17007. * Minimum scale of emitting particles on X axis.
  17008. */
  17009. minScaleX: number;
  17010. /**
  17011. * Maximum scale of emitting particles on X axis.
  17012. */
  17013. maxScaleX: number;
  17014. /**
  17015. * Minimum scale of emitting particles on Y axis.
  17016. */
  17017. minScaleY: number;
  17018. /**
  17019. * Maximum scale of emitting particles on Y axis.
  17020. */
  17021. maxScaleY: number;
  17022. /**
  17023. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17024. */
  17025. color1: Color4;
  17026. /**
  17027. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17028. */
  17029. color2: Color4;
  17030. /**
  17031. * Color the particle will have at the end of its lifetime.
  17032. */
  17033. colorDead: Color4;
  17034. /**
  17035. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17036. */
  17037. emitRate: number;
  17038. /**
  17039. * You can use gravity if you want to give an orientation to your particles.
  17040. */
  17041. gravity: Vector3;
  17042. /**
  17043. * Minimum power of emitting particles.
  17044. */
  17045. minEmitPower: number;
  17046. /**
  17047. * Maximum power of emitting particles.
  17048. */
  17049. maxEmitPower: number;
  17050. /**
  17051. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17052. */
  17053. minAngularSpeed: number;
  17054. /**
  17055. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17056. */
  17057. maxAngularSpeed: number;
  17058. /**
  17059. * Gets or sets the minimal initial rotation in radians.
  17060. */
  17061. minInitialRotation: number;
  17062. /**
  17063. * Gets or sets the maximal initial rotation in radians.
  17064. */
  17065. maxInitialRotation: number;
  17066. /**
  17067. * The particle emitter type defines the emitter used by the particle system.
  17068. * It can be for example box, sphere, or cone...
  17069. */
  17070. particleEmitterType: Nullable<IParticleEmitterType>;
  17071. /**
  17072. * Defines the delay in milliseconds before starting the system (0 by default)
  17073. */
  17074. startDelay: number;
  17075. /**
  17076. * 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
  17077. */
  17078. preWarmCycles: number;
  17079. /**
  17080. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17081. */
  17082. preWarmStepOffset: number;
  17083. /**
  17084. * 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)
  17085. */
  17086. spriteCellChangeSpeed: number;
  17087. /**
  17088. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17089. */
  17090. startSpriteCellID: number;
  17091. /**
  17092. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17093. */
  17094. endSpriteCellID: number;
  17095. /**
  17096. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17097. */
  17098. spriteCellWidth: number;
  17099. /**
  17100. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17101. */
  17102. spriteCellHeight: number;
  17103. /**
  17104. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17105. */
  17106. spriteRandomStartCell: boolean;
  17107. /**
  17108. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17109. */
  17110. isAnimationSheetEnabled: boolean;
  17111. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17112. translationPivot: Vector2;
  17113. /**
  17114. * Gets or sets a texture used to add random noise to particle positions
  17115. */
  17116. noiseTexture: Nullable<BaseTexture>;
  17117. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17118. noiseStrength: Vector3;
  17119. /**
  17120. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17121. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17122. */
  17123. billboardMode: number;
  17124. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17125. limitVelocityDamping: number;
  17126. /**
  17127. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17128. */
  17129. beginAnimationOnStart: boolean;
  17130. /**
  17131. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17132. */
  17133. beginAnimationFrom: number;
  17134. /**
  17135. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17136. */
  17137. beginAnimationTo: number;
  17138. /**
  17139. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17140. */
  17141. beginAnimationLoop: boolean;
  17142. /**
  17143. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17144. */
  17145. disposeOnStop: boolean;
  17146. /**
  17147. * Specifies if the particles are updated in emitter local space or world space
  17148. */
  17149. isLocal: boolean;
  17150. /** Snippet ID if the particle system was created from the snippet server */
  17151. snippetId: string;
  17152. /** Gets or sets a matrix to use to compute projection */
  17153. defaultProjectionMatrix: Matrix;
  17154. /**
  17155. * Gets the maximum number of particles active at the same time.
  17156. * @returns The max number of active particles.
  17157. */
  17158. getCapacity(): number;
  17159. /**
  17160. * Gets the number of particles active at the same time.
  17161. * @returns The number of active particles.
  17162. */
  17163. getActiveCount(): number;
  17164. /**
  17165. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17166. * @returns True if it has been started, otherwise false.
  17167. */
  17168. isStarted(): boolean;
  17169. /**
  17170. * Animates the particle system for this frame.
  17171. */
  17172. animate(): void;
  17173. /**
  17174. * Renders the particle system in its current state.
  17175. * @returns the current number of particles
  17176. */
  17177. render(): number;
  17178. /**
  17179. * Dispose the particle system and frees its associated resources.
  17180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17181. */
  17182. dispose(disposeTexture?: boolean): void;
  17183. /**
  17184. * An event triggered when the system is disposed
  17185. */
  17186. onDisposeObservable: Observable<IParticleSystem>;
  17187. /**
  17188. * An event triggered when the system is stopped
  17189. */
  17190. onStoppedObservable: Observable<IParticleSystem>;
  17191. /**
  17192. * Clones the particle system.
  17193. * @param name The name of the cloned object
  17194. * @param newEmitter The new emitter to use
  17195. * @returns the cloned particle system
  17196. */
  17197. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17198. /**
  17199. * Serializes the particle system to a JSON object
  17200. * @param serializeTexture defines if the texture must be serialized as well
  17201. * @returns the JSON object
  17202. */
  17203. serialize(serializeTexture: boolean): any;
  17204. /**
  17205. * Rebuild the particle system
  17206. */
  17207. rebuild(): void;
  17208. /** Force the system to rebuild all gradients that need to be resync */
  17209. forceRefreshGradients(): void;
  17210. /**
  17211. * Starts the particle system and begins to emit
  17212. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17213. */
  17214. start(delay?: number): void;
  17215. /**
  17216. * Stops the particle system.
  17217. */
  17218. stop(): void;
  17219. /**
  17220. * Remove all active particles
  17221. */
  17222. reset(): void;
  17223. /**
  17224. * Gets a boolean indicating that the system is stopping
  17225. * @returns true if the system is currently stopping
  17226. */
  17227. isStopping(): boolean;
  17228. /**
  17229. * Is this system ready to be used/rendered
  17230. * @return true if the system is ready
  17231. */
  17232. isReady(): boolean;
  17233. /**
  17234. * Returns the string "ParticleSystem"
  17235. * @returns a string containing the class name
  17236. */
  17237. getClassName(): string;
  17238. /**
  17239. * Gets the custom effect used to render the particles
  17240. * @param blendMode Blend mode for which the effect should be retrieved
  17241. * @returns The effect
  17242. */
  17243. getCustomEffect(blendMode: number): Nullable<Effect>;
  17244. /**
  17245. * Sets the custom effect used to render the particles
  17246. * @param effect The effect to set
  17247. * @param blendMode Blend mode for which the effect should be set
  17248. */
  17249. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17250. /**
  17251. * Fill the defines array according to the current settings of the particle system
  17252. * @param defines Array to be updated
  17253. * @param blendMode blend mode to take into account when updating the array
  17254. */
  17255. fillDefines(defines: Array<string>, blendMode: number): void;
  17256. /**
  17257. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17258. * @param uniforms Uniforms array to fill
  17259. * @param attributes Attributes array to fill
  17260. * @param samplers Samplers array to fill
  17261. */
  17262. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17263. /**
  17264. * Observable that will be called just before the particles are drawn
  17265. */
  17266. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17267. /**
  17268. * Gets the name of the particle vertex shader
  17269. */
  17270. vertexShaderName: string;
  17271. /**
  17272. * Adds a new color gradient
  17273. * @param gradient defines the gradient to use (between 0 and 1)
  17274. * @param color1 defines the color to affect to the specified gradient
  17275. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17276. * @returns the current particle system
  17277. */
  17278. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17279. /**
  17280. * Remove a specific color gradient
  17281. * @param gradient defines the gradient to remove
  17282. * @returns the current particle system
  17283. */
  17284. removeColorGradient(gradient: number): IParticleSystem;
  17285. /**
  17286. * Adds a new size gradient
  17287. * @param gradient defines the gradient to use (between 0 and 1)
  17288. * @param factor defines the size factor to affect to the specified gradient
  17289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17290. * @returns the current particle system
  17291. */
  17292. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17293. /**
  17294. * Remove a specific size gradient
  17295. * @param gradient defines the gradient to remove
  17296. * @returns the current particle system
  17297. */
  17298. removeSizeGradient(gradient: number): IParticleSystem;
  17299. /**
  17300. * Gets the current list of color gradients.
  17301. * You must use addColorGradient and removeColorGradient to udpate this list
  17302. * @returns the list of color gradients
  17303. */
  17304. getColorGradients(): Nullable<Array<ColorGradient>>;
  17305. /**
  17306. * Gets the current list of size gradients.
  17307. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17308. * @returns the list of size gradients
  17309. */
  17310. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17311. /**
  17312. * Gets the current list of angular speed gradients.
  17313. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17314. * @returns the list of angular speed gradients
  17315. */
  17316. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17317. /**
  17318. * Adds a new angular speed gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param factor defines the angular speed to affect to the specified gradient
  17321. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17322. * @returns the current particle system
  17323. */
  17324. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific angular speed gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Gets the current list of velocity gradients.
  17333. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17334. * @returns the list of velocity gradients
  17335. */
  17336. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17337. /**
  17338. * Adds a new velocity gradient
  17339. * @param gradient defines the gradient to use (between 0 and 1)
  17340. * @param factor defines the velocity to affect to the specified gradient
  17341. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17342. * @returns the current particle system
  17343. */
  17344. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17345. /**
  17346. * Remove a specific velocity gradient
  17347. * @param gradient defines the gradient to remove
  17348. * @returns the current particle system
  17349. */
  17350. removeVelocityGradient(gradient: number): IParticleSystem;
  17351. /**
  17352. * Gets the current list of limit velocity gradients.
  17353. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17354. * @returns the list of limit velocity gradients
  17355. */
  17356. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17357. /**
  17358. * Adds a new limit velocity gradient
  17359. * @param gradient defines the gradient to use (between 0 and 1)
  17360. * @param factor defines the limit velocity to affect to the specified gradient
  17361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17362. * @returns the current particle system
  17363. */
  17364. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17365. /**
  17366. * Remove a specific limit velocity gradient
  17367. * @param gradient defines the gradient to remove
  17368. * @returns the current particle system
  17369. */
  17370. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17371. /**
  17372. * Adds a new drag gradient
  17373. * @param gradient defines the gradient to use (between 0 and 1)
  17374. * @param factor defines the drag to affect to the specified gradient
  17375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17376. * @returns the current particle system
  17377. */
  17378. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17379. /**
  17380. * Remove a specific drag gradient
  17381. * @param gradient defines the gradient to remove
  17382. * @returns the current particle system
  17383. */
  17384. removeDragGradient(gradient: number): IParticleSystem;
  17385. /**
  17386. * Gets the current list of drag gradients.
  17387. * You must use addDragGradient and removeDragGradient to udpate this list
  17388. * @returns the list of drag gradients
  17389. */
  17390. getDragGradients(): Nullable<Array<FactorGradient>>;
  17391. /**
  17392. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17393. * @param gradient defines the gradient to use (between 0 and 1)
  17394. * @param factor defines the emit rate to affect to the specified gradient
  17395. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17396. * @returns the current particle system
  17397. */
  17398. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17399. /**
  17400. * Remove a specific emit rate gradient
  17401. * @param gradient defines the gradient to remove
  17402. * @returns the current particle system
  17403. */
  17404. removeEmitRateGradient(gradient: number): IParticleSystem;
  17405. /**
  17406. * Gets the current list of emit rate gradients.
  17407. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17408. * @returns the list of emit rate gradients
  17409. */
  17410. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17411. /**
  17412. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17413. * @param gradient defines the gradient to use (between 0 and 1)
  17414. * @param factor defines the start size to affect to the specified gradient
  17415. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17416. * @returns the current particle system
  17417. */
  17418. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17419. /**
  17420. * Remove a specific start size gradient
  17421. * @param gradient defines the gradient to remove
  17422. * @returns the current particle system
  17423. */
  17424. removeStartSizeGradient(gradient: number): IParticleSystem;
  17425. /**
  17426. * Gets the current list of start size gradients.
  17427. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17428. * @returns the list of start size gradients
  17429. */
  17430. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17431. /**
  17432. * Adds a new life time gradient
  17433. * @param gradient defines the gradient to use (between 0 and 1)
  17434. * @param factor defines the life time factor to affect to the specified gradient
  17435. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17436. * @returns the current particle system
  17437. */
  17438. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17439. /**
  17440. * Remove a specific life time gradient
  17441. * @param gradient defines the gradient to remove
  17442. * @returns the current particle system
  17443. */
  17444. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17445. /**
  17446. * Gets the current list of life time gradients.
  17447. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17448. * @returns the list of life time gradients
  17449. */
  17450. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17451. /**
  17452. * Gets the current list of color gradients.
  17453. * You must use addColorGradient and removeColorGradient to udpate this list
  17454. * @returns the list of color gradients
  17455. */
  17456. getColorGradients(): Nullable<Array<ColorGradient>>;
  17457. /**
  17458. * Adds a new ramp gradient used to remap particle colors
  17459. * @param gradient defines the gradient to use (between 0 and 1)
  17460. * @param color defines the color to affect to the specified gradient
  17461. * @returns the current particle system
  17462. */
  17463. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17464. /**
  17465. * Gets the current list of ramp gradients.
  17466. * You must use addRampGradient and removeRampGradient to udpate this list
  17467. * @returns the list of ramp gradients
  17468. */
  17469. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17470. /** Gets or sets a boolean indicating that ramp gradients must be used
  17471. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17472. */
  17473. useRampGradients: boolean;
  17474. /**
  17475. * Adds a new color remap gradient
  17476. * @param gradient defines the gradient to use (between 0 and 1)
  17477. * @param min defines the color remap minimal range
  17478. * @param max defines the color remap maximal range
  17479. * @returns the current particle system
  17480. */
  17481. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17482. /**
  17483. * Gets the current list of color remap gradients.
  17484. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17485. * @returns the list of color remap gradients
  17486. */
  17487. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17488. /**
  17489. * Adds a new alpha remap gradient
  17490. * @param gradient defines the gradient to use (between 0 and 1)
  17491. * @param min defines the alpha remap minimal range
  17492. * @param max defines the alpha remap maximal range
  17493. * @returns the current particle system
  17494. */
  17495. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17496. /**
  17497. * Gets the current list of alpha remap gradients.
  17498. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17499. * @returns the list of alpha remap gradients
  17500. */
  17501. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17502. /**
  17503. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17504. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17505. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17506. * @returns the emitter
  17507. */
  17508. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17509. /**
  17510. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17511. * @param radius The radius of the hemisphere to emit from
  17512. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17513. * @returns the emitter
  17514. */
  17515. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17516. /**
  17517. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17518. * @param radius The radius of the sphere to emit from
  17519. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17520. * @returns the emitter
  17521. */
  17522. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17523. /**
  17524. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17525. * @param radius The radius of the sphere to emit from
  17526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17528. * @returns the emitter
  17529. */
  17530. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17531. /**
  17532. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17533. * @param radius The radius of the emission cylinder
  17534. * @param height The height of the emission cylinder
  17535. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17536. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17537. * @returns the emitter
  17538. */
  17539. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17540. /**
  17541. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17542. * @param radius The radius of the cylinder to emit from
  17543. * @param height The height of the emission cylinder
  17544. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17545. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17546. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17547. * @returns the emitter
  17548. */
  17549. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17550. /**
  17551. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17552. * @param radius The radius of the cone to emit from
  17553. * @param angle The base angle of the cone
  17554. * @returns the emitter
  17555. */
  17556. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17557. /**
  17558. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17559. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17560. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17561. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17562. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17563. * @returns the emitter
  17564. */
  17565. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17566. /**
  17567. * Get hosting scene
  17568. * @returns the scene
  17569. */
  17570. getScene(): Nullable<Scene>;
  17571. }
  17572. }
  17573. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  17574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17577. /**
  17578. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17579. */
  17580. export class ColorSplitterBlock extends NodeMaterialBlock {
  17581. /**
  17582. * Create a new ColorSplitterBlock
  17583. * @param name defines the block name
  17584. */
  17585. constructor(name: string);
  17586. /**
  17587. * Gets the current class name
  17588. * @returns the class name
  17589. */
  17590. getClassName(): string;
  17591. /**
  17592. * Gets the rgba component (input)
  17593. */
  17594. get rgba(): NodeMaterialConnectionPoint;
  17595. /**
  17596. * Gets the rgb component (input)
  17597. */
  17598. get rgbIn(): NodeMaterialConnectionPoint;
  17599. /**
  17600. * Gets the rgb component (output)
  17601. */
  17602. get rgbOut(): NodeMaterialConnectionPoint;
  17603. /**
  17604. * Gets the r component (output)
  17605. */
  17606. get r(): NodeMaterialConnectionPoint;
  17607. /**
  17608. * Gets the g component (output)
  17609. */
  17610. get g(): NodeMaterialConnectionPoint;
  17611. /**
  17612. * Gets the b component (output)
  17613. */
  17614. get b(): NodeMaterialConnectionPoint;
  17615. /**
  17616. * Gets the a component (output)
  17617. */
  17618. get a(): NodeMaterialConnectionPoint;
  17619. protected _inputRename(name: string): string;
  17620. protected _outputRename(name: string): string;
  17621. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17622. }
  17623. }
  17624. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  17625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  17627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  17628. import { Scene } from "babylonjs/scene";
  17629. /**
  17630. * Operations supported by the Trigonometry block
  17631. */
  17632. export enum TrigonometryBlockOperations {
  17633. /** Cos */
  17634. Cos = 0,
  17635. /** Sin */
  17636. Sin = 1,
  17637. /** Abs */
  17638. Abs = 2,
  17639. /** Exp */
  17640. Exp = 3,
  17641. /** Exp2 */
  17642. Exp2 = 4,
  17643. /** Round */
  17644. Round = 5,
  17645. /** Floor */
  17646. Floor = 6,
  17647. /** Ceiling */
  17648. Ceiling = 7,
  17649. /** Square root */
  17650. Sqrt = 8,
  17651. /** Log */
  17652. Log = 9,
  17653. /** Tangent */
  17654. Tan = 10,
  17655. /** Arc tangent */
  17656. ArcTan = 11,
  17657. /** Arc cosinus */
  17658. ArcCos = 12,
  17659. /** Arc sinus */
  17660. ArcSin = 13,
  17661. /** Fraction */
  17662. Fract = 14,
  17663. /** Sign */
  17664. Sign = 15,
  17665. /** To radians (from degrees) */
  17666. Radians = 16,
  17667. /** To degrees (from radians) */
  17668. Degrees = 17
  17669. }
  17670. /**
  17671. * Block used to apply trigonometry operation to floats
  17672. */
  17673. export class TrigonometryBlock extends NodeMaterialBlock {
  17674. /**
  17675. * Gets or sets the operation applied by the block
  17676. */
  17677. operation: TrigonometryBlockOperations;
  17678. /**
  17679. * Creates a new TrigonometryBlock
  17680. * @param name defines the block name
  17681. */
  17682. constructor(name: string);
  17683. /**
  17684. * Gets the current class name
  17685. * @returns the class name
  17686. */
  17687. getClassName(): string;
  17688. /**
  17689. * Gets the input component
  17690. */
  17691. get input(): NodeMaterialConnectionPoint;
  17692. /**
  17693. * Gets the output component
  17694. */
  17695. get output(): NodeMaterialConnectionPoint;
  17696. protected _buildBlock(state: NodeMaterialBuildState): this;
  17697. serialize(): any;
  17698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17699. protected _dumpPropertiesCode(): string;
  17700. }
  17701. }
  17702. declare module "babylonjs/Materials/Node/nodeMaterial" {
  17703. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  17704. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  17705. import { Scene } from "babylonjs/scene";
  17706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17707. import { Matrix } from "babylonjs/Maths/math.vector";
  17708. import { Mesh } from "babylonjs/Meshes/mesh";
  17709. import { Engine } from "babylonjs/Engines/engine";
  17710. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17711. import { Observable } from "babylonjs/Misc/observable";
  17712. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17713. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17714. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  17715. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17716. import { Nullable } from "babylonjs/types";
  17717. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  17718. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  17719. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  17720. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  17721. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  17722. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  17723. import { Effect } from "babylonjs/Materials/effect";
  17724. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  17725. import { Camera } from "babylonjs/Cameras/camera";
  17726. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  17727. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17728. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17729. /**
  17730. * Interface used to configure the node material editor
  17731. */
  17732. export interface INodeMaterialEditorOptions {
  17733. /** Define the URl to load node editor script */
  17734. editorURL?: string;
  17735. }
  17736. /** @hidden */
  17737. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17738. NORMAL: boolean;
  17739. TANGENT: boolean;
  17740. UV1: boolean;
  17741. /** BONES */
  17742. NUM_BONE_INFLUENCERS: number;
  17743. BonesPerMesh: number;
  17744. BONETEXTURE: boolean;
  17745. /** MORPH TARGETS */
  17746. MORPHTARGETS: boolean;
  17747. MORPHTARGETS_NORMAL: boolean;
  17748. MORPHTARGETS_TANGENT: boolean;
  17749. MORPHTARGETS_UV: boolean;
  17750. NUM_MORPH_INFLUENCERS: number;
  17751. /** IMAGE PROCESSING */
  17752. IMAGEPROCESSING: boolean;
  17753. VIGNETTE: boolean;
  17754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17755. VIGNETTEBLENDMODEOPAQUE: boolean;
  17756. TONEMAPPING: boolean;
  17757. TONEMAPPING_ACES: boolean;
  17758. CONTRAST: boolean;
  17759. EXPOSURE: boolean;
  17760. COLORCURVES: boolean;
  17761. COLORGRADING: boolean;
  17762. COLORGRADING3D: boolean;
  17763. SAMPLER3DGREENDEPTH: boolean;
  17764. SAMPLER3DBGRMAP: boolean;
  17765. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17766. /** MISC. */
  17767. BUMPDIRECTUV: number;
  17768. constructor();
  17769. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17770. }
  17771. /**
  17772. * Class used to configure NodeMaterial
  17773. */
  17774. export interface INodeMaterialOptions {
  17775. /**
  17776. * Defines if blocks should emit comments
  17777. */
  17778. emitComments: boolean;
  17779. }
  17780. /**
  17781. * Class used to create a node based material built by assembling shader blocks
  17782. */
  17783. export class NodeMaterial extends PushMaterial {
  17784. private static _BuildIdGenerator;
  17785. private _options;
  17786. private _vertexCompilationState;
  17787. private _fragmentCompilationState;
  17788. private _sharedData;
  17789. private _buildId;
  17790. private _buildWasSuccessful;
  17791. private _cachedWorldViewMatrix;
  17792. private _cachedWorldViewProjectionMatrix;
  17793. private _optimizers;
  17794. private _animationFrame;
  17795. /** Define the Url to load node editor script */
  17796. static EditorURL: string;
  17797. /** Define the Url to load snippets */
  17798. static SnippetUrl: string;
  17799. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17800. static IgnoreTexturesAtLoadTime: boolean;
  17801. private BJSNODEMATERIALEDITOR;
  17802. /** Get the inspector from bundle or global */
  17803. private _getGlobalNodeMaterialEditor;
  17804. /**
  17805. * Snippet ID if the material was created from the snippet server
  17806. */
  17807. snippetId: string;
  17808. /**
  17809. * Gets or sets data used by visual editor
  17810. * @see https://nme.babylonjs.com
  17811. */
  17812. editorData: any;
  17813. /**
  17814. * 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)
  17815. */
  17816. ignoreAlpha: boolean;
  17817. /**
  17818. * Defines the maximum number of lights that can be used in the material
  17819. */
  17820. maxSimultaneousLights: number;
  17821. /**
  17822. * Observable raised when the material is built
  17823. */
  17824. onBuildObservable: Observable<NodeMaterial>;
  17825. /**
  17826. * Gets or sets the root nodes of the material vertex shader
  17827. */
  17828. _vertexOutputNodes: NodeMaterialBlock[];
  17829. /**
  17830. * Gets or sets the root nodes of the material fragment (pixel) shader
  17831. */
  17832. _fragmentOutputNodes: NodeMaterialBlock[];
  17833. /** Gets or sets options to control the node material overall behavior */
  17834. get options(): INodeMaterialOptions;
  17835. set options(options: INodeMaterialOptions);
  17836. /**
  17837. * Default configuration related to image processing available in the standard Material.
  17838. */
  17839. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17840. /**
  17841. * Gets the image processing configuration used either in this material.
  17842. */
  17843. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17844. /**
  17845. * Sets the Default image processing configuration used either in the this material.
  17846. *
  17847. * If sets to null, the scene one is in use.
  17848. */
  17849. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17850. /**
  17851. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17852. */
  17853. attachedBlocks: NodeMaterialBlock[];
  17854. /**
  17855. * Specifies the mode of the node material
  17856. * @hidden
  17857. */
  17858. _mode: NodeMaterialModes;
  17859. /**
  17860. * Gets the mode property
  17861. */
  17862. get mode(): NodeMaterialModes;
  17863. /**
  17864. * A free comment about the material
  17865. */
  17866. comment: string;
  17867. /**
  17868. * Create a new node based material
  17869. * @param name defines the material name
  17870. * @param scene defines the hosting scene
  17871. * @param options defines creation option
  17872. */
  17873. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17874. /**
  17875. * Gets the current class name of the material e.g. "NodeMaterial"
  17876. * @returns the class name
  17877. */
  17878. getClassName(): string;
  17879. /**
  17880. * Keep track of the image processing observer to allow dispose and replace.
  17881. */
  17882. private _imageProcessingObserver;
  17883. /**
  17884. * Attaches a new image processing configuration to the Standard Material.
  17885. * @param configuration
  17886. */
  17887. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17888. /**
  17889. * Get a block by its name
  17890. * @param name defines the name of the block to retrieve
  17891. * @returns the required block or null if not found
  17892. */
  17893. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17894. /**
  17895. * Get a block by its name
  17896. * @param predicate defines the predicate used to find the good candidate
  17897. * @returns the required block or null if not found
  17898. */
  17899. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17900. /**
  17901. * Get an input block by its name
  17902. * @param predicate defines the predicate used to find the good candidate
  17903. * @returns the required input block or null if not found
  17904. */
  17905. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17906. /**
  17907. * Gets the list of input blocks attached to this material
  17908. * @returns an array of InputBlocks
  17909. */
  17910. getInputBlocks(): InputBlock[];
  17911. /**
  17912. * Adds a new optimizer to the list of optimizers
  17913. * @param optimizer defines the optimizers to add
  17914. * @returns the current material
  17915. */
  17916. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17917. /**
  17918. * Remove an optimizer from the list of optimizers
  17919. * @param optimizer defines the optimizers to remove
  17920. * @returns the current material
  17921. */
  17922. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17923. /**
  17924. * Add a new block to the list of output nodes
  17925. * @param node defines the node to add
  17926. * @returns the current material
  17927. */
  17928. addOutputNode(node: NodeMaterialBlock): this;
  17929. /**
  17930. * Remove a block from the list of root nodes
  17931. * @param node defines the node to remove
  17932. * @returns the current material
  17933. */
  17934. removeOutputNode(node: NodeMaterialBlock): this;
  17935. private _addVertexOutputNode;
  17936. private _removeVertexOutputNode;
  17937. private _addFragmentOutputNode;
  17938. private _removeFragmentOutputNode;
  17939. /**
  17940. * Specifies if the material will require alpha blending
  17941. * @returns a boolean specifying if alpha blending is needed
  17942. */
  17943. needAlphaBlending(): boolean;
  17944. /**
  17945. * Specifies if this material should be rendered in alpha test mode
  17946. * @returns a boolean specifying if an alpha test is needed.
  17947. */
  17948. needAlphaTesting(): boolean;
  17949. private _initializeBlock;
  17950. private _resetDualBlocks;
  17951. /**
  17952. * Remove a block from the current node material
  17953. * @param block defines the block to remove
  17954. */
  17955. removeBlock(block: NodeMaterialBlock): void;
  17956. /**
  17957. * Build the material and generates the inner effect
  17958. * @param verbose defines if the build should log activity
  17959. */
  17960. build(verbose?: boolean): void;
  17961. /**
  17962. * Runs an otpimization phase to try to improve the shader code
  17963. */
  17964. optimize(): void;
  17965. private _prepareDefinesForAttributes;
  17966. /**
  17967. * Create a post process from the material
  17968. * @param camera The camera to apply the render pass to.
  17969. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17971. * @param engine The engine which the post process will be applied. (default: current engine)
  17972. * @param reusable If the post process can be reused on the same frame. (default: false)
  17973. * @param textureType Type of textures used when performing the post process. (default: 0)
  17974. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17975. * @returns the post process created
  17976. */
  17977. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17978. /**
  17979. * Create the post process effect from the material
  17980. * @param postProcess The post process to create the effect for
  17981. */
  17982. createEffectForPostProcess(postProcess: PostProcess): void;
  17983. private _createEffectForPostProcess;
  17984. /**
  17985. * Create a new procedural texture based on this node material
  17986. * @param size defines the size of the texture
  17987. * @param scene defines the hosting scene
  17988. * @returns the new procedural texture attached to this node material
  17989. */
  17990. createProceduralTexture(size: number | {
  17991. width: number;
  17992. height: number;
  17993. layers?: number;
  17994. }, scene: Scene): Nullable<ProceduralTexture>;
  17995. private _createEffectForParticles;
  17996. private _checkInternals;
  17997. /**
  17998. * Create the effect to be used as the custom effect for a particle system
  17999. * @param particleSystem Particle system to create the effect for
  18000. * @param onCompiled defines a function to call when the effect creation is successful
  18001. * @param onError defines a function to call when the effect creation has failed
  18002. */
  18003. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18004. private _processDefines;
  18005. /**
  18006. * Get if the submesh is ready to be used and all its information available.
  18007. * Child classes can use it to update shaders
  18008. * @param mesh defines the mesh to check
  18009. * @param subMesh defines which submesh to check
  18010. * @param useInstances specifies that instances should be used
  18011. * @returns a boolean indicating that the submesh is ready or not
  18012. */
  18013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18014. /**
  18015. * Get a string representing the shaders built by the current node graph
  18016. */
  18017. get compiledShaders(): string;
  18018. /**
  18019. * Binds the world matrix to the material
  18020. * @param world defines the world transformation matrix
  18021. */
  18022. bindOnlyWorldMatrix(world: Matrix): void;
  18023. /**
  18024. * Binds the submesh to this material by preparing the effect and shader to draw
  18025. * @param world defines the world transformation matrix
  18026. * @param mesh defines the mesh containing the submesh
  18027. * @param subMesh defines the submesh to bind the material to
  18028. */
  18029. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18030. /**
  18031. * Gets the active textures from the material
  18032. * @returns an array of textures
  18033. */
  18034. getActiveTextures(): BaseTexture[];
  18035. /**
  18036. * Gets the list of texture blocks
  18037. * @returns an array of texture blocks
  18038. */
  18039. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18040. /**
  18041. * Specifies if the material uses a texture
  18042. * @param texture defines the texture to check against the material
  18043. * @returns a boolean specifying if the material uses the texture
  18044. */
  18045. hasTexture(texture: BaseTexture): boolean;
  18046. /**
  18047. * Disposes the material
  18048. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18049. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18050. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18051. */
  18052. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18053. /** Creates the node editor window. */
  18054. private _createNodeEditor;
  18055. /**
  18056. * Launch the node material editor
  18057. * @param config Define the configuration of the editor
  18058. * @return a promise fulfilled when the node editor is visible
  18059. */
  18060. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18061. /**
  18062. * Clear the current material
  18063. */
  18064. clear(): void;
  18065. /**
  18066. * Clear the current material and set it to a default state
  18067. */
  18068. setToDefault(): void;
  18069. /**
  18070. * Clear the current material and set it to a default state for post process
  18071. */
  18072. setToDefaultPostProcess(): void;
  18073. /**
  18074. * Clear the current material and set it to a default state for procedural texture
  18075. */
  18076. setToDefaultProceduralTexture(): void;
  18077. /**
  18078. * Clear the current material and set it to a default state for particle
  18079. */
  18080. setToDefaultParticle(): void;
  18081. /**
  18082. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18083. * @param url defines the url to load from
  18084. * @returns a promise that will fullfil when the material is fully loaded
  18085. */
  18086. loadAsync(url: string): Promise<void>;
  18087. private _gatherBlocks;
  18088. /**
  18089. * Generate a string containing the code declaration required to create an equivalent of this material
  18090. * @returns a string
  18091. */
  18092. generateCode(): string;
  18093. /**
  18094. * Serializes this material in a JSON representation
  18095. * @returns the serialized material object
  18096. */
  18097. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18098. private _restoreConnections;
  18099. /**
  18100. * Clear the current graph and load a new one from a serialization object
  18101. * @param source defines the JSON representation of the material
  18102. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18103. * @param merge defines whether or not the source must be merged or replace the current content
  18104. */
  18105. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18106. /**
  18107. * Makes a duplicate of the current material.
  18108. * @param name - name to use for the new material.
  18109. */
  18110. clone(name: string): NodeMaterial;
  18111. /**
  18112. * Creates a node material from parsed material data
  18113. * @param source defines the JSON representation of the material
  18114. * @param scene defines the hosting scene
  18115. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18116. * @returns a new node material
  18117. */
  18118. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18119. /**
  18120. * Creates a node material from a snippet saved in a remote file
  18121. * @param name defines the name of the material to create
  18122. * @param url defines the url to load from
  18123. * @param scene defines the hosting scene
  18124. * @returns a promise that will resolve to the new node material
  18125. */
  18126. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18127. /**
  18128. * Creates a node material from a snippet saved by the node material editor
  18129. * @param snippetId defines the snippet to load
  18130. * @param scene defines the hosting scene
  18131. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18132. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18133. * @returns a promise that will resolve to the new node material
  18134. */
  18135. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18136. /**
  18137. * Creates a new node material set to default basic configuration
  18138. * @param name defines the name of the material
  18139. * @param scene defines the hosting scene
  18140. * @returns a new NodeMaterial
  18141. */
  18142. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18143. }
  18144. }
  18145. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  18146. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18147. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  18148. import { Nullable } from "babylonjs/types";
  18149. module "babylonjs/Engines/thinEngine" {
  18150. interface ThinEngine {
  18151. /**
  18152. * Unbind a list of render target textures from the webGL context
  18153. * This is used only when drawBuffer extension or webGL2 are active
  18154. * @param textures defines the render target textures to unbind
  18155. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18156. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18157. */
  18158. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18159. /**
  18160. * Create a multi render target texture
  18161. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18162. * @param size defines the size of the texture
  18163. * @param options defines the creation options
  18164. * @returns the cube texture as an InternalTexture
  18165. */
  18166. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18167. /**
  18168. * Update the sample count for a given multiple render target texture
  18169. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18170. * @param textures defines the textures to update
  18171. * @param samples defines the sample count to set
  18172. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18173. */
  18174. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18175. /**
  18176. * Select a subsets of attachments to draw to.
  18177. * @param attachments gl attachments
  18178. */
  18179. bindAttachments(attachments: number[]): void;
  18180. /**
  18181. * Creates a layout object to draw/clear on specific textures in a MRT
  18182. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18183. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18184. */
  18185. buildTextureLayout(textureStatus: boolean[]): number[];
  18186. /**
  18187. * Restores the webgl state to only draw on the main color attachment
  18188. */
  18189. restoreSingleAttachment(): void;
  18190. }
  18191. }
  18192. }
  18193. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  18194. import { Scene } from "babylonjs/scene";
  18195. import { Engine } from "babylonjs/Engines/engine";
  18196. import { Texture } from "babylonjs/Materials/Textures/texture";
  18197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18198. import "babylonjs/Engines/Extensions/engine.multiRender";
  18199. /**
  18200. * Creation options of the multi render target texture.
  18201. */
  18202. export interface IMultiRenderTargetOptions {
  18203. /**
  18204. * Define if the texture needs to create mip maps after render.
  18205. */
  18206. generateMipMaps?: boolean;
  18207. /**
  18208. * Define the types of all the draw buffers we want to create
  18209. */
  18210. types?: number[];
  18211. /**
  18212. * Define the sampling modes of all the draw buffers we want to create
  18213. */
  18214. samplingModes?: number[];
  18215. /**
  18216. * Define if a depth buffer is required
  18217. */
  18218. generateDepthBuffer?: boolean;
  18219. /**
  18220. * Define if a stencil buffer is required
  18221. */
  18222. generateStencilBuffer?: boolean;
  18223. /**
  18224. * Define if a depth texture is required instead of a depth buffer
  18225. */
  18226. generateDepthTexture?: boolean;
  18227. /**
  18228. * Define the number of desired draw buffers
  18229. */
  18230. textureCount?: number;
  18231. /**
  18232. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18233. */
  18234. doNotChangeAspectRatio?: boolean;
  18235. /**
  18236. * Define the default type of the buffers we are creating
  18237. */
  18238. defaultType?: number;
  18239. }
  18240. /**
  18241. * A multi render target, like a render target provides the ability to render to a texture.
  18242. * Unlike the render target, it can render to several draw buffers in one draw.
  18243. * This is specially interesting in deferred rendering or for any effects requiring more than
  18244. * just one color from a single pass.
  18245. */
  18246. export class MultiRenderTarget extends RenderTargetTexture {
  18247. private _internalTextures;
  18248. private _textures;
  18249. private _multiRenderTargetOptions;
  18250. private _count;
  18251. /**
  18252. * Get if draw buffers are currently supported by the used hardware and browser.
  18253. */
  18254. get isSupported(): boolean;
  18255. /**
  18256. * Get the list of textures generated by the multi render target.
  18257. */
  18258. get textures(): Texture[];
  18259. /**
  18260. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18261. */
  18262. get count(): number;
  18263. /**
  18264. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18265. */
  18266. get depthTexture(): Texture;
  18267. /**
  18268. * Set the wrapping mode on U of all the textures we are rendering to.
  18269. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18270. */
  18271. set wrapU(wrap: number);
  18272. /**
  18273. * Set the wrapping mode on V of all the textures we are rendering to.
  18274. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18275. */
  18276. set wrapV(wrap: number);
  18277. /**
  18278. * Instantiate a new multi render target texture.
  18279. * A multi render target, like a render target provides the ability to render to a texture.
  18280. * Unlike the render target, it can render to several draw buffers in one draw.
  18281. * This is specially interesting in deferred rendering or for any effects requiring more than
  18282. * just one color from a single pass.
  18283. * @param name Define the name of the texture
  18284. * @param size Define the size of the buffers to render to
  18285. * @param count Define the number of target we are rendering into
  18286. * @param scene Define the scene the texture belongs to
  18287. * @param options Define the options used to create the multi render target
  18288. */
  18289. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18290. private _initTypes;
  18291. /** @hidden */
  18292. _rebuild(forceFullRebuild?: boolean): void;
  18293. private _createInternalTextures;
  18294. private _createTextures;
  18295. /**
  18296. * Replaces a texture within the MRT.
  18297. * @param texture The new texture to insert in the MRT
  18298. * @param index The index of the texture to replace
  18299. */
  18300. replaceTexture(texture: Texture, index: number): void;
  18301. /**
  18302. * Define the number of samples used if MSAA is enabled.
  18303. */
  18304. get samples(): number;
  18305. set samples(value: number);
  18306. /**
  18307. * Resize all the textures in the multi render target.
  18308. * Be careful as it will recreate all the data in the new texture.
  18309. * @param size Define the new size
  18310. */
  18311. resize(size: any): void;
  18312. /**
  18313. * Changes the number of render targets in this MRT
  18314. * Be careful as it will recreate all the data in the new texture.
  18315. * @param count new texture count
  18316. * @param options Specifies texture types and sampling modes for new textures
  18317. */
  18318. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18320. /**
  18321. * Dispose the render targets and their associated resources
  18322. */
  18323. dispose(): void;
  18324. /**
  18325. * Release all the underlying texture used as draw buffers.
  18326. */
  18327. releaseInternalTextures(): void;
  18328. }
  18329. }
  18330. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  18331. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18332. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18333. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18334. /** @hidden */
  18335. export var imageProcessingPixelShader: {
  18336. name: string;
  18337. shader: string;
  18338. };
  18339. }
  18340. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  18341. import { Nullable } from "babylonjs/types";
  18342. import { Color4 } from "babylonjs/Maths/math.color";
  18343. import { Camera } from "babylonjs/Cameras/camera";
  18344. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18345. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  18346. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  18347. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18348. import { Engine } from "babylonjs/Engines/engine";
  18349. import "babylonjs/Shaders/imageProcessing.fragment";
  18350. import "babylonjs/Shaders/postprocess.vertex";
  18351. /**
  18352. * ImageProcessingPostProcess
  18353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18354. */
  18355. export class ImageProcessingPostProcess extends PostProcess {
  18356. /**
  18357. * Default configuration related to image processing available in the PBR Material.
  18358. */
  18359. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18360. /**
  18361. * Gets the image processing configuration used either in this material.
  18362. */
  18363. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18364. /**
  18365. * Sets the Default image processing configuration used either in the this material.
  18366. *
  18367. * If sets to null, the scene one is in use.
  18368. */
  18369. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18370. /**
  18371. * Keep track of the image processing observer to allow dispose and replace.
  18372. */
  18373. private _imageProcessingObserver;
  18374. /**
  18375. * Attaches a new image processing configuration to the PBR Material.
  18376. * @param configuration
  18377. */
  18378. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18379. /**
  18380. * If the post process is supported.
  18381. */
  18382. get isSupported(): boolean;
  18383. /**
  18384. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18385. */
  18386. get colorCurves(): Nullable<ColorCurves>;
  18387. /**
  18388. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18389. */
  18390. set colorCurves(value: Nullable<ColorCurves>);
  18391. /**
  18392. * Gets wether the color curves effect is enabled.
  18393. */
  18394. get colorCurvesEnabled(): boolean;
  18395. /**
  18396. * Sets wether the color curves effect is enabled.
  18397. */
  18398. set colorCurvesEnabled(value: boolean);
  18399. /**
  18400. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18401. */
  18402. get colorGradingTexture(): Nullable<BaseTexture>;
  18403. /**
  18404. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18405. */
  18406. set colorGradingTexture(value: Nullable<BaseTexture>);
  18407. /**
  18408. * Gets wether the color grading effect is enabled.
  18409. */
  18410. get colorGradingEnabled(): boolean;
  18411. /**
  18412. * Gets wether the color grading effect is enabled.
  18413. */
  18414. set colorGradingEnabled(value: boolean);
  18415. /**
  18416. * Gets exposure used in the effect.
  18417. */
  18418. get exposure(): number;
  18419. /**
  18420. * Sets exposure used in the effect.
  18421. */
  18422. set exposure(value: number);
  18423. /**
  18424. * Gets wether tonemapping is enabled or not.
  18425. */
  18426. get toneMappingEnabled(): boolean;
  18427. /**
  18428. * Sets wether tonemapping is enabled or not
  18429. */
  18430. set toneMappingEnabled(value: boolean);
  18431. /**
  18432. * Gets the type of tone mapping effect.
  18433. */
  18434. get toneMappingType(): number;
  18435. /**
  18436. * Sets the type of tone mapping effect.
  18437. */
  18438. set toneMappingType(value: number);
  18439. /**
  18440. * Gets contrast used in the effect.
  18441. */
  18442. get contrast(): number;
  18443. /**
  18444. * Sets contrast used in the effect.
  18445. */
  18446. set contrast(value: number);
  18447. /**
  18448. * Gets Vignette stretch size.
  18449. */
  18450. get vignetteStretch(): number;
  18451. /**
  18452. * Sets Vignette stretch size.
  18453. */
  18454. set vignetteStretch(value: number);
  18455. /**
  18456. * Gets Vignette centre X Offset.
  18457. */
  18458. get vignetteCentreX(): number;
  18459. /**
  18460. * Sets Vignette centre X Offset.
  18461. */
  18462. set vignetteCentreX(value: number);
  18463. /**
  18464. * Gets Vignette centre Y Offset.
  18465. */
  18466. get vignetteCentreY(): number;
  18467. /**
  18468. * Sets Vignette centre Y Offset.
  18469. */
  18470. set vignetteCentreY(value: number);
  18471. /**
  18472. * Gets Vignette weight or intensity of the vignette effect.
  18473. */
  18474. get vignetteWeight(): number;
  18475. /**
  18476. * Sets Vignette weight or intensity of the vignette effect.
  18477. */
  18478. set vignetteWeight(value: number);
  18479. /**
  18480. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18481. * if vignetteEnabled is set to true.
  18482. */
  18483. get vignetteColor(): Color4;
  18484. /**
  18485. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18486. * if vignetteEnabled is set to true.
  18487. */
  18488. set vignetteColor(value: Color4);
  18489. /**
  18490. * Gets Camera field of view used by the Vignette effect.
  18491. */
  18492. get vignetteCameraFov(): number;
  18493. /**
  18494. * Sets Camera field of view used by the Vignette effect.
  18495. */
  18496. set vignetteCameraFov(value: number);
  18497. /**
  18498. * Gets the vignette blend mode allowing different kind of effect.
  18499. */
  18500. get vignetteBlendMode(): number;
  18501. /**
  18502. * Sets the vignette blend mode allowing different kind of effect.
  18503. */
  18504. set vignetteBlendMode(value: number);
  18505. /**
  18506. * Gets wether the vignette effect is enabled.
  18507. */
  18508. get vignetteEnabled(): boolean;
  18509. /**
  18510. * Sets wether the vignette effect is enabled.
  18511. */
  18512. set vignetteEnabled(value: boolean);
  18513. private _fromLinearSpace;
  18514. /**
  18515. * Gets wether the input of the processing is in Gamma or Linear Space.
  18516. */
  18517. get fromLinearSpace(): boolean;
  18518. /**
  18519. * Sets wether the input of the processing is in Gamma or Linear Space.
  18520. */
  18521. set fromLinearSpace(value: boolean);
  18522. /**
  18523. * Defines cache preventing GC.
  18524. */
  18525. private _defines;
  18526. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18527. /**
  18528. * "ImageProcessingPostProcess"
  18529. * @returns "ImageProcessingPostProcess"
  18530. */
  18531. getClassName(): string;
  18532. /**
  18533. * @hidden
  18534. */
  18535. _updateParameters(): void;
  18536. dispose(camera?: Camera): void;
  18537. }
  18538. }
  18539. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  18540. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18541. /**
  18542. * Interface for defining prepass effects in the prepass post-process pipeline
  18543. */
  18544. export interface PrePassEffectConfiguration {
  18545. /**
  18546. * Name of the effect
  18547. */
  18548. name: string;
  18549. /**
  18550. * Post process to attach for this effect
  18551. */
  18552. postProcess?: PostProcess;
  18553. /**
  18554. * Textures required in the MRT
  18555. */
  18556. texturesRequired: number[];
  18557. /**
  18558. * Is the effect enabled
  18559. */
  18560. enabled: boolean;
  18561. /**
  18562. * Disposes the effect configuration
  18563. */
  18564. dispose?: () => void;
  18565. /**
  18566. * Creates the associated post process
  18567. */
  18568. createPostProcess?: () => PostProcess;
  18569. }
  18570. }
  18571. declare module "babylonjs/Materials/fresnelParameters" {
  18572. import { DeepImmutable } from "babylonjs/types";
  18573. import { Color3 } from "babylonjs/Maths/math.color";
  18574. /**
  18575. * Options to be used when creating a FresnelParameters.
  18576. */
  18577. export type IFresnelParametersCreationOptions = {
  18578. /**
  18579. * Define the color used on edges (grazing angle)
  18580. */
  18581. leftColor?: Color3;
  18582. /**
  18583. * Define the color used on center
  18584. */
  18585. rightColor?: Color3;
  18586. /**
  18587. * Define bias applied to computed fresnel term
  18588. */
  18589. bias?: number;
  18590. /**
  18591. * Defined the power exponent applied to fresnel term
  18592. */
  18593. power?: number;
  18594. /**
  18595. * Define if the fresnel effect is enable or not.
  18596. */
  18597. isEnabled?: boolean;
  18598. };
  18599. /**
  18600. * Serialized format for FresnelParameters.
  18601. */
  18602. export type IFresnelParametersSerialized = {
  18603. /**
  18604. * Define the color used on edges (grazing angle) [as an array]
  18605. */
  18606. leftColor: number[];
  18607. /**
  18608. * Define the color used on center [as an array]
  18609. */
  18610. rightColor: number[];
  18611. /**
  18612. * Define bias applied to computed fresnel term
  18613. */
  18614. bias: number;
  18615. /**
  18616. * Defined the power exponent applied to fresnel term
  18617. */
  18618. power?: number;
  18619. /**
  18620. * Define if the fresnel effect is enable or not.
  18621. */
  18622. isEnabled: boolean;
  18623. };
  18624. /**
  18625. * This represents all the required information to add a fresnel effect on a material:
  18626. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18627. */
  18628. export class FresnelParameters {
  18629. private _isEnabled;
  18630. /**
  18631. * Define if the fresnel effect is enable or not.
  18632. */
  18633. get isEnabled(): boolean;
  18634. set isEnabled(value: boolean);
  18635. /**
  18636. * Define the color used on edges (grazing angle)
  18637. */
  18638. leftColor: Color3;
  18639. /**
  18640. * Define the color used on center
  18641. */
  18642. rightColor: Color3;
  18643. /**
  18644. * Define bias applied to computed fresnel term
  18645. */
  18646. bias: number;
  18647. /**
  18648. * Defined the power exponent applied to fresnel term
  18649. */
  18650. power: number;
  18651. /**
  18652. * Creates a new FresnelParameters object.
  18653. *
  18654. * @param options provide your own settings to optionally to override defaults
  18655. */
  18656. constructor(options?: IFresnelParametersCreationOptions);
  18657. /**
  18658. * Clones the current fresnel and its valuues
  18659. * @returns a clone fresnel configuration
  18660. */
  18661. clone(): FresnelParameters;
  18662. /**
  18663. * Determines equality between FresnelParameters objects
  18664. * @param otherFresnelParameters defines the second operand
  18665. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18666. */
  18667. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18668. /**
  18669. * Serializes the current fresnel parameters to a JSON representation.
  18670. * @return the JSON serialization
  18671. */
  18672. serialize(): IFresnelParametersSerialized;
  18673. /**
  18674. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18675. * @param parsedFresnelParameters Define the JSON representation
  18676. * @returns the parsed parameters
  18677. */
  18678. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18679. }
  18680. }
  18681. declare module "babylonjs/Materials/materialFlags" {
  18682. /**
  18683. * This groups all the flags used to control the materials channel.
  18684. */
  18685. export class MaterialFlags {
  18686. private static _DiffuseTextureEnabled;
  18687. /**
  18688. * Are diffuse textures enabled in the application.
  18689. */
  18690. static get DiffuseTextureEnabled(): boolean;
  18691. static set DiffuseTextureEnabled(value: boolean);
  18692. private static _DetailTextureEnabled;
  18693. /**
  18694. * Are detail textures enabled in the application.
  18695. */
  18696. static get DetailTextureEnabled(): boolean;
  18697. static set DetailTextureEnabled(value: boolean);
  18698. private static _AmbientTextureEnabled;
  18699. /**
  18700. * Are ambient textures enabled in the application.
  18701. */
  18702. static get AmbientTextureEnabled(): boolean;
  18703. static set AmbientTextureEnabled(value: boolean);
  18704. private static _OpacityTextureEnabled;
  18705. /**
  18706. * Are opacity textures enabled in the application.
  18707. */
  18708. static get OpacityTextureEnabled(): boolean;
  18709. static set OpacityTextureEnabled(value: boolean);
  18710. private static _ReflectionTextureEnabled;
  18711. /**
  18712. * Are reflection textures enabled in the application.
  18713. */
  18714. static get ReflectionTextureEnabled(): boolean;
  18715. static set ReflectionTextureEnabled(value: boolean);
  18716. private static _EmissiveTextureEnabled;
  18717. /**
  18718. * Are emissive textures enabled in the application.
  18719. */
  18720. static get EmissiveTextureEnabled(): boolean;
  18721. static set EmissiveTextureEnabled(value: boolean);
  18722. private static _SpecularTextureEnabled;
  18723. /**
  18724. * Are specular textures enabled in the application.
  18725. */
  18726. static get SpecularTextureEnabled(): boolean;
  18727. static set SpecularTextureEnabled(value: boolean);
  18728. private static _BumpTextureEnabled;
  18729. /**
  18730. * Are bump textures enabled in the application.
  18731. */
  18732. static get BumpTextureEnabled(): boolean;
  18733. static set BumpTextureEnabled(value: boolean);
  18734. private static _LightmapTextureEnabled;
  18735. /**
  18736. * Are lightmap textures enabled in the application.
  18737. */
  18738. static get LightmapTextureEnabled(): boolean;
  18739. static set LightmapTextureEnabled(value: boolean);
  18740. private static _RefractionTextureEnabled;
  18741. /**
  18742. * Are refraction textures enabled in the application.
  18743. */
  18744. static get RefractionTextureEnabled(): boolean;
  18745. static set RefractionTextureEnabled(value: boolean);
  18746. private static _ColorGradingTextureEnabled;
  18747. /**
  18748. * Are color grading textures enabled in the application.
  18749. */
  18750. static get ColorGradingTextureEnabled(): boolean;
  18751. static set ColorGradingTextureEnabled(value: boolean);
  18752. private static _FresnelEnabled;
  18753. /**
  18754. * Are fresnels enabled in the application.
  18755. */
  18756. static get FresnelEnabled(): boolean;
  18757. static set FresnelEnabled(value: boolean);
  18758. private static _ClearCoatTextureEnabled;
  18759. /**
  18760. * Are clear coat textures enabled in the application.
  18761. */
  18762. static get ClearCoatTextureEnabled(): boolean;
  18763. static set ClearCoatTextureEnabled(value: boolean);
  18764. private static _ClearCoatBumpTextureEnabled;
  18765. /**
  18766. * Are clear coat bump textures enabled in the application.
  18767. */
  18768. static get ClearCoatBumpTextureEnabled(): boolean;
  18769. static set ClearCoatBumpTextureEnabled(value: boolean);
  18770. private static _ClearCoatTintTextureEnabled;
  18771. /**
  18772. * Are clear coat tint textures enabled in the application.
  18773. */
  18774. static get ClearCoatTintTextureEnabled(): boolean;
  18775. static set ClearCoatTintTextureEnabled(value: boolean);
  18776. private static _SheenTextureEnabled;
  18777. /**
  18778. * Are sheen textures enabled in the application.
  18779. */
  18780. static get SheenTextureEnabled(): boolean;
  18781. static set SheenTextureEnabled(value: boolean);
  18782. private static _AnisotropicTextureEnabled;
  18783. /**
  18784. * Are anisotropic textures enabled in the application.
  18785. */
  18786. static get AnisotropicTextureEnabled(): boolean;
  18787. static set AnisotropicTextureEnabled(value: boolean);
  18788. private static _ThicknessTextureEnabled;
  18789. /**
  18790. * Are thickness textures enabled in the application.
  18791. */
  18792. static get ThicknessTextureEnabled(): boolean;
  18793. static set ThicknessTextureEnabled(value: boolean);
  18794. }
  18795. }
  18796. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  18797. /** @hidden */
  18798. export var defaultFragmentDeclaration: {
  18799. name: string;
  18800. shader: string;
  18801. };
  18802. }
  18803. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  18804. /** @hidden */
  18805. export var defaultUboDeclaration: {
  18806. name: string;
  18807. shader: string;
  18808. };
  18809. }
  18810. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  18811. /** @hidden */
  18812. export var prePassDeclaration: {
  18813. name: string;
  18814. shader: string;
  18815. };
  18816. }
  18817. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  18818. /** @hidden */
  18819. export var lightFragmentDeclaration: {
  18820. name: string;
  18821. shader: string;
  18822. };
  18823. }
  18824. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  18825. /** @hidden */
  18826. export var lightUboDeclaration: {
  18827. name: string;
  18828. shader: string;
  18829. };
  18830. }
  18831. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  18832. /** @hidden */
  18833. export var lightsFragmentFunctions: {
  18834. name: string;
  18835. shader: string;
  18836. };
  18837. }
  18838. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  18839. /** @hidden */
  18840. export var shadowsFragmentFunctions: {
  18841. name: string;
  18842. shader: string;
  18843. };
  18844. }
  18845. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  18846. /** @hidden */
  18847. export var fresnelFunction: {
  18848. name: string;
  18849. shader: string;
  18850. };
  18851. }
  18852. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  18853. /** @hidden */
  18854. export var bumpFragmentMainFunctions: {
  18855. name: string;
  18856. shader: string;
  18857. };
  18858. }
  18859. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  18860. /** @hidden */
  18861. export var bumpFragmentFunctions: {
  18862. name: string;
  18863. shader: string;
  18864. };
  18865. }
  18866. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  18867. /** @hidden */
  18868. export var logDepthDeclaration: {
  18869. name: string;
  18870. shader: string;
  18871. };
  18872. }
  18873. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  18874. /** @hidden */
  18875. export var fogFragmentDeclaration: {
  18876. name: string;
  18877. shader: string;
  18878. };
  18879. }
  18880. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  18881. /** @hidden */
  18882. export var bumpFragment: {
  18883. name: string;
  18884. shader: string;
  18885. };
  18886. }
  18887. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  18888. /** @hidden */
  18889. export var depthPrePass: {
  18890. name: string;
  18891. shader: string;
  18892. };
  18893. }
  18894. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  18895. /** @hidden */
  18896. export var lightFragment: {
  18897. name: string;
  18898. shader: string;
  18899. };
  18900. }
  18901. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  18902. /** @hidden */
  18903. export var logDepthFragment: {
  18904. name: string;
  18905. shader: string;
  18906. };
  18907. }
  18908. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  18909. /** @hidden */
  18910. export var fogFragment: {
  18911. name: string;
  18912. shader: string;
  18913. };
  18914. }
  18915. declare module "babylonjs/Shaders/default.fragment" {
  18916. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  18917. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  18918. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  18919. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  18920. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  18921. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  18922. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  18923. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  18924. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  18925. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  18926. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  18927. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  18928. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  18929. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  18930. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  18931. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  18932. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  18933. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  18934. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  18935. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  18936. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  18937. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  18938. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  18939. /** @hidden */
  18940. export var defaultPixelShader: {
  18941. name: string;
  18942. shader: string;
  18943. };
  18944. }
  18945. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  18946. /** @hidden */
  18947. export var defaultVertexDeclaration: {
  18948. name: string;
  18949. shader: string;
  18950. };
  18951. }
  18952. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  18953. /** @hidden */
  18954. export var bonesDeclaration: {
  18955. name: string;
  18956. shader: string;
  18957. };
  18958. }
  18959. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  18960. /** @hidden */
  18961. export var instancesDeclaration: {
  18962. name: string;
  18963. shader: string;
  18964. };
  18965. }
  18966. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  18967. /** @hidden */
  18968. export var prePassVertexDeclaration: {
  18969. name: string;
  18970. shader: string;
  18971. };
  18972. }
  18973. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  18974. /** @hidden */
  18975. export var bumpVertexDeclaration: {
  18976. name: string;
  18977. shader: string;
  18978. };
  18979. }
  18980. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  18981. /** @hidden */
  18982. export var fogVertexDeclaration: {
  18983. name: string;
  18984. shader: string;
  18985. };
  18986. }
  18987. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  18988. /** @hidden */
  18989. export var morphTargetsVertexGlobalDeclaration: {
  18990. name: string;
  18991. shader: string;
  18992. };
  18993. }
  18994. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  18995. /** @hidden */
  18996. export var morphTargetsVertexDeclaration: {
  18997. name: string;
  18998. shader: string;
  18999. };
  19000. }
  19001. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  19002. /** @hidden */
  19003. export var morphTargetsVertex: {
  19004. name: string;
  19005. shader: string;
  19006. };
  19007. }
  19008. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  19009. /** @hidden */
  19010. export var instancesVertex: {
  19011. name: string;
  19012. shader: string;
  19013. };
  19014. }
  19015. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  19016. /** @hidden */
  19017. export var bonesVertex: {
  19018. name: string;
  19019. shader: string;
  19020. };
  19021. }
  19022. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  19023. /** @hidden */
  19024. export var prePassVertex: {
  19025. name: string;
  19026. shader: string;
  19027. };
  19028. }
  19029. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  19030. /** @hidden */
  19031. export var bumpVertex: {
  19032. name: string;
  19033. shader: string;
  19034. };
  19035. }
  19036. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  19037. /** @hidden */
  19038. export var fogVertex: {
  19039. name: string;
  19040. shader: string;
  19041. };
  19042. }
  19043. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  19044. /** @hidden */
  19045. export var shadowsVertex: {
  19046. name: string;
  19047. shader: string;
  19048. };
  19049. }
  19050. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  19051. /** @hidden */
  19052. export var pointCloudVertex: {
  19053. name: string;
  19054. shader: string;
  19055. };
  19056. }
  19057. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  19058. /** @hidden */
  19059. export var logDepthVertex: {
  19060. name: string;
  19061. shader: string;
  19062. };
  19063. }
  19064. declare module "babylonjs/Shaders/default.vertex" {
  19065. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  19066. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  19067. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19068. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19069. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19070. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  19071. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  19072. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19073. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  19074. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  19075. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  19076. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  19077. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  19078. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  19079. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  19080. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19081. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19082. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  19083. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  19084. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19085. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  19086. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  19087. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  19088. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  19089. /** @hidden */
  19090. export var defaultVertexShader: {
  19091. name: string;
  19092. shader: string;
  19093. };
  19094. }
  19095. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  19096. import { Nullable } from "babylonjs/types";
  19097. import { Scene } from "babylonjs/scene";
  19098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19099. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19100. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19101. /**
  19102. * @hidden
  19103. */
  19104. export interface IMaterialDetailMapDefines {
  19105. DETAIL: boolean;
  19106. DETAILDIRECTUV: number;
  19107. DETAIL_NORMALBLENDMETHOD: number;
  19108. /** @hidden */
  19109. _areTexturesDirty: boolean;
  19110. }
  19111. /**
  19112. * Define the code related to the detail map parameters of a material
  19113. *
  19114. * Inspired from:
  19115. * 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
  19116. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19117. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19118. */
  19119. export class DetailMapConfiguration {
  19120. private _texture;
  19121. /**
  19122. * The detail texture of the material.
  19123. */
  19124. texture: Nullable<BaseTexture>;
  19125. /**
  19126. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19127. * Bigger values mean stronger blending
  19128. */
  19129. diffuseBlendLevel: number;
  19130. /**
  19131. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19132. * Bigger values mean stronger blending. Only used with PBR materials
  19133. */
  19134. roughnessBlendLevel: number;
  19135. /**
  19136. * Defines how strong the bump effect from the detail map is
  19137. * Bigger values mean stronger effect
  19138. */
  19139. bumpLevel: number;
  19140. private _normalBlendMethod;
  19141. /**
  19142. * The method used to blend the bump and detail normals together
  19143. */
  19144. normalBlendMethod: number;
  19145. private _isEnabled;
  19146. /**
  19147. * Enable or disable the detail map on this material
  19148. */
  19149. isEnabled: boolean;
  19150. /** @hidden */
  19151. private _internalMarkAllSubMeshesAsTexturesDirty;
  19152. /** @hidden */
  19153. _markAllSubMeshesAsTexturesDirty(): void;
  19154. /**
  19155. * Instantiate a new detail map
  19156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19157. */
  19158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19159. /**
  19160. * Gets whether the submesh is ready to be used or not.
  19161. * @param defines the list of "defines" to update.
  19162. * @param scene defines the scene the material belongs to.
  19163. * @returns - boolean indicating that the submesh is ready or not.
  19164. */
  19165. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19166. /**
  19167. * Update the defines for detail map usage
  19168. * @param defines the list of "defines" to update.
  19169. * @param scene defines the scene the material belongs to.
  19170. */
  19171. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19172. /**
  19173. * Binds the material data.
  19174. * @param uniformBuffer defines the Uniform buffer to fill in.
  19175. * @param scene defines the scene the material belongs to.
  19176. * @param isFrozen defines whether the material is frozen or not.
  19177. */
  19178. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19179. /**
  19180. * Checks to see if a texture is used in the material.
  19181. * @param texture - Base texture to use.
  19182. * @returns - Boolean specifying if a texture is used in the material.
  19183. */
  19184. hasTexture(texture: BaseTexture): boolean;
  19185. /**
  19186. * Returns an array of the actively used textures.
  19187. * @param activeTextures Array of BaseTextures
  19188. */
  19189. getActiveTextures(activeTextures: BaseTexture[]): void;
  19190. /**
  19191. * Returns the animatable textures.
  19192. * @param animatables Array of animatable textures.
  19193. */
  19194. getAnimatables(animatables: IAnimatable[]): void;
  19195. /**
  19196. * Disposes the resources of the material.
  19197. * @param forceDisposeTextures - Forces the disposal of all textures.
  19198. */
  19199. dispose(forceDisposeTextures?: boolean): void;
  19200. /**
  19201. * Get the current class name useful for serialization or dynamic coding.
  19202. * @returns "DetailMap"
  19203. */
  19204. getClassName(): string;
  19205. /**
  19206. * Add the required uniforms to the current list.
  19207. * @param uniforms defines the current uniform list.
  19208. */
  19209. static AddUniforms(uniforms: string[]): void;
  19210. /**
  19211. * Add the required samplers to the current list.
  19212. * @param samplers defines the current sampler list.
  19213. */
  19214. static AddSamplers(samplers: string[]): void;
  19215. /**
  19216. * Add the required uniforms to the current buffer.
  19217. * @param uniformBuffer defines the current uniform buffer.
  19218. */
  19219. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19220. /**
  19221. * Makes a duplicate of the current instance into another one.
  19222. * @param detailMap define the instance where to copy the info
  19223. */
  19224. copyTo(detailMap: DetailMapConfiguration): void;
  19225. /**
  19226. * Serializes this detail map instance
  19227. * @returns - An object with the serialized instance.
  19228. */
  19229. serialize(): any;
  19230. /**
  19231. * Parses a detail map setting from a serialized object.
  19232. * @param source - Serialized object.
  19233. * @param scene Defines the scene we are parsing for
  19234. * @param rootUrl Defines the rootUrl to load from
  19235. */
  19236. parse(source: any, scene: Scene, rootUrl: string): void;
  19237. }
  19238. }
  19239. declare module "babylonjs/Materials/standardMaterial" {
  19240. import { SmartArray } from "babylonjs/Misc/smartArray";
  19241. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19242. import { Nullable } from "babylonjs/types";
  19243. import { Scene } from "babylonjs/scene";
  19244. import { Matrix } from "babylonjs/Maths/math.vector";
  19245. import { Color3 } from "babylonjs/Maths/math.color";
  19246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19248. import { Mesh } from "babylonjs/Meshes/mesh";
  19249. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  19250. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19251. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  19252. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  19253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  19254. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  19255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19256. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19257. import "babylonjs/Shaders/default.fragment";
  19258. import "babylonjs/Shaders/default.vertex";
  19259. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  19260. /** @hidden */
  19261. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19262. MAINUV1: boolean;
  19263. MAINUV2: boolean;
  19264. DIFFUSE: boolean;
  19265. DIFFUSEDIRECTUV: number;
  19266. DETAIL: boolean;
  19267. DETAILDIRECTUV: number;
  19268. DETAIL_NORMALBLENDMETHOD: number;
  19269. AMBIENT: boolean;
  19270. AMBIENTDIRECTUV: number;
  19271. OPACITY: boolean;
  19272. OPACITYDIRECTUV: number;
  19273. OPACITYRGB: boolean;
  19274. REFLECTION: boolean;
  19275. EMISSIVE: boolean;
  19276. EMISSIVEDIRECTUV: number;
  19277. SPECULAR: boolean;
  19278. SPECULARDIRECTUV: number;
  19279. BUMP: boolean;
  19280. BUMPDIRECTUV: number;
  19281. PARALLAX: boolean;
  19282. PARALLAXOCCLUSION: boolean;
  19283. SPECULAROVERALPHA: boolean;
  19284. CLIPPLANE: boolean;
  19285. CLIPPLANE2: boolean;
  19286. CLIPPLANE3: boolean;
  19287. CLIPPLANE4: boolean;
  19288. CLIPPLANE5: boolean;
  19289. CLIPPLANE6: boolean;
  19290. ALPHATEST: boolean;
  19291. DEPTHPREPASS: boolean;
  19292. ALPHAFROMDIFFUSE: boolean;
  19293. POINTSIZE: boolean;
  19294. FOG: boolean;
  19295. SPECULARTERM: boolean;
  19296. DIFFUSEFRESNEL: boolean;
  19297. OPACITYFRESNEL: boolean;
  19298. REFLECTIONFRESNEL: boolean;
  19299. REFRACTIONFRESNEL: boolean;
  19300. EMISSIVEFRESNEL: boolean;
  19301. FRESNEL: boolean;
  19302. NORMAL: boolean;
  19303. UV1: boolean;
  19304. UV2: boolean;
  19305. VERTEXCOLOR: boolean;
  19306. VERTEXALPHA: boolean;
  19307. NUM_BONE_INFLUENCERS: number;
  19308. BonesPerMesh: number;
  19309. BONETEXTURE: boolean;
  19310. BONES_VELOCITY_ENABLED: boolean;
  19311. INSTANCES: boolean;
  19312. THIN_INSTANCES: boolean;
  19313. GLOSSINESS: boolean;
  19314. ROUGHNESS: boolean;
  19315. EMISSIVEASILLUMINATION: boolean;
  19316. LINKEMISSIVEWITHDIFFUSE: boolean;
  19317. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19318. LIGHTMAP: boolean;
  19319. LIGHTMAPDIRECTUV: number;
  19320. OBJECTSPACE_NORMALMAP: boolean;
  19321. USELIGHTMAPASSHADOWMAP: boolean;
  19322. REFLECTIONMAP_3D: boolean;
  19323. REFLECTIONMAP_SPHERICAL: boolean;
  19324. REFLECTIONMAP_PLANAR: boolean;
  19325. REFLECTIONMAP_CUBIC: boolean;
  19326. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19327. REFLECTIONMAP_PROJECTION: boolean;
  19328. REFLECTIONMAP_SKYBOX: boolean;
  19329. REFLECTIONMAP_EXPLICIT: boolean;
  19330. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19331. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19332. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19333. INVERTCUBICMAP: boolean;
  19334. LOGARITHMICDEPTH: boolean;
  19335. REFRACTION: boolean;
  19336. REFRACTIONMAP_3D: boolean;
  19337. REFLECTIONOVERALPHA: boolean;
  19338. TWOSIDEDLIGHTING: boolean;
  19339. SHADOWFLOAT: boolean;
  19340. MORPHTARGETS: boolean;
  19341. MORPHTARGETS_NORMAL: boolean;
  19342. MORPHTARGETS_TANGENT: boolean;
  19343. MORPHTARGETS_UV: boolean;
  19344. NUM_MORPH_INFLUENCERS: number;
  19345. NONUNIFORMSCALING: boolean;
  19346. PREMULTIPLYALPHA: boolean;
  19347. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19348. ALPHABLEND: boolean;
  19349. PREPASS: boolean;
  19350. PREPASS_IRRADIANCE: boolean;
  19351. PREPASS_IRRADIANCE_INDEX: number;
  19352. PREPASS_ALBEDO: boolean;
  19353. PREPASS_ALBEDO_INDEX: number;
  19354. PREPASS_DEPTHNORMAL: boolean;
  19355. PREPASS_DEPTHNORMAL_INDEX: number;
  19356. PREPASS_POSITION: boolean;
  19357. PREPASS_POSITION_INDEX: number;
  19358. PREPASS_VELOCITY: boolean;
  19359. PREPASS_VELOCITY_INDEX: number;
  19360. PREPASS_REFLECTIVITY: boolean;
  19361. PREPASS_REFLECTIVITY_INDEX: number;
  19362. SCENE_MRT_COUNT: number;
  19363. RGBDLIGHTMAP: boolean;
  19364. RGBDREFLECTION: boolean;
  19365. RGBDREFRACTION: boolean;
  19366. IMAGEPROCESSING: boolean;
  19367. VIGNETTE: boolean;
  19368. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19369. VIGNETTEBLENDMODEOPAQUE: boolean;
  19370. TONEMAPPING: boolean;
  19371. TONEMAPPING_ACES: boolean;
  19372. CONTRAST: boolean;
  19373. COLORCURVES: boolean;
  19374. COLORGRADING: boolean;
  19375. COLORGRADING3D: boolean;
  19376. SAMPLER3DGREENDEPTH: boolean;
  19377. SAMPLER3DBGRMAP: boolean;
  19378. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19379. MULTIVIEW: boolean;
  19380. /**
  19381. * If the reflection texture on this material is in linear color space
  19382. * @hidden
  19383. */
  19384. IS_REFLECTION_LINEAR: boolean;
  19385. /**
  19386. * If the refraction texture on this material is in linear color space
  19387. * @hidden
  19388. */
  19389. IS_REFRACTION_LINEAR: boolean;
  19390. EXPOSURE: boolean;
  19391. constructor();
  19392. setReflectionMode(modeToEnable: string): void;
  19393. }
  19394. /**
  19395. * This is the default material used in Babylon. It is the best trade off between quality
  19396. * and performances.
  19397. * @see https://doc.babylonjs.com/babylon101/materials
  19398. */
  19399. export class StandardMaterial extends PushMaterial {
  19400. private _diffuseTexture;
  19401. /**
  19402. * The basic texture of the material as viewed under a light.
  19403. */
  19404. diffuseTexture: Nullable<BaseTexture>;
  19405. private _ambientTexture;
  19406. /**
  19407. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19408. */
  19409. ambientTexture: Nullable<BaseTexture>;
  19410. private _opacityTexture;
  19411. /**
  19412. * Define the transparency of the material from a texture.
  19413. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19414. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19415. */
  19416. opacityTexture: Nullable<BaseTexture>;
  19417. private _reflectionTexture;
  19418. /**
  19419. * Define the texture used to display the reflection.
  19420. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19421. */
  19422. reflectionTexture: Nullable<BaseTexture>;
  19423. private _emissiveTexture;
  19424. /**
  19425. * Define texture of the material as if self lit.
  19426. * This will be mixed in the final result even in the absence of light.
  19427. */
  19428. emissiveTexture: Nullable<BaseTexture>;
  19429. private _specularTexture;
  19430. /**
  19431. * Define how the color and intensity of the highlight given by the light in the material.
  19432. */
  19433. specularTexture: Nullable<BaseTexture>;
  19434. private _bumpTexture;
  19435. /**
  19436. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19437. * 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.
  19438. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19439. */
  19440. bumpTexture: Nullable<BaseTexture>;
  19441. private _lightmapTexture;
  19442. /**
  19443. * Complex lighting can be computationally expensive to compute at runtime.
  19444. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19445. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19446. */
  19447. lightmapTexture: Nullable<BaseTexture>;
  19448. private _refractionTexture;
  19449. /**
  19450. * Define the texture used to display the refraction.
  19451. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19452. */
  19453. refractionTexture: Nullable<BaseTexture>;
  19454. /**
  19455. * The color of the material lit by the environmental background lighting.
  19456. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19457. */
  19458. ambientColor: Color3;
  19459. /**
  19460. * The basic color of the material as viewed under a light.
  19461. */
  19462. diffuseColor: Color3;
  19463. /**
  19464. * Define how the color and intensity of the highlight given by the light in the material.
  19465. */
  19466. specularColor: Color3;
  19467. /**
  19468. * Define the color of the material as if self lit.
  19469. * This will be mixed in the final result even in the absence of light.
  19470. */
  19471. emissiveColor: Color3;
  19472. /**
  19473. * Defines how sharp are the highlights in the material.
  19474. * The bigger the value the sharper giving a more glossy feeling to the result.
  19475. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19476. */
  19477. specularPower: number;
  19478. private _useAlphaFromDiffuseTexture;
  19479. /**
  19480. * Does the transparency come from the diffuse texture alpha channel.
  19481. */
  19482. useAlphaFromDiffuseTexture: boolean;
  19483. private _useEmissiveAsIllumination;
  19484. /**
  19485. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19486. */
  19487. useEmissiveAsIllumination: boolean;
  19488. private _linkEmissiveWithDiffuse;
  19489. /**
  19490. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19491. * the emissive level when the final color is close to one.
  19492. */
  19493. linkEmissiveWithDiffuse: boolean;
  19494. private _useSpecularOverAlpha;
  19495. /**
  19496. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19497. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19498. */
  19499. useSpecularOverAlpha: boolean;
  19500. private _useReflectionOverAlpha;
  19501. /**
  19502. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19503. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19504. */
  19505. useReflectionOverAlpha: boolean;
  19506. private _disableLighting;
  19507. /**
  19508. * Does lights from the scene impacts this material.
  19509. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19510. */
  19511. disableLighting: boolean;
  19512. private _useObjectSpaceNormalMap;
  19513. /**
  19514. * Allows using an object space normal map (instead of tangent space).
  19515. */
  19516. useObjectSpaceNormalMap: boolean;
  19517. private _useParallax;
  19518. /**
  19519. * Is parallax enabled or not.
  19520. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19521. */
  19522. useParallax: boolean;
  19523. private _useParallaxOcclusion;
  19524. /**
  19525. * Is parallax occlusion enabled or not.
  19526. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19527. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19528. */
  19529. useParallaxOcclusion: boolean;
  19530. /**
  19531. * 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.
  19532. */
  19533. parallaxScaleBias: number;
  19534. private _roughness;
  19535. /**
  19536. * Helps to define how blurry the reflections should appears in the material.
  19537. */
  19538. roughness: number;
  19539. /**
  19540. * In case of refraction, define the value of the index of refraction.
  19541. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19542. */
  19543. indexOfRefraction: number;
  19544. /**
  19545. * Invert the refraction texture alongside the y axis.
  19546. * It can be useful with procedural textures or probe for instance.
  19547. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19548. */
  19549. invertRefractionY: boolean;
  19550. /**
  19551. * Defines the alpha limits in alpha test mode.
  19552. */
  19553. alphaCutOff: number;
  19554. private _useLightmapAsShadowmap;
  19555. /**
  19556. * In case of light mapping, define whether the map contains light or shadow informations.
  19557. */
  19558. useLightmapAsShadowmap: boolean;
  19559. private _diffuseFresnelParameters;
  19560. /**
  19561. * Define the diffuse fresnel parameters of the material.
  19562. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19563. */
  19564. diffuseFresnelParameters: FresnelParameters;
  19565. private _opacityFresnelParameters;
  19566. /**
  19567. * Define the opacity fresnel parameters of the material.
  19568. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19569. */
  19570. opacityFresnelParameters: FresnelParameters;
  19571. private _reflectionFresnelParameters;
  19572. /**
  19573. * Define the reflection fresnel parameters of the material.
  19574. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19575. */
  19576. reflectionFresnelParameters: FresnelParameters;
  19577. private _refractionFresnelParameters;
  19578. /**
  19579. * Define the refraction fresnel parameters of the material.
  19580. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19581. */
  19582. refractionFresnelParameters: FresnelParameters;
  19583. private _emissiveFresnelParameters;
  19584. /**
  19585. * Define the emissive fresnel parameters of the material.
  19586. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19587. */
  19588. emissiveFresnelParameters: FresnelParameters;
  19589. private _useReflectionFresnelFromSpecular;
  19590. /**
  19591. * If true automatically deducts the fresnels values from the material specularity.
  19592. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19593. */
  19594. useReflectionFresnelFromSpecular: boolean;
  19595. private _useGlossinessFromSpecularMapAlpha;
  19596. /**
  19597. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19598. */
  19599. useGlossinessFromSpecularMapAlpha: boolean;
  19600. private _maxSimultaneousLights;
  19601. /**
  19602. * Defines the maximum number of lights that can be used in the material
  19603. */
  19604. maxSimultaneousLights: number;
  19605. private _invertNormalMapX;
  19606. /**
  19607. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19608. */
  19609. invertNormalMapX: boolean;
  19610. private _invertNormalMapY;
  19611. /**
  19612. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19613. */
  19614. invertNormalMapY: boolean;
  19615. private _twoSidedLighting;
  19616. /**
  19617. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19618. */
  19619. twoSidedLighting: boolean;
  19620. /**
  19621. * Default configuration related to image processing available in the standard Material.
  19622. */
  19623. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19624. /**
  19625. * Gets the image processing configuration used either in this material.
  19626. */
  19627. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19628. /**
  19629. * Sets the Default image processing configuration used either in the this material.
  19630. *
  19631. * If sets to null, the scene one is in use.
  19632. */
  19633. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19634. /**
  19635. * Keep track of the image processing observer to allow dispose and replace.
  19636. */
  19637. private _imageProcessingObserver;
  19638. /**
  19639. * Attaches a new image processing configuration to the Standard Material.
  19640. * @param configuration
  19641. */
  19642. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19643. /**
  19644. * Defines additionnal PrePass parameters for the material.
  19645. */
  19646. readonly prePassConfiguration: PrePassConfiguration;
  19647. /**
  19648. * Gets wether the color curves effect is enabled.
  19649. */
  19650. get cameraColorCurvesEnabled(): boolean;
  19651. /**
  19652. * Sets wether the color curves effect is enabled.
  19653. */
  19654. set cameraColorCurvesEnabled(value: boolean);
  19655. /**
  19656. * Gets wether the color grading effect is enabled.
  19657. */
  19658. get cameraColorGradingEnabled(): boolean;
  19659. /**
  19660. * Gets wether the color grading effect is enabled.
  19661. */
  19662. set cameraColorGradingEnabled(value: boolean);
  19663. /**
  19664. * Gets wether tonemapping is enabled or not.
  19665. */
  19666. get cameraToneMappingEnabled(): boolean;
  19667. /**
  19668. * Sets wether tonemapping is enabled or not
  19669. */
  19670. set cameraToneMappingEnabled(value: boolean);
  19671. /**
  19672. * The camera exposure used on this material.
  19673. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19674. * This corresponds to a photographic exposure.
  19675. */
  19676. get cameraExposure(): number;
  19677. /**
  19678. * The camera exposure used on this material.
  19679. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19680. * This corresponds to a photographic exposure.
  19681. */
  19682. set cameraExposure(value: number);
  19683. /**
  19684. * Gets The camera contrast used on this material.
  19685. */
  19686. get cameraContrast(): number;
  19687. /**
  19688. * Sets The camera contrast used on this material.
  19689. */
  19690. set cameraContrast(value: number);
  19691. /**
  19692. * Gets the Color Grading 2D Lookup Texture.
  19693. */
  19694. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19695. /**
  19696. * Sets the Color Grading 2D Lookup Texture.
  19697. */
  19698. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19699. /**
  19700. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19701. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19702. * 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;
  19703. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19704. */
  19705. get cameraColorCurves(): Nullable<ColorCurves>;
  19706. /**
  19707. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19708. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19709. * 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;
  19710. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19711. */
  19712. set cameraColorCurves(value: Nullable<ColorCurves>);
  19713. /**
  19714. * Can this material render to several textures at once
  19715. */
  19716. get canRenderToMRT(): boolean;
  19717. /**
  19718. * Defines the detail map parameters for the material.
  19719. */
  19720. readonly detailMap: DetailMapConfiguration;
  19721. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19722. protected _worldViewProjectionMatrix: Matrix;
  19723. protected _globalAmbientColor: Color3;
  19724. protected _useLogarithmicDepth: boolean;
  19725. protected _rebuildInParallel: boolean;
  19726. /**
  19727. * Instantiates a new standard material.
  19728. * This is the default material used in Babylon. It is the best trade off between quality
  19729. * and performances.
  19730. * @see https://doc.babylonjs.com/babylon101/materials
  19731. * @param name Define the name of the material in the scene
  19732. * @param scene Define the scene the material belong to
  19733. */
  19734. constructor(name: string, scene: Scene);
  19735. /**
  19736. * Gets a boolean indicating that current material needs to register RTT
  19737. */
  19738. get hasRenderTargetTextures(): boolean;
  19739. /**
  19740. * Gets the current class name of the material e.g. "StandardMaterial"
  19741. * Mainly use in serialization.
  19742. * @returns the class name
  19743. */
  19744. getClassName(): string;
  19745. /**
  19746. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19747. * You can try switching to logarithmic depth.
  19748. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19749. */
  19750. get useLogarithmicDepth(): boolean;
  19751. set useLogarithmicDepth(value: boolean);
  19752. /**
  19753. * Specifies if the material will require alpha blending
  19754. * @returns a boolean specifying if alpha blending is needed
  19755. */
  19756. needAlphaBlending(): boolean;
  19757. /**
  19758. * Specifies if this material should be rendered in alpha test mode
  19759. * @returns a boolean specifying if an alpha test is needed.
  19760. */
  19761. needAlphaTesting(): boolean;
  19762. /**
  19763. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19764. */
  19765. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19766. /**
  19767. * Specifies whether or not there is a usable alpha channel for transparency.
  19768. */
  19769. protected _hasAlphaChannel(): boolean;
  19770. /**
  19771. * Get the texture used for alpha test purpose.
  19772. * @returns the diffuse texture in case of the standard material.
  19773. */
  19774. getAlphaTestTexture(): Nullable<BaseTexture>;
  19775. /**
  19776. * Get if the submesh is ready to be used and all its information available.
  19777. * Child classes can use it to update shaders
  19778. * @param mesh defines the mesh to check
  19779. * @param subMesh defines which submesh to check
  19780. * @param useInstances specifies that instances should be used
  19781. * @returns a boolean indicating that the submesh is ready or not
  19782. */
  19783. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19784. /**
  19785. * Builds the material UBO layouts.
  19786. * Used internally during the effect preparation.
  19787. */
  19788. buildUniformLayout(): void;
  19789. /**
  19790. * Unbinds the material from the mesh
  19791. */
  19792. unbind(): void;
  19793. /**
  19794. * Binds the submesh to this material by preparing the effect and shader to draw
  19795. * @param world defines the world transformation matrix
  19796. * @param mesh defines the mesh containing the submesh
  19797. * @param subMesh defines the submesh to bind the material to
  19798. */
  19799. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19800. /**
  19801. * Get the list of animatables in the material.
  19802. * @returns the list of animatables object used in the material
  19803. */
  19804. getAnimatables(): IAnimatable[];
  19805. /**
  19806. * Gets the active textures from the material
  19807. * @returns an array of textures
  19808. */
  19809. getActiveTextures(): BaseTexture[];
  19810. /**
  19811. * Specifies if the material uses a texture
  19812. * @param texture defines the texture to check against the material
  19813. * @returns a boolean specifying if the material uses the texture
  19814. */
  19815. hasTexture(texture: BaseTexture): boolean;
  19816. /**
  19817. * Disposes the material
  19818. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19819. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19820. */
  19821. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19822. /**
  19823. * Makes a duplicate of the material, and gives it a new name
  19824. * @param name defines the new name for the duplicated material
  19825. * @returns the cloned material
  19826. */
  19827. clone(name: string): StandardMaterial;
  19828. /**
  19829. * Serializes this material in a JSON representation
  19830. * @returns the serialized material object
  19831. */
  19832. serialize(): any;
  19833. /**
  19834. * Creates a standard material from parsed material data
  19835. * @param source defines the JSON representation of the material
  19836. * @param scene defines the hosting scene
  19837. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19838. * @returns a new standard material
  19839. */
  19840. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19841. /**
  19842. * Are diffuse textures enabled in the application.
  19843. */
  19844. static get DiffuseTextureEnabled(): boolean;
  19845. static set DiffuseTextureEnabled(value: boolean);
  19846. /**
  19847. * Are detail textures enabled in the application.
  19848. */
  19849. static get DetailTextureEnabled(): boolean;
  19850. static set DetailTextureEnabled(value: boolean);
  19851. /**
  19852. * Are ambient textures enabled in the application.
  19853. */
  19854. static get AmbientTextureEnabled(): boolean;
  19855. static set AmbientTextureEnabled(value: boolean);
  19856. /**
  19857. * Are opacity textures enabled in the application.
  19858. */
  19859. static get OpacityTextureEnabled(): boolean;
  19860. static set OpacityTextureEnabled(value: boolean);
  19861. /**
  19862. * Are reflection textures enabled in the application.
  19863. */
  19864. static get ReflectionTextureEnabled(): boolean;
  19865. static set ReflectionTextureEnabled(value: boolean);
  19866. /**
  19867. * Are emissive textures enabled in the application.
  19868. */
  19869. static get EmissiveTextureEnabled(): boolean;
  19870. static set EmissiveTextureEnabled(value: boolean);
  19871. /**
  19872. * Are specular textures enabled in the application.
  19873. */
  19874. static get SpecularTextureEnabled(): boolean;
  19875. static set SpecularTextureEnabled(value: boolean);
  19876. /**
  19877. * Are bump textures enabled in the application.
  19878. */
  19879. static get BumpTextureEnabled(): boolean;
  19880. static set BumpTextureEnabled(value: boolean);
  19881. /**
  19882. * Are lightmap textures enabled in the application.
  19883. */
  19884. static get LightmapTextureEnabled(): boolean;
  19885. static set LightmapTextureEnabled(value: boolean);
  19886. /**
  19887. * Are refraction textures enabled in the application.
  19888. */
  19889. static get RefractionTextureEnabled(): boolean;
  19890. static set RefractionTextureEnabled(value: boolean);
  19891. /**
  19892. * Are color grading textures enabled in the application.
  19893. */
  19894. static get ColorGradingTextureEnabled(): boolean;
  19895. static set ColorGradingTextureEnabled(value: boolean);
  19896. /**
  19897. * Are fresnels enabled in the application.
  19898. */
  19899. static get FresnelEnabled(): boolean;
  19900. static set FresnelEnabled(value: boolean);
  19901. }
  19902. }
  19903. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  19904. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  19905. /** @hidden */
  19906. export var rgbdDecodePixelShader: {
  19907. name: string;
  19908. shader: string;
  19909. };
  19910. }
  19911. declare module "babylonjs/Misc/rgbdTextureTools" {
  19912. import "babylonjs/Shaders/rgbdDecode.fragment";
  19913. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19914. import { Texture } from "babylonjs/Materials/Textures/texture";
  19915. /**
  19916. * Class used to host RGBD texture specific utilities
  19917. */
  19918. export class RGBDTextureTools {
  19919. /**
  19920. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19921. * @param texture the texture to expand.
  19922. */
  19923. static ExpandRGBDTexture(texture: Texture): void;
  19924. }
  19925. }
  19926. declare module "babylonjs/Misc/brdfTextureTools" {
  19927. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19928. import { Scene } from "babylonjs/scene";
  19929. /**
  19930. * Class used to host texture specific utilities
  19931. */
  19932. export class BRDFTextureTools {
  19933. /**
  19934. * Prevents texture cache collision
  19935. */
  19936. private static _instanceNumber;
  19937. /**
  19938. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19939. * @param scene defines the hosting scene
  19940. * @returns the environment BRDF texture
  19941. */
  19942. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19943. private static _environmentBRDFBase64Texture;
  19944. }
  19945. }
  19946. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  19947. import { Nullable } from "babylonjs/types";
  19948. import { Color3 } from "babylonjs/Maths/math.color";
  19949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19950. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19951. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  19952. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  19953. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19954. import { Engine } from "babylonjs/Engines/engine";
  19955. import { Scene } from "babylonjs/scene";
  19956. /**
  19957. * @hidden
  19958. */
  19959. export interface IMaterialClearCoatDefines {
  19960. CLEARCOAT: boolean;
  19961. CLEARCOAT_DEFAULTIOR: boolean;
  19962. CLEARCOAT_TEXTURE: boolean;
  19963. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19964. CLEARCOAT_TEXTUREDIRECTUV: number;
  19965. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19966. CLEARCOAT_BUMP: boolean;
  19967. CLEARCOAT_BUMPDIRECTUV: number;
  19968. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19969. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19970. CLEARCOAT_REMAP_F0: boolean;
  19971. CLEARCOAT_TINT: boolean;
  19972. CLEARCOAT_TINT_TEXTURE: boolean;
  19973. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19974. /** @hidden */
  19975. _areTexturesDirty: boolean;
  19976. }
  19977. /**
  19978. * Define the code related to the clear coat parameters of the pbr material.
  19979. */
  19980. export class PBRClearCoatConfiguration {
  19981. /**
  19982. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19983. * The default fits with a polyurethane material.
  19984. * @hidden
  19985. */
  19986. static readonly _DefaultIndexOfRefraction: number;
  19987. private _isEnabled;
  19988. /**
  19989. * Defines if the clear coat is enabled in the material.
  19990. */
  19991. isEnabled: boolean;
  19992. /**
  19993. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19994. */
  19995. intensity: number;
  19996. /**
  19997. * Defines the clear coat layer roughness.
  19998. */
  19999. roughness: number;
  20000. private _indexOfRefraction;
  20001. /**
  20002. * Defines the index of refraction of the clear coat.
  20003. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20004. * The default fits with a polyurethane material.
  20005. * Changing the default value is more performance intensive.
  20006. */
  20007. indexOfRefraction: number;
  20008. private _texture;
  20009. /**
  20010. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20011. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20012. * if textureRoughness is not empty, else no texture roughness is used
  20013. */
  20014. texture: Nullable<BaseTexture>;
  20015. private _useRoughnessFromMainTexture;
  20016. /**
  20017. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20018. * If false, the green channel from textureRoughness is used for roughness
  20019. */
  20020. useRoughnessFromMainTexture: boolean;
  20021. private _textureRoughness;
  20022. /**
  20023. * Stores the clear coat roughness in a texture (green channel)
  20024. * Not used if useRoughnessFromMainTexture is true
  20025. */
  20026. textureRoughness: Nullable<BaseTexture>;
  20027. private _remapF0OnInterfaceChange;
  20028. /**
  20029. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20030. */
  20031. remapF0OnInterfaceChange: boolean;
  20032. private _bumpTexture;
  20033. /**
  20034. * Define the clear coat specific bump texture.
  20035. */
  20036. bumpTexture: Nullable<BaseTexture>;
  20037. private _isTintEnabled;
  20038. /**
  20039. * Defines if the clear coat tint is enabled in the material.
  20040. */
  20041. isTintEnabled: boolean;
  20042. /**
  20043. * Defines the clear coat tint of the material.
  20044. * This is only use if tint is enabled
  20045. */
  20046. tintColor: Color3;
  20047. /**
  20048. * Defines the distance at which the tint color should be found in the
  20049. * clear coat media.
  20050. * This is only use if tint is enabled
  20051. */
  20052. tintColorAtDistance: number;
  20053. /**
  20054. * Defines the clear coat layer thickness.
  20055. * This is only use if tint is enabled
  20056. */
  20057. tintThickness: number;
  20058. private _tintTexture;
  20059. /**
  20060. * Stores the clear tint values in a texture.
  20061. * rgb is tint
  20062. * a is a thickness factor
  20063. */
  20064. tintTexture: Nullable<BaseTexture>;
  20065. /** @hidden */
  20066. private _internalMarkAllSubMeshesAsTexturesDirty;
  20067. /** @hidden */
  20068. _markAllSubMeshesAsTexturesDirty(): void;
  20069. /**
  20070. * Instantiate a new istance of clear coat configuration.
  20071. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20072. */
  20073. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20074. /**
  20075. * Gets wehter the submesh is ready to be used or not.
  20076. * @param defines the list of "defines" to update.
  20077. * @param scene defines the scene the material belongs to.
  20078. * @param engine defines the engine the material belongs to.
  20079. * @param disableBumpMap defines wether the material disables bump or not.
  20080. * @returns - boolean indicating that the submesh is ready or not.
  20081. */
  20082. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20083. /**
  20084. * Checks to see if a texture is used in the material.
  20085. * @param defines the list of "defines" to update.
  20086. * @param scene defines the scene to the material belongs to.
  20087. */
  20088. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20089. /**
  20090. * Binds the material data.
  20091. * @param uniformBuffer defines the Uniform buffer to fill in.
  20092. * @param scene defines the scene the material belongs to.
  20093. * @param engine defines the engine the material belongs to.
  20094. * @param disableBumpMap defines wether the material disables bump or not.
  20095. * @param isFrozen defines wether the material is frozen or not.
  20096. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20097. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20098. * @param subMesh the submesh to bind data for
  20099. */
  20100. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20101. /**
  20102. * Checks to see if a texture is used in the material.
  20103. * @param texture - Base texture to use.
  20104. * @returns - Boolean specifying if a texture is used in the material.
  20105. */
  20106. hasTexture(texture: BaseTexture): boolean;
  20107. /**
  20108. * Returns an array of the actively used textures.
  20109. * @param activeTextures Array of BaseTextures
  20110. */
  20111. getActiveTextures(activeTextures: BaseTexture[]): void;
  20112. /**
  20113. * Returns the animatable textures.
  20114. * @param animatables Array of animatable textures.
  20115. */
  20116. getAnimatables(animatables: IAnimatable[]): void;
  20117. /**
  20118. * Disposes the resources of the material.
  20119. * @param forceDisposeTextures - Forces the disposal of all textures.
  20120. */
  20121. dispose(forceDisposeTextures?: boolean): void;
  20122. /**
  20123. * Get the current class name of the texture useful for serialization or dynamic coding.
  20124. * @returns "PBRClearCoatConfiguration"
  20125. */
  20126. getClassName(): string;
  20127. /**
  20128. * Add fallbacks to the effect fallbacks list.
  20129. * @param defines defines the Base texture to use.
  20130. * @param fallbacks defines the current fallback list.
  20131. * @param currentRank defines the current fallback rank.
  20132. * @returns the new fallback rank.
  20133. */
  20134. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20135. /**
  20136. * Add the required uniforms to the current list.
  20137. * @param uniforms defines the current uniform list.
  20138. */
  20139. static AddUniforms(uniforms: string[]): void;
  20140. /**
  20141. * Add the required samplers to the current list.
  20142. * @param samplers defines the current sampler list.
  20143. */
  20144. static AddSamplers(samplers: string[]): void;
  20145. /**
  20146. * Add the required uniforms to the current buffer.
  20147. * @param uniformBuffer defines the current uniform buffer.
  20148. */
  20149. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20150. /**
  20151. * Makes a duplicate of the current configuration into another one.
  20152. * @param clearCoatConfiguration define the config where to copy the info
  20153. */
  20154. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20155. /**
  20156. * Serializes this clear coat configuration.
  20157. * @returns - An object with the serialized config.
  20158. */
  20159. serialize(): any;
  20160. /**
  20161. * Parses a anisotropy Configuration from a serialized object.
  20162. * @param source - Serialized object.
  20163. * @param scene Defines the scene we are parsing for
  20164. * @param rootUrl Defines the rootUrl to load from
  20165. */
  20166. parse(source: any, scene: Scene, rootUrl: string): void;
  20167. }
  20168. }
  20169. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  20170. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20172. import { Vector2 } from "babylonjs/Maths/math.vector";
  20173. import { Scene } from "babylonjs/scene";
  20174. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20175. import { Nullable } from "babylonjs/types";
  20176. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20177. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20178. /**
  20179. * @hidden
  20180. */
  20181. export interface IMaterialAnisotropicDefines {
  20182. ANISOTROPIC: boolean;
  20183. ANISOTROPIC_TEXTURE: boolean;
  20184. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20185. MAINUV1: boolean;
  20186. _areTexturesDirty: boolean;
  20187. _needUVs: boolean;
  20188. }
  20189. /**
  20190. * Define the code related to the anisotropic parameters of the pbr material.
  20191. */
  20192. export class PBRAnisotropicConfiguration {
  20193. private _isEnabled;
  20194. /**
  20195. * Defines if the anisotropy is enabled in the material.
  20196. */
  20197. isEnabled: boolean;
  20198. /**
  20199. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20200. */
  20201. intensity: number;
  20202. /**
  20203. * Defines if the effect is along the tangents, bitangents or in between.
  20204. * By default, the effect is "strectching" the highlights along the tangents.
  20205. */
  20206. direction: Vector2;
  20207. private _texture;
  20208. /**
  20209. * Stores the anisotropy values in a texture.
  20210. * rg is direction (like normal from -1 to 1)
  20211. * b is a intensity
  20212. */
  20213. texture: Nullable<BaseTexture>;
  20214. /** @hidden */
  20215. private _internalMarkAllSubMeshesAsTexturesDirty;
  20216. /** @hidden */
  20217. _markAllSubMeshesAsTexturesDirty(): void;
  20218. /**
  20219. * Instantiate a new istance of anisotropy configuration.
  20220. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20221. */
  20222. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20223. /**
  20224. * Specifies that the submesh is ready to be used.
  20225. * @param defines the list of "defines" to update.
  20226. * @param scene defines the scene the material belongs to.
  20227. * @returns - boolean indicating that the submesh is ready or not.
  20228. */
  20229. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20230. /**
  20231. * Checks to see if a texture is used in the material.
  20232. * @param defines the list of "defines" to update.
  20233. * @param mesh the mesh we are preparing the defines for.
  20234. * @param scene defines the scene the material belongs to.
  20235. */
  20236. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20237. /**
  20238. * Binds the material data.
  20239. * @param uniformBuffer defines the Uniform buffer to fill in.
  20240. * @param scene defines the scene the material belongs to.
  20241. * @param isFrozen defines wether the material is frozen or not.
  20242. */
  20243. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20244. /**
  20245. * Checks to see if a texture is used in the material.
  20246. * @param texture - Base texture to use.
  20247. * @returns - Boolean specifying if a texture is used in the material.
  20248. */
  20249. hasTexture(texture: BaseTexture): boolean;
  20250. /**
  20251. * Returns an array of the actively used textures.
  20252. * @param activeTextures Array of BaseTextures
  20253. */
  20254. getActiveTextures(activeTextures: BaseTexture[]): void;
  20255. /**
  20256. * Returns the animatable textures.
  20257. * @param animatables Array of animatable textures.
  20258. */
  20259. getAnimatables(animatables: IAnimatable[]): void;
  20260. /**
  20261. * Disposes the resources of the material.
  20262. * @param forceDisposeTextures - Forces the disposal of all textures.
  20263. */
  20264. dispose(forceDisposeTextures?: boolean): void;
  20265. /**
  20266. * Get the current class name of the texture useful for serialization or dynamic coding.
  20267. * @returns "PBRAnisotropicConfiguration"
  20268. */
  20269. getClassName(): string;
  20270. /**
  20271. * Add fallbacks to the effect fallbacks list.
  20272. * @param defines defines the Base texture to use.
  20273. * @param fallbacks defines the current fallback list.
  20274. * @param currentRank defines the current fallback rank.
  20275. * @returns the new fallback rank.
  20276. */
  20277. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20278. /**
  20279. * Add the required uniforms to the current list.
  20280. * @param uniforms defines the current uniform list.
  20281. */
  20282. static AddUniforms(uniforms: string[]): void;
  20283. /**
  20284. * Add the required uniforms to the current buffer.
  20285. * @param uniformBuffer defines the current uniform buffer.
  20286. */
  20287. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20288. /**
  20289. * Add the required samplers to the current list.
  20290. * @param samplers defines the current sampler list.
  20291. */
  20292. static AddSamplers(samplers: string[]): void;
  20293. /**
  20294. * Makes a duplicate of the current configuration into another one.
  20295. * @param anisotropicConfiguration define the config where to copy the info
  20296. */
  20297. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20298. /**
  20299. * Serializes this anisotropy configuration.
  20300. * @returns - An object with the serialized config.
  20301. */
  20302. serialize(): any;
  20303. /**
  20304. * Parses a anisotropy Configuration from a serialized object.
  20305. * @param source - Serialized object.
  20306. * @param scene Defines the scene we are parsing for
  20307. * @param rootUrl Defines the rootUrl to load from
  20308. */
  20309. parse(source: any, scene: Scene, rootUrl: string): void;
  20310. }
  20311. }
  20312. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  20313. import { Scene } from "babylonjs/scene";
  20314. /**
  20315. * @hidden
  20316. */
  20317. export interface IMaterialBRDFDefines {
  20318. BRDF_V_HEIGHT_CORRELATED: boolean;
  20319. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20320. SPHERICAL_HARMONICS: boolean;
  20321. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20322. /** @hidden */
  20323. _areMiscDirty: boolean;
  20324. }
  20325. /**
  20326. * Define the code related to the BRDF parameters of the pbr material.
  20327. */
  20328. export class PBRBRDFConfiguration {
  20329. /**
  20330. * Default value used for the energy conservation.
  20331. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20332. */
  20333. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20334. /**
  20335. * Default value used for the Smith Visibility Height Correlated mode.
  20336. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20337. */
  20338. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20339. /**
  20340. * Default value used for the IBL diffuse part.
  20341. * This can help switching back to the polynomials mode globally which is a tiny bit
  20342. * less GPU intensive at the drawback of a lower quality.
  20343. */
  20344. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20345. /**
  20346. * Default value used for activating energy conservation for the specular workflow.
  20347. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20348. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20349. */
  20350. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20351. private _useEnergyConservation;
  20352. /**
  20353. * Defines if the material uses energy conservation.
  20354. */
  20355. useEnergyConservation: boolean;
  20356. private _useSmithVisibilityHeightCorrelated;
  20357. /**
  20358. * LEGACY Mode set to false
  20359. * Defines if the material uses height smith correlated visibility term.
  20360. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20361. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20362. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20363. * Not relying on height correlated will also disable energy conservation.
  20364. */
  20365. useSmithVisibilityHeightCorrelated: boolean;
  20366. private _useSphericalHarmonics;
  20367. /**
  20368. * LEGACY Mode set to false
  20369. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20370. * diffuse part of the IBL.
  20371. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20372. * to the ground truth.
  20373. */
  20374. useSphericalHarmonics: boolean;
  20375. private _useSpecularGlossinessInputEnergyConservation;
  20376. /**
  20377. * Defines if the material uses energy conservation, when the specular workflow is active.
  20378. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20379. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20380. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20381. */
  20382. useSpecularGlossinessInputEnergyConservation: boolean;
  20383. /** @hidden */
  20384. private _internalMarkAllSubMeshesAsMiscDirty;
  20385. /** @hidden */
  20386. _markAllSubMeshesAsMiscDirty(): void;
  20387. /**
  20388. * Instantiate a new istance of clear coat configuration.
  20389. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20390. */
  20391. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20392. /**
  20393. * Checks to see if a texture is used in the material.
  20394. * @param defines the list of "defines" to update.
  20395. */
  20396. prepareDefines(defines: IMaterialBRDFDefines): void;
  20397. /**
  20398. * Get the current class name of the texture useful for serialization or dynamic coding.
  20399. * @returns "PBRClearCoatConfiguration"
  20400. */
  20401. getClassName(): string;
  20402. /**
  20403. * Makes a duplicate of the current configuration into another one.
  20404. * @param brdfConfiguration define the config where to copy the info
  20405. */
  20406. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20407. /**
  20408. * Serializes this BRDF configuration.
  20409. * @returns - An object with the serialized config.
  20410. */
  20411. serialize(): any;
  20412. /**
  20413. * Parses a anisotropy Configuration from a serialized object.
  20414. * @param source - Serialized object.
  20415. * @param scene Defines the scene we are parsing for
  20416. * @param rootUrl Defines the rootUrl to load from
  20417. */
  20418. parse(source: any, scene: Scene, rootUrl: string): void;
  20419. }
  20420. }
  20421. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  20422. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20423. import { Color3 } from "babylonjs/Maths/math.color";
  20424. import { Scene } from "babylonjs/scene";
  20425. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20426. import { Nullable } from "babylonjs/types";
  20427. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20428. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20429. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20430. /**
  20431. * @hidden
  20432. */
  20433. export interface IMaterialSheenDefines {
  20434. SHEEN: boolean;
  20435. SHEEN_TEXTURE: boolean;
  20436. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20437. SHEEN_TEXTUREDIRECTUV: number;
  20438. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20439. SHEEN_LINKWITHALBEDO: boolean;
  20440. SHEEN_ROUGHNESS: boolean;
  20441. SHEEN_ALBEDOSCALING: boolean;
  20442. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20443. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20444. /** @hidden */
  20445. _areTexturesDirty: boolean;
  20446. }
  20447. /**
  20448. * Define the code related to the Sheen parameters of the pbr material.
  20449. */
  20450. export class PBRSheenConfiguration {
  20451. private _isEnabled;
  20452. /**
  20453. * Defines if the material uses sheen.
  20454. */
  20455. isEnabled: boolean;
  20456. private _linkSheenWithAlbedo;
  20457. /**
  20458. * Defines if the sheen is linked to the sheen color.
  20459. */
  20460. linkSheenWithAlbedo: boolean;
  20461. /**
  20462. * Defines the sheen intensity.
  20463. */
  20464. intensity: number;
  20465. /**
  20466. * Defines the sheen color.
  20467. */
  20468. color: Color3;
  20469. private _texture;
  20470. /**
  20471. * Stores the sheen tint values in a texture.
  20472. * rgb is tint
  20473. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  20474. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20475. */
  20476. texture: Nullable<BaseTexture>;
  20477. private _useRoughnessFromMainTexture;
  20478. /**
  20479. * Indicates that the alpha channel of the texture property will be used for roughness.
  20480. * Has no effect if the roughness (and texture!) property is not defined
  20481. */
  20482. useRoughnessFromMainTexture: boolean;
  20483. private _roughness;
  20484. /**
  20485. * Defines the sheen roughness.
  20486. * It is not taken into account if linkSheenWithAlbedo is true.
  20487. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20488. */
  20489. roughness: Nullable<number>;
  20490. private _textureRoughness;
  20491. /**
  20492. * Stores the sheen roughness in a texture.
  20493. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20494. */
  20495. textureRoughness: Nullable<BaseTexture>;
  20496. private _albedoScaling;
  20497. /**
  20498. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20499. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20500. * making it easier to setup and tweak the effect
  20501. */
  20502. albedoScaling: boolean;
  20503. /** @hidden */
  20504. private _internalMarkAllSubMeshesAsTexturesDirty;
  20505. /** @hidden */
  20506. _markAllSubMeshesAsTexturesDirty(): void;
  20507. /**
  20508. * Instantiate a new istance of clear coat configuration.
  20509. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20510. */
  20511. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20512. /**
  20513. * Specifies that the submesh is ready to be used.
  20514. * @param defines the list of "defines" to update.
  20515. * @param scene defines the scene the material belongs to.
  20516. * @returns - boolean indicating that the submesh is ready or not.
  20517. */
  20518. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20519. /**
  20520. * Checks to see if a texture is used in the material.
  20521. * @param defines the list of "defines" to update.
  20522. * @param scene defines the scene the material belongs to.
  20523. */
  20524. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20525. /**
  20526. * Binds the material data.
  20527. * @param uniformBuffer defines the Uniform buffer to fill in.
  20528. * @param scene defines the scene the material belongs to.
  20529. * @param isFrozen defines wether the material is frozen or not.
  20530. * @param subMesh the submesh to bind data for
  20531. */
  20532. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20533. /**
  20534. * Checks to see if a texture is used in the material.
  20535. * @param texture - Base texture to use.
  20536. * @returns - Boolean specifying if a texture is used in the material.
  20537. */
  20538. hasTexture(texture: BaseTexture): boolean;
  20539. /**
  20540. * Returns an array of the actively used textures.
  20541. * @param activeTextures Array of BaseTextures
  20542. */
  20543. getActiveTextures(activeTextures: BaseTexture[]): void;
  20544. /**
  20545. * Returns the animatable textures.
  20546. * @param animatables Array of animatable textures.
  20547. */
  20548. getAnimatables(animatables: IAnimatable[]): void;
  20549. /**
  20550. * Disposes the resources of the material.
  20551. * @param forceDisposeTextures - Forces the disposal of all textures.
  20552. */
  20553. dispose(forceDisposeTextures?: boolean): void;
  20554. /**
  20555. * Get the current class name of the texture useful for serialization or dynamic coding.
  20556. * @returns "PBRSheenConfiguration"
  20557. */
  20558. getClassName(): string;
  20559. /**
  20560. * Add fallbacks to the effect fallbacks list.
  20561. * @param defines defines the Base texture to use.
  20562. * @param fallbacks defines the current fallback list.
  20563. * @param currentRank defines the current fallback rank.
  20564. * @returns the new fallback rank.
  20565. */
  20566. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20567. /**
  20568. * Add the required uniforms to the current list.
  20569. * @param uniforms defines the current uniform list.
  20570. */
  20571. static AddUniforms(uniforms: string[]): void;
  20572. /**
  20573. * Add the required uniforms to the current buffer.
  20574. * @param uniformBuffer defines the current uniform buffer.
  20575. */
  20576. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20577. /**
  20578. * Add the required samplers to the current list.
  20579. * @param samplers defines the current sampler list.
  20580. */
  20581. static AddSamplers(samplers: string[]): void;
  20582. /**
  20583. * Makes a duplicate of the current configuration into another one.
  20584. * @param sheenConfiguration define the config where to copy the info
  20585. */
  20586. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20587. /**
  20588. * Serializes this BRDF configuration.
  20589. * @returns - An object with the serialized config.
  20590. */
  20591. serialize(): any;
  20592. /**
  20593. * Parses a anisotropy Configuration from a serialized object.
  20594. * @param source - Serialized object.
  20595. * @param scene Defines the scene we are parsing for
  20596. * @param rootUrl Defines the rootUrl to load from
  20597. */
  20598. parse(source: any, scene: Scene, rootUrl: string): void;
  20599. }
  20600. }
  20601. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  20602. import { Nullable } from "babylonjs/types";
  20603. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20604. import { Color3 } from "babylonjs/Maths/math.color";
  20605. import { SmartArray } from "babylonjs/Misc/smartArray";
  20606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20607. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20608. import { Effect } from "babylonjs/Materials/effect";
  20609. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20610. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20611. import { Engine } from "babylonjs/Engines/engine";
  20612. import { Scene } from "babylonjs/scene";
  20613. /**
  20614. * @hidden
  20615. */
  20616. export interface IMaterialSubSurfaceDefines {
  20617. SUBSURFACE: boolean;
  20618. SS_REFRACTION: boolean;
  20619. SS_TRANSLUCENCY: boolean;
  20620. SS_SCATTERING: boolean;
  20621. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20622. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20623. SS_REFRACTIONMAP_3D: boolean;
  20624. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20625. SS_LODINREFRACTIONALPHA: boolean;
  20626. SS_GAMMAREFRACTION: boolean;
  20627. SS_RGBDREFRACTION: boolean;
  20628. SS_LINEARSPECULARREFRACTION: boolean;
  20629. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20630. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20631. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20632. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20633. /** @hidden */
  20634. _areTexturesDirty: boolean;
  20635. }
  20636. /**
  20637. * Define the code related to the sub surface parameters of the pbr material.
  20638. */
  20639. export class PBRSubSurfaceConfiguration {
  20640. private _isRefractionEnabled;
  20641. /**
  20642. * Defines if the refraction is enabled in the material.
  20643. */
  20644. isRefractionEnabled: boolean;
  20645. private _isTranslucencyEnabled;
  20646. /**
  20647. * Defines if the translucency is enabled in the material.
  20648. */
  20649. isTranslucencyEnabled: boolean;
  20650. private _isScatteringEnabled;
  20651. /**
  20652. * Defines if the sub surface scattering is enabled in the material.
  20653. */
  20654. isScatteringEnabled: boolean;
  20655. private _scatteringDiffusionProfileIndex;
  20656. /**
  20657. * Diffusion profile for subsurface scattering.
  20658. * Useful for better scattering in the skins or foliages.
  20659. */
  20660. get scatteringDiffusionProfile(): Nullable<Color3>;
  20661. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20662. /**
  20663. * Defines the refraction intensity of the material.
  20664. * The refraction when enabled replaces the Diffuse part of the material.
  20665. * The intensity helps transitionning between diffuse and refraction.
  20666. */
  20667. refractionIntensity: number;
  20668. /**
  20669. * Defines the translucency intensity of the material.
  20670. * When translucency has been enabled, this defines how much of the "translucency"
  20671. * is addded to the diffuse part of the material.
  20672. */
  20673. translucencyIntensity: number;
  20674. /**
  20675. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20676. */
  20677. useAlbedoToTintRefraction: boolean;
  20678. private _thicknessTexture;
  20679. /**
  20680. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20681. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20682. * 0 would mean minimumThickness
  20683. * 1 would mean maximumThickness
  20684. * The other channels might be use as a mask to vary the different effects intensity.
  20685. */
  20686. thicknessTexture: Nullable<BaseTexture>;
  20687. private _refractionTexture;
  20688. /**
  20689. * Defines the texture to use for refraction.
  20690. */
  20691. refractionTexture: Nullable<BaseTexture>;
  20692. private _indexOfRefraction;
  20693. /**
  20694. * Index of refraction of the material base layer.
  20695. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20696. *
  20697. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20698. *
  20699. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20700. */
  20701. indexOfRefraction: number;
  20702. private _volumeIndexOfRefraction;
  20703. /**
  20704. * Index of refraction of the material's volume.
  20705. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20706. *
  20707. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20708. * the volume will use the same IOR as the surface.
  20709. */
  20710. get volumeIndexOfRefraction(): number;
  20711. set volumeIndexOfRefraction(value: number);
  20712. private _invertRefractionY;
  20713. /**
  20714. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20715. */
  20716. invertRefractionY: boolean;
  20717. private _linkRefractionWithTransparency;
  20718. /**
  20719. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20720. * Materials half opaque for instance using refraction could benefit from this control.
  20721. */
  20722. linkRefractionWithTransparency: boolean;
  20723. /**
  20724. * Defines the minimum thickness stored in the thickness map.
  20725. * If no thickness map is defined, this value will be used to simulate thickness.
  20726. */
  20727. minimumThickness: number;
  20728. /**
  20729. * Defines the maximum thickness stored in the thickness map.
  20730. */
  20731. maximumThickness: number;
  20732. /**
  20733. * Defines the volume tint of the material.
  20734. * This is used for both translucency and scattering.
  20735. */
  20736. tintColor: Color3;
  20737. /**
  20738. * Defines the distance at which the tint color should be found in the media.
  20739. * This is used for refraction only.
  20740. */
  20741. tintColorAtDistance: number;
  20742. /**
  20743. * Defines how far each channel transmit through the media.
  20744. * It is defined as a color to simplify it selection.
  20745. */
  20746. diffusionDistance: Color3;
  20747. private _useMaskFromThicknessTexture;
  20748. /**
  20749. * Stores the intensity of the different subsurface effects in the thickness texture.
  20750. * * the green channel is the translucency intensity.
  20751. * * the blue channel is the scattering intensity.
  20752. * * the alpha channel is the refraction intensity.
  20753. */
  20754. useMaskFromThicknessTexture: boolean;
  20755. private _scene;
  20756. private _useMaskFromThicknessTextureGltf;
  20757. /**
  20758. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20759. * matches the channel-packing that is used by glTF.
  20760. * * the red channel is the transmission/translucency intensity.
  20761. * * the green channel is the thickness.
  20762. */
  20763. useMaskFromThicknessTextureGltf: boolean;
  20764. /** @hidden */
  20765. private _internalMarkAllSubMeshesAsTexturesDirty;
  20766. private _internalMarkScenePrePassDirty;
  20767. /** @hidden */
  20768. _markAllSubMeshesAsTexturesDirty(): void;
  20769. /** @hidden */
  20770. _markScenePrePassDirty(): void;
  20771. /**
  20772. * Instantiate a new istance of sub surface configuration.
  20773. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20774. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20775. * @param scene The scene
  20776. */
  20777. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20778. /**
  20779. * Gets wehter the submesh is ready to be used or not.
  20780. * @param defines the list of "defines" to update.
  20781. * @param scene defines the scene the material belongs to.
  20782. * @returns - boolean indicating that the submesh is ready or not.
  20783. */
  20784. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20785. /**
  20786. * Checks to see if a texture is used in the material.
  20787. * @param defines the list of "defines" to update.
  20788. * @param scene defines the scene to the material belongs to.
  20789. */
  20790. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20791. /**
  20792. * Binds the material data.
  20793. * @param uniformBuffer defines the Uniform buffer to fill in.
  20794. * @param scene defines the scene the material belongs to.
  20795. * @param engine defines the engine the material belongs to.
  20796. * @param isFrozen defines whether the material is frozen or not.
  20797. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20798. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20799. */
  20800. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20801. /**
  20802. * Unbinds the material from the mesh.
  20803. * @param activeEffect defines the effect that should be unbound from.
  20804. * @returns true if unbound, otherwise false
  20805. */
  20806. unbind(activeEffect: Effect): boolean;
  20807. /**
  20808. * Returns the texture used for refraction or null if none is used.
  20809. * @param scene defines the scene the material belongs to.
  20810. * @returns - Refraction texture if present. If no refraction texture and refraction
  20811. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20812. */
  20813. private _getRefractionTexture;
  20814. /**
  20815. * Returns true if alpha blending should be disabled.
  20816. */
  20817. get disableAlphaBlending(): boolean;
  20818. /**
  20819. * Fills the list of render target textures.
  20820. * @param renderTargets the list of render targets to update
  20821. */
  20822. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20823. /**
  20824. * Checks to see if a texture is used in the material.
  20825. * @param texture - Base texture to use.
  20826. * @returns - Boolean specifying if a texture is used in the material.
  20827. */
  20828. hasTexture(texture: BaseTexture): boolean;
  20829. /**
  20830. * Gets a boolean indicating that current material needs to register RTT
  20831. * @returns true if this uses a render target otherwise false.
  20832. */
  20833. hasRenderTargetTextures(): boolean;
  20834. /**
  20835. * Returns an array of the actively used textures.
  20836. * @param activeTextures Array of BaseTextures
  20837. */
  20838. getActiveTextures(activeTextures: BaseTexture[]): void;
  20839. /**
  20840. * Returns the animatable textures.
  20841. * @param animatables Array of animatable textures.
  20842. */
  20843. getAnimatables(animatables: IAnimatable[]): void;
  20844. /**
  20845. * Disposes the resources of the material.
  20846. * @param forceDisposeTextures - Forces the disposal of all textures.
  20847. */
  20848. dispose(forceDisposeTextures?: boolean): void;
  20849. /**
  20850. * Get the current class name of the texture useful for serialization or dynamic coding.
  20851. * @returns "PBRSubSurfaceConfiguration"
  20852. */
  20853. getClassName(): string;
  20854. /**
  20855. * Add fallbacks to the effect fallbacks list.
  20856. * @param defines defines the Base texture to use.
  20857. * @param fallbacks defines the current fallback list.
  20858. * @param currentRank defines the current fallback rank.
  20859. * @returns the new fallback rank.
  20860. */
  20861. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20862. /**
  20863. * Add the required uniforms to the current list.
  20864. * @param uniforms defines the current uniform list.
  20865. */
  20866. static AddUniforms(uniforms: string[]): void;
  20867. /**
  20868. * Add the required samplers to the current list.
  20869. * @param samplers defines the current sampler list.
  20870. */
  20871. static AddSamplers(samplers: string[]): void;
  20872. /**
  20873. * Add the required uniforms to the current buffer.
  20874. * @param uniformBuffer defines the current uniform buffer.
  20875. */
  20876. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20877. /**
  20878. * Makes a duplicate of the current configuration into another one.
  20879. * @param configuration define the config where to copy the info
  20880. */
  20881. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20882. /**
  20883. * Serializes this Sub Surface configuration.
  20884. * @returns - An object with the serialized config.
  20885. */
  20886. serialize(): any;
  20887. /**
  20888. * Parses a anisotropy Configuration from a serialized object.
  20889. * @param source - Serialized object.
  20890. * @param scene Defines the scene we are parsing for
  20891. * @param rootUrl Defines the rootUrl to load from
  20892. */
  20893. parse(source: any, scene: Scene, rootUrl: string): void;
  20894. }
  20895. }
  20896. declare module "babylonjs/Maths/sphericalPolynomial" {
  20897. import { Vector3 } from "babylonjs/Maths/math.vector";
  20898. import { Color3 } from "babylonjs/Maths/math.color";
  20899. /**
  20900. * Class representing spherical harmonics coefficients to the 3rd degree
  20901. */
  20902. export class SphericalHarmonics {
  20903. /**
  20904. * Defines whether or not the harmonics have been prescaled for rendering.
  20905. */
  20906. preScaled: boolean;
  20907. /**
  20908. * The l0,0 coefficients of the spherical harmonics
  20909. */
  20910. l00: Vector3;
  20911. /**
  20912. * The l1,-1 coefficients of the spherical harmonics
  20913. */
  20914. l1_1: Vector3;
  20915. /**
  20916. * The l1,0 coefficients of the spherical harmonics
  20917. */
  20918. l10: Vector3;
  20919. /**
  20920. * The l1,1 coefficients of the spherical harmonics
  20921. */
  20922. l11: Vector3;
  20923. /**
  20924. * The l2,-2 coefficients of the spherical harmonics
  20925. */
  20926. l2_2: Vector3;
  20927. /**
  20928. * The l2,-1 coefficients of the spherical harmonics
  20929. */
  20930. l2_1: Vector3;
  20931. /**
  20932. * The l2,0 coefficients of the spherical harmonics
  20933. */
  20934. l20: Vector3;
  20935. /**
  20936. * The l2,1 coefficients of the spherical harmonics
  20937. */
  20938. l21: Vector3;
  20939. /**
  20940. * The l2,2 coefficients of the spherical harmonics
  20941. */
  20942. l22: Vector3;
  20943. /**
  20944. * Adds a light to the spherical harmonics
  20945. * @param direction the direction of the light
  20946. * @param color the color of the light
  20947. * @param deltaSolidAngle the delta solid angle of the light
  20948. */
  20949. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20950. /**
  20951. * Scales the spherical harmonics by the given amount
  20952. * @param scale the amount to scale
  20953. */
  20954. scaleInPlace(scale: number): void;
  20955. /**
  20956. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20957. *
  20958. * ```
  20959. * E_lm = A_l * L_lm
  20960. * ```
  20961. *
  20962. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20963. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20964. * the scaling factors are given in equation 9.
  20965. */
  20966. convertIncidentRadianceToIrradiance(): void;
  20967. /**
  20968. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20969. *
  20970. * ```
  20971. * L = (1/pi) * E * rho
  20972. * ```
  20973. *
  20974. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20975. */
  20976. convertIrradianceToLambertianRadiance(): void;
  20977. /**
  20978. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20979. * required operations at run time.
  20980. *
  20981. * This is simply done by scaling back the SH with Ylm constants parameter.
  20982. * The trigonometric part being applied by the shader at run time.
  20983. */
  20984. preScaleForRendering(): void;
  20985. /**
  20986. * Constructs a spherical harmonics from an array.
  20987. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20988. * @returns the spherical harmonics
  20989. */
  20990. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20991. /**
  20992. * Gets the spherical harmonics from polynomial
  20993. * @param polynomial the spherical polynomial
  20994. * @returns the spherical harmonics
  20995. */
  20996. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20997. }
  20998. /**
  20999. * Class representing spherical polynomial coefficients to the 3rd degree
  21000. */
  21001. export class SphericalPolynomial {
  21002. private _harmonics;
  21003. /**
  21004. * The spherical harmonics used to create the polynomials.
  21005. */
  21006. get preScaledHarmonics(): SphericalHarmonics;
  21007. /**
  21008. * The x coefficients of the spherical polynomial
  21009. */
  21010. x: Vector3;
  21011. /**
  21012. * The y coefficients of the spherical polynomial
  21013. */
  21014. y: Vector3;
  21015. /**
  21016. * The z coefficients of the spherical polynomial
  21017. */
  21018. z: Vector3;
  21019. /**
  21020. * The xx coefficients of the spherical polynomial
  21021. */
  21022. xx: Vector3;
  21023. /**
  21024. * The yy coefficients of the spherical polynomial
  21025. */
  21026. yy: Vector3;
  21027. /**
  21028. * The zz coefficients of the spherical polynomial
  21029. */
  21030. zz: Vector3;
  21031. /**
  21032. * The xy coefficients of the spherical polynomial
  21033. */
  21034. xy: Vector3;
  21035. /**
  21036. * The yz coefficients of the spherical polynomial
  21037. */
  21038. yz: Vector3;
  21039. /**
  21040. * The zx coefficients of the spherical polynomial
  21041. */
  21042. zx: Vector3;
  21043. /**
  21044. * Adds an ambient color to the spherical polynomial
  21045. * @param color the color to add
  21046. */
  21047. addAmbient(color: Color3): void;
  21048. /**
  21049. * Scales the spherical polynomial by the given amount
  21050. * @param scale the amount to scale
  21051. */
  21052. scaleInPlace(scale: number): void;
  21053. /**
  21054. * Gets the spherical polynomial from harmonics
  21055. * @param harmonics the spherical harmonics
  21056. * @returns the spherical polynomial
  21057. */
  21058. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21059. /**
  21060. * Constructs a spherical polynomial from an array.
  21061. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21062. * @returns the spherical polynomial
  21063. */
  21064. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21065. }
  21066. }
  21067. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  21068. import { Nullable } from "babylonjs/types";
  21069. /**
  21070. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21071. */
  21072. export interface CubeMapInfo {
  21073. /**
  21074. * The pixel array for the front face.
  21075. * This is stored in format, left to right, up to down format.
  21076. */
  21077. front: Nullable<ArrayBufferView>;
  21078. /**
  21079. * The pixel array for the back face.
  21080. * This is stored in format, left to right, up to down format.
  21081. */
  21082. back: Nullable<ArrayBufferView>;
  21083. /**
  21084. * The pixel array for the left face.
  21085. * This is stored in format, left to right, up to down format.
  21086. */
  21087. left: Nullable<ArrayBufferView>;
  21088. /**
  21089. * The pixel array for the right face.
  21090. * This is stored in format, left to right, up to down format.
  21091. */
  21092. right: Nullable<ArrayBufferView>;
  21093. /**
  21094. * The pixel array for the up face.
  21095. * This is stored in format, left to right, up to down format.
  21096. */
  21097. up: Nullable<ArrayBufferView>;
  21098. /**
  21099. * The pixel array for the down face.
  21100. * This is stored in format, left to right, up to down format.
  21101. */
  21102. down: Nullable<ArrayBufferView>;
  21103. /**
  21104. * The size of the cubemap stored.
  21105. *
  21106. * Each faces will be size * size pixels.
  21107. */
  21108. size: number;
  21109. /**
  21110. * The format of the texture.
  21111. *
  21112. * RGBA, RGB.
  21113. */
  21114. format: number;
  21115. /**
  21116. * The type of the texture data.
  21117. *
  21118. * UNSIGNED_INT, FLOAT.
  21119. */
  21120. type: number;
  21121. /**
  21122. * Specifies whether the texture is in gamma space.
  21123. */
  21124. gammaSpace: boolean;
  21125. }
  21126. /**
  21127. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21128. */
  21129. export class PanoramaToCubeMapTools {
  21130. private static FACE_LEFT;
  21131. private static FACE_RIGHT;
  21132. private static FACE_FRONT;
  21133. private static FACE_BACK;
  21134. private static FACE_DOWN;
  21135. private static FACE_UP;
  21136. /**
  21137. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21138. *
  21139. * @param float32Array The source data.
  21140. * @param inputWidth The width of the input panorama.
  21141. * @param inputHeight The height of the input panorama.
  21142. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21143. * @return The cubemap data
  21144. */
  21145. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21146. private static CreateCubemapTexture;
  21147. private static CalcProjectionSpherical;
  21148. }
  21149. }
  21150. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  21151. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21152. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21153. import { Nullable } from "babylonjs/types";
  21154. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  21155. /**
  21156. * Helper class dealing with the extraction of spherical polynomial dataArray
  21157. * from a cube map.
  21158. */
  21159. export class CubeMapToSphericalPolynomialTools {
  21160. private static FileFaces;
  21161. /**
  21162. * Converts a texture to the according Spherical Polynomial data.
  21163. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21164. *
  21165. * @param texture The texture to extract the information from.
  21166. * @return The Spherical Polynomial data.
  21167. */
  21168. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  21169. /**
  21170. * Converts a cubemap to the according Spherical Polynomial data.
  21171. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21172. *
  21173. * @param cubeInfo The Cube map to extract the information from.
  21174. * @return The Spherical Polynomial data.
  21175. */
  21176. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21177. }
  21178. }
  21179. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  21180. import { Nullable } from "babylonjs/types";
  21181. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  21182. module "babylonjs/Materials/Textures/baseTexture" {
  21183. interface BaseTexture {
  21184. /**
  21185. * Get the polynomial representation of the texture data.
  21186. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21187. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21188. */
  21189. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21190. }
  21191. }
  21192. }
  21193. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  21194. /** @hidden */
  21195. export var pbrFragmentDeclaration: {
  21196. name: string;
  21197. shader: string;
  21198. };
  21199. }
  21200. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  21201. /** @hidden */
  21202. export var pbrUboDeclaration: {
  21203. name: string;
  21204. shader: string;
  21205. };
  21206. }
  21207. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  21208. /** @hidden */
  21209. export var pbrFragmentExtraDeclaration: {
  21210. name: string;
  21211. shader: string;
  21212. };
  21213. }
  21214. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  21215. /** @hidden */
  21216. export var pbrFragmentSamplersDeclaration: {
  21217. name: string;
  21218. shader: string;
  21219. };
  21220. }
  21221. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  21222. /** @hidden */
  21223. export var subSurfaceScatteringFunctions: {
  21224. name: string;
  21225. shader: string;
  21226. };
  21227. }
  21228. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  21229. /** @hidden */
  21230. export var importanceSampling: {
  21231. name: string;
  21232. shader: string;
  21233. };
  21234. }
  21235. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  21236. /** @hidden */
  21237. export var pbrHelperFunctions: {
  21238. name: string;
  21239. shader: string;
  21240. };
  21241. }
  21242. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  21243. /** @hidden */
  21244. export var harmonicsFunctions: {
  21245. name: string;
  21246. shader: string;
  21247. };
  21248. }
  21249. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  21250. /** @hidden */
  21251. export var pbrDirectLightingSetupFunctions: {
  21252. name: string;
  21253. shader: string;
  21254. };
  21255. }
  21256. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  21257. /** @hidden */
  21258. export var pbrDirectLightingFalloffFunctions: {
  21259. name: string;
  21260. shader: string;
  21261. };
  21262. }
  21263. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  21264. /** @hidden */
  21265. export var pbrBRDFFunctions: {
  21266. name: string;
  21267. shader: string;
  21268. };
  21269. }
  21270. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  21271. /** @hidden */
  21272. export var hdrFilteringFunctions: {
  21273. name: string;
  21274. shader: string;
  21275. };
  21276. }
  21277. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  21278. /** @hidden */
  21279. export var pbrDirectLightingFunctions: {
  21280. name: string;
  21281. shader: string;
  21282. };
  21283. }
  21284. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  21285. /** @hidden */
  21286. export var pbrIBLFunctions: {
  21287. name: string;
  21288. shader: string;
  21289. };
  21290. }
  21291. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  21292. /** @hidden */
  21293. export var pbrBlockAlbedoOpacity: {
  21294. name: string;
  21295. shader: string;
  21296. };
  21297. }
  21298. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  21299. /** @hidden */
  21300. export var pbrBlockReflectivity: {
  21301. name: string;
  21302. shader: string;
  21303. };
  21304. }
  21305. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  21306. /** @hidden */
  21307. export var pbrBlockAmbientOcclusion: {
  21308. name: string;
  21309. shader: string;
  21310. };
  21311. }
  21312. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  21313. /** @hidden */
  21314. export var pbrBlockAlphaFresnel: {
  21315. name: string;
  21316. shader: string;
  21317. };
  21318. }
  21319. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  21320. /** @hidden */
  21321. export var pbrBlockAnisotropic: {
  21322. name: string;
  21323. shader: string;
  21324. };
  21325. }
  21326. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  21327. /** @hidden */
  21328. export var pbrBlockReflection: {
  21329. name: string;
  21330. shader: string;
  21331. };
  21332. }
  21333. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  21334. /** @hidden */
  21335. export var pbrBlockSheen: {
  21336. name: string;
  21337. shader: string;
  21338. };
  21339. }
  21340. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  21341. /** @hidden */
  21342. export var pbrBlockClearcoat: {
  21343. name: string;
  21344. shader: string;
  21345. };
  21346. }
  21347. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  21348. /** @hidden */
  21349. export var pbrBlockSubSurface: {
  21350. name: string;
  21351. shader: string;
  21352. };
  21353. }
  21354. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  21355. /** @hidden */
  21356. export var pbrBlockNormalGeometric: {
  21357. name: string;
  21358. shader: string;
  21359. };
  21360. }
  21361. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  21362. /** @hidden */
  21363. export var pbrBlockNormalFinal: {
  21364. name: string;
  21365. shader: string;
  21366. };
  21367. }
  21368. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  21369. /** @hidden */
  21370. export var pbrBlockLightmapInit: {
  21371. name: string;
  21372. shader: string;
  21373. };
  21374. }
  21375. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  21376. /** @hidden */
  21377. export var pbrBlockGeometryInfo: {
  21378. name: string;
  21379. shader: string;
  21380. };
  21381. }
  21382. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  21383. /** @hidden */
  21384. export var pbrBlockReflectance0: {
  21385. name: string;
  21386. shader: string;
  21387. };
  21388. }
  21389. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  21390. /** @hidden */
  21391. export var pbrBlockReflectance: {
  21392. name: string;
  21393. shader: string;
  21394. };
  21395. }
  21396. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  21397. /** @hidden */
  21398. export var pbrBlockDirectLighting: {
  21399. name: string;
  21400. shader: string;
  21401. };
  21402. }
  21403. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  21404. /** @hidden */
  21405. export var pbrBlockFinalLitComponents: {
  21406. name: string;
  21407. shader: string;
  21408. };
  21409. }
  21410. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  21411. /** @hidden */
  21412. export var pbrBlockFinalUnlitComponents: {
  21413. name: string;
  21414. shader: string;
  21415. };
  21416. }
  21417. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  21418. /** @hidden */
  21419. export var pbrBlockFinalColorComposition: {
  21420. name: string;
  21421. shader: string;
  21422. };
  21423. }
  21424. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  21425. /** @hidden */
  21426. export var pbrBlockImageProcessing: {
  21427. name: string;
  21428. shader: string;
  21429. };
  21430. }
  21431. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  21432. /** @hidden */
  21433. export var pbrDebug: {
  21434. name: string;
  21435. shader: string;
  21436. };
  21437. }
  21438. declare module "babylonjs/Shaders/pbr.fragment" {
  21439. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  21440. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  21441. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21442. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  21443. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21444. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21445. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  21446. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  21447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  21448. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21449. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  21450. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21451. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  21452. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  21453. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  21454. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  21455. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  21456. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21457. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  21458. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  21459. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  21460. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  21461. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  21462. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  21463. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  21464. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  21465. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21466. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  21467. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  21468. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  21469. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  21470. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  21471. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  21472. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  21473. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  21474. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  21475. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  21476. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  21477. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  21478. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  21479. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  21480. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  21481. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  21482. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  21483. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  21484. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  21485. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  21486. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  21487. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  21488. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  21489. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  21490. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  21491. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  21492. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  21493. /** @hidden */
  21494. export var pbrPixelShader: {
  21495. name: string;
  21496. shader: string;
  21497. };
  21498. }
  21499. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  21500. /** @hidden */
  21501. export var pbrVertexDeclaration: {
  21502. name: string;
  21503. shader: string;
  21504. };
  21505. }
  21506. declare module "babylonjs/Shaders/pbr.vertex" {
  21507. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  21508. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  21509. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21510. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  21511. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  21512. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  21513. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  21514. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  21515. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  21516. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  21517. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  21518. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  21519. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  21520. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  21521. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  21522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  21523. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  21524. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  21525. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  21526. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  21527. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  21528. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  21529. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  21530. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  21531. /** @hidden */
  21532. export var pbrVertexShader: {
  21533. name: string;
  21534. shader: string;
  21535. };
  21536. }
  21537. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  21538. import { Nullable } from "babylonjs/types";
  21539. import { Scene } from "babylonjs/scene";
  21540. import { Matrix } from "babylonjs/Maths/math.vector";
  21541. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21543. import { Mesh } from "babylonjs/Meshes/mesh";
  21544. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  21545. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  21546. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  21547. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  21548. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  21549. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21550. import { Color3 } from "babylonjs/Maths/math.color";
  21551. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  21552. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  21553. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21554. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  21555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21556. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21557. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  21558. import "babylonjs/Shaders/pbr.fragment";
  21559. import "babylonjs/Shaders/pbr.vertex";
  21560. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  21561. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  21562. /**
  21563. * Manages the defines for the PBR Material.
  21564. * @hidden
  21565. */
  21566. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21567. PBR: boolean;
  21568. NUM_SAMPLES: string;
  21569. REALTIME_FILTERING: boolean;
  21570. MAINUV1: boolean;
  21571. MAINUV2: boolean;
  21572. UV1: boolean;
  21573. UV2: boolean;
  21574. ALBEDO: boolean;
  21575. GAMMAALBEDO: boolean;
  21576. ALBEDODIRECTUV: number;
  21577. VERTEXCOLOR: boolean;
  21578. DETAIL: boolean;
  21579. DETAILDIRECTUV: number;
  21580. DETAIL_NORMALBLENDMETHOD: number;
  21581. AMBIENT: boolean;
  21582. AMBIENTDIRECTUV: number;
  21583. AMBIENTINGRAYSCALE: boolean;
  21584. OPACITY: boolean;
  21585. VERTEXALPHA: boolean;
  21586. OPACITYDIRECTUV: number;
  21587. OPACITYRGB: boolean;
  21588. ALPHATEST: boolean;
  21589. DEPTHPREPASS: boolean;
  21590. ALPHABLEND: boolean;
  21591. ALPHAFROMALBEDO: boolean;
  21592. ALPHATESTVALUE: string;
  21593. SPECULAROVERALPHA: boolean;
  21594. RADIANCEOVERALPHA: boolean;
  21595. ALPHAFRESNEL: boolean;
  21596. LINEARALPHAFRESNEL: boolean;
  21597. PREMULTIPLYALPHA: boolean;
  21598. EMISSIVE: boolean;
  21599. EMISSIVEDIRECTUV: number;
  21600. REFLECTIVITY: boolean;
  21601. REFLECTIVITYDIRECTUV: number;
  21602. SPECULARTERM: boolean;
  21603. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21604. MICROSURFACEAUTOMATIC: boolean;
  21605. LODBASEDMICROSFURACE: boolean;
  21606. MICROSURFACEMAP: boolean;
  21607. MICROSURFACEMAPDIRECTUV: number;
  21608. METALLICWORKFLOW: boolean;
  21609. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21610. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21611. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21612. AOSTOREINMETALMAPRED: boolean;
  21613. METALLIC_REFLECTANCE: boolean;
  21614. METALLIC_REFLECTANCEDIRECTUV: number;
  21615. ENVIRONMENTBRDF: boolean;
  21616. ENVIRONMENTBRDF_RGBD: boolean;
  21617. NORMAL: boolean;
  21618. TANGENT: boolean;
  21619. BUMP: boolean;
  21620. BUMPDIRECTUV: number;
  21621. OBJECTSPACE_NORMALMAP: boolean;
  21622. PARALLAX: boolean;
  21623. PARALLAXOCCLUSION: boolean;
  21624. NORMALXYSCALE: boolean;
  21625. LIGHTMAP: boolean;
  21626. LIGHTMAPDIRECTUV: number;
  21627. USELIGHTMAPASSHADOWMAP: boolean;
  21628. GAMMALIGHTMAP: boolean;
  21629. RGBDLIGHTMAP: boolean;
  21630. REFLECTION: boolean;
  21631. REFLECTIONMAP_3D: boolean;
  21632. REFLECTIONMAP_SPHERICAL: boolean;
  21633. REFLECTIONMAP_PLANAR: boolean;
  21634. REFLECTIONMAP_CUBIC: boolean;
  21635. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21636. REFLECTIONMAP_PROJECTION: boolean;
  21637. REFLECTIONMAP_SKYBOX: boolean;
  21638. REFLECTIONMAP_EXPLICIT: boolean;
  21639. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21640. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21641. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21642. INVERTCUBICMAP: boolean;
  21643. USESPHERICALFROMREFLECTIONMAP: boolean;
  21644. USEIRRADIANCEMAP: boolean;
  21645. SPHERICAL_HARMONICS: boolean;
  21646. USESPHERICALINVERTEX: boolean;
  21647. REFLECTIONMAP_OPPOSITEZ: boolean;
  21648. LODINREFLECTIONALPHA: boolean;
  21649. GAMMAREFLECTION: boolean;
  21650. RGBDREFLECTION: boolean;
  21651. LINEARSPECULARREFLECTION: boolean;
  21652. RADIANCEOCCLUSION: boolean;
  21653. HORIZONOCCLUSION: boolean;
  21654. INSTANCES: boolean;
  21655. THIN_INSTANCES: boolean;
  21656. PREPASS: boolean;
  21657. PREPASS_IRRADIANCE: boolean;
  21658. PREPASS_IRRADIANCE_INDEX: number;
  21659. PREPASS_ALBEDO: boolean;
  21660. PREPASS_ALBEDO_INDEX: number;
  21661. PREPASS_DEPTHNORMAL: boolean;
  21662. PREPASS_DEPTHNORMAL_INDEX: number;
  21663. PREPASS_POSITION: boolean;
  21664. PREPASS_POSITION_INDEX: number;
  21665. PREPASS_VELOCITY: boolean;
  21666. PREPASS_VELOCITY_INDEX: number;
  21667. PREPASS_REFLECTIVITY: boolean;
  21668. PREPASS_REFLECTIVITY_INDEX: number;
  21669. SCENE_MRT_COUNT: number;
  21670. NUM_BONE_INFLUENCERS: number;
  21671. BonesPerMesh: number;
  21672. BONETEXTURE: boolean;
  21673. BONES_VELOCITY_ENABLED: boolean;
  21674. NONUNIFORMSCALING: boolean;
  21675. MORPHTARGETS: boolean;
  21676. MORPHTARGETS_NORMAL: boolean;
  21677. MORPHTARGETS_TANGENT: boolean;
  21678. MORPHTARGETS_UV: boolean;
  21679. NUM_MORPH_INFLUENCERS: number;
  21680. IMAGEPROCESSING: boolean;
  21681. VIGNETTE: boolean;
  21682. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21683. VIGNETTEBLENDMODEOPAQUE: boolean;
  21684. TONEMAPPING: boolean;
  21685. TONEMAPPING_ACES: boolean;
  21686. CONTRAST: boolean;
  21687. COLORCURVES: boolean;
  21688. COLORGRADING: boolean;
  21689. COLORGRADING3D: boolean;
  21690. SAMPLER3DGREENDEPTH: boolean;
  21691. SAMPLER3DBGRMAP: boolean;
  21692. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21693. EXPOSURE: boolean;
  21694. MULTIVIEW: boolean;
  21695. USEPHYSICALLIGHTFALLOFF: boolean;
  21696. USEGLTFLIGHTFALLOFF: boolean;
  21697. TWOSIDEDLIGHTING: boolean;
  21698. SHADOWFLOAT: boolean;
  21699. CLIPPLANE: boolean;
  21700. CLIPPLANE2: boolean;
  21701. CLIPPLANE3: boolean;
  21702. CLIPPLANE4: boolean;
  21703. CLIPPLANE5: boolean;
  21704. CLIPPLANE6: boolean;
  21705. POINTSIZE: boolean;
  21706. FOG: boolean;
  21707. LOGARITHMICDEPTH: boolean;
  21708. FORCENORMALFORWARD: boolean;
  21709. SPECULARAA: boolean;
  21710. CLEARCOAT: boolean;
  21711. CLEARCOAT_DEFAULTIOR: boolean;
  21712. CLEARCOAT_TEXTURE: boolean;
  21713. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21714. CLEARCOAT_TEXTUREDIRECTUV: number;
  21715. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21716. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21717. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21718. CLEARCOAT_BUMP: boolean;
  21719. CLEARCOAT_BUMPDIRECTUV: number;
  21720. CLEARCOAT_REMAP_F0: boolean;
  21721. CLEARCOAT_TINT: boolean;
  21722. CLEARCOAT_TINT_TEXTURE: boolean;
  21723. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21724. ANISOTROPIC: boolean;
  21725. ANISOTROPIC_TEXTURE: boolean;
  21726. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21727. BRDF_V_HEIGHT_CORRELATED: boolean;
  21728. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21729. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21730. SHEEN: boolean;
  21731. SHEEN_TEXTURE: boolean;
  21732. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21733. SHEEN_TEXTUREDIRECTUV: number;
  21734. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21735. SHEEN_LINKWITHALBEDO: boolean;
  21736. SHEEN_ROUGHNESS: boolean;
  21737. SHEEN_ALBEDOSCALING: boolean;
  21738. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21739. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21740. SUBSURFACE: boolean;
  21741. SS_REFRACTION: boolean;
  21742. SS_TRANSLUCENCY: boolean;
  21743. SS_SCATTERING: boolean;
  21744. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21745. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21746. SS_REFRACTIONMAP_3D: boolean;
  21747. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21748. SS_LODINREFRACTIONALPHA: boolean;
  21749. SS_GAMMAREFRACTION: boolean;
  21750. SS_RGBDREFRACTION: boolean;
  21751. SS_LINEARSPECULARREFRACTION: boolean;
  21752. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21753. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21754. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21755. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21756. UNLIT: boolean;
  21757. DEBUGMODE: number;
  21758. /**
  21759. * Initializes the PBR Material defines.
  21760. */
  21761. constructor();
  21762. /**
  21763. * Resets the PBR Material defines.
  21764. */
  21765. reset(): void;
  21766. }
  21767. /**
  21768. * The Physically based material base class of BJS.
  21769. *
  21770. * This offers the main features of a standard PBR material.
  21771. * For more information, please refer to the documentation :
  21772. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21773. */
  21774. export abstract class PBRBaseMaterial extends PushMaterial {
  21775. /**
  21776. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21777. */
  21778. static readonly PBRMATERIAL_OPAQUE: number;
  21779. /**
  21780. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21781. */
  21782. static readonly PBRMATERIAL_ALPHATEST: number;
  21783. /**
  21784. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21785. */
  21786. static readonly PBRMATERIAL_ALPHABLEND: number;
  21787. /**
  21788. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21789. * They are also discarded below the alpha cutoff threshold to improve performances.
  21790. */
  21791. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21792. /**
  21793. * Defines the default value of how much AO map is occluding the analytical lights
  21794. * (point spot...).
  21795. */
  21796. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21797. /**
  21798. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21799. */
  21800. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21801. /**
  21802. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21803. * to enhance interoperability with other engines.
  21804. */
  21805. static readonly LIGHTFALLOFF_GLTF: number;
  21806. /**
  21807. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21808. * to enhance interoperability with other materials.
  21809. */
  21810. static readonly LIGHTFALLOFF_STANDARD: number;
  21811. /**
  21812. * Intensity of the direct lights e.g. the four lights available in your scene.
  21813. * This impacts both the direct diffuse and specular highlights.
  21814. */
  21815. protected _directIntensity: number;
  21816. /**
  21817. * Intensity of the emissive part of the material.
  21818. * This helps controlling the emissive effect without modifying the emissive color.
  21819. */
  21820. protected _emissiveIntensity: number;
  21821. /**
  21822. * Intensity of the environment e.g. how much the environment will light the object
  21823. * either through harmonics for rough material or through the refelction for shiny ones.
  21824. */
  21825. protected _environmentIntensity: number;
  21826. /**
  21827. * This is a special control allowing the reduction of the specular highlights coming from the
  21828. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21829. */
  21830. protected _specularIntensity: number;
  21831. /**
  21832. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21833. */
  21834. private _lightingInfos;
  21835. /**
  21836. * Debug Control allowing disabling the bump map on this material.
  21837. */
  21838. protected _disableBumpMap: boolean;
  21839. /**
  21840. * AKA Diffuse Texture in standard nomenclature.
  21841. */
  21842. protected _albedoTexture: Nullable<BaseTexture>;
  21843. /**
  21844. * AKA Occlusion Texture in other nomenclature.
  21845. */
  21846. protected _ambientTexture: Nullable<BaseTexture>;
  21847. /**
  21848. * AKA Occlusion Texture Intensity in other nomenclature.
  21849. */
  21850. protected _ambientTextureStrength: number;
  21851. /**
  21852. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21853. * 1 means it completely occludes it
  21854. * 0 mean it has no impact
  21855. */
  21856. protected _ambientTextureImpactOnAnalyticalLights: number;
  21857. /**
  21858. * Stores the alpha values in a texture.
  21859. */
  21860. protected _opacityTexture: Nullable<BaseTexture>;
  21861. /**
  21862. * Stores the reflection values in a texture.
  21863. */
  21864. protected _reflectionTexture: Nullable<BaseTexture>;
  21865. /**
  21866. * Stores the emissive values in a texture.
  21867. */
  21868. protected _emissiveTexture: Nullable<BaseTexture>;
  21869. /**
  21870. * AKA Specular texture in other nomenclature.
  21871. */
  21872. protected _reflectivityTexture: Nullable<BaseTexture>;
  21873. /**
  21874. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21875. */
  21876. protected _metallicTexture: Nullable<BaseTexture>;
  21877. /**
  21878. * Specifies the metallic scalar of the metallic/roughness workflow.
  21879. * Can also be used to scale the metalness values of the metallic texture.
  21880. */
  21881. protected _metallic: Nullable<number>;
  21882. /**
  21883. * Specifies the roughness scalar of the metallic/roughness workflow.
  21884. * Can also be used to scale the roughness values of the metallic texture.
  21885. */
  21886. protected _roughness: Nullable<number>;
  21887. /**
  21888. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21889. * By default the indexOfrefraction is used to compute F0;
  21890. *
  21891. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21892. *
  21893. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21894. * F90 = metallicReflectanceColor;
  21895. */
  21896. protected _metallicF0Factor: number;
  21897. /**
  21898. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21899. * By default the F90 is always 1;
  21900. *
  21901. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21902. *
  21903. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21904. * F90 = metallicReflectanceColor;
  21905. */
  21906. protected _metallicReflectanceColor: Color3;
  21907. /**
  21908. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21909. * This is multiply against the scalar values defined in the material.
  21910. */
  21911. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21912. /**
  21913. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21914. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21915. */
  21916. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21917. /**
  21918. * Stores surface normal data used to displace a mesh in a texture.
  21919. */
  21920. protected _bumpTexture: Nullable<BaseTexture>;
  21921. /**
  21922. * Stores the pre-calculated light information of a mesh in a texture.
  21923. */
  21924. protected _lightmapTexture: Nullable<BaseTexture>;
  21925. /**
  21926. * The color of a material in ambient lighting.
  21927. */
  21928. protected _ambientColor: Color3;
  21929. /**
  21930. * AKA Diffuse Color in other nomenclature.
  21931. */
  21932. protected _albedoColor: Color3;
  21933. /**
  21934. * AKA Specular Color in other nomenclature.
  21935. */
  21936. protected _reflectivityColor: Color3;
  21937. /**
  21938. * The color applied when light is reflected from a material.
  21939. */
  21940. protected _reflectionColor: Color3;
  21941. /**
  21942. * The color applied when light is emitted from a material.
  21943. */
  21944. protected _emissiveColor: Color3;
  21945. /**
  21946. * AKA Glossiness in other nomenclature.
  21947. */
  21948. protected _microSurface: number;
  21949. /**
  21950. * Specifies that the material will use the light map as a show map.
  21951. */
  21952. protected _useLightmapAsShadowmap: boolean;
  21953. /**
  21954. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21955. * makes the reflect vector face the model (under horizon).
  21956. */
  21957. protected _useHorizonOcclusion: boolean;
  21958. /**
  21959. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21960. * too much the area relying on ambient texture to define their ambient occlusion.
  21961. */
  21962. protected _useRadianceOcclusion: boolean;
  21963. /**
  21964. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21965. */
  21966. protected _useAlphaFromAlbedoTexture: boolean;
  21967. /**
  21968. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21969. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21970. */
  21971. protected _useSpecularOverAlpha: boolean;
  21972. /**
  21973. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21974. */
  21975. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21976. /**
  21977. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21978. */
  21979. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21980. /**
  21981. * Specifies if the metallic texture contains the roughness information in its green channel.
  21982. */
  21983. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21984. /**
  21985. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21986. */
  21987. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21988. /**
  21989. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21990. */
  21991. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21992. /**
  21993. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21994. */
  21995. protected _useAmbientInGrayScale: boolean;
  21996. /**
  21997. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21998. * The material will try to infer what glossiness each pixel should be.
  21999. */
  22000. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  22001. /**
  22002. * Defines the falloff type used in this material.
  22003. * It by default is Physical.
  22004. */
  22005. protected _lightFalloff: number;
  22006. /**
  22007. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22008. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22009. */
  22010. protected _useRadianceOverAlpha: boolean;
  22011. /**
  22012. * Allows using an object space normal map (instead of tangent space).
  22013. */
  22014. protected _useObjectSpaceNormalMap: boolean;
  22015. /**
  22016. * Allows using the bump map in parallax mode.
  22017. */
  22018. protected _useParallax: boolean;
  22019. /**
  22020. * Allows using the bump map in parallax occlusion mode.
  22021. */
  22022. protected _useParallaxOcclusion: boolean;
  22023. /**
  22024. * Controls the scale bias of the parallax mode.
  22025. */
  22026. protected _parallaxScaleBias: number;
  22027. /**
  22028. * If sets to true, disables all the lights affecting the material.
  22029. */
  22030. protected _disableLighting: boolean;
  22031. /**
  22032. * Number of Simultaneous lights allowed on the material.
  22033. */
  22034. protected _maxSimultaneousLights: number;
  22035. /**
  22036. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  22037. */
  22038. protected _invertNormalMapX: boolean;
  22039. /**
  22040. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  22041. */
  22042. protected _invertNormalMapY: boolean;
  22043. /**
  22044. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22045. */
  22046. protected _twoSidedLighting: boolean;
  22047. /**
  22048. * Defines the alpha limits in alpha test mode.
  22049. */
  22050. protected _alphaCutOff: number;
  22051. /**
  22052. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22053. */
  22054. protected _forceAlphaTest: boolean;
  22055. /**
  22056. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22057. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22058. */
  22059. protected _useAlphaFresnel: boolean;
  22060. /**
  22061. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22062. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22063. */
  22064. protected _useLinearAlphaFresnel: boolean;
  22065. /**
  22066. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  22067. * from cos thetav and roughness:
  22068. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  22069. */
  22070. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  22071. /**
  22072. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22073. */
  22074. protected _forceIrradianceInFragment: boolean;
  22075. private _realTimeFiltering;
  22076. /**
  22077. * Enables realtime filtering on the texture.
  22078. */
  22079. get realTimeFiltering(): boolean;
  22080. set realTimeFiltering(b: boolean);
  22081. private _realTimeFilteringQuality;
  22082. /**
  22083. * Quality switch for realtime filtering
  22084. */
  22085. get realTimeFilteringQuality(): number;
  22086. set realTimeFilteringQuality(n: number);
  22087. /**
  22088. * Can this material render to several textures at once
  22089. */
  22090. get canRenderToMRT(): boolean;
  22091. /**
  22092. * Force normal to face away from face.
  22093. */
  22094. protected _forceNormalForward: boolean;
  22095. /**
  22096. * Enables specular anti aliasing in the PBR shader.
  22097. * It will both interacts on the Geometry for analytical and IBL lighting.
  22098. * It also prefilter the roughness map based on the bump values.
  22099. */
  22100. protected _enableSpecularAntiAliasing: boolean;
  22101. /**
  22102. * Default configuration related to image processing available in the PBR Material.
  22103. */
  22104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22105. /**
  22106. * Keep track of the image processing observer to allow dispose and replace.
  22107. */
  22108. private _imageProcessingObserver;
  22109. /**
  22110. * Attaches a new image processing configuration to the PBR Material.
  22111. * @param configuration
  22112. */
  22113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22114. /**
  22115. * Stores the available render targets.
  22116. */
  22117. private _renderTargets;
  22118. /**
  22119. * Sets the global ambient color for the material used in lighting calculations.
  22120. */
  22121. private _globalAmbientColor;
  22122. /**
  22123. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22124. */
  22125. private _useLogarithmicDepth;
  22126. /**
  22127. * If set to true, no lighting calculations will be applied.
  22128. */
  22129. private _unlit;
  22130. private _debugMode;
  22131. /**
  22132. * @hidden
  22133. * This is reserved for the inspector.
  22134. * Defines the material debug mode.
  22135. * It helps seeing only some components of the material while troubleshooting.
  22136. */
  22137. debugMode: number;
  22138. /**
  22139. * @hidden
  22140. * This is reserved for the inspector.
  22141. * Specify from where on screen the debug mode should start.
  22142. * The value goes from -1 (full screen) to 1 (not visible)
  22143. * It helps with side by side comparison against the final render
  22144. * This defaults to -1
  22145. */
  22146. private debugLimit;
  22147. /**
  22148. * @hidden
  22149. * This is reserved for the inspector.
  22150. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22151. * You can use the factor to better multiply the final value.
  22152. */
  22153. private debugFactor;
  22154. /**
  22155. * Defines the clear coat layer parameters for the material.
  22156. */
  22157. readonly clearCoat: PBRClearCoatConfiguration;
  22158. /**
  22159. * Defines the anisotropic parameters for the material.
  22160. */
  22161. readonly anisotropy: PBRAnisotropicConfiguration;
  22162. /**
  22163. * Defines the BRDF parameters for the material.
  22164. */
  22165. readonly brdf: PBRBRDFConfiguration;
  22166. /**
  22167. * Defines the Sheen parameters for the material.
  22168. */
  22169. readonly sheen: PBRSheenConfiguration;
  22170. /**
  22171. * Defines the SubSurface parameters for the material.
  22172. */
  22173. readonly subSurface: PBRSubSurfaceConfiguration;
  22174. /**
  22175. * Defines additionnal PrePass parameters for the material.
  22176. */
  22177. readonly prePassConfiguration: PrePassConfiguration;
  22178. /**
  22179. * Defines the detail map parameters for the material.
  22180. */
  22181. readonly detailMap: DetailMapConfiguration;
  22182. protected _rebuildInParallel: boolean;
  22183. /**
  22184. * Instantiates a new PBRMaterial instance.
  22185. *
  22186. * @param name The material name
  22187. * @param scene The scene the material will be use in.
  22188. */
  22189. constructor(name: string, scene: Scene);
  22190. /**
  22191. * Gets a boolean indicating that current material needs to register RTT
  22192. */
  22193. get hasRenderTargetTextures(): boolean;
  22194. /**
  22195. * Gets the name of the material class.
  22196. */
  22197. getClassName(): string;
  22198. /**
  22199. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22200. */
  22201. get useLogarithmicDepth(): boolean;
  22202. /**
  22203. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22204. */
  22205. set useLogarithmicDepth(value: boolean);
  22206. /**
  22207. * Returns true if alpha blending should be disabled.
  22208. */
  22209. protected get _disableAlphaBlending(): boolean;
  22210. /**
  22211. * Specifies whether or not this material should be rendered in alpha blend mode.
  22212. */
  22213. needAlphaBlending(): boolean;
  22214. /**
  22215. * Specifies whether or not this material should be rendered in alpha test mode.
  22216. */
  22217. needAlphaTesting(): boolean;
  22218. /**
  22219. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22220. */
  22221. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22222. /**
  22223. * Specifies whether or not there is a usable alpha channel for transparency.
  22224. */
  22225. protected _hasAlphaChannel(): boolean;
  22226. /**
  22227. * Gets the texture used for the alpha test.
  22228. */
  22229. getAlphaTestTexture(): Nullable<BaseTexture>;
  22230. /**
  22231. * Specifies that the submesh is ready to be used.
  22232. * @param mesh - BJS mesh.
  22233. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22234. * @param useInstances - Specifies that instances should be used.
  22235. * @returns - boolean indicating that the submesh is ready or not.
  22236. */
  22237. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22238. /**
  22239. * Specifies if the material uses metallic roughness workflow.
  22240. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22241. */
  22242. isMetallicWorkflow(): boolean;
  22243. private _prepareEffect;
  22244. private _prepareDefines;
  22245. /**
  22246. * Force shader compilation
  22247. */
  22248. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22249. /**
  22250. * Initializes the uniform buffer layout for the shader.
  22251. */
  22252. buildUniformLayout(): void;
  22253. /**
  22254. * Unbinds the material from the mesh
  22255. */
  22256. unbind(): void;
  22257. /**
  22258. * Binds the submesh data.
  22259. * @param world - The world matrix.
  22260. * @param mesh - The BJS mesh.
  22261. * @param subMesh - A submesh of the BJS mesh.
  22262. */
  22263. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22264. /**
  22265. * Returns the animatable textures.
  22266. * @returns - Array of animatable textures.
  22267. */
  22268. getAnimatables(): IAnimatable[];
  22269. /**
  22270. * Returns the texture used for reflections.
  22271. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22272. */
  22273. private _getReflectionTexture;
  22274. /**
  22275. * Returns an array of the actively used textures.
  22276. * @returns - Array of BaseTextures
  22277. */
  22278. getActiveTextures(): BaseTexture[];
  22279. /**
  22280. * Checks to see if a texture is used in the material.
  22281. * @param texture - Base texture to use.
  22282. * @returns - Boolean specifying if a texture is used in the material.
  22283. */
  22284. hasTexture(texture: BaseTexture): boolean;
  22285. /**
  22286. * Sets the required values to the prepass renderer.
  22287. * @param prePassRenderer defines the prepass renderer to setup
  22288. */
  22289. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22290. /**
  22291. * Disposes the resources of the material.
  22292. * @param forceDisposeEffect - Forces the disposal of effects.
  22293. * @param forceDisposeTextures - Forces the disposal of all textures.
  22294. */
  22295. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22296. }
  22297. }
  22298. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  22299. import { Nullable } from "babylonjs/types";
  22300. import { Scene } from "babylonjs/scene";
  22301. import { Color3 } from "babylonjs/Maths/math.color";
  22302. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  22303. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  22304. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22305. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  22306. /**
  22307. * The Physically based material of BJS.
  22308. *
  22309. * This offers the main features of a standard PBR material.
  22310. * For more information, please refer to the documentation :
  22311. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22312. */
  22313. export class PBRMaterial extends PBRBaseMaterial {
  22314. /**
  22315. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22316. */
  22317. static readonly PBRMATERIAL_OPAQUE: number;
  22318. /**
  22319. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22320. */
  22321. static readonly PBRMATERIAL_ALPHATEST: number;
  22322. /**
  22323. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22324. */
  22325. static readonly PBRMATERIAL_ALPHABLEND: number;
  22326. /**
  22327. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22328. * They are also discarded below the alpha cutoff threshold to improve performances.
  22329. */
  22330. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22331. /**
  22332. * Defines the default value of how much AO map is occluding the analytical lights
  22333. * (point spot...).
  22334. */
  22335. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22336. /**
  22337. * Intensity of the direct lights e.g. the four lights available in your scene.
  22338. * This impacts both the direct diffuse and specular highlights.
  22339. */
  22340. directIntensity: number;
  22341. /**
  22342. * Intensity of the emissive part of the material.
  22343. * This helps controlling the emissive effect without modifying the emissive color.
  22344. */
  22345. emissiveIntensity: number;
  22346. /**
  22347. * Intensity of the environment e.g. how much the environment will light the object
  22348. * either through harmonics for rough material or through the refelction for shiny ones.
  22349. */
  22350. environmentIntensity: number;
  22351. /**
  22352. * This is a special control allowing the reduction of the specular highlights coming from the
  22353. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22354. */
  22355. specularIntensity: number;
  22356. /**
  22357. * Debug Control allowing disabling the bump map on this material.
  22358. */
  22359. disableBumpMap: boolean;
  22360. /**
  22361. * AKA Diffuse Texture in standard nomenclature.
  22362. */
  22363. albedoTexture: BaseTexture;
  22364. /**
  22365. * AKA Occlusion Texture in other nomenclature.
  22366. */
  22367. ambientTexture: BaseTexture;
  22368. /**
  22369. * AKA Occlusion Texture Intensity in other nomenclature.
  22370. */
  22371. ambientTextureStrength: number;
  22372. /**
  22373. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22374. * 1 means it completely occludes it
  22375. * 0 mean it has no impact
  22376. */
  22377. ambientTextureImpactOnAnalyticalLights: number;
  22378. /**
  22379. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22380. */
  22381. opacityTexture: BaseTexture;
  22382. /**
  22383. * Stores the reflection values in a texture.
  22384. */
  22385. reflectionTexture: Nullable<BaseTexture>;
  22386. /**
  22387. * Stores the emissive values in a texture.
  22388. */
  22389. emissiveTexture: BaseTexture;
  22390. /**
  22391. * AKA Specular texture in other nomenclature.
  22392. */
  22393. reflectivityTexture: BaseTexture;
  22394. /**
  22395. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22396. */
  22397. metallicTexture: BaseTexture;
  22398. /**
  22399. * Specifies the metallic scalar of the metallic/roughness workflow.
  22400. * Can also be used to scale the metalness values of the metallic texture.
  22401. */
  22402. metallic: Nullable<number>;
  22403. /**
  22404. * Specifies the roughness scalar of the metallic/roughness workflow.
  22405. * Can also be used to scale the roughness values of the metallic texture.
  22406. */
  22407. roughness: Nullable<number>;
  22408. /**
  22409. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22410. * By default the indexOfrefraction is used to compute F0;
  22411. *
  22412. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22413. *
  22414. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22415. * F90 = metallicReflectanceColor;
  22416. */
  22417. metallicF0Factor: number;
  22418. /**
  22419. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22420. * By default the F90 is always 1;
  22421. *
  22422. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22423. *
  22424. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22425. * F90 = metallicReflectanceColor;
  22426. */
  22427. metallicReflectanceColor: Color3;
  22428. /**
  22429. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22430. * This is multiply against the scalar values defined in the material.
  22431. */
  22432. metallicReflectanceTexture: Nullable<BaseTexture>;
  22433. /**
  22434. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22435. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22436. */
  22437. microSurfaceTexture: BaseTexture;
  22438. /**
  22439. * Stores surface normal data used to displace a mesh in a texture.
  22440. */
  22441. bumpTexture: BaseTexture;
  22442. /**
  22443. * Stores the pre-calculated light information of a mesh in a texture.
  22444. */
  22445. lightmapTexture: BaseTexture;
  22446. /**
  22447. * Stores the refracted light information in a texture.
  22448. */
  22449. get refractionTexture(): Nullable<BaseTexture>;
  22450. set refractionTexture(value: Nullable<BaseTexture>);
  22451. /**
  22452. * The color of a material in ambient lighting.
  22453. */
  22454. ambientColor: Color3;
  22455. /**
  22456. * AKA Diffuse Color in other nomenclature.
  22457. */
  22458. albedoColor: Color3;
  22459. /**
  22460. * AKA Specular Color in other nomenclature.
  22461. */
  22462. reflectivityColor: Color3;
  22463. /**
  22464. * The color reflected from the material.
  22465. */
  22466. reflectionColor: Color3;
  22467. /**
  22468. * The color emitted from the material.
  22469. */
  22470. emissiveColor: Color3;
  22471. /**
  22472. * AKA Glossiness in other nomenclature.
  22473. */
  22474. microSurface: number;
  22475. /**
  22476. * Index of refraction of the material base layer.
  22477. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22478. *
  22479. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22480. *
  22481. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22482. */
  22483. get indexOfRefraction(): number;
  22484. set indexOfRefraction(value: number);
  22485. /**
  22486. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22487. */
  22488. get invertRefractionY(): boolean;
  22489. set invertRefractionY(value: boolean);
  22490. /**
  22491. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22492. * Materials half opaque for instance using refraction could benefit from this control.
  22493. */
  22494. get linkRefractionWithTransparency(): boolean;
  22495. set linkRefractionWithTransparency(value: boolean);
  22496. /**
  22497. * If true, the light map contains occlusion information instead of lighting info.
  22498. */
  22499. useLightmapAsShadowmap: boolean;
  22500. /**
  22501. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22502. */
  22503. useAlphaFromAlbedoTexture: boolean;
  22504. /**
  22505. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22506. */
  22507. forceAlphaTest: boolean;
  22508. /**
  22509. * Defines the alpha limits in alpha test mode.
  22510. */
  22511. alphaCutOff: number;
  22512. /**
  22513. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22514. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22515. */
  22516. useSpecularOverAlpha: boolean;
  22517. /**
  22518. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22519. */
  22520. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22521. /**
  22522. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22523. */
  22524. useRoughnessFromMetallicTextureAlpha: boolean;
  22525. /**
  22526. * Specifies if the metallic texture contains the roughness information in its green channel.
  22527. */
  22528. useRoughnessFromMetallicTextureGreen: boolean;
  22529. /**
  22530. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22531. */
  22532. useMetallnessFromMetallicTextureBlue: boolean;
  22533. /**
  22534. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22535. */
  22536. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22537. /**
  22538. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22539. */
  22540. useAmbientInGrayScale: boolean;
  22541. /**
  22542. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22543. * The material will try to infer what glossiness each pixel should be.
  22544. */
  22545. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22546. /**
  22547. * BJS is using an harcoded light falloff based on a manually sets up range.
  22548. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22549. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22550. */
  22551. get usePhysicalLightFalloff(): boolean;
  22552. /**
  22553. * BJS is using an harcoded light falloff based on a manually sets up range.
  22554. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22555. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22556. */
  22557. set usePhysicalLightFalloff(value: boolean);
  22558. /**
  22559. * In order to support the falloff compatibility with gltf, a special mode has been added
  22560. * to reproduce the gltf light falloff.
  22561. */
  22562. get useGLTFLightFalloff(): boolean;
  22563. /**
  22564. * In order to support the falloff compatibility with gltf, a special mode has been added
  22565. * to reproduce the gltf light falloff.
  22566. */
  22567. set useGLTFLightFalloff(value: boolean);
  22568. /**
  22569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22571. */
  22572. useRadianceOverAlpha: boolean;
  22573. /**
  22574. * Allows using an object space normal map (instead of tangent space).
  22575. */
  22576. useObjectSpaceNormalMap: boolean;
  22577. /**
  22578. * Allows using the bump map in parallax mode.
  22579. */
  22580. useParallax: boolean;
  22581. /**
  22582. * Allows using the bump map in parallax occlusion mode.
  22583. */
  22584. useParallaxOcclusion: boolean;
  22585. /**
  22586. * Controls the scale bias of the parallax mode.
  22587. */
  22588. parallaxScaleBias: number;
  22589. /**
  22590. * If sets to true, disables all the lights affecting the material.
  22591. */
  22592. disableLighting: boolean;
  22593. /**
  22594. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22595. */
  22596. forceIrradianceInFragment: boolean;
  22597. /**
  22598. * Number of Simultaneous lights allowed on the material.
  22599. */
  22600. maxSimultaneousLights: number;
  22601. /**
  22602. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22603. */
  22604. invertNormalMapX: boolean;
  22605. /**
  22606. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22607. */
  22608. invertNormalMapY: boolean;
  22609. /**
  22610. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22611. */
  22612. twoSidedLighting: boolean;
  22613. /**
  22614. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22615. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22616. */
  22617. useAlphaFresnel: boolean;
  22618. /**
  22619. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22620. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22621. */
  22622. useLinearAlphaFresnel: boolean;
  22623. /**
  22624. * Let user defines the brdf lookup texture used for IBL.
  22625. * A default 8bit version is embedded but you could point at :
  22626. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22627. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22628. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22629. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22630. */
  22631. environmentBRDFTexture: Nullable<BaseTexture>;
  22632. /**
  22633. * Force normal to face away from face.
  22634. */
  22635. forceNormalForward: boolean;
  22636. /**
  22637. * Enables specular anti aliasing in the PBR shader.
  22638. * It will both interacts on the Geometry for analytical and IBL lighting.
  22639. * It also prefilter the roughness map based on the bump values.
  22640. */
  22641. enableSpecularAntiAliasing: boolean;
  22642. /**
  22643. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22644. * makes the reflect vector face the model (under horizon).
  22645. */
  22646. useHorizonOcclusion: boolean;
  22647. /**
  22648. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22649. * too much the area relying on ambient texture to define their ambient occlusion.
  22650. */
  22651. useRadianceOcclusion: boolean;
  22652. /**
  22653. * If set to true, no lighting calculations will be applied.
  22654. */
  22655. unlit: boolean;
  22656. /**
  22657. * Gets the image processing configuration used either in this material.
  22658. */
  22659. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22660. /**
  22661. * Sets the Default image processing configuration used either in the this material.
  22662. *
  22663. * If sets to null, the scene one is in use.
  22664. */
  22665. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22666. /**
  22667. * Gets wether the color curves effect is enabled.
  22668. */
  22669. get cameraColorCurvesEnabled(): boolean;
  22670. /**
  22671. * Sets wether the color curves effect is enabled.
  22672. */
  22673. set cameraColorCurvesEnabled(value: boolean);
  22674. /**
  22675. * Gets wether the color grading effect is enabled.
  22676. */
  22677. get cameraColorGradingEnabled(): boolean;
  22678. /**
  22679. * Gets wether the color grading effect is enabled.
  22680. */
  22681. set cameraColorGradingEnabled(value: boolean);
  22682. /**
  22683. * Gets wether tonemapping is enabled or not.
  22684. */
  22685. get cameraToneMappingEnabled(): boolean;
  22686. /**
  22687. * Sets wether tonemapping is enabled or not
  22688. */
  22689. set cameraToneMappingEnabled(value: boolean);
  22690. /**
  22691. * The camera exposure used on this material.
  22692. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22693. * This corresponds to a photographic exposure.
  22694. */
  22695. get cameraExposure(): number;
  22696. /**
  22697. * The camera exposure used on this material.
  22698. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22699. * This corresponds to a photographic exposure.
  22700. */
  22701. set cameraExposure(value: number);
  22702. /**
  22703. * Gets The camera contrast used on this material.
  22704. */
  22705. get cameraContrast(): number;
  22706. /**
  22707. * Sets The camera contrast used on this material.
  22708. */
  22709. set cameraContrast(value: number);
  22710. /**
  22711. * Gets the Color Grading 2D Lookup Texture.
  22712. */
  22713. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22714. /**
  22715. * Sets the Color Grading 2D Lookup Texture.
  22716. */
  22717. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22718. /**
  22719. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22720. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22721. * 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;
  22722. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22723. */
  22724. get cameraColorCurves(): Nullable<ColorCurves>;
  22725. /**
  22726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22728. * 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;
  22729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22730. */
  22731. set cameraColorCurves(value: Nullable<ColorCurves>);
  22732. /**
  22733. * Instantiates a new PBRMaterial instance.
  22734. *
  22735. * @param name The material name
  22736. * @param scene The scene the material will be use in.
  22737. */
  22738. constructor(name: string, scene: Scene);
  22739. /**
  22740. * Returns the name of this material class.
  22741. */
  22742. getClassName(): string;
  22743. /**
  22744. * Makes a duplicate of the current material.
  22745. * @param name - name to use for the new material.
  22746. */
  22747. clone(name: string): PBRMaterial;
  22748. /**
  22749. * Serializes this PBR Material.
  22750. * @returns - An object with the serialized material.
  22751. */
  22752. serialize(): any;
  22753. /**
  22754. * Parses a PBR Material from a serialized object.
  22755. * @param source - Serialized object.
  22756. * @param scene - BJS scene instance.
  22757. * @param rootUrl - url for the scene object
  22758. * @returns - PBRMaterial
  22759. */
  22760. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22761. }
  22762. }
  22763. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  22764. /** @hidden */
  22765. export var mrtFragmentDeclaration: {
  22766. name: string;
  22767. shader: string;
  22768. };
  22769. }
  22770. declare module "babylonjs/Shaders/geometry.fragment" {
  22771. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  22772. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  22773. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  22774. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  22775. /** @hidden */
  22776. export var geometryPixelShader: {
  22777. name: string;
  22778. shader: string;
  22779. };
  22780. }
  22781. declare module "babylonjs/Shaders/geometry.vertex" {
  22782. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  22783. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  22784. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  22785. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  22786. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  22787. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  22788. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  22789. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  22790. /** @hidden */
  22791. export var geometryVertexShader: {
  22792. name: string;
  22793. shader: string;
  22794. };
  22795. }
  22796. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  22797. import { Matrix } from "babylonjs/Maths/math.vector";
  22798. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22799. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22800. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  22801. import { Effect } from "babylonjs/Materials/effect";
  22802. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  22803. import { Scene } from "babylonjs/scene";
  22804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22805. import { Nullable } from "babylonjs/types";
  22806. import "babylonjs/Shaders/geometry.fragment";
  22807. import "babylonjs/Shaders/geometry.vertex";
  22808. /** @hidden */
  22809. interface ISavedTransformationMatrix {
  22810. world: Matrix;
  22811. viewProjection: Matrix;
  22812. }
  22813. /**
  22814. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22815. */
  22816. export class GeometryBufferRenderer {
  22817. /**
  22818. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22819. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22820. */
  22821. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22822. /**
  22823. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22824. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22825. */
  22826. static readonly POSITION_TEXTURE_TYPE: number;
  22827. /**
  22828. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22829. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22830. */
  22831. static readonly VELOCITY_TEXTURE_TYPE: number;
  22832. /**
  22833. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22834. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22835. */
  22836. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22837. /**
  22838. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22839. * in order to compute objects velocities when enableVelocity is set to "true"
  22840. * @hidden
  22841. */
  22842. _previousTransformationMatrices: {
  22843. [index: number]: ISavedTransformationMatrix;
  22844. };
  22845. /**
  22846. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22847. * in order to compute objects velocities when enableVelocity is set to "true"
  22848. * @hidden
  22849. */
  22850. _previousBonesTransformationMatrices: {
  22851. [index: number]: Float32Array;
  22852. };
  22853. /**
  22854. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22855. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22856. */
  22857. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22858. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22859. renderTransparentMeshes: boolean;
  22860. private _scene;
  22861. private _resizeObserver;
  22862. private _multiRenderTarget;
  22863. private _ratio;
  22864. private _enablePosition;
  22865. private _enableVelocity;
  22866. private _enableReflectivity;
  22867. private _positionIndex;
  22868. private _velocityIndex;
  22869. private _reflectivityIndex;
  22870. private _depthNormalIndex;
  22871. private _linkedWithPrePass;
  22872. private _prePassRenderer;
  22873. private _attachments;
  22874. protected _effect: Effect;
  22875. protected _cachedDefines: string;
  22876. /**
  22877. * @hidden
  22878. * Sets up internal structures to share outputs with PrePassRenderer
  22879. * This method should only be called by the PrePassRenderer itself
  22880. */
  22881. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22882. /**
  22883. * @hidden
  22884. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22885. * This method should only be called by the PrePassRenderer itself
  22886. */
  22887. _unlinkPrePassRenderer(): void;
  22888. /**
  22889. * @hidden
  22890. * Resets the geometry buffer layout
  22891. */
  22892. _resetLayout(): void;
  22893. /**
  22894. * @hidden
  22895. * Replaces a texture in the geometry buffer renderer
  22896. * Useful when linking textures of the prepass renderer
  22897. */
  22898. _forceTextureType(geometryBufferType: number, index: number): void;
  22899. /**
  22900. * @hidden
  22901. * Sets texture attachments
  22902. * Useful when linking textures of the prepass renderer
  22903. */
  22904. _setAttachments(attachments: number[]): void;
  22905. /**
  22906. * @hidden
  22907. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22908. * Useful when linking textures of the prepass renderer
  22909. */
  22910. _linkInternalTexture(internalTexture: InternalTexture): void;
  22911. /**
  22912. * Gets the render list (meshes to be rendered) used in the G buffer.
  22913. */
  22914. get renderList(): Nullable<AbstractMesh[]>;
  22915. /**
  22916. * Set the render list (meshes to be rendered) used in the G buffer.
  22917. */
  22918. set renderList(meshes: Nullable<AbstractMesh[]>);
  22919. /**
  22920. * Gets wether or not G buffer are supported by the running hardware.
  22921. * This requires draw buffer supports
  22922. */
  22923. get isSupported(): boolean;
  22924. /**
  22925. * Returns the index of the given texture type in the G-Buffer textures array
  22926. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22927. * @returns the index of the given texture type in the G-Buffer textures array
  22928. */
  22929. getTextureIndex(textureType: number): number;
  22930. /**
  22931. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22932. */
  22933. get enablePosition(): boolean;
  22934. /**
  22935. * Sets whether or not objects positions are enabled for the G buffer.
  22936. */
  22937. set enablePosition(enable: boolean);
  22938. /**
  22939. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22940. */
  22941. get enableVelocity(): boolean;
  22942. /**
  22943. * Sets wether or not objects velocities are enabled for the G buffer.
  22944. */
  22945. set enableVelocity(enable: boolean);
  22946. /**
  22947. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22948. */
  22949. get enableReflectivity(): boolean;
  22950. /**
  22951. * Sets wether or not objects roughness are enabled for the G buffer.
  22952. */
  22953. set enableReflectivity(enable: boolean);
  22954. /**
  22955. * Gets the scene associated with the buffer.
  22956. */
  22957. get scene(): Scene;
  22958. /**
  22959. * Gets the ratio used by the buffer during its creation.
  22960. * How big is the buffer related to the main canvas.
  22961. */
  22962. get ratio(): number;
  22963. /** @hidden */
  22964. static _SceneComponentInitialization: (scene: Scene) => void;
  22965. /**
  22966. * Creates a new G Buffer for the scene
  22967. * @param scene The scene the buffer belongs to
  22968. * @param ratio How big is the buffer related to the main canvas.
  22969. */
  22970. constructor(scene: Scene, ratio?: number);
  22971. /**
  22972. * Checks wether everything is ready to render a submesh to the G buffer.
  22973. * @param subMesh the submesh to check readiness for
  22974. * @param useInstances is the mesh drawn using instance or not
  22975. * @returns true if ready otherwise false
  22976. */
  22977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22978. /**
  22979. * Gets the current underlying G Buffer.
  22980. * @returns the buffer
  22981. */
  22982. getGBuffer(): MultiRenderTarget;
  22983. /**
  22984. * Gets the number of samples used to render the buffer (anti aliasing).
  22985. */
  22986. get samples(): number;
  22987. /**
  22988. * Sets the number of samples used to render the buffer (anti aliasing).
  22989. */
  22990. set samples(value: number);
  22991. /**
  22992. * Disposes the renderer and frees up associated resources.
  22993. */
  22994. dispose(): void;
  22995. private _assignRenderTargetIndices;
  22996. protected _createRenderTargets(): void;
  22997. private _copyBonesTransformationMatrices;
  22998. }
  22999. }
  23000. declare module "babylonjs/Rendering/prePassRenderer" {
  23001. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  23002. import { Scene } from "babylonjs/scene";
  23003. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  23004. import { Effect } from "babylonjs/Materials/effect";
  23005. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23007. import { Material } from "babylonjs/Materials/material";
  23008. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23009. /**
  23010. * Renders a pre pass of the scene
  23011. * This means every mesh in the scene will be rendered to a render target texture
  23012. * And then this texture will be composited to the rendering canvas with post processes
  23013. * It is necessary for effects like subsurface scattering or deferred shading
  23014. */
  23015. export class PrePassRenderer {
  23016. /** @hidden */
  23017. static _SceneComponentInitialization: (scene: Scene) => void;
  23018. private _textureFormats;
  23019. /**
  23020. * To save performance, we can excluded skinned meshes from the prepass
  23021. */
  23022. excludedSkinnedMesh: AbstractMesh[];
  23023. /**
  23024. * Force material to be excluded from the prepass
  23025. * Can be useful when `useGeometryBufferFallback` is set to `true`
  23026. * and you don't want a material to show in the effect.
  23027. */
  23028. excludedMaterials: Material[];
  23029. private _textureIndices;
  23030. private _scene;
  23031. private _engine;
  23032. private _isDirty;
  23033. /**
  23034. * Number of textures in the multi render target texture where the scene is directly rendered
  23035. */
  23036. mrtCount: number;
  23037. /**
  23038. * The render target where the scene is directly rendered
  23039. */
  23040. prePassRT: MultiRenderTarget;
  23041. private _multiRenderAttachments;
  23042. private _defaultAttachments;
  23043. private _clearAttachments;
  23044. private _postProcesses;
  23045. private readonly _clearColor;
  23046. /**
  23047. * Image processing post process for composition
  23048. */
  23049. imageProcessingPostProcess: ImageProcessingPostProcess;
  23050. /**
  23051. * Configuration for prepass effects
  23052. */
  23053. private _effectConfigurations;
  23054. private _mrtFormats;
  23055. private _mrtLayout;
  23056. private _enabled;
  23057. /**
  23058. * Indicates if the prepass is enabled
  23059. */
  23060. get enabled(): boolean;
  23061. /**
  23062. * How many samples are used for MSAA of the scene render target
  23063. */
  23064. get samples(): number;
  23065. set samples(n: number);
  23066. private _geometryBuffer;
  23067. private _useGeometryBufferFallback;
  23068. /**
  23069. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  23070. */
  23071. get useGeometryBufferFallback(): boolean;
  23072. set useGeometryBufferFallback(value: boolean);
  23073. /**
  23074. * Set to true to disable gamma transform in PrePass.
  23075. * Can be useful in case you already proceed to gamma transform on a material level
  23076. * and your post processes don't need to be in linear color space.
  23077. */
  23078. disableGammaTransform: boolean;
  23079. /**
  23080. * Instanciates a prepass renderer
  23081. * @param scene The scene
  23082. */
  23083. constructor(scene: Scene);
  23084. private _initializeAttachments;
  23085. private _createCompositionEffect;
  23086. /**
  23087. * Indicates if rendering a prepass is supported
  23088. */
  23089. get isSupported(): boolean;
  23090. /**
  23091. * Sets the proper output textures to draw in the engine.
  23092. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23093. * @param subMesh Submesh on which the effect is applied
  23094. */
  23095. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  23096. /**
  23097. * Restores attachments for single texture draw.
  23098. */
  23099. restoreAttachments(): void;
  23100. /**
  23101. * @hidden
  23102. */
  23103. _beforeCameraDraw(): void;
  23104. /**
  23105. * @hidden
  23106. */
  23107. _afterCameraDraw(): void;
  23108. private _checkRTSize;
  23109. private _bindFrameBuffer;
  23110. /**
  23111. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23112. */
  23113. clear(): void;
  23114. private _setState;
  23115. private _updateGeometryBufferLayout;
  23116. /**
  23117. * Adds an effect configuration to the prepass.
  23118. * If an effect has already been added, it won't add it twice and will return the configuration
  23119. * already present.
  23120. * @param cfg the effect configuration
  23121. * @return the effect configuration now used by the prepass
  23122. */
  23123. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23124. /**
  23125. * Returns the index of a texture in the multi render target texture array.
  23126. * @param type Texture type
  23127. * @return The index
  23128. */
  23129. getIndex(type: number): number;
  23130. private _enable;
  23131. private _disable;
  23132. private _resetLayout;
  23133. private _resetPostProcessChain;
  23134. private _bindPostProcessChain;
  23135. /**
  23136. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23137. */
  23138. markAsDirty(): void;
  23139. /**
  23140. * Enables a texture on the MultiRenderTarget for prepass
  23141. */
  23142. private _enableTextures;
  23143. private _update;
  23144. private _markAllMaterialsAsPrePassDirty;
  23145. /**
  23146. * Disposes the prepass renderer.
  23147. */
  23148. dispose(): void;
  23149. }
  23150. }
  23151. declare module "babylonjs/PostProcesses/postProcess" {
  23152. import { Nullable } from "babylonjs/types";
  23153. import { SmartArray } from "babylonjs/Misc/smartArray";
  23154. import { Observable } from "babylonjs/Misc/observable";
  23155. import { Vector2 } from "babylonjs/Maths/math.vector";
  23156. import { Camera } from "babylonjs/Cameras/camera";
  23157. import { Effect } from "babylonjs/Materials/effect";
  23158. import "babylonjs/Shaders/postprocess.vertex";
  23159. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23160. import { Engine } from "babylonjs/Engines/engine";
  23161. import { Color4 } from "babylonjs/Maths/math.color";
  23162. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23163. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23164. import { Scene } from "babylonjs/scene";
  23165. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23166. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  23167. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  23168. /**
  23169. * Size options for a post process
  23170. */
  23171. export type PostProcessOptions = {
  23172. width: number;
  23173. height: number;
  23174. };
  23175. /**
  23176. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23177. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23178. */
  23179. export class PostProcess {
  23180. /**
  23181. * Gets or sets the unique id of the post process
  23182. */
  23183. uniqueId: number;
  23184. /** Name of the PostProcess. */
  23185. name: string;
  23186. /**
  23187. * Width of the texture to apply the post process on
  23188. */
  23189. width: number;
  23190. /**
  23191. * Height of the texture to apply the post process on
  23192. */
  23193. height: number;
  23194. /**
  23195. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23196. */
  23197. nodeMaterialSource: Nullable<NodeMaterial>;
  23198. /**
  23199. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23200. * @hidden
  23201. */
  23202. _outputTexture: Nullable<InternalTexture>;
  23203. /**
  23204. * Sampling mode used by the shader
  23205. * See https://doc.babylonjs.com/classes/3.1/texture
  23206. */
  23207. renderTargetSamplingMode: number;
  23208. /**
  23209. * Clear color to use when screen clearing
  23210. */
  23211. clearColor: Color4;
  23212. /**
  23213. * If the buffer needs to be cleared before applying the post process. (default: true)
  23214. * Should be set to false if shader will overwrite all previous pixels.
  23215. */
  23216. autoClear: boolean;
  23217. /**
  23218. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23219. */
  23220. alphaMode: number;
  23221. /**
  23222. * Sets the setAlphaBlendConstants of the babylon engine
  23223. */
  23224. alphaConstants: Color4;
  23225. /**
  23226. * Animations to be used for the post processing
  23227. */
  23228. animations: import("babylonjs/Animations/animation").Animation[];
  23229. /**
  23230. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23231. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23232. */
  23233. enablePixelPerfectMode: boolean;
  23234. /**
  23235. * Force the postprocess to be applied without taking in account viewport
  23236. */
  23237. forceFullscreenViewport: boolean;
  23238. /**
  23239. * List of inspectable custom properties (used by the Inspector)
  23240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23241. */
  23242. inspectableCustomProperties: IInspectable[];
  23243. /**
  23244. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23245. *
  23246. * | Value | Type | Description |
  23247. * | ----- | ----------------------------------- | ----------- |
  23248. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23249. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23250. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23251. *
  23252. */
  23253. scaleMode: number;
  23254. /**
  23255. * Force textures to be a power of two (default: false)
  23256. */
  23257. alwaysForcePOT: boolean;
  23258. private _samples;
  23259. /**
  23260. * Number of sample textures (default: 1)
  23261. */
  23262. get samples(): number;
  23263. set samples(n: number);
  23264. /**
  23265. * Modify the scale of the post process to be the same as the viewport (default: false)
  23266. */
  23267. adaptScaleToCurrentViewport: boolean;
  23268. private _camera;
  23269. protected _scene: Scene;
  23270. private _engine;
  23271. private _options;
  23272. private _reusable;
  23273. private _textureType;
  23274. private _textureFormat;
  23275. /**
  23276. * Smart array of input and output textures for the post process.
  23277. * @hidden
  23278. */
  23279. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23280. /**
  23281. * The index in _textures that corresponds to the output texture.
  23282. * @hidden
  23283. */
  23284. _currentRenderTextureInd: number;
  23285. private _effect;
  23286. private _samplers;
  23287. private _fragmentUrl;
  23288. private _vertexUrl;
  23289. private _parameters;
  23290. private _scaleRatio;
  23291. protected _indexParameters: any;
  23292. private _shareOutputWithPostProcess;
  23293. private _texelSize;
  23294. private _forcedOutputTexture;
  23295. /**
  23296. * Prepass configuration in case this post process needs a texture from prepass
  23297. * @hidden
  23298. */
  23299. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23300. /**
  23301. * Returns the fragment url or shader name used in the post process.
  23302. * @returns the fragment url or name in the shader store.
  23303. */
  23304. getEffectName(): string;
  23305. /**
  23306. * An event triggered when the postprocess is activated.
  23307. */
  23308. onActivateObservable: Observable<Camera>;
  23309. private _onActivateObserver;
  23310. /**
  23311. * A function that is added to the onActivateObservable
  23312. */
  23313. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23314. /**
  23315. * An event triggered when the postprocess changes its size.
  23316. */
  23317. onSizeChangedObservable: Observable<PostProcess>;
  23318. private _onSizeChangedObserver;
  23319. /**
  23320. * A function that is added to the onSizeChangedObservable
  23321. */
  23322. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23323. /**
  23324. * An event triggered when the postprocess applies its effect.
  23325. */
  23326. onApplyObservable: Observable<Effect>;
  23327. private _onApplyObserver;
  23328. /**
  23329. * A function that is added to the onApplyObservable
  23330. */
  23331. set onApply(callback: (effect: Effect) => void);
  23332. /**
  23333. * An event triggered before rendering the postprocess
  23334. */
  23335. onBeforeRenderObservable: Observable<Effect>;
  23336. private _onBeforeRenderObserver;
  23337. /**
  23338. * A function that is added to the onBeforeRenderObservable
  23339. */
  23340. set onBeforeRender(callback: (effect: Effect) => void);
  23341. /**
  23342. * An event triggered after rendering the postprocess
  23343. */
  23344. onAfterRenderObservable: Observable<Effect>;
  23345. private _onAfterRenderObserver;
  23346. /**
  23347. * A function that is added to the onAfterRenderObservable
  23348. */
  23349. set onAfterRender(callback: (efect: Effect) => void);
  23350. /**
  23351. * 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
  23352. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23353. */
  23354. get inputTexture(): InternalTexture;
  23355. set inputTexture(value: InternalTexture);
  23356. /**
  23357. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23358. * the only way to unset it is to use this function to restore its internal state
  23359. */
  23360. restoreDefaultInputTexture(): void;
  23361. /**
  23362. * Gets the camera which post process is applied to.
  23363. * @returns The camera the post process is applied to.
  23364. */
  23365. getCamera(): Camera;
  23366. /**
  23367. * Gets the texel size of the postprocess.
  23368. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23369. */
  23370. get texelSize(): Vector2;
  23371. /**
  23372. * Creates a new instance PostProcess
  23373. * @param name The name of the PostProcess.
  23374. * @param fragmentUrl The url of the fragment shader to be used.
  23375. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23376. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23377. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23378. * @param camera The camera to apply the render pass to.
  23379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23380. * @param engine The engine which the post process will be applied. (default: current engine)
  23381. * @param reusable If the post process can be reused on the same frame. (default: false)
  23382. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23383. * @param textureType Type of textures used when performing the post process. (default: 0)
  23384. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23385. * @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
  23386. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23387. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23388. */
  23389. 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);
  23390. /**
  23391. * Gets a string identifying the name of the class
  23392. * @returns "PostProcess" string
  23393. */
  23394. getClassName(): string;
  23395. /**
  23396. * Gets the engine which this post process belongs to.
  23397. * @returns The engine the post process was enabled with.
  23398. */
  23399. getEngine(): Engine;
  23400. /**
  23401. * The effect that is created when initializing the post process.
  23402. * @returns The created effect corresponding the the postprocess.
  23403. */
  23404. getEffect(): Effect;
  23405. /**
  23406. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23407. * @param postProcess The post process to share the output with.
  23408. * @returns This post process.
  23409. */
  23410. shareOutputWith(postProcess: PostProcess): PostProcess;
  23411. /**
  23412. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23413. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23414. */
  23415. useOwnOutput(): void;
  23416. /**
  23417. * Updates the effect with the current post process compile time values and recompiles the shader.
  23418. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23419. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23420. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23421. * @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
  23422. * @param onCompiled Called when the shader has been compiled.
  23423. * @param onError Called if there is an error when compiling a shader.
  23424. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23425. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23426. */
  23427. 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;
  23428. /**
  23429. * The post process is reusable if it can be used multiple times within one frame.
  23430. * @returns If the post process is reusable
  23431. */
  23432. isReusable(): boolean;
  23433. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23434. markTextureDirty(): void;
  23435. /**
  23436. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23437. * 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.
  23438. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23439. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23440. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23441. * @returns The target texture that was bound to be written to.
  23442. */
  23443. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23444. /**
  23445. * If the post process is supported.
  23446. */
  23447. get isSupported(): boolean;
  23448. /**
  23449. * The aspect ratio of the output texture.
  23450. */
  23451. get aspectRatio(): number;
  23452. /**
  23453. * Get a value indicating if the post-process is ready to be used
  23454. * @returns true if the post-process is ready (shader is compiled)
  23455. */
  23456. isReady(): boolean;
  23457. /**
  23458. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23459. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23460. */
  23461. apply(): Nullable<Effect>;
  23462. private _disposeTextures;
  23463. /**
  23464. * Sets the required values to the prepass renderer.
  23465. * @param prePassRenderer defines the prepass renderer to setup.
  23466. * @returns true if the pre pass is needed.
  23467. */
  23468. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23469. /**
  23470. * Disposes the post process.
  23471. * @param camera The camera to dispose the post process on.
  23472. */
  23473. dispose(camera?: Camera): void;
  23474. /**
  23475. * Serializes the particle system to a JSON object
  23476. * @returns the JSON object
  23477. */
  23478. serialize(): any;
  23479. /**
  23480. * Creates a material from parsed material data
  23481. * @param parsedPostProcess defines parsed post process data
  23482. * @param scene defines the hosting scene
  23483. * @param rootUrl defines the root URL to use to load textures
  23484. * @returns a new post process
  23485. */
  23486. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23487. }
  23488. }
  23489. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23490. /** @hidden */
  23491. export var kernelBlurVaryingDeclaration: {
  23492. name: string;
  23493. shader: string;
  23494. };
  23495. }
  23496. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  23497. /** @hidden */
  23498. export var packingFunctions: {
  23499. name: string;
  23500. shader: string;
  23501. };
  23502. }
  23503. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23504. /** @hidden */
  23505. export var kernelBlurFragment: {
  23506. name: string;
  23507. shader: string;
  23508. };
  23509. }
  23510. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23511. /** @hidden */
  23512. export var kernelBlurFragment2: {
  23513. name: string;
  23514. shader: string;
  23515. };
  23516. }
  23517. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23518. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23519. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23520. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23521. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23522. /** @hidden */
  23523. export var kernelBlurPixelShader: {
  23524. name: string;
  23525. shader: string;
  23526. };
  23527. }
  23528. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23529. /** @hidden */
  23530. export var kernelBlurVertex: {
  23531. name: string;
  23532. shader: string;
  23533. };
  23534. }
  23535. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23536. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23537. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23538. /** @hidden */
  23539. export var kernelBlurVertexShader: {
  23540. name: string;
  23541. shader: string;
  23542. };
  23543. }
  23544. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23545. import { Vector2 } from "babylonjs/Maths/math.vector";
  23546. import { Nullable } from "babylonjs/types";
  23547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23548. import { Camera } from "babylonjs/Cameras/camera";
  23549. import { Effect } from "babylonjs/Materials/effect";
  23550. import { Engine } from "babylonjs/Engines/engine";
  23551. import "babylonjs/Shaders/kernelBlur.fragment";
  23552. import "babylonjs/Shaders/kernelBlur.vertex";
  23553. import { Scene } from "babylonjs/scene";
  23554. /**
  23555. * The Blur Post Process which blurs an image based on a kernel and direction.
  23556. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23557. */
  23558. export class BlurPostProcess extends PostProcess {
  23559. private blockCompilation;
  23560. protected _kernel: number;
  23561. protected _idealKernel: number;
  23562. protected _packedFloat: boolean;
  23563. private _staticDefines;
  23564. /** The direction in which to blur the image. */
  23565. direction: Vector2;
  23566. /**
  23567. * Sets the length in pixels of the blur sample region
  23568. */
  23569. set kernel(v: number);
  23570. /**
  23571. * Gets the length in pixels of the blur sample region
  23572. */
  23573. get kernel(): number;
  23574. /**
  23575. * Sets wether or not the blur needs to unpack/repack floats
  23576. */
  23577. set packedFloat(v: boolean);
  23578. /**
  23579. * Gets wether or not the blur is unpacking/repacking floats
  23580. */
  23581. get packedFloat(): boolean;
  23582. /**
  23583. * Gets a string identifying the name of the class
  23584. * @returns "BlurPostProcess" string
  23585. */
  23586. getClassName(): string;
  23587. /**
  23588. * Creates a new instance BlurPostProcess
  23589. * @param name The name of the effect.
  23590. * @param direction The direction in which to blur the image.
  23591. * @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.
  23592. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23593. * @param camera The camera to apply the render pass to.
  23594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23595. * @param engine The engine which the post process will be applied. (default: current engine)
  23596. * @param reusable If the post process can be reused on the same frame. (default: false)
  23597. * @param textureType Type of textures used when performing the post process. (default: 0)
  23598. * @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)
  23599. */
  23600. 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);
  23601. /**
  23602. * Updates the effect with the current post process compile time values and recompiles the shader.
  23603. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23604. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23605. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23606. * @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
  23607. * @param onCompiled Called when the shader has been compiled.
  23608. * @param onError Called if there is an error when compiling a shader.
  23609. */
  23610. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23611. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23612. /**
  23613. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23614. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23615. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23616. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23617. * The gaps between physical kernels are compensated for in the weighting of the samples
  23618. * @param idealKernel Ideal blur kernel.
  23619. * @return Nearest best kernel.
  23620. */
  23621. protected _nearestBestKernel(idealKernel: number): number;
  23622. /**
  23623. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23624. * @param x The point on the Gaussian distribution to sample.
  23625. * @return the value of the Gaussian function at x.
  23626. */
  23627. protected _gaussianWeight(x: number): number;
  23628. /**
  23629. * Generates a string that can be used as a floating point number in GLSL.
  23630. * @param x Value to print.
  23631. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23632. * @return GLSL float string.
  23633. */
  23634. protected _glslFloat(x: number, decimalFigures?: number): string;
  23635. /** @hidden */
  23636. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23637. }
  23638. }
  23639. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23640. import { Scene } from "babylonjs/scene";
  23641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23642. import { Plane } from "babylonjs/Maths/math.plane";
  23643. /**
  23644. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23645. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23646. * You can then easily use it as a reflectionTexture on a flat surface.
  23647. * In case the surface is not a plane, please consider relying on reflection probes.
  23648. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23649. */
  23650. export class MirrorTexture extends RenderTargetTexture {
  23651. private scene;
  23652. /**
  23653. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23654. * 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.
  23655. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23656. */
  23657. mirrorPlane: Plane;
  23658. /**
  23659. * Define the blur ratio used to blur the reflection if needed.
  23660. */
  23661. set blurRatio(value: number);
  23662. get blurRatio(): number;
  23663. /**
  23664. * Define the adaptive blur kernel used to blur the reflection if needed.
  23665. * This will autocompute the closest best match for the `blurKernel`
  23666. */
  23667. set adaptiveBlurKernel(value: number);
  23668. /**
  23669. * Define the blur kernel used to blur the reflection if needed.
  23670. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23671. */
  23672. set blurKernel(value: number);
  23673. /**
  23674. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23675. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23676. */
  23677. set blurKernelX(value: number);
  23678. get blurKernelX(): number;
  23679. /**
  23680. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23681. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23682. */
  23683. set blurKernelY(value: number);
  23684. get blurKernelY(): number;
  23685. private _autoComputeBlurKernel;
  23686. protected _onRatioRescale(): void;
  23687. private _updateGammaSpace;
  23688. private _imageProcessingConfigChangeObserver;
  23689. private _transformMatrix;
  23690. private _mirrorMatrix;
  23691. private _savedViewMatrix;
  23692. private _blurX;
  23693. private _blurY;
  23694. private _adaptiveBlurKernel;
  23695. private _blurKernelX;
  23696. private _blurKernelY;
  23697. private _blurRatio;
  23698. /**
  23699. * Instantiates a Mirror Texture.
  23700. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23701. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23702. * You can then easily use it as a reflectionTexture on a flat surface.
  23703. * In case the surface is not a plane, please consider relying on reflection probes.
  23704. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23705. * @param name
  23706. * @param size
  23707. * @param scene
  23708. * @param generateMipMaps
  23709. * @param type
  23710. * @param samplingMode
  23711. * @param generateDepthBuffer
  23712. */
  23713. constructor(name: string, size: number | {
  23714. width: number;
  23715. height: number;
  23716. } | {
  23717. ratio: number;
  23718. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23719. private _preparePostProcesses;
  23720. /**
  23721. * Clone the mirror texture.
  23722. * @returns the cloned texture
  23723. */
  23724. clone(): MirrorTexture;
  23725. /**
  23726. * Serialize the texture to a JSON representation you could use in Parse later on
  23727. * @returns the serialized JSON representation
  23728. */
  23729. serialize(): any;
  23730. /**
  23731. * Dispose the texture and release its associated resources.
  23732. */
  23733. dispose(): void;
  23734. }
  23735. }
  23736. declare module "babylonjs/Materials/Textures/texture" {
  23737. import { Observable } from "babylonjs/Misc/observable";
  23738. import { Nullable } from "babylonjs/types";
  23739. import { Matrix } from "babylonjs/Maths/math.vector";
  23740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23741. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23742. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23743. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23744. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23745. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23746. import { Scene } from "babylonjs/scene";
  23747. /**
  23748. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23749. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23750. */
  23751. export class Texture extends BaseTexture {
  23752. /**
  23753. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23754. */
  23755. static SerializeBuffers: boolean;
  23756. /**
  23757. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23758. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23759. */
  23760. static ForceSerializeBuffers: boolean;
  23761. /** @hidden */
  23762. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23763. /** @hidden */
  23764. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23765. /** @hidden */
  23766. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23767. /** nearest is mag = nearest and min = nearest and mip = linear */
  23768. static readonly NEAREST_SAMPLINGMODE: number;
  23769. /** nearest is mag = nearest and min = nearest and mip = linear */
  23770. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23771. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23772. static readonly BILINEAR_SAMPLINGMODE: number;
  23773. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23774. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23775. /** Trilinear is mag = linear and min = linear and mip = linear */
  23776. static readonly TRILINEAR_SAMPLINGMODE: number;
  23777. /** Trilinear is mag = linear and min = linear and mip = linear */
  23778. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23779. /** mag = nearest and min = nearest and mip = nearest */
  23780. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23781. /** mag = nearest and min = linear and mip = nearest */
  23782. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23783. /** mag = nearest and min = linear and mip = linear */
  23784. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23785. /** mag = nearest and min = linear and mip = none */
  23786. static readonly NEAREST_LINEAR: number;
  23787. /** mag = nearest and min = nearest and mip = none */
  23788. static readonly NEAREST_NEAREST: number;
  23789. /** mag = linear and min = nearest and mip = nearest */
  23790. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23791. /** mag = linear and min = nearest and mip = linear */
  23792. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23793. /** mag = linear and min = linear and mip = none */
  23794. static readonly LINEAR_LINEAR: number;
  23795. /** mag = linear and min = nearest and mip = none */
  23796. static readonly LINEAR_NEAREST: number;
  23797. /** Explicit coordinates mode */
  23798. static readonly EXPLICIT_MODE: number;
  23799. /** Spherical coordinates mode */
  23800. static readonly SPHERICAL_MODE: number;
  23801. /** Planar coordinates mode */
  23802. static readonly PLANAR_MODE: number;
  23803. /** Cubic coordinates mode */
  23804. static readonly CUBIC_MODE: number;
  23805. /** Projection coordinates mode */
  23806. static readonly PROJECTION_MODE: number;
  23807. /** Inverse Cubic coordinates mode */
  23808. static readonly SKYBOX_MODE: number;
  23809. /** Inverse Cubic coordinates mode */
  23810. static readonly INVCUBIC_MODE: number;
  23811. /** Equirectangular coordinates mode */
  23812. static readonly EQUIRECTANGULAR_MODE: number;
  23813. /** Equirectangular Fixed coordinates mode */
  23814. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23815. /** Equirectangular Fixed Mirrored coordinates mode */
  23816. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23817. /** Texture is not repeating outside of 0..1 UVs */
  23818. static readonly CLAMP_ADDRESSMODE: number;
  23819. /** Texture is repeating outside of 0..1 UVs */
  23820. static readonly WRAP_ADDRESSMODE: number;
  23821. /** Texture is repeating and mirrored */
  23822. static readonly MIRROR_ADDRESSMODE: number;
  23823. /**
  23824. * 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
  23825. */
  23826. static UseSerializedUrlIfAny: boolean;
  23827. /**
  23828. * Define the url of the texture.
  23829. */
  23830. url: Nullable<string>;
  23831. /**
  23832. * Define an offset on the texture to offset the u coordinates of the UVs
  23833. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23834. */
  23835. uOffset: number;
  23836. /**
  23837. * Define an offset on the texture to offset the v coordinates of the UVs
  23838. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23839. */
  23840. vOffset: number;
  23841. /**
  23842. * Define an offset on the texture to scale the u coordinates of the UVs
  23843. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23844. */
  23845. uScale: number;
  23846. /**
  23847. * Define an offset on the texture to scale the v coordinates of the UVs
  23848. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23849. */
  23850. vScale: number;
  23851. /**
  23852. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23853. * @see https://doc.babylonjs.com/how_to/more_materials
  23854. */
  23855. uAng: number;
  23856. /**
  23857. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23858. * @see https://doc.babylonjs.com/how_to/more_materials
  23859. */
  23860. vAng: number;
  23861. /**
  23862. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23863. * @see https://doc.babylonjs.com/how_to/more_materials
  23864. */
  23865. wAng: number;
  23866. /**
  23867. * Defines the center of rotation (U)
  23868. */
  23869. uRotationCenter: number;
  23870. /**
  23871. * Defines the center of rotation (V)
  23872. */
  23873. vRotationCenter: number;
  23874. /**
  23875. * Defines the center of rotation (W)
  23876. */
  23877. wRotationCenter: number;
  23878. /**
  23879. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23880. */
  23881. homogeneousRotationInUVTransform: boolean;
  23882. /**
  23883. * Are mip maps generated for this texture or not.
  23884. */
  23885. get noMipmap(): boolean;
  23886. /**
  23887. * List of inspectable custom properties (used by the Inspector)
  23888. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23889. */
  23890. inspectableCustomProperties: Nullable<IInspectable[]>;
  23891. private _noMipmap;
  23892. /** @hidden */
  23893. _invertY: boolean;
  23894. private _rowGenerationMatrix;
  23895. private _cachedTextureMatrix;
  23896. private _projectionModeMatrix;
  23897. private _t0;
  23898. private _t1;
  23899. private _t2;
  23900. private _cachedUOffset;
  23901. private _cachedVOffset;
  23902. private _cachedUScale;
  23903. private _cachedVScale;
  23904. private _cachedUAng;
  23905. private _cachedVAng;
  23906. private _cachedWAng;
  23907. private _cachedProjectionMatrixId;
  23908. private _cachedURotationCenter;
  23909. private _cachedVRotationCenter;
  23910. private _cachedWRotationCenter;
  23911. private _cachedHomogeneousRotationInUVTransform;
  23912. private _cachedCoordinatesMode;
  23913. /** @hidden */
  23914. protected _initialSamplingMode: number;
  23915. /** @hidden */
  23916. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23917. private _deleteBuffer;
  23918. protected _format: Nullable<number>;
  23919. private _delayedOnLoad;
  23920. private _delayedOnError;
  23921. private _mimeType?;
  23922. private _loaderOptions?;
  23923. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23924. get mimeType(): string | undefined;
  23925. /**
  23926. * Observable triggered once the texture has been loaded.
  23927. */
  23928. onLoadObservable: Observable<Texture>;
  23929. protected _isBlocking: boolean;
  23930. /**
  23931. * Is the texture preventing material to render while loading.
  23932. * If false, a default texture will be used instead of the loading one during the preparation step.
  23933. */
  23934. set isBlocking(value: boolean);
  23935. get isBlocking(): boolean;
  23936. /**
  23937. * Get the current sampling mode associated with the texture.
  23938. */
  23939. get samplingMode(): number;
  23940. /**
  23941. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23942. */
  23943. get invertY(): boolean;
  23944. /**
  23945. * Instantiates a new texture.
  23946. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23947. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23948. * @param url defines the url of the picture to load as a texture
  23949. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23950. * @param noMipmap defines if the texture will require mip maps or not
  23951. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23952. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23953. * @param onLoad defines a callback triggered when the texture has been loaded
  23954. * @param onError defines a callback triggered when an error occurred during the loading session
  23955. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23956. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23957. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23958. * @param mimeType defines an optional mime type information
  23959. * @param loaderOptions options to be passed to the loader
  23960. */
  23961. 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, loaderOptions?: any);
  23962. /**
  23963. * Update the url (and optional buffer) of this texture if url was null during construction.
  23964. * @param url the url of the texture
  23965. * @param buffer the buffer of the texture (defaults to null)
  23966. * @param onLoad callback called when the texture is loaded (defaults to null)
  23967. */
  23968. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23969. /**
  23970. * Finish the loading sequence of a texture flagged as delayed load.
  23971. * @hidden
  23972. */
  23973. delayLoad(): void;
  23974. private _prepareRowForTextureGeneration;
  23975. /**
  23976. * Checks if the texture has the same transform matrix than another texture
  23977. * @param texture texture to check against
  23978. * @returns true if the transforms are the same, else false
  23979. */
  23980. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23981. /**
  23982. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23983. * @returns the transform matrix of the texture.
  23984. */
  23985. getTextureMatrix(uBase?: number): Matrix;
  23986. /**
  23987. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23988. * @returns The reflection texture transform
  23989. */
  23990. getReflectionTextureMatrix(): Matrix;
  23991. /**
  23992. * Clones the texture.
  23993. * @returns the cloned texture
  23994. */
  23995. clone(): Texture;
  23996. /**
  23997. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23998. * @returns The JSON representation of the texture
  23999. */
  24000. serialize(): any;
  24001. /**
  24002. * Get the current class name of the texture useful for serialization or dynamic coding.
  24003. * @returns "Texture"
  24004. */
  24005. getClassName(): string;
  24006. /**
  24007. * Dispose the texture and release its associated resources.
  24008. */
  24009. dispose(): void;
  24010. /**
  24011. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24012. * @param parsedTexture Define the JSON representation of the texture
  24013. * @param scene Define the scene the parsed texture should be instantiated in
  24014. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24015. * @returns The parsed texture if successful
  24016. */
  24017. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24018. /**
  24019. * Creates a texture from its base 64 representation.
  24020. * @param data Define the base64 payload without the data: prefix
  24021. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24022. * @param scene Define the scene the texture should belong to
  24023. * @param noMipmap Forces the texture to not create mip map information if true
  24024. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24025. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24026. * @param onLoad define a callback triggered when the texture has been loaded
  24027. * @param onError define a callback triggered when an error occurred during the loading session
  24028. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24029. * @returns the created texture
  24030. */
  24031. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24032. /**
  24033. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24034. * @param data Define the base64 payload without the data: prefix
  24035. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24036. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24037. * @param scene Define the scene the texture should belong to
  24038. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24039. * @param noMipmap Forces the texture to not create mip map information if true
  24040. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24041. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24042. * @param onLoad define a callback triggered when the texture has been loaded
  24043. * @param onError define a callback triggered when an error occurred during the loading session
  24044. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24045. * @returns the created texture
  24046. */
  24047. 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;
  24048. }
  24049. }
  24050. declare module "babylonjs/Sprites/thinSprite" {
  24051. import { IVector3Like, IColor4Like } from "babylonjs/Maths/math.like";
  24052. import { Nullable } from "babylonjs/types";
  24053. /**
  24054. * ThinSprite Class used to represent a thin sprite
  24055. * This is the base class for sprites but can also directly be used with ThinEngine
  24056. * @see https://doc.babylonjs.com/babylon101/sprites
  24057. */
  24058. export class ThinSprite {
  24059. /** Gets or sets the cell index in the sprite sheet */
  24060. cellIndex: number;
  24061. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  24062. cellRef: string;
  24063. /** Gets or sets the current world position */
  24064. position: IVector3Like;
  24065. /** Gets or sets the main color */
  24066. color: IColor4Like;
  24067. /** Gets or sets the width */
  24068. width: number;
  24069. /** Gets or sets the height */
  24070. height: number;
  24071. /** Gets or sets rotation angle */
  24072. angle: number;
  24073. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24074. invertU: boolean;
  24075. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  24076. invertV: boolean;
  24077. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  24078. isVisible: boolean;
  24079. /**
  24080. * Returns a boolean indicating if the animation is started
  24081. */
  24082. get animationStarted(): boolean;
  24083. /** Gets the initial key for the animation (setting it will restart the animation) */
  24084. get fromIndex(): number;
  24085. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24086. get toIndex(): number;
  24087. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24088. get loopAnimation(): boolean;
  24089. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24090. get delay(): number;
  24091. /** @hidden */
  24092. _xOffset: number;
  24093. /** @hidden */
  24094. _yOffset: number;
  24095. /** @hidden */
  24096. _xSize: number;
  24097. /** @hidden */
  24098. _ySize: number;
  24099. private _animationStarted;
  24100. protected _loopAnimation: boolean;
  24101. protected _fromIndex: number;
  24102. protected _toIndex: number;
  24103. protected _delay: number;
  24104. private _direction;
  24105. private _time;
  24106. private _onBaseAnimationEnd;
  24107. /**
  24108. * Creates a new Thin Sprite
  24109. */
  24110. constructor();
  24111. /**
  24112. * Starts an animation
  24113. * @param from defines the initial key
  24114. * @param to defines the end key
  24115. * @param loop defines if the animation must loop
  24116. * @param delay defines the start delay (in ms)
  24117. * @param onAnimationEnd defines a callback for when the animation ends
  24118. */
  24119. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  24120. /** Stops current animation (if any) */
  24121. stopAnimation(): void;
  24122. /** @hidden */
  24123. _animate(deltaTime: number): void;
  24124. }
  24125. }
  24126. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  24127. /** @hidden */
  24128. export var imageProcessingCompatibility: {
  24129. name: string;
  24130. shader: string;
  24131. };
  24132. }
  24133. declare module "babylonjs/Shaders/sprites.fragment" {
  24134. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24135. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24136. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  24137. /** @hidden */
  24138. export var spritesPixelShader: {
  24139. name: string;
  24140. shader: string;
  24141. };
  24142. }
  24143. declare module "babylonjs/Shaders/sprites.vertex" {
  24144. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24145. /** @hidden */
  24146. export var spritesVertexShader: {
  24147. name: string;
  24148. shader: string;
  24149. };
  24150. }
  24151. declare module "babylonjs/Sprites/spriteRenderer" {
  24152. import { Nullable } from "babylonjs/types";
  24153. import { IMatrixLike } from "babylonjs/Maths/math.like";
  24154. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24155. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24156. import { ISize } from "babylonjs/Maths/math.size";
  24157. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  24158. import { Scene } from "babylonjs/scene";
  24159. import "babylonjs/Engines/Extensions/engine.alpha";
  24160. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  24161. import "babylonjs/Shaders/sprites.fragment";
  24162. import "babylonjs/Shaders/sprites.vertex";
  24163. /**
  24164. * Class used to render sprites.
  24165. *
  24166. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  24167. */
  24168. export class SpriteRenderer {
  24169. /**
  24170. * Defines the texture of the spritesheet
  24171. */
  24172. texture: Nullable<ThinTexture>;
  24173. /**
  24174. * Defines the default width of a cell in the spritesheet
  24175. */
  24176. cellWidth: number;
  24177. /**
  24178. * Defines the default height of a cell in the spritesheet
  24179. */
  24180. cellHeight: number;
  24181. /**
  24182. * Blend mode use to render the particle, it can be any of
  24183. * the static Constants.ALPHA_x properties provided in this class.
  24184. * Default value is Constants.ALPHA_COMBINE
  24185. */
  24186. blendMode: number;
  24187. /**
  24188. * Gets or sets a boolean indicating if alpha mode is automatically
  24189. * reset.
  24190. */
  24191. autoResetAlpha: boolean;
  24192. /**
  24193. * Disables writing to the depth buffer when rendering the sprites.
  24194. * It can be handy to disable depth writing when using textures without alpha channel
  24195. * and setting some specific blend modes.
  24196. */
  24197. disableDepthWrite: boolean;
  24198. /**
  24199. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24200. */
  24201. fogEnabled: boolean;
  24202. /**
  24203. * Gets the capacity of the manager
  24204. */
  24205. get capacity(): number;
  24206. private readonly _engine;
  24207. private readonly _useVAO;
  24208. private readonly _useInstancing;
  24209. private readonly _scene;
  24210. private readonly _capacity;
  24211. private readonly _epsilon;
  24212. private _vertexBufferSize;
  24213. private _vertexData;
  24214. private _buffer;
  24215. private _vertexBuffers;
  24216. private _spriteBuffer;
  24217. private _indexBuffer;
  24218. private _effectBase;
  24219. private _effectFog;
  24220. private _vertexArrayObject;
  24221. /**
  24222. * Creates a new sprite Renderer
  24223. * @param engine defines the engine the renderer works with
  24224. * @param capacity defines the maximum allowed number of sprites
  24225. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24226. * @param scene defines the hosting scene
  24227. */
  24228. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24229. /**
  24230. * Render all child sprites
  24231. * @param sprites defines the list of sprites to render
  24232. * @param deltaTime defines the time since last frame
  24233. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24234. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24235. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24236. */
  24237. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24238. private _appendSpriteVertex;
  24239. /**
  24240. * Release associated resources
  24241. */
  24242. dispose(): void;
  24243. }
  24244. }
  24245. declare module "babylonjs/Sprites/spriteManager" {
  24246. import { IDisposable, Scene } from "babylonjs/scene";
  24247. import { Nullable } from "babylonjs/types";
  24248. import { Observable } from "babylonjs/Misc/observable";
  24249. import { Sprite } from "babylonjs/Sprites/sprite";
  24250. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24251. import { Camera } from "babylonjs/Cameras/camera";
  24252. import { Texture } from "babylonjs/Materials/Textures/texture";
  24253. import { Ray } from "babylonjs/Culling/ray";
  24254. /**
  24255. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24256. */
  24257. export interface ISpriteManager extends IDisposable {
  24258. /**
  24259. * Gets manager's name
  24260. */
  24261. name: string;
  24262. /**
  24263. * Restricts the camera to viewing objects with the same layerMask.
  24264. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24265. */
  24266. layerMask: number;
  24267. /**
  24268. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24269. */
  24270. isPickable: boolean;
  24271. /**
  24272. * Gets the hosting scene
  24273. */
  24274. scene: Scene;
  24275. /**
  24276. * Specifies the rendering group id for this mesh (0 by default)
  24277. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24278. */
  24279. renderingGroupId: number;
  24280. /**
  24281. * Defines the list of sprites managed by the manager.
  24282. */
  24283. sprites: Array<Sprite>;
  24284. /**
  24285. * Gets or sets the spritesheet texture
  24286. */
  24287. texture: Texture;
  24288. /** Defines the default width of a cell in the spritesheet */
  24289. cellWidth: number;
  24290. /** Defines the default height of a cell in the spritesheet */
  24291. cellHeight: number;
  24292. /**
  24293. * Tests the intersection of a sprite with a specific ray.
  24294. * @param ray The ray we are sending to test the collision
  24295. * @param camera The camera space we are sending rays in
  24296. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24297. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24298. * @returns picking info or null.
  24299. */
  24300. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24301. /**
  24302. * Intersects the sprites with a ray
  24303. * @param ray defines the ray to intersect with
  24304. * @param camera defines the current active camera
  24305. * @param predicate defines a predicate used to select candidate sprites
  24306. * @returns null if no hit or a PickingInfo array
  24307. */
  24308. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24309. /**
  24310. * Renders the list of sprites on screen.
  24311. */
  24312. render(): void;
  24313. }
  24314. /**
  24315. * Class used to manage multiple sprites on the same spritesheet
  24316. * @see https://doc.babylonjs.com/babylon101/sprites
  24317. */
  24318. export class SpriteManager implements ISpriteManager {
  24319. /** defines the manager's name */
  24320. name: string;
  24321. /** Define the Url to load snippets */
  24322. static SnippetUrl: string;
  24323. /** Snippet ID if the manager was created from the snippet server */
  24324. snippetId: string;
  24325. /** Gets the list of sprites */
  24326. sprites: Sprite[];
  24327. /** Gets or sets the rendering group id (0 by default) */
  24328. renderingGroupId: number;
  24329. /** Gets or sets camera layer mask */
  24330. layerMask: number;
  24331. /** Gets or sets a boolean indicating if the sprites are pickable */
  24332. isPickable: boolean;
  24333. /**
  24334. * An event triggered when the manager is disposed.
  24335. */
  24336. onDisposeObservable: Observable<SpriteManager>;
  24337. /**
  24338. * Callback called when the manager is disposed
  24339. */
  24340. set onDispose(callback: () => void);
  24341. /**
  24342. * Gets or sets the unique id of the sprite
  24343. */
  24344. uniqueId: number;
  24345. /**
  24346. * Gets the array of sprites
  24347. */
  24348. get children(): Sprite[];
  24349. /**
  24350. * Gets the hosting scene
  24351. */
  24352. get scene(): Scene;
  24353. /**
  24354. * Gets the capacity of the manager
  24355. */
  24356. get capacity(): number;
  24357. /**
  24358. * Gets or sets the spritesheet texture
  24359. */
  24360. get texture(): Texture;
  24361. set texture(value: Texture);
  24362. /** Defines the default width of a cell in the spritesheet */
  24363. get cellWidth(): number;
  24364. set cellWidth(value: number);
  24365. /** Defines the default height of a cell in the spritesheet */
  24366. get cellHeight(): number;
  24367. set cellHeight(value: number);
  24368. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24369. get fogEnabled(): boolean;
  24370. set fogEnabled(value: boolean);
  24371. /**
  24372. * Blend mode use to render the particle, it can be any of
  24373. * the static Constants.ALPHA_x properties provided in this class.
  24374. * Default value is Constants.ALPHA_COMBINE
  24375. */
  24376. get blendMode(): number;
  24377. set blendMode(blendMode: number);
  24378. /** Disables writing to the depth buffer when rendering the sprites.
  24379. * It can be handy to disable depth writing when using textures without alpha channel
  24380. * and setting some specific blend modes.
  24381. */
  24382. disableDepthWrite: boolean;
  24383. private _spriteRenderer;
  24384. /** Associative array from JSON sprite data file */
  24385. private _cellData;
  24386. /** Array of sprite names from JSON sprite data file */
  24387. private _spriteMap;
  24388. /** True when packed cell data from JSON file is ready*/
  24389. private _packedAndReady;
  24390. private _textureContent;
  24391. private _onDisposeObserver;
  24392. private _fromPacked;
  24393. private _scene;
  24394. /**
  24395. * Creates a new sprite manager
  24396. * @param name defines the manager's name
  24397. * @param imgUrl defines the sprite sheet url
  24398. * @param capacity defines the maximum allowed number of sprites
  24399. * @param cellSize defines the size of a sprite cell
  24400. * @param scene defines the hosting scene
  24401. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24402. * @param samplingMode defines the smapling mode to use with spritesheet
  24403. * @param fromPacked set to false; do not alter
  24404. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24405. */
  24406. constructor(
  24407. /** defines the manager's name */
  24408. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24409. /**
  24410. * Returns the string "SpriteManager"
  24411. * @returns "SpriteManager"
  24412. */
  24413. getClassName(): string;
  24414. private _makePacked;
  24415. private _checkTextureAlpha;
  24416. /**
  24417. * Intersects the sprites with a ray
  24418. * @param ray defines the ray to intersect with
  24419. * @param camera defines the current active camera
  24420. * @param predicate defines a predicate used to select candidate sprites
  24421. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24422. * @returns null if no hit or a PickingInfo
  24423. */
  24424. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24425. /**
  24426. * Intersects the sprites with a ray
  24427. * @param ray defines the ray to intersect with
  24428. * @param camera defines the current active camera
  24429. * @param predicate defines a predicate used to select candidate sprites
  24430. * @returns null if no hit or a PickingInfo array
  24431. */
  24432. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24433. /**
  24434. * Render all child sprites
  24435. */
  24436. render(): void;
  24437. private _customUpdate;
  24438. /**
  24439. * Release associated resources
  24440. */
  24441. dispose(): void;
  24442. /**
  24443. * Serializes the sprite manager to a JSON object
  24444. * @param serializeTexture defines if the texture must be serialized as well
  24445. * @returns the JSON object
  24446. */
  24447. serialize(serializeTexture?: boolean): any;
  24448. /**
  24449. * Parses a JSON object to create a new sprite manager.
  24450. * @param parsedManager The JSON object to parse
  24451. * @param scene The scene to create the sprite managerin
  24452. * @param rootUrl The root url to use to load external dependencies like texture
  24453. * @returns the new sprite manager
  24454. */
  24455. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24456. /**
  24457. * Creates a sprite manager from a snippet saved in a remote file
  24458. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24459. * @param url defines the url to load from
  24460. * @param scene defines the hosting scene
  24461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24462. * @returns a promise that will resolve to the new sprite manager
  24463. */
  24464. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24465. /**
  24466. * Creates a sprite manager from a snippet saved by the sprite editor
  24467. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24468. * @param scene defines the hosting scene
  24469. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24470. * @returns a promise that will resolve to the new sprite manager
  24471. */
  24472. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24473. }
  24474. }
  24475. declare module "babylonjs/Sprites/sprite" {
  24476. import { Vector3 } from "babylonjs/Maths/math.vector";
  24477. import { Nullable } from "babylonjs/types";
  24478. import { ActionManager } from "babylonjs/Actions/actionManager";
  24479. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  24480. import { Color4 } from "babylonjs/Maths/math.color";
  24481. import { Observable } from "babylonjs/Misc/observable";
  24482. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24483. import { ThinSprite } from "babylonjs/Sprites/thinSprite";
  24484. import { Animation } from "babylonjs/Animations/animation";
  24485. /**
  24486. * Class used to represent a sprite
  24487. * @see https://doc.babylonjs.com/babylon101/sprites
  24488. */
  24489. export class Sprite extends ThinSprite implements IAnimatable {
  24490. /** defines the name */
  24491. name: string;
  24492. /** Gets or sets the current world position */
  24493. position: Vector3;
  24494. /** Gets or sets the main color */
  24495. color: Color4;
  24496. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24497. disposeWhenFinishedAnimating: boolean;
  24498. /** Gets the list of attached animations */
  24499. animations: Nullable<Array<Animation>>;
  24500. /** Gets or sets a boolean indicating if the sprite can be picked */
  24501. isPickable: boolean;
  24502. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24503. useAlphaForPicking: boolean;
  24504. /**
  24505. * Gets or sets the associated action manager
  24506. */
  24507. actionManager: Nullable<ActionManager>;
  24508. /**
  24509. * An event triggered when the control has been disposed
  24510. */
  24511. onDisposeObservable: Observable<Sprite>;
  24512. private _manager;
  24513. private _onAnimationEnd;
  24514. /**
  24515. * Gets or sets the sprite size
  24516. */
  24517. get size(): number;
  24518. set size(value: number);
  24519. /**
  24520. * Gets or sets the unique id of the sprite
  24521. */
  24522. uniqueId: number;
  24523. /**
  24524. * Gets the manager of this sprite
  24525. */
  24526. get manager(): ISpriteManager;
  24527. /**
  24528. * Creates a new Sprite
  24529. * @param name defines the name
  24530. * @param manager defines the manager
  24531. */
  24532. constructor(
  24533. /** defines the name */
  24534. name: string, manager: ISpriteManager);
  24535. /**
  24536. * Returns the string "Sprite"
  24537. * @returns "Sprite"
  24538. */
  24539. getClassName(): string;
  24540. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24541. get fromIndex(): number;
  24542. set fromIndex(value: number);
  24543. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24544. get toIndex(): number;
  24545. set toIndex(value: number);
  24546. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24547. get loopAnimation(): boolean;
  24548. set loopAnimation(value: boolean);
  24549. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24550. get delay(): number;
  24551. set delay(value: number);
  24552. /**
  24553. * Starts an animation
  24554. * @param from defines the initial key
  24555. * @param to defines the end key
  24556. * @param loop defines if the animation must loop
  24557. * @param delay defines the start delay (in ms)
  24558. * @param onAnimationEnd defines a callback to call when animation ends
  24559. */
  24560. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24561. private _endAnimation;
  24562. /** Release associated resources */
  24563. dispose(): void;
  24564. /**
  24565. * Serializes the sprite to a JSON object
  24566. * @returns the JSON object
  24567. */
  24568. serialize(): any;
  24569. /**
  24570. * Parses a JSON object to create a new sprite
  24571. * @param parsedSprite The JSON object to parse
  24572. * @param manager defines the hosting manager
  24573. * @returns the new sprite
  24574. */
  24575. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24576. }
  24577. }
  24578. declare module "babylonjs/Collisions/pickingInfo" {
  24579. import { Nullable } from "babylonjs/types";
  24580. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  24581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24582. import { Sprite } from "babylonjs/Sprites/sprite";
  24583. import { Ray } from "babylonjs/Culling/ray";
  24584. /**
  24585. * Information about the result of picking within a scene
  24586. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24587. */
  24588. export class PickingInfo {
  24589. /** @hidden */
  24590. _pickingUnavailable: boolean;
  24591. /**
  24592. * If the pick collided with an object
  24593. */
  24594. hit: boolean;
  24595. /**
  24596. * Distance away where the pick collided
  24597. */
  24598. distance: number;
  24599. /**
  24600. * The location of pick collision
  24601. */
  24602. pickedPoint: Nullable<Vector3>;
  24603. /**
  24604. * The mesh corresponding the the pick collision
  24605. */
  24606. pickedMesh: Nullable<AbstractMesh>;
  24607. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24608. bu: number;
  24609. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24610. bv: number;
  24611. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24612. faceId: number;
  24613. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24614. subMeshFaceId: number;
  24615. /** Id of the the submesh that was picked */
  24616. subMeshId: number;
  24617. /** If a sprite was picked, this will be the sprite the pick collided with */
  24618. pickedSprite: Nullable<Sprite>;
  24619. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24620. thinInstanceIndex: number;
  24621. /**
  24622. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24623. */
  24624. originMesh: Nullable<AbstractMesh>;
  24625. /**
  24626. * The ray that was used to perform the picking.
  24627. */
  24628. ray: Nullable<Ray>;
  24629. /**
  24630. * Gets the normal correspodning to the face the pick collided with
  24631. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24632. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24633. * @returns The normal correspodning to the face the pick collided with
  24634. */
  24635. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24636. /**
  24637. * Gets the texture coordinates of where the pick occured
  24638. * @returns the vector containing the coordnates of the texture
  24639. */
  24640. getTextureCoordinates(): Nullable<Vector2>;
  24641. }
  24642. }
  24643. declare module "babylonjs/Events/pointerEvents" {
  24644. import { Nullable } from "babylonjs/types";
  24645. import { Vector2 } from "babylonjs/Maths/math.vector";
  24646. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24647. import { Ray } from "babylonjs/Culling/ray";
  24648. /**
  24649. * Gather the list of pointer event types as constants.
  24650. */
  24651. export class PointerEventTypes {
  24652. /**
  24653. * 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.
  24654. */
  24655. static readonly POINTERDOWN: number;
  24656. /**
  24657. * The pointerup event is fired when a pointer is no longer active.
  24658. */
  24659. static readonly POINTERUP: number;
  24660. /**
  24661. * The pointermove event is fired when a pointer changes coordinates.
  24662. */
  24663. static readonly POINTERMOVE: number;
  24664. /**
  24665. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24666. */
  24667. static readonly POINTERWHEEL: number;
  24668. /**
  24669. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24670. */
  24671. static readonly POINTERPICK: number;
  24672. /**
  24673. * The pointertap event is fired when a the object has been touched and released without drag.
  24674. */
  24675. static readonly POINTERTAP: number;
  24676. /**
  24677. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24678. */
  24679. static readonly POINTERDOUBLETAP: number;
  24680. }
  24681. /**
  24682. * Base class of pointer info types.
  24683. */
  24684. export class PointerInfoBase {
  24685. /**
  24686. * Defines the type of event (PointerEventTypes)
  24687. */
  24688. type: number;
  24689. /**
  24690. * Defines the related dom event
  24691. */
  24692. event: PointerEvent | MouseWheelEvent;
  24693. /**
  24694. * Instantiates the base class of pointers info.
  24695. * @param type Defines the type of event (PointerEventTypes)
  24696. * @param event Defines the related dom event
  24697. */
  24698. constructor(
  24699. /**
  24700. * Defines the type of event (PointerEventTypes)
  24701. */
  24702. type: number,
  24703. /**
  24704. * Defines the related dom event
  24705. */
  24706. event: PointerEvent | MouseWheelEvent);
  24707. }
  24708. /**
  24709. * This class is used to store pointer related info for the onPrePointerObservable event.
  24710. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24711. */
  24712. export class PointerInfoPre extends PointerInfoBase {
  24713. /**
  24714. * Ray from a pointer if availible (eg. 6dof controller)
  24715. */
  24716. ray: Nullable<Ray>;
  24717. /**
  24718. * Defines the local position of the pointer on the canvas.
  24719. */
  24720. localPosition: Vector2;
  24721. /**
  24722. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24723. */
  24724. skipOnPointerObservable: boolean;
  24725. /**
  24726. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24727. * @param type Defines the type of event (PointerEventTypes)
  24728. * @param event Defines the related dom event
  24729. * @param localX Defines the local x coordinates of the pointer when the event occured
  24730. * @param localY Defines the local y coordinates of the pointer when the event occured
  24731. */
  24732. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24733. }
  24734. /**
  24735. * This type contains all the data related to a pointer event in Babylon.js.
  24736. * 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.
  24737. */
  24738. export class PointerInfo extends PointerInfoBase {
  24739. /**
  24740. * Defines the picking info associated to the info (if any)\
  24741. */
  24742. pickInfo: Nullable<PickingInfo>;
  24743. /**
  24744. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24745. * @param type Defines the type of event (PointerEventTypes)
  24746. * @param event Defines the related dom event
  24747. * @param pickInfo Defines the picking info associated to the info (if any)\
  24748. */
  24749. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24750. /**
  24751. * Defines the picking info associated to the info (if any)\
  24752. */
  24753. pickInfo: Nullable<PickingInfo>);
  24754. }
  24755. /**
  24756. * Data relating to a touch event on the screen.
  24757. */
  24758. export interface PointerTouch {
  24759. /**
  24760. * X coordinate of touch.
  24761. */
  24762. x: number;
  24763. /**
  24764. * Y coordinate of touch.
  24765. */
  24766. y: number;
  24767. /**
  24768. * Id of touch. Unique for each finger.
  24769. */
  24770. pointerId: number;
  24771. /**
  24772. * Event type passed from DOM.
  24773. */
  24774. type: any;
  24775. }
  24776. }
  24777. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  24778. import { Observable } from "babylonjs/Misc/observable";
  24779. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24780. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24781. /**
  24782. * Manage the mouse inputs to control the movement of a free camera.
  24783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24784. */
  24785. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24786. /**
  24787. * Define if touch is enabled in the mouse input
  24788. */
  24789. touchEnabled: boolean;
  24790. /**
  24791. * Defines the camera the input is attached to.
  24792. */
  24793. camera: FreeCamera;
  24794. /**
  24795. * Defines the buttons associated with the input to handle camera move.
  24796. */
  24797. buttons: number[];
  24798. /**
  24799. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24800. */
  24801. angularSensibility: number;
  24802. private _pointerInput;
  24803. private _onMouseMove;
  24804. private _observer;
  24805. private previousPosition;
  24806. /**
  24807. * Observable for when a pointer move event occurs containing the move offset
  24808. */
  24809. onPointerMovedObservable: Observable<{
  24810. offsetX: number;
  24811. offsetY: number;
  24812. }>;
  24813. /**
  24814. * @hidden
  24815. * If the camera should be rotated automatically based on pointer movement
  24816. */
  24817. _allowCameraRotation: boolean;
  24818. /**
  24819. * Manage the mouse inputs to control the movement of a free camera.
  24820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24821. * @param touchEnabled Defines if touch is enabled or not
  24822. */
  24823. constructor(
  24824. /**
  24825. * Define if touch is enabled in the mouse input
  24826. */
  24827. touchEnabled?: boolean);
  24828. /**
  24829. * Attach the input controls to a specific dom element to get the input from.
  24830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24831. */
  24832. attachControl(noPreventDefault?: boolean): void;
  24833. /**
  24834. * Called on JS contextmenu event.
  24835. * Override this method to provide functionality.
  24836. */
  24837. protected onContextMenu(evt: PointerEvent): void;
  24838. /**
  24839. * Detach the current controls from the specified dom element.
  24840. */
  24841. detachControl(): void;
  24842. /**
  24843. * Gets the class name of the current intput.
  24844. * @returns the class name
  24845. */
  24846. getClassName(): string;
  24847. /**
  24848. * Get the friendly name associated with the input class.
  24849. * @returns the input friendly name
  24850. */
  24851. getSimpleName(): string;
  24852. }
  24853. }
  24854. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  24855. import { Observable } from "babylonjs/Misc/observable";
  24856. import { Camera } from "babylonjs/Cameras/camera";
  24857. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  24858. /**
  24859. * Base class for mouse wheel input..
  24860. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24861. * for example usage.
  24862. */
  24863. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24864. /**
  24865. * Defines the camera the input is attached to.
  24866. */
  24867. abstract camera: Camera;
  24868. /**
  24869. * How fast is the camera moves in relation to X axis mouseWheel events.
  24870. * Use negative value to reverse direction.
  24871. */
  24872. wheelPrecisionX: number;
  24873. /**
  24874. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24875. * Use negative value to reverse direction.
  24876. */
  24877. wheelPrecisionY: number;
  24878. /**
  24879. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24880. * Use negative value to reverse direction.
  24881. */
  24882. wheelPrecisionZ: number;
  24883. /**
  24884. * Observable for when a mouse wheel move event occurs.
  24885. */
  24886. onChangedObservable: Observable<{
  24887. wheelDeltaX: number;
  24888. wheelDeltaY: number;
  24889. wheelDeltaZ: number;
  24890. }>;
  24891. private _wheel;
  24892. private _observer;
  24893. /**
  24894. * Attach the input controls to a specific dom element to get the input from.
  24895. * @param noPreventDefault Defines whether event caught by the controls
  24896. * should call preventdefault().
  24897. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24898. */
  24899. attachControl(noPreventDefault?: boolean): void;
  24900. /**
  24901. * Detach the current controls from the specified dom element.
  24902. */
  24903. detachControl(): void;
  24904. /**
  24905. * Called for each rendered frame.
  24906. */
  24907. checkInputs(): void;
  24908. /**
  24909. * Gets the class name of the current intput.
  24910. * @returns the class name
  24911. */
  24912. getClassName(): string;
  24913. /**
  24914. * Get the friendly name associated with the input class.
  24915. * @returns the input friendly name
  24916. */
  24917. getSimpleName(): string;
  24918. /**
  24919. * Incremental value of multiple mouse wheel movements of the X axis.
  24920. * Should be zero-ed when read.
  24921. */
  24922. protected _wheelDeltaX: number;
  24923. /**
  24924. * Incremental value of multiple mouse wheel movements of the Y axis.
  24925. * Should be zero-ed when read.
  24926. */
  24927. protected _wheelDeltaY: number;
  24928. /**
  24929. * Incremental value of multiple mouse wheel movements of the Z axis.
  24930. * Should be zero-ed when read.
  24931. */
  24932. protected _wheelDeltaZ: number;
  24933. /**
  24934. * Firefox uses a different scheme to report scroll distances to other
  24935. * browsers. Rather than use complicated methods to calculate the exact
  24936. * multiple we need to apply, let's just cheat and use a constant.
  24937. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24938. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24939. */
  24940. private readonly _ffMultiplier;
  24941. /**
  24942. * Different event attributes for wheel data fall into a few set ranges.
  24943. * Some relevant but dated date here:
  24944. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24945. */
  24946. private readonly _normalize;
  24947. }
  24948. }
  24949. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  24950. import { Nullable } from "babylonjs/types";
  24951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  24952. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  24953. import { Coordinate } from "babylonjs/Maths/math.axis";
  24954. /**
  24955. * Manage the mouse wheel inputs to control a free camera.
  24956. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24957. */
  24958. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24959. /**
  24960. * Defines the camera the input is attached to.
  24961. */
  24962. camera: FreeCamera;
  24963. /**
  24964. * Gets the class name of the current input.
  24965. * @returns the class name
  24966. */
  24967. getClassName(): string;
  24968. /**
  24969. * Set which movement axis (relative to camera's orientation) the mouse
  24970. * wheel's X axis controls.
  24971. * @param axis The axis to be moved. Set null to clear.
  24972. */
  24973. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24974. /**
  24975. * Get the configured movement axis (relative to camera's orientation) the
  24976. * mouse wheel's X axis controls.
  24977. * @returns The configured axis or null if none.
  24978. */
  24979. get wheelXMoveRelative(): Nullable<Coordinate>;
  24980. /**
  24981. * Set which movement axis (relative to camera's orientation) the mouse
  24982. * wheel's Y axis controls.
  24983. * @param axis The axis to be moved. Set null to clear.
  24984. */
  24985. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24986. /**
  24987. * Get the configured movement axis (relative to camera's orientation) the
  24988. * mouse wheel's Y axis controls.
  24989. * @returns The configured axis or null if none.
  24990. */
  24991. get wheelYMoveRelative(): Nullable<Coordinate>;
  24992. /**
  24993. * Set which movement axis (relative to camera's orientation) the mouse
  24994. * wheel's Z axis controls.
  24995. * @param axis The axis to be moved. Set null to clear.
  24996. */
  24997. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24998. /**
  24999. * Get the configured movement axis (relative to camera's orientation) the
  25000. * mouse wheel's Z axis controls.
  25001. * @returns The configured axis or null if none.
  25002. */
  25003. get wheelZMoveRelative(): Nullable<Coordinate>;
  25004. /**
  25005. * Set which rotation axis (relative to camera's orientation) the mouse
  25006. * wheel's X axis controls.
  25007. * @param axis The axis to be moved. Set null to clear.
  25008. */
  25009. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  25010. /**
  25011. * Get the configured rotation axis (relative to camera's orientation) the
  25012. * mouse wheel's X axis controls.
  25013. * @returns The configured axis or null if none.
  25014. */
  25015. get wheelXRotateRelative(): Nullable<Coordinate>;
  25016. /**
  25017. * Set which rotation axis (relative to camera's orientation) the mouse
  25018. * wheel's Y axis controls.
  25019. * @param axis The axis to be moved. Set null to clear.
  25020. */
  25021. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  25022. /**
  25023. * Get the configured rotation axis (relative to camera's orientation) the
  25024. * mouse wheel's Y axis controls.
  25025. * @returns The configured axis or null if none.
  25026. */
  25027. get wheelYRotateRelative(): Nullable<Coordinate>;
  25028. /**
  25029. * Set which rotation axis (relative to camera's orientation) the mouse
  25030. * wheel's Z axis controls.
  25031. * @param axis The axis to be moved. Set null to clear.
  25032. */
  25033. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  25034. /**
  25035. * Get the configured rotation axis (relative to camera's orientation) the
  25036. * mouse wheel's Z axis controls.
  25037. * @returns The configured axis or null if none.
  25038. */
  25039. get wheelZRotateRelative(): Nullable<Coordinate>;
  25040. /**
  25041. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  25042. * controls.
  25043. * @param axis The axis to be moved. Set null to clear.
  25044. */
  25045. set wheelXMoveScene(axis: Nullable<Coordinate>);
  25046. /**
  25047. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25048. * X axis controls.
  25049. * @returns The configured axis or null if none.
  25050. */
  25051. get wheelXMoveScene(): Nullable<Coordinate>;
  25052. /**
  25053. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  25054. * controls.
  25055. * @param axis The axis to be moved. Set null to clear.
  25056. */
  25057. set wheelYMoveScene(axis: Nullable<Coordinate>);
  25058. /**
  25059. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25060. * Y axis controls.
  25061. * @returns The configured axis or null if none.
  25062. */
  25063. get wheelYMoveScene(): Nullable<Coordinate>;
  25064. /**
  25065. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  25066. * controls.
  25067. * @param axis The axis to be moved. Set null to clear.
  25068. */
  25069. set wheelZMoveScene(axis: Nullable<Coordinate>);
  25070. /**
  25071. * Get the configured movement axis (relative to the scene) the mouse wheel's
  25072. * Z axis controls.
  25073. * @returns The configured axis or null if none.
  25074. */
  25075. get wheelZMoveScene(): Nullable<Coordinate>;
  25076. /**
  25077. * Called for each rendered frame.
  25078. */
  25079. checkInputs(): void;
  25080. private _moveRelative;
  25081. private _rotateRelative;
  25082. private _moveScene;
  25083. /**
  25084. * These are set to the desired default behaviour.
  25085. */
  25086. private _wheelXAction;
  25087. private _wheelXActionCoordinate;
  25088. private _wheelYAction;
  25089. private _wheelYActionCoordinate;
  25090. private _wheelZAction;
  25091. private _wheelZActionCoordinate;
  25092. /**
  25093. * Update the camera according to any configured properties for the 3
  25094. * mouse-wheel axis.
  25095. */
  25096. private _updateCamera;
  25097. }
  25098. }
  25099. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  25100. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  25101. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25102. /**
  25103. * Manage the touch inputs to control the movement of a free camera.
  25104. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25105. */
  25106. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  25107. /**
  25108. * Define if mouse events can be treated as touch events
  25109. */
  25110. allowMouse: boolean;
  25111. /**
  25112. * Defines the camera the input is attached to.
  25113. */
  25114. camera: FreeCamera;
  25115. /**
  25116. * Defines the touch sensibility for rotation.
  25117. * The higher the faster.
  25118. */
  25119. touchAngularSensibility: number;
  25120. /**
  25121. * Defines the touch sensibility for move.
  25122. * The higher the faster.
  25123. */
  25124. touchMoveSensibility: number;
  25125. private _offsetX;
  25126. private _offsetY;
  25127. private _pointerPressed;
  25128. private _pointerInput?;
  25129. private _observer;
  25130. private _onLostFocus;
  25131. /**
  25132. * Manage the touch inputs to control the movement of a free camera.
  25133. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25134. * @param allowMouse Defines if mouse events can be treated as touch events
  25135. */
  25136. constructor(
  25137. /**
  25138. * Define if mouse events can be treated as touch events
  25139. */
  25140. allowMouse?: boolean);
  25141. /**
  25142. * Attach the input controls to a specific dom element to get the input from.
  25143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25144. */
  25145. attachControl(noPreventDefault?: boolean): void;
  25146. /**
  25147. * Detach the current controls from the specified dom element.
  25148. */
  25149. detachControl(): void;
  25150. /**
  25151. * Update the current camera state depending on the inputs that have been used this frame.
  25152. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  25153. */
  25154. checkInputs(): void;
  25155. /**
  25156. * Gets the class name of the current intput.
  25157. * @returns the class name
  25158. */
  25159. getClassName(): string;
  25160. /**
  25161. * Get the friendly name associated with the input class.
  25162. * @returns the input friendly name
  25163. */
  25164. getSimpleName(): string;
  25165. }
  25166. }
  25167. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  25168. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25169. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25170. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  25171. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  25172. import { Nullable } from "babylonjs/types";
  25173. /**
  25174. * Default Inputs manager for the FreeCamera.
  25175. * It groups all the default supported inputs for ease of use.
  25176. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  25177. */
  25178. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  25179. /**
  25180. * @hidden
  25181. */
  25182. _mouseInput: Nullable<FreeCameraMouseInput>;
  25183. /**
  25184. * @hidden
  25185. */
  25186. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  25187. /**
  25188. * Instantiates a new FreeCameraInputsManager.
  25189. * @param camera Defines the camera the inputs belong to
  25190. */
  25191. constructor(camera: FreeCamera);
  25192. /**
  25193. * Add keyboard input support to the input manager.
  25194. * @returns the current input manager
  25195. */
  25196. addKeyboard(): FreeCameraInputsManager;
  25197. /**
  25198. * Add mouse input support to the input manager.
  25199. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  25200. * @returns the current input manager
  25201. */
  25202. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  25203. /**
  25204. * Removes the mouse input support from the manager
  25205. * @returns the current input manager
  25206. */
  25207. removeMouse(): FreeCameraInputsManager;
  25208. /**
  25209. * Add mouse wheel input support to the input manager.
  25210. * @returns the current input manager
  25211. */
  25212. addMouseWheel(): FreeCameraInputsManager;
  25213. /**
  25214. * Removes the mouse wheel input support from the manager
  25215. * @returns the current input manager
  25216. */
  25217. removeMouseWheel(): FreeCameraInputsManager;
  25218. /**
  25219. * Add touch input support to the input manager.
  25220. * @returns the current input manager
  25221. */
  25222. addTouch(): FreeCameraInputsManager;
  25223. /**
  25224. * Remove all attached input methods from a camera
  25225. */
  25226. clear(): void;
  25227. }
  25228. }
  25229. declare module "babylonjs/Cameras/freeCamera" {
  25230. import { Vector3 } from "babylonjs/Maths/math.vector";
  25231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25232. import { Scene } from "babylonjs/scene";
  25233. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  25234. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  25235. /**
  25236. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25237. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25238. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25239. */
  25240. export class FreeCamera extends TargetCamera {
  25241. /**
  25242. * Define the collision ellipsoid of the camera.
  25243. * This is helpful to simulate a camera body like the player body around the camera
  25244. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25245. */
  25246. ellipsoid: Vector3;
  25247. /**
  25248. * Define an offset for the position of the ellipsoid around the camera.
  25249. * This can be helpful to determine the center of the body near the gravity center of the body
  25250. * instead of its head.
  25251. */
  25252. ellipsoidOffset: Vector3;
  25253. /**
  25254. * Enable or disable collisions of the camera with the rest of the scene objects.
  25255. */
  25256. checkCollisions: boolean;
  25257. /**
  25258. * Enable or disable gravity on the camera.
  25259. */
  25260. applyGravity: boolean;
  25261. /**
  25262. * Define the input manager associated to the camera.
  25263. */
  25264. inputs: FreeCameraInputsManager;
  25265. /**
  25266. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25267. * Higher values reduce sensitivity.
  25268. */
  25269. get angularSensibility(): number;
  25270. /**
  25271. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25272. * Higher values reduce sensitivity.
  25273. */
  25274. set angularSensibility(value: number);
  25275. /**
  25276. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25277. */
  25278. get keysUp(): number[];
  25279. set keysUp(value: number[]);
  25280. /**
  25281. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25282. */
  25283. get keysUpward(): number[];
  25284. set keysUpward(value: number[]);
  25285. /**
  25286. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25287. */
  25288. get keysDown(): number[];
  25289. set keysDown(value: number[]);
  25290. /**
  25291. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25292. */
  25293. get keysDownward(): number[];
  25294. set keysDownward(value: number[]);
  25295. /**
  25296. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25297. */
  25298. get keysLeft(): number[];
  25299. set keysLeft(value: number[]);
  25300. /**
  25301. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25302. */
  25303. get keysRight(): number[];
  25304. set keysRight(value: number[]);
  25305. /**
  25306. * Event raised when the camera collide with a mesh in the scene.
  25307. */
  25308. onCollide: (collidedMesh: AbstractMesh) => void;
  25309. private _collider;
  25310. private _needMoveForGravity;
  25311. private _oldPosition;
  25312. private _diffPosition;
  25313. private _newPosition;
  25314. /** @hidden */
  25315. _localDirection: Vector3;
  25316. /** @hidden */
  25317. _transformedDirection: Vector3;
  25318. /**
  25319. * Instantiates a Free Camera.
  25320. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25321. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25322. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25323. * @param name Define the name of the camera in the scene
  25324. * @param position Define the start position of the camera in the scene
  25325. * @param scene Define the scene the camera belongs to
  25326. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25327. */
  25328. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25329. /**
  25330. * Attach the input controls to a specific dom element to get the input from.
  25331. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25332. */
  25333. attachControl(noPreventDefault?: boolean): void;
  25334. /**
  25335. * Attach the input controls to a specific dom element to get the input from.
  25336. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25338. * BACK COMPAT SIGNATURE ONLY.
  25339. */
  25340. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25341. /**
  25342. * Detach the current controls from the specified dom element.
  25343. */
  25344. detachControl(): void;
  25345. /**
  25346. * Detach the current controls from the specified dom element.
  25347. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  25348. */
  25349. detachControl(ignored: any): void;
  25350. private _collisionMask;
  25351. /**
  25352. * Define a collision mask to limit the list of object the camera can collide with
  25353. */
  25354. get collisionMask(): number;
  25355. set collisionMask(mask: number);
  25356. /** @hidden */
  25357. _collideWithWorld(displacement: Vector3): void;
  25358. private _onCollisionPositionChange;
  25359. /** @hidden */
  25360. _checkInputs(): void;
  25361. /** @hidden */
  25362. _decideIfNeedsToMove(): boolean;
  25363. /** @hidden */
  25364. _updatePosition(): void;
  25365. /**
  25366. * Destroy the camera and release the current resources hold by it.
  25367. */
  25368. dispose(): void;
  25369. /**
  25370. * Gets the current object class name.
  25371. * @return the class name
  25372. */
  25373. getClassName(): string;
  25374. }
  25375. }
  25376. declare module "babylonjs/Gamepads/gamepad" {
  25377. import { Observable } from "babylonjs/Misc/observable";
  25378. /**
  25379. * Represents a gamepad control stick position
  25380. */
  25381. export class StickValues {
  25382. /**
  25383. * The x component of the control stick
  25384. */
  25385. x: number;
  25386. /**
  25387. * The y component of the control stick
  25388. */
  25389. y: number;
  25390. /**
  25391. * Initializes the gamepad x and y control stick values
  25392. * @param x The x component of the gamepad control stick value
  25393. * @param y The y component of the gamepad control stick value
  25394. */
  25395. constructor(
  25396. /**
  25397. * The x component of the control stick
  25398. */
  25399. x: number,
  25400. /**
  25401. * The y component of the control stick
  25402. */
  25403. y: number);
  25404. }
  25405. /**
  25406. * An interface which manages callbacks for gamepad button changes
  25407. */
  25408. export interface GamepadButtonChanges {
  25409. /**
  25410. * Called when a gamepad has been changed
  25411. */
  25412. changed: boolean;
  25413. /**
  25414. * Called when a gamepad press event has been triggered
  25415. */
  25416. pressChanged: boolean;
  25417. /**
  25418. * Called when a touch event has been triggered
  25419. */
  25420. touchChanged: boolean;
  25421. /**
  25422. * Called when a value has changed
  25423. */
  25424. valueChanged: boolean;
  25425. }
  25426. /**
  25427. * Represents a gamepad
  25428. */
  25429. export class Gamepad {
  25430. /**
  25431. * The id of the gamepad
  25432. */
  25433. id: string;
  25434. /**
  25435. * The index of the gamepad
  25436. */
  25437. index: number;
  25438. /**
  25439. * The browser gamepad
  25440. */
  25441. browserGamepad: any;
  25442. /**
  25443. * Specifies what type of gamepad this represents
  25444. */
  25445. type: number;
  25446. private _leftStick;
  25447. private _rightStick;
  25448. /** @hidden */
  25449. _isConnected: boolean;
  25450. private _leftStickAxisX;
  25451. private _leftStickAxisY;
  25452. private _rightStickAxisX;
  25453. private _rightStickAxisY;
  25454. /**
  25455. * Triggered when the left control stick has been changed
  25456. */
  25457. private _onleftstickchanged;
  25458. /**
  25459. * Triggered when the right control stick has been changed
  25460. */
  25461. private _onrightstickchanged;
  25462. /**
  25463. * Represents a gamepad controller
  25464. */
  25465. static GAMEPAD: number;
  25466. /**
  25467. * Represents a generic controller
  25468. */
  25469. static GENERIC: number;
  25470. /**
  25471. * Represents an XBox controller
  25472. */
  25473. static XBOX: number;
  25474. /**
  25475. * Represents a pose-enabled controller
  25476. */
  25477. static POSE_ENABLED: number;
  25478. /**
  25479. * Represents an Dual Shock controller
  25480. */
  25481. static DUALSHOCK: number;
  25482. /**
  25483. * Specifies whether the left control stick should be Y-inverted
  25484. */
  25485. protected _invertLeftStickY: boolean;
  25486. /**
  25487. * Specifies if the gamepad has been connected
  25488. */
  25489. get isConnected(): boolean;
  25490. /**
  25491. * Initializes the gamepad
  25492. * @param id The id of the gamepad
  25493. * @param index The index of the gamepad
  25494. * @param browserGamepad The browser gamepad
  25495. * @param leftStickX The x component of the left joystick
  25496. * @param leftStickY The y component of the left joystick
  25497. * @param rightStickX The x component of the right joystick
  25498. * @param rightStickY The y component of the right joystick
  25499. */
  25500. constructor(
  25501. /**
  25502. * The id of the gamepad
  25503. */
  25504. id: string,
  25505. /**
  25506. * The index of the gamepad
  25507. */
  25508. index: number,
  25509. /**
  25510. * The browser gamepad
  25511. */
  25512. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25513. /**
  25514. * Callback triggered when the left joystick has changed
  25515. * @param callback
  25516. */
  25517. onleftstickchanged(callback: (values: StickValues) => void): void;
  25518. /**
  25519. * Callback triggered when the right joystick has changed
  25520. * @param callback
  25521. */
  25522. onrightstickchanged(callback: (values: StickValues) => void): void;
  25523. /**
  25524. * Gets the left joystick
  25525. */
  25526. get leftStick(): StickValues;
  25527. /**
  25528. * Sets the left joystick values
  25529. */
  25530. set leftStick(newValues: StickValues);
  25531. /**
  25532. * Gets the right joystick
  25533. */
  25534. get rightStick(): StickValues;
  25535. /**
  25536. * Sets the right joystick value
  25537. */
  25538. set rightStick(newValues: StickValues);
  25539. /**
  25540. * Updates the gamepad joystick positions
  25541. */
  25542. update(): void;
  25543. /**
  25544. * Disposes the gamepad
  25545. */
  25546. dispose(): void;
  25547. }
  25548. /**
  25549. * Represents a generic gamepad
  25550. */
  25551. export class GenericPad extends Gamepad {
  25552. private _buttons;
  25553. private _onbuttondown;
  25554. private _onbuttonup;
  25555. /**
  25556. * Observable triggered when a button has been pressed
  25557. */
  25558. onButtonDownObservable: Observable<number>;
  25559. /**
  25560. * Observable triggered when a button has been released
  25561. */
  25562. onButtonUpObservable: Observable<number>;
  25563. /**
  25564. * Callback triggered when a button has been pressed
  25565. * @param callback Called when a button has been pressed
  25566. */
  25567. onbuttondown(callback: (buttonPressed: number) => void): void;
  25568. /**
  25569. * Callback triggered when a button has been released
  25570. * @param callback Called when a button has been released
  25571. */
  25572. onbuttonup(callback: (buttonReleased: number) => void): void;
  25573. /**
  25574. * Initializes the generic gamepad
  25575. * @param id The id of the generic gamepad
  25576. * @param index The index of the generic gamepad
  25577. * @param browserGamepad The browser gamepad
  25578. */
  25579. constructor(id: string, index: number, browserGamepad: any);
  25580. private _setButtonValue;
  25581. /**
  25582. * Updates the generic gamepad
  25583. */
  25584. update(): void;
  25585. /**
  25586. * Disposes the generic gamepad
  25587. */
  25588. dispose(): void;
  25589. }
  25590. }
  25591. declare module "babylonjs/Animations/runtimeAnimation" {
  25592. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  25593. import { Animatable } from "babylonjs/Animations/animatable";
  25594. import { Scene } from "babylonjs/scene";
  25595. /**
  25596. * Defines a runtime animation
  25597. */
  25598. export class RuntimeAnimation {
  25599. private _events;
  25600. /**
  25601. * The current frame of the runtime animation
  25602. */
  25603. private _currentFrame;
  25604. /**
  25605. * The animation used by the runtime animation
  25606. */
  25607. private _animation;
  25608. /**
  25609. * The target of the runtime animation
  25610. */
  25611. private _target;
  25612. /**
  25613. * The initiating animatable
  25614. */
  25615. private _host;
  25616. /**
  25617. * The original value of the runtime animation
  25618. */
  25619. private _originalValue;
  25620. /**
  25621. * The original blend value of the runtime animation
  25622. */
  25623. private _originalBlendValue;
  25624. /**
  25625. * The offsets cache of the runtime animation
  25626. */
  25627. private _offsetsCache;
  25628. /**
  25629. * The high limits cache of the runtime animation
  25630. */
  25631. private _highLimitsCache;
  25632. /**
  25633. * Specifies if the runtime animation has been stopped
  25634. */
  25635. private _stopped;
  25636. /**
  25637. * The blending factor of the runtime animation
  25638. */
  25639. private _blendingFactor;
  25640. /**
  25641. * The BabylonJS scene
  25642. */
  25643. private _scene;
  25644. /**
  25645. * The current value of the runtime animation
  25646. */
  25647. private _currentValue;
  25648. /** @hidden */
  25649. _animationState: _IAnimationState;
  25650. /**
  25651. * The active target of the runtime animation
  25652. */
  25653. private _activeTargets;
  25654. private _currentActiveTarget;
  25655. private _directTarget;
  25656. /**
  25657. * The target path of the runtime animation
  25658. */
  25659. private _targetPath;
  25660. /**
  25661. * The weight of the runtime animation
  25662. */
  25663. private _weight;
  25664. /**
  25665. * The ratio offset of the runtime animation
  25666. */
  25667. private _ratioOffset;
  25668. /**
  25669. * The previous delay of the runtime animation
  25670. */
  25671. private _previousDelay;
  25672. /**
  25673. * The previous ratio of the runtime animation
  25674. */
  25675. private _previousRatio;
  25676. private _enableBlending;
  25677. private _keys;
  25678. private _minFrame;
  25679. private _maxFrame;
  25680. private _minValue;
  25681. private _maxValue;
  25682. private _targetIsArray;
  25683. /**
  25684. * Gets the current frame of the runtime animation
  25685. */
  25686. get currentFrame(): number;
  25687. /**
  25688. * Gets the weight of the runtime animation
  25689. */
  25690. get weight(): number;
  25691. /**
  25692. * Gets the current value of the runtime animation
  25693. */
  25694. get currentValue(): any;
  25695. /**
  25696. * Gets the target path of the runtime animation
  25697. */
  25698. get targetPath(): string;
  25699. /**
  25700. * Gets the actual target of the runtime animation
  25701. */
  25702. get target(): any;
  25703. /**
  25704. * Gets the additive state of the runtime animation
  25705. */
  25706. get isAdditive(): boolean;
  25707. /** @hidden */
  25708. _onLoop: () => void;
  25709. /**
  25710. * Create a new RuntimeAnimation object
  25711. * @param target defines the target of the animation
  25712. * @param animation defines the source animation object
  25713. * @param scene defines the hosting scene
  25714. * @param host defines the initiating Animatable
  25715. */
  25716. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25717. private _preparePath;
  25718. /**
  25719. * Gets the animation from the runtime animation
  25720. */
  25721. get animation(): Animation;
  25722. /**
  25723. * Resets the runtime animation to the beginning
  25724. * @param restoreOriginal defines whether to restore the target property to the original value
  25725. */
  25726. reset(restoreOriginal?: boolean): void;
  25727. /**
  25728. * Specifies if the runtime animation is stopped
  25729. * @returns Boolean specifying if the runtime animation is stopped
  25730. */
  25731. isStopped(): boolean;
  25732. /**
  25733. * Disposes of the runtime animation
  25734. */
  25735. dispose(): void;
  25736. /**
  25737. * Apply the interpolated value to the target
  25738. * @param currentValue defines the value computed by the animation
  25739. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25740. */
  25741. setValue(currentValue: any, weight: number): void;
  25742. private _getOriginalValues;
  25743. private _setValue;
  25744. /**
  25745. * Gets the loop pmode of the runtime animation
  25746. * @returns Loop Mode
  25747. */
  25748. private _getCorrectLoopMode;
  25749. /**
  25750. * Move the current animation to a given frame
  25751. * @param frame defines the frame to move to
  25752. */
  25753. goToFrame(frame: number): void;
  25754. /**
  25755. * @hidden Internal use only
  25756. */
  25757. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25758. /**
  25759. * Execute the current animation
  25760. * @param delay defines the delay to add to the current frame
  25761. * @param from defines the lower bound of the animation range
  25762. * @param to defines the upper bound of the animation range
  25763. * @param loop defines if the current animation must loop
  25764. * @param speedRatio defines the current speed ratio
  25765. * @param weight defines the weight of the animation (default is -1 so no weight)
  25766. * @param onLoop optional callback called when animation loops
  25767. * @returns a boolean indicating if the animation is running
  25768. */
  25769. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25770. }
  25771. }
  25772. declare module "babylonjs/Animations/animatable" {
  25773. import { Animation } from "babylonjs/Animations/animation";
  25774. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25775. import { Nullable } from "babylonjs/types";
  25776. import { Observable } from "babylonjs/Misc/observable";
  25777. import { Scene } from "babylonjs/scene";
  25778. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  25779. import { Node } from "babylonjs/node";
  25780. /**
  25781. * Class used to store an actual running animation
  25782. */
  25783. export class Animatable {
  25784. /** defines the target object */
  25785. target: any;
  25786. /** defines the starting frame number (default is 0) */
  25787. fromFrame: number;
  25788. /** defines the ending frame number (default is 100) */
  25789. toFrame: number;
  25790. /** defines if the animation must loop (default is false) */
  25791. loopAnimation: boolean;
  25792. /** defines a callback to call when animation ends if it is not looping */
  25793. onAnimationEnd?: (() => void) | null | undefined;
  25794. /** defines a callback to call when animation loops */
  25795. onAnimationLoop?: (() => void) | null | undefined;
  25796. /** defines whether the animation should be evaluated additively */
  25797. isAdditive: boolean;
  25798. private _localDelayOffset;
  25799. private _pausedDelay;
  25800. private _runtimeAnimations;
  25801. private _paused;
  25802. private _scene;
  25803. private _speedRatio;
  25804. private _weight;
  25805. private _syncRoot;
  25806. /**
  25807. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25808. * This will only apply for non looping animation (default is true)
  25809. */
  25810. disposeOnEnd: boolean;
  25811. /**
  25812. * Gets a boolean indicating if the animation has started
  25813. */
  25814. animationStarted: boolean;
  25815. /**
  25816. * Observer raised when the animation ends
  25817. */
  25818. onAnimationEndObservable: Observable<Animatable>;
  25819. /**
  25820. * Observer raised when the animation loops
  25821. */
  25822. onAnimationLoopObservable: Observable<Animatable>;
  25823. /**
  25824. * Gets the root Animatable used to synchronize and normalize animations
  25825. */
  25826. get syncRoot(): Nullable<Animatable>;
  25827. /**
  25828. * Gets the current frame of the first RuntimeAnimation
  25829. * Used to synchronize Animatables
  25830. */
  25831. get masterFrame(): number;
  25832. /**
  25833. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25834. */
  25835. get weight(): number;
  25836. set weight(value: number);
  25837. /**
  25838. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25839. */
  25840. get speedRatio(): number;
  25841. set speedRatio(value: number);
  25842. /**
  25843. * Creates a new Animatable
  25844. * @param scene defines the hosting scene
  25845. * @param target defines the target object
  25846. * @param fromFrame defines the starting frame number (default is 0)
  25847. * @param toFrame defines the ending frame number (default is 100)
  25848. * @param loopAnimation defines if the animation must loop (default is false)
  25849. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25850. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25851. * @param animations defines a group of animation to add to the new Animatable
  25852. * @param onAnimationLoop defines a callback to call when animation loops
  25853. * @param isAdditive defines whether the animation should be evaluated additively
  25854. */
  25855. constructor(scene: Scene,
  25856. /** defines the target object */
  25857. target: any,
  25858. /** defines the starting frame number (default is 0) */
  25859. fromFrame?: number,
  25860. /** defines the ending frame number (default is 100) */
  25861. toFrame?: number,
  25862. /** defines if the animation must loop (default is false) */
  25863. loopAnimation?: boolean, speedRatio?: number,
  25864. /** defines a callback to call when animation ends if it is not looping */
  25865. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25866. /** defines a callback to call when animation loops */
  25867. onAnimationLoop?: (() => void) | null | undefined,
  25868. /** defines whether the animation should be evaluated additively */
  25869. isAdditive?: boolean);
  25870. /**
  25871. * Synchronize and normalize current Animatable with a source Animatable
  25872. * This is useful when using animation weights and when animations are not of the same length
  25873. * @param root defines the root Animatable to synchronize with
  25874. * @returns the current Animatable
  25875. */
  25876. syncWith(root: Animatable): Animatable;
  25877. /**
  25878. * Gets the list of runtime animations
  25879. * @returns an array of RuntimeAnimation
  25880. */
  25881. getAnimations(): RuntimeAnimation[];
  25882. /**
  25883. * Adds more animations to the current animatable
  25884. * @param target defines the target of the animations
  25885. * @param animations defines the new animations to add
  25886. */
  25887. appendAnimations(target: any, animations: Animation[]): void;
  25888. /**
  25889. * Gets the source animation for a specific property
  25890. * @param property defines the propertyu to look for
  25891. * @returns null or the source animation for the given property
  25892. */
  25893. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25894. /**
  25895. * Gets the runtime animation for a specific property
  25896. * @param property defines the propertyu to look for
  25897. * @returns null or the runtime animation for the given property
  25898. */
  25899. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25900. /**
  25901. * Resets the animatable to its original state
  25902. */
  25903. reset(): void;
  25904. /**
  25905. * Allows the animatable to blend with current running animations
  25906. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25907. * @param blendingSpeed defines the blending speed to use
  25908. */
  25909. enableBlending(blendingSpeed: number): void;
  25910. /**
  25911. * Disable animation blending
  25912. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25913. */
  25914. disableBlending(): void;
  25915. /**
  25916. * Jump directly to a given frame
  25917. * @param frame defines the frame to jump to
  25918. */
  25919. goToFrame(frame: number): void;
  25920. /**
  25921. * Pause the animation
  25922. */
  25923. pause(): void;
  25924. /**
  25925. * Restart the animation
  25926. */
  25927. restart(): void;
  25928. private _raiseOnAnimationEnd;
  25929. /**
  25930. * Stop and delete the current animation
  25931. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25932. * @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)
  25933. */
  25934. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25935. /**
  25936. * Wait asynchronously for the animation to end
  25937. * @returns a promise which will be fullfilled when the animation ends
  25938. */
  25939. waitAsync(): Promise<Animatable>;
  25940. /** @hidden */
  25941. _animate(delay: number): boolean;
  25942. }
  25943. module "babylonjs/scene" {
  25944. interface Scene {
  25945. /** @hidden */
  25946. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25947. /** @hidden */
  25948. _processLateAnimationBindingsForMatrices(holder: {
  25949. totalWeight: number;
  25950. totalAdditiveWeight: number;
  25951. animations: RuntimeAnimation[];
  25952. additiveAnimations: RuntimeAnimation[];
  25953. originalValue: Matrix;
  25954. }): any;
  25955. /** @hidden */
  25956. _processLateAnimationBindingsForQuaternions(holder: {
  25957. totalWeight: number;
  25958. totalAdditiveWeight: number;
  25959. animations: RuntimeAnimation[];
  25960. additiveAnimations: RuntimeAnimation[];
  25961. originalValue: Quaternion;
  25962. }, refQuaternion: Quaternion): Quaternion;
  25963. /** @hidden */
  25964. _processLateAnimationBindings(): void;
  25965. /**
  25966. * Will start the animation sequence of a given target
  25967. * @param target defines the target
  25968. * @param from defines from which frame should animation start
  25969. * @param to defines until which frame should animation run.
  25970. * @param weight defines the weight to apply to the animation (1.0 by default)
  25971. * @param loop defines if the animation loops
  25972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25973. * @param onAnimationEnd defines the function to be executed when the animation ends
  25974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25976. * @param onAnimationLoop defines the callback to call when an animation loops
  25977. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25978. * @returns the animatable object created for this animation
  25979. */
  25980. 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;
  25981. /**
  25982. * Will start the animation sequence of a given target
  25983. * @param target defines the target
  25984. * @param from defines from which frame should animation start
  25985. * @param to defines until which frame should animation run.
  25986. * @param loop defines if the animation loops
  25987. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25988. * @param onAnimationEnd defines the function to be executed when the animation ends
  25989. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25990. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25991. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25992. * @param onAnimationLoop defines the callback to call when an animation loops
  25993. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25994. * @returns the animatable object created for this animation
  25995. */
  25996. 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;
  25997. /**
  25998. * Will start the animation sequence of a given target and its hierarchy
  25999. * @param target defines the target
  26000. * @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.
  26001. * @param from defines from which frame should animation start
  26002. * @param to defines until which frame should animation run.
  26003. * @param loop defines if the animation loops
  26004. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  26005. * @param onAnimationEnd defines the function to be executed when the animation ends
  26006. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  26007. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  26008. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  26009. * @param onAnimationLoop defines the callback to call when an animation loops
  26010. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26011. * @returns the list of created animatables
  26012. */
  26013. 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[];
  26014. /**
  26015. * Begin a new animation on a given node
  26016. * @param target defines the target where the animation will take place
  26017. * @param animations defines the list of animations to start
  26018. * @param from defines the initial value
  26019. * @param to defines the final value
  26020. * @param loop defines if you want animation to loop (off by default)
  26021. * @param speedRatio defines the speed ratio to apply to all animations
  26022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26023. * @param onAnimationLoop defines the callback to call when an animation loops
  26024. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26025. * @returns the list of created animatables
  26026. */
  26027. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  26028. /**
  26029. * Begin a new animation on a given node and its hierarchy
  26030. * @param target defines the root node where the animation will take place
  26031. * @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.
  26032. * @param animations defines the list of animations to start
  26033. * @param from defines the initial value
  26034. * @param to defines the final value
  26035. * @param loop defines if you want animation to loop (off by default)
  26036. * @param speedRatio defines the speed ratio to apply to all animations
  26037. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26038. * @param onAnimationLoop defines the callback to call when an animation loops
  26039. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  26040. * @returns the list of animatables created for all nodes
  26041. */
  26042. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  26043. /**
  26044. * Gets the animatable associated with a specific target
  26045. * @param target defines the target of the animatable
  26046. * @returns the required animatable if found
  26047. */
  26048. getAnimatableByTarget(target: any): Nullable<Animatable>;
  26049. /**
  26050. * Gets all animatables associated with a given target
  26051. * @param target defines the target to look animatables for
  26052. * @returns an array of Animatables
  26053. */
  26054. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  26055. /**
  26056. * Stops and removes all animations that have been applied to the scene
  26057. */
  26058. stopAllAnimations(): void;
  26059. /**
  26060. * Gets the current delta time used by animation engine
  26061. */
  26062. deltaTime: number;
  26063. }
  26064. }
  26065. module "babylonjs/Bones/bone" {
  26066. interface Bone {
  26067. /**
  26068. * Copy an animation range from another bone
  26069. * @param source defines the source bone
  26070. * @param rangeName defines the range name to copy
  26071. * @param frameOffset defines the frame offset
  26072. * @param rescaleAsRequired defines if rescaling must be applied if required
  26073. * @param skelDimensionsRatio defines the scaling ratio
  26074. * @returns true if operation was successful
  26075. */
  26076. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  26077. }
  26078. }
  26079. }
  26080. declare module "babylonjs/Animations/animationPropertiesOverride" {
  26081. /**
  26082. * Class used to override all child animations of a given target
  26083. */
  26084. export class AnimationPropertiesOverride {
  26085. /**
  26086. * Gets or sets a value indicating if animation blending must be used
  26087. */
  26088. enableBlending: boolean;
  26089. /**
  26090. * Gets or sets the blending speed to use when enableBlending is true
  26091. */
  26092. blendingSpeed: number;
  26093. /**
  26094. * Gets or sets the default loop mode to use
  26095. */
  26096. loopMode: number;
  26097. }
  26098. }
  26099. declare module "babylonjs/Bones/skeleton" {
  26100. import { Bone } from "babylonjs/Bones/bone";
  26101. import { Observable } from "babylonjs/Misc/observable";
  26102. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  26103. import { Scene } from "babylonjs/scene";
  26104. import { Nullable } from "babylonjs/types";
  26105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26106. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26107. import { Animatable } from "babylonjs/Animations/animatable";
  26108. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26109. import { Animation } from "babylonjs/Animations/animation";
  26110. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26111. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26112. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26113. /**
  26114. * Class used to handle skinning animations
  26115. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26116. */
  26117. export class Skeleton implements IAnimatable {
  26118. /** defines the skeleton name */
  26119. name: string;
  26120. /** defines the skeleton Id */
  26121. id: string;
  26122. /**
  26123. * Defines the list of child bones
  26124. */
  26125. bones: Bone[];
  26126. /**
  26127. * Defines an estimate of the dimension of the skeleton at rest
  26128. */
  26129. dimensionsAtRest: Vector3;
  26130. /**
  26131. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  26132. */
  26133. needInitialSkinMatrix: boolean;
  26134. /**
  26135. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  26136. */
  26137. overrideMesh: Nullable<AbstractMesh>;
  26138. /**
  26139. * Gets the list of animations attached to this skeleton
  26140. */
  26141. animations: Array<Animation>;
  26142. private _scene;
  26143. private _isDirty;
  26144. private _transformMatrices;
  26145. private _transformMatrixTexture;
  26146. private _meshesWithPoseMatrix;
  26147. private _animatables;
  26148. private _identity;
  26149. private _synchronizedWithMesh;
  26150. private _ranges;
  26151. private _lastAbsoluteTransformsUpdateId;
  26152. private _canUseTextureForBones;
  26153. private _uniqueId;
  26154. /** @hidden */
  26155. _numBonesWithLinkedTransformNode: number;
  26156. /** @hidden */
  26157. _hasWaitingData: Nullable<boolean>;
  26158. /** @hidden */
  26159. _waitingOverrideMeshId: Nullable<string>;
  26160. /**
  26161. * Specifies if the skeleton should be serialized
  26162. */
  26163. doNotSerialize: boolean;
  26164. private _useTextureToStoreBoneMatrices;
  26165. /**
  26166. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  26167. * Please note that this option is not available if the hardware does not support it
  26168. */
  26169. get useTextureToStoreBoneMatrices(): boolean;
  26170. set useTextureToStoreBoneMatrices(value: boolean);
  26171. private _animationPropertiesOverride;
  26172. /**
  26173. * Gets or sets the animation properties override
  26174. */
  26175. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26176. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26177. /**
  26178. * List of inspectable custom properties (used by the Inspector)
  26179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26180. */
  26181. inspectableCustomProperties: IInspectable[];
  26182. /**
  26183. * An observable triggered before computing the skeleton's matrices
  26184. */
  26185. onBeforeComputeObservable: Observable<Skeleton>;
  26186. /**
  26187. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  26188. */
  26189. get isUsingTextureForMatrices(): boolean;
  26190. /**
  26191. * Gets the unique ID of this skeleton
  26192. */
  26193. get uniqueId(): number;
  26194. /**
  26195. * Creates a new skeleton
  26196. * @param name defines the skeleton name
  26197. * @param id defines the skeleton Id
  26198. * @param scene defines the hosting scene
  26199. */
  26200. constructor(
  26201. /** defines the skeleton name */
  26202. name: string,
  26203. /** defines the skeleton Id */
  26204. id: string, scene: Scene);
  26205. /**
  26206. * Gets the current object class name.
  26207. * @return the class name
  26208. */
  26209. getClassName(): string;
  26210. /**
  26211. * Returns an array containing the root bones
  26212. * @returns an array containing the root bones
  26213. */
  26214. getChildren(): Array<Bone>;
  26215. /**
  26216. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  26217. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26218. * @returns a Float32Array containing matrices data
  26219. */
  26220. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  26221. /**
  26222. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  26223. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  26224. * @returns a raw texture containing the data
  26225. */
  26226. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  26227. /**
  26228. * Gets the current hosting scene
  26229. * @returns a scene object
  26230. */
  26231. getScene(): Scene;
  26232. /**
  26233. * Gets a string representing the current skeleton data
  26234. * @param fullDetails defines a boolean indicating if we want a verbose version
  26235. * @returns a string representing the current skeleton data
  26236. */
  26237. toString(fullDetails?: boolean): string;
  26238. /**
  26239. * Get bone's index searching by name
  26240. * @param name defines bone's name to search for
  26241. * @return the indice of the bone. Returns -1 if not found
  26242. */
  26243. getBoneIndexByName(name: string): number;
  26244. /**
  26245. * Creater a new animation range
  26246. * @param name defines the name of the range
  26247. * @param from defines the start key
  26248. * @param to defines the end key
  26249. */
  26250. createAnimationRange(name: string, from: number, to: number): void;
  26251. /**
  26252. * Delete a specific animation range
  26253. * @param name defines the name of the range
  26254. * @param deleteFrames defines if frames must be removed as well
  26255. */
  26256. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26257. /**
  26258. * Gets a specific animation range
  26259. * @param name defines the name of the range to look for
  26260. * @returns the requested animation range or null if not found
  26261. */
  26262. getAnimationRange(name: string): Nullable<AnimationRange>;
  26263. /**
  26264. * Gets the list of all animation ranges defined on this skeleton
  26265. * @returns an array
  26266. */
  26267. getAnimationRanges(): Nullable<AnimationRange>[];
  26268. /**
  26269. * Copy animation range from a source skeleton.
  26270. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26271. * @param source defines the source skeleton
  26272. * @param name defines the name of the range to copy
  26273. * @param rescaleAsRequired defines if rescaling must be applied if required
  26274. * @returns true if operation was successful
  26275. */
  26276. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26277. /**
  26278. * Forces the skeleton to go to rest pose
  26279. */
  26280. returnToRest(): void;
  26281. private _getHighestAnimationFrame;
  26282. /**
  26283. * Begin a specific animation range
  26284. * @param name defines the name of the range to start
  26285. * @param loop defines if looping must be turned on (false by default)
  26286. * @param speedRatio defines the speed ratio to apply (1 by default)
  26287. * @param onAnimationEnd defines a callback which will be called when animation will end
  26288. * @returns a new animatable
  26289. */
  26290. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26291. /**
  26292. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26293. * @param skeleton defines the Skeleton containing the animation range to convert
  26294. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26295. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26296. * @returns the original skeleton
  26297. */
  26298. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26299. /** @hidden */
  26300. _markAsDirty(): void;
  26301. /** @hidden */
  26302. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26303. /** @hidden */
  26304. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26305. private _computeTransformMatrices;
  26306. /**
  26307. * Build all resources required to render a skeleton
  26308. */
  26309. prepare(): void;
  26310. /**
  26311. * Gets the list of animatables currently running for this skeleton
  26312. * @returns an array of animatables
  26313. */
  26314. getAnimatables(): IAnimatable[];
  26315. /**
  26316. * Clone the current skeleton
  26317. * @param name defines the name of the new skeleton
  26318. * @param id defines the id of the new skeleton
  26319. * @returns the new skeleton
  26320. */
  26321. clone(name: string, id?: string): Skeleton;
  26322. /**
  26323. * Enable animation blending for this skeleton
  26324. * @param blendingSpeed defines the blending speed to apply
  26325. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26326. */
  26327. enableBlending(blendingSpeed?: number): void;
  26328. /**
  26329. * Releases all resources associated with the current skeleton
  26330. */
  26331. dispose(): void;
  26332. /**
  26333. * Serialize the skeleton in a JSON object
  26334. * @returns a JSON object
  26335. */
  26336. serialize(): any;
  26337. /**
  26338. * Creates a new skeleton from serialized data
  26339. * @param parsedSkeleton defines the serialized data
  26340. * @param scene defines the hosting scene
  26341. * @returns a new skeleton
  26342. */
  26343. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26344. /**
  26345. * Compute all node absolute transforms
  26346. * @param forceUpdate defines if computation must be done even if cache is up to date
  26347. */
  26348. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26349. /**
  26350. * Gets the root pose matrix
  26351. * @returns a matrix
  26352. */
  26353. getPoseMatrix(): Nullable<Matrix>;
  26354. /**
  26355. * Sorts bones per internal index
  26356. */
  26357. sortBones(): void;
  26358. private _sortBones;
  26359. /**
  26360. * Set the current local matrix as the restPose for all bones in the skeleton.
  26361. */
  26362. setCurrentPoseAsRest(): void;
  26363. }
  26364. }
  26365. declare module "babylonjs/Bones/bone" {
  26366. import { Skeleton } from "babylonjs/Bones/skeleton";
  26367. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  26368. import { Nullable } from "babylonjs/types";
  26369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26370. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26371. import { Node } from "babylonjs/node";
  26372. import { Space } from "babylonjs/Maths/math.axis";
  26373. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26374. /**
  26375. * Class used to store bone information
  26376. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26377. */
  26378. export class Bone extends Node {
  26379. /**
  26380. * defines the bone name
  26381. */
  26382. name: string;
  26383. private static _tmpVecs;
  26384. private static _tmpQuat;
  26385. private static _tmpMats;
  26386. /**
  26387. * Gets the list of child bones
  26388. */
  26389. children: Bone[];
  26390. /** Gets the animations associated with this bone */
  26391. animations: import("babylonjs/Animations/animation").Animation[];
  26392. /**
  26393. * Gets or sets bone length
  26394. */
  26395. length: number;
  26396. /**
  26397. * @hidden Internal only
  26398. * Set this value to map this bone to a different index in the transform matrices
  26399. * Set this value to -1 to exclude the bone from the transform matrices
  26400. */
  26401. _index: Nullable<number>;
  26402. private _skeleton;
  26403. private _localMatrix;
  26404. private _restPose;
  26405. private _bindPose;
  26406. private _baseMatrix;
  26407. private _absoluteTransform;
  26408. private _invertedAbsoluteTransform;
  26409. private _parent;
  26410. private _scalingDeterminant;
  26411. private _worldTransform;
  26412. private _localScaling;
  26413. private _localRotation;
  26414. private _localPosition;
  26415. private _needToDecompose;
  26416. private _needToCompose;
  26417. /** @hidden */
  26418. _linkedTransformNode: Nullable<TransformNode>;
  26419. /** @hidden */
  26420. _waitingTransformNodeId: Nullable<string>;
  26421. /** @hidden */
  26422. get _matrix(): Matrix;
  26423. /** @hidden */
  26424. set _matrix(value: Matrix);
  26425. /**
  26426. * Create a new bone
  26427. * @param name defines the bone name
  26428. * @param skeleton defines the parent skeleton
  26429. * @param parentBone defines the parent (can be null if the bone is the root)
  26430. * @param localMatrix defines the local matrix
  26431. * @param restPose defines the rest pose matrix
  26432. * @param baseMatrix defines the base matrix
  26433. * @param index defines index of the bone in the hiearchy
  26434. */
  26435. constructor(
  26436. /**
  26437. * defines the bone name
  26438. */
  26439. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26440. /**
  26441. * Gets the current object class name.
  26442. * @return the class name
  26443. */
  26444. getClassName(): string;
  26445. /**
  26446. * Gets the parent skeleton
  26447. * @returns a skeleton
  26448. */
  26449. getSkeleton(): Skeleton;
  26450. /**
  26451. * Gets parent bone
  26452. * @returns a bone or null if the bone is the root of the bone hierarchy
  26453. */
  26454. getParent(): Nullable<Bone>;
  26455. /**
  26456. * Returns an array containing the root bones
  26457. * @returns an array containing the root bones
  26458. */
  26459. getChildren(): Array<Bone>;
  26460. /**
  26461. * Gets the node index in matrix array generated for rendering
  26462. * @returns the node index
  26463. */
  26464. getIndex(): number;
  26465. /**
  26466. * Sets the parent bone
  26467. * @param parent defines the parent (can be null if the bone is the root)
  26468. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26469. */
  26470. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26471. /**
  26472. * Gets the local matrix
  26473. * @returns a matrix
  26474. */
  26475. getLocalMatrix(): Matrix;
  26476. /**
  26477. * Gets the base matrix (initial matrix which remains unchanged)
  26478. * @returns a matrix
  26479. */
  26480. getBaseMatrix(): Matrix;
  26481. /**
  26482. * Gets the rest pose matrix
  26483. * @returns a matrix
  26484. */
  26485. getRestPose(): Matrix;
  26486. /**
  26487. * Sets the rest pose matrix
  26488. * @param matrix the local-space rest pose to set for this bone
  26489. */
  26490. setRestPose(matrix: Matrix): void;
  26491. /**
  26492. * Gets the bind pose matrix
  26493. * @returns the bind pose matrix
  26494. */
  26495. getBindPose(): Matrix;
  26496. /**
  26497. * Sets the bind pose matrix
  26498. * @param matrix the local-space bind pose to set for this bone
  26499. */
  26500. setBindPose(matrix: Matrix): void;
  26501. /**
  26502. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26503. */
  26504. getWorldMatrix(): Matrix;
  26505. /**
  26506. * Sets the local matrix to rest pose matrix
  26507. */
  26508. returnToRest(): void;
  26509. /**
  26510. * Gets the inverse of the absolute transform matrix.
  26511. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26512. * @returns a matrix
  26513. */
  26514. getInvertedAbsoluteTransform(): Matrix;
  26515. /**
  26516. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26517. * @returns a matrix
  26518. */
  26519. getAbsoluteTransform(): Matrix;
  26520. /**
  26521. * Links with the given transform node.
  26522. * The local matrix of this bone is copied from the transform node every frame.
  26523. * @param transformNode defines the transform node to link to
  26524. */
  26525. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26526. /**
  26527. * Gets the node used to drive the bone's transformation
  26528. * @returns a transform node or null
  26529. */
  26530. getTransformNode(): Nullable<TransformNode>;
  26531. /** Gets or sets current position (in local space) */
  26532. get position(): Vector3;
  26533. set position(newPosition: Vector3);
  26534. /** Gets or sets current rotation (in local space) */
  26535. get rotation(): Vector3;
  26536. set rotation(newRotation: Vector3);
  26537. /** Gets or sets current rotation quaternion (in local space) */
  26538. get rotationQuaternion(): Quaternion;
  26539. set rotationQuaternion(newRotation: Quaternion);
  26540. /** Gets or sets current scaling (in local space) */
  26541. get scaling(): Vector3;
  26542. set scaling(newScaling: Vector3);
  26543. /**
  26544. * Gets the animation properties override
  26545. */
  26546. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26547. private _decompose;
  26548. private _compose;
  26549. /**
  26550. * Update the base and local matrices
  26551. * @param matrix defines the new base or local matrix
  26552. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26553. * @param updateLocalMatrix defines if the local matrix should be updated
  26554. */
  26555. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26556. /** @hidden */
  26557. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26558. /**
  26559. * Flag the bone as dirty (Forcing it to update everything)
  26560. */
  26561. markAsDirty(): void;
  26562. /** @hidden */
  26563. _markAsDirtyAndCompose(): void;
  26564. private _markAsDirtyAndDecompose;
  26565. /**
  26566. * Translate the bone in local or world space
  26567. * @param vec The amount to translate the bone
  26568. * @param space The space that the translation is in
  26569. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26570. */
  26571. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26572. /**
  26573. * Set the postion of the bone in local or world space
  26574. * @param position The position to set the bone
  26575. * @param space The space that the position is in
  26576. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26577. */
  26578. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26579. /**
  26580. * Set the absolute position of the bone (world space)
  26581. * @param position The position to set the bone
  26582. * @param mesh The mesh that this bone is attached to
  26583. */
  26584. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26585. /**
  26586. * Scale the bone on the x, y and z axes (in local space)
  26587. * @param x The amount to scale the bone on the x axis
  26588. * @param y The amount to scale the bone on the y axis
  26589. * @param z The amount to scale the bone on the z axis
  26590. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26591. */
  26592. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26593. /**
  26594. * Set the bone scaling in local space
  26595. * @param scale defines the scaling vector
  26596. */
  26597. setScale(scale: Vector3): void;
  26598. /**
  26599. * Gets the current scaling in local space
  26600. * @returns the current scaling vector
  26601. */
  26602. getScale(): Vector3;
  26603. /**
  26604. * Gets the current scaling in local space and stores it in a target vector
  26605. * @param result defines the target vector
  26606. */
  26607. getScaleToRef(result: Vector3): void;
  26608. /**
  26609. * Set the yaw, pitch, and roll of the bone in local or world space
  26610. * @param yaw The rotation of the bone on the y axis
  26611. * @param pitch The rotation of the bone on the x axis
  26612. * @param roll The rotation of the bone on the z axis
  26613. * @param space The space that the axes of rotation are in
  26614. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26615. */
  26616. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26617. /**
  26618. * Add a rotation to the bone on an axis in local or world space
  26619. * @param axis The axis to rotate the bone on
  26620. * @param amount The amount to rotate the bone
  26621. * @param space The space that the axis is in
  26622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26623. */
  26624. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26625. /**
  26626. * Set the rotation of the bone to a particular axis angle in local or world space
  26627. * @param axis The axis to rotate the bone on
  26628. * @param angle The angle that the bone should be rotated to
  26629. * @param space The space that the axis is in
  26630. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26631. */
  26632. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26633. /**
  26634. * Set the euler rotation of the bone in local or world space
  26635. * @param rotation The euler rotation that the bone should be set to
  26636. * @param space The space that the rotation is in
  26637. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26638. */
  26639. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26640. /**
  26641. * Set the quaternion rotation of the bone in local or world space
  26642. * @param quat The quaternion rotation that the bone should be set to
  26643. * @param space The space that the rotation is in
  26644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26645. */
  26646. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26647. /**
  26648. * Set the rotation matrix of the bone in local or world space
  26649. * @param rotMat The rotation matrix that the bone should be set to
  26650. * @param space The space that the rotation is in
  26651. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26652. */
  26653. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26654. private _rotateWithMatrix;
  26655. private _getNegativeRotationToRef;
  26656. /**
  26657. * Get the position of the bone in local or world space
  26658. * @param space The space that the returned position is in
  26659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26660. * @returns The position of the bone
  26661. */
  26662. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26663. /**
  26664. * Copy the position of the bone to a vector3 in local or world space
  26665. * @param space The space that the returned position is in
  26666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26667. * @param result The vector3 to copy the position to
  26668. */
  26669. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26670. /**
  26671. * Get the absolute position of the bone (world space)
  26672. * @param mesh The mesh that this bone is attached to
  26673. * @returns The absolute position of the bone
  26674. */
  26675. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26676. /**
  26677. * Copy the absolute position of the bone (world space) to the result param
  26678. * @param mesh The mesh that this bone is attached to
  26679. * @param result The vector3 to copy the absolute position to
  26680. */
  26681. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26682. /**
  26683. * Compute the absolute transforms of this bone and its children
  26684. */
  26685. computeAbsoluteTransforms(): void;
  26686. /**
  26687. * Get the world direction from an axis that is in the local space of the bone
  26688. * @param localAxis The local direction that is used to compute the world direction
  26689. * @param mesh The mesh that this bone is attached to
  26690. * @returns The world direction
  26691. */
  26692. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26693. /**
  26694. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26695. * @param localAxis The local direction that is used to compute the world direction
  26696. * @param mesh The mesh that this bone is attached to
  26697. * @param result The vector3 that the world direction will be copied to
  26698. */
  26699. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26700. /**
  26701. * Get the euler rotation of the bone in local or world space
  26702. * @param space The space that the rotation should be in
  26703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26704. * @returns The euler rotation
  26705. */
  26706. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26707. /**
  26708. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26709. * @param space The space that the rotation should be in
  26710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26711. * @param result The vector3 that the rotation should be copied to
  26712. */
  26713. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26714. /**
  26715. * Get the quaternion rotation of the bone in either local or world space
  26716. * @param space The space that the rotation should be in
  26717. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26718. * @returns The quaternion rotation
  26719. */
  26720. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26721. /**
  26722. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26723. * @param space The space that the rotation should be in
  26724. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26725. * @param result The quaternion that the rotation should be copied to
  26726. */
  26727. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26728. /**
  26729. * Get the rotation matrix of the bone in local or world space
  26730. * @param space The space that the rotation should be in
  26731. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26732. * @returns The rotation matrix
  26733. */
  26734. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26735. /**
  26736. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26737. * @param space The space that the rotation should be in
  26738. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26739. * @param result The quaternion that the rotation should be copied to
  26740. */
  26741. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26742. /**
  26743. * Get the world position of a point that is in the local space of the bone
  26744. * @param position The local position
  26745. * @param mesh The mesh that this bone is attached to
  26746. * @returns The world position
  26747. */
  26748. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26749. /**
  26750. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26751. * @param position The local position
  26752. * @param mesh The mesh that this bone is attached to
  26753. * @param result The vector3 that the world position should be copied to
  26754. */
  26755. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26756. /**
  26757. * Get the local position of a point that is in world space
  26758. * @param position The world position
  26759. * @param mesh The mesh that this bone is attached to
  26760. * @returns The local position
  26761. */
  26762. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26763. /**
  26764. * Get the local position of a point that is in world space and copy it to the result param
  26765. * @param position The world position
  26766. * @param mesh The mesh that this bone is attached to
  26767. * @param result The vector3 that the local position should be copied to
  26768. */
  26769. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26770. /**
  26771. * Set the current local matrix as the restPose for this bone.
  26772. */
  26773. setCurrentPoseAsRest(): void;
  26774. }
  26775. }
  26776. declare module "babylonjs/Meshes/transformNode" {
  26777. import { DeepImmutable } from "babylonjs/types";
  26778. import { Observable } from "babylonjs/Misc/observable";
  26779. import { Nullable } from "babylonjs/types";
  26780. import { Camera } from "babylonjs/Cameras/camera";
  26781. import { Scene } from "babylonjs/scene";
  26782. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26783. import { Node } from "babylonjs/node";
  26784. import { Bone } from "babylonjs/Bones/bone";
  26785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26786. import { Space } from "babylonjs/Maths/math.axis";
  26787. /**
  26788. * 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.
  26789. * @see https://doc.babylonjs.com/how_to/transformnode
  26790. */
  26791. export class TransformNode extends Node {
  26792. /**
  26793. * Object will not rotate to face the camera
  26794. */
  26795. static BILLBOARDMODE_NONE: number;
  26796. /**
  26797. * Object will rotate to face the camera but only on the x axis
  26798. */
  26799. static BILLBOARDMODE_X: number;
  26800. /**
  26801. * Object will rotate to face the camera but only on the y axis
  26802. */
  26803. static BILLBOARDMODE_Y: number;
  26804. /**
  26805. * Object will rotate to face the camera but only on the z axis
  26806. */
  26807. static BILLBOARDMODE_Z: number;
  26808. /**
  26809. * Object will rotate to face the camera
  26810. */
  26811. static BILLBOARDMODE_ALL: number;
  26812. /**
  26813. * Object will rotate to face the camera's position instead of orientation
  26814. */
  26815. static BILLBOARDMODE_USE_POSITION: number;
  26816. private static _TmpRotation;
  26817. private static _TmpScaling;
  26818. private static _TmpTranslation;
  26819. private _forward;
  26820. private _forwardInverted;
  26821. private _up;
  26822. private _right;
  26823. private _rightInverted;
  26824. private _position;
  26825. private _rotation;
  26826. private _rotationQuaternion;
  26827. protected _scaling: Vector3;
  26828. protected _isDirty: boolean;
  26829. private _transformToBoneReferal;
  26830. private _isAbsoluteSynced;
  26831. private _billboardMode;
  26832. /**
  26833. * Gets or sets the billboard mode. Default is 0.
  26834. *
  26835. * | Value | Type | Description |
  26836. * | --- | --- | --- |
  26837. * | 0 | BILLBOARDMODE_NONE | |
  26838. * | 1 | BILLBOARDMODE_X | |
  26839. * | 2 | BILLBOARDMODE_Y | |
  26840. * | 4 | BILLBOARDMODE_Z | |
  26841. * | 7 | BILLBOARDMODE_ALL | |
  26842. *
  26843. */
  26844. get billboardMode(): number;
  26845. set billboardMode(value: number);
  26846. private _preserveParentRotationForBillboard;
  26847. /**
  26848. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26849. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26850. */
  26851. get preserveParentRotationForBillboard(): boolean;
  26852. set preserveParentRotationForBillboard(value: boolean);
  26853. /**
  26854. * 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
  26855. */
  26856. scalingDeterminant: number;
  26857. private _infiniteDistance;
  26858. /**
  26859. * Gets or sets the distance of the object to max, often used by skybox
  26860. */
  26861. get infiniteDistance(): boolean;
  26862. set infiniteDistance(value: boolean);
  26863. /**
  26864. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26865. * By default the system will update normals to compensate
  26866. */
  26867. ignoreNonUniformScaling: boolean;
  26868. /**
  26869. * 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
  26870. */
  26871. reIntegrateRotationIntoRotationQuaternion: boolean;
  26872. /** @hidden */
  26873. _poseMatrix: Nullable<Matrix>;
  26874. /** @hidden */
  26875. _localMatrix: Matrix;
  26876. private _usePivotMatrix;
  26877. private _absolutePosition;
  26878. private _absoluteScaling;
  26879. private _absoluteRotationQuaternion;
  26880. private _pivotMatrix;
  26881. private _pivotMatrixInverse;
  26882. /** @hidden */
  26883. _postMultiplyPivotMatrix: boolean;
  26884. protected _isWorldMatrixFrozen: boolean;
  26885. /** @hidden */
  26886. _indexInSceneTransformNodesArray: number;
  26887. /**
  26888. * An event triggered after the world matrix is updated
  26889. */
  26890. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26891. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26892. /**
  26893. * Gets a string identifying the name of the class
  26894. * @returns "TransformNode" string
  26895. */
  26896. getClassName(): string;
  26897. /**
  26898. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26899. */
  26900. get position(): Vector3;
  26901. set position(newPosition: Vector3);
  26902. /**
  26903. * 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)).
  26904. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26905. */
  26906. get rotation(): Vector3;
  26907. set rotation(newRotation: Vector3);
  26908. /**
  26909. * 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)).
  26910. */
  26911. get scaling(): Vector3;
  26912. set scaling(newScaling: Vector3);
  26913. /**
  26914. * 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).
  26915. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26916. */
  26917. get rotationQuaternion(): Nullable<Quaternion>;
  26918. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26919. /**
  26920. * The forward direction of that transform in world space.
  26921. */
  26922. get forward(): Vector3;
  26923. /**
  26924. * The up direction of that transform in world space.
  26925. */
  26926. get up(): Vector3;
  26927. /**
  26928. * The right direction of that transform in world space.
  26929. */
  26930. get right(): Vector3;
  26931. /**
  26932. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26933. * @param matrix the matrix to copy the pose from
  26934. * @returns this TransformNode.
  26935. */
  26936. updatePoseMatrix(matrix: Matrix): TransformNode;
  26937. /**
  26938. * Returns the mesh Pose matrix.
  26939. * @returns the pose matrix
  26940. */
  26941. getPoseMatrix(): Matrix;
  26942. /** @hidden */
  26943. _isSynchronized(): boolean;
  26944. /** @hidden */
  26945. _initCache(): void;
  26946. /**
  26947. * Flag the transform node as dirty (Forcing it to update everything)
  26948. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26949. * @returns this transform node
  26950. */
  26951. markAsDirty(property: string): TransformNode;
  26952. /**
  26953. * Returns the current mesh absolute position.
  26954. * Returns a Vector3.
  26955. */
  26956. get absolutePosition(): Vector3;
  26957. /**
  26958. * Returns the current mesh absolute scaling.
  26959. * Returns a Vector3.
  26960. */
  26961. get absoluteScaling(): Vector3;
  26962. /**
  26963. * Returns the current mesh absolute rotation.
  26964. * Returns a Quaternion.
  26965. */
  26966. get absoluteRotationQuaternion(): Quaternion;
  26967. /**
  26968. * Sets a new matrix to apply before all other transformation
  26969. * @param matrix defines the transform matrix
  26970. * @returns the current TransformNode
  26971. */
  26972. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26973. /**
  26974. * Sets a new pivot matrix to the current node
  26975. * @param matrix defines the new pivot matrix to use
  26976. * @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
  26977. * @returns the current TransformNode
  26978. */
  26979. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26980. /**
  26981. * Returns the mesh pivot matrix.
  26982. * Default : Identity.
  26983. * @returns the matrix
  26984. */
  26985. getPivotMatrix(): Matrix;
  26986. /**
  26987. * Instantiate (when possible) or clone that node with its hierarchy
  26988. * @param newParent defines the new parent to use for the instance (or clone)
  26989. * @param options defines options to configure how copy is done
  26990. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26991. * @returns an instance (or a clone) of the current node with its hiearchy
  26992. */
  26993. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26994. doNotInstantiate: boolean;
  26995. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26996. /**
  26997. * Prevents the World matrix to be computed any longer
  26998. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26999. * @returns the TransformNode.
  27000. */
  27001. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  27002. /**
  27003. * Allows back the World matrix computation.
  27004. * @returns the TransformNode.
  27005. */
  27006. unfreezeWorldMatrix(): this;
  27007. /**
  27008. * True if the World matrix has been frozen.
  27009. */
  27010. get isWorldMatrixFrozen(): boolean;
  27011. /**
  27012. * Retuns the mesh absolute position in the World.
  27013. * @returns a Vector3.
  27014. */
  27015. getAbsolutePosition(): Vector3;
  27016. /**
  27017. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  27018. * @param absolutePosition the absolute position to set
  27019. * @returns the TransformNode.
  27020. */
  27021. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27022. /**
  27023. * Sets the mesh position in its local space.
  27024. * @param vector3 the position to set in localspace
  27025. * @returns the TransformNode.
  27026. */
  27027. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  27028. /**
  27029. * Returns the mesh position in the local space from the current World matrix values.
  27030. * @returns a new Vector3.
  27031. */
  27032. getPositionExpressedInLocalSpace(): Vector3;
  27033. /**
  27034. * Translates the mesh along the passed Vector3 in its local space.
  27035. * @param vector3 the distance to translate in localspace
  27036. * @returns the TransformNode.
  27037. */
  27038. locallyTranslate(vector3: Vector3): TransformNode;
  27039. private static _lookAtVectorCache;
  27040. /**
  27041. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  27042. * @param targetPoint the position (must be in same space as current mesh) to look at
  27043. * @param yawCor optional yaw (y-axis) correction in radians
  27044. * @param pitchCor optional pitch (x-axis) correction in radians
  27045. * @param rollCor optional roll (z-axis) correction in radians
  27046. * @param space the choosen space of the target
  27047. * @returns the TransformNode.
  27048. */
  27049. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  27050. /**
  27051. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27052. * This Vector3 is expressed in the World space.
  27053. * @param localAxis axis to rotate
  27054. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  27055. */
  27056. getDirection(localAxis: Vector3): Vector3;
  27057. /**
  27058. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  27059. * localAxis is expressed in the mesh local space.
  27060. * result is computed in the Wordl space from the mesh World matrix.
  27061. * @param localAxis axis to rotate
  27062. * @param result the resulting transformnode
  27063. * @returns this TransformNode.
  27064. */
  27065. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  27066. /**
  27067. * Sets this transform node rotation to the given local axis.
  27068. * @param localAxis the axis in local space
  27069. * @param yawCor optional yaw (y-axis) correction in radians
  27070. * @param pitchCor optional pitch (x-axis) correction in radians
  27071. * @param rollCor optional roll (z-axis) correction in radians
  27072. * @returns this TransformNode
  27073. */
  27074. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  27075. /**
  27076. * Sets a new pivot point to the current node
  27077. * @param point defines the new pivot point to use
  27078. * @param space defines if the point is in world or local space (local by default)
  27079. * @returns the current TransformNode
  27080. */
  27081. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  27082. /**
  27083. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  27084. * @returns the pivot point
  27085. */
  27086. getPivotPoint(): Vector3;
  27087. /**
  27088. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  27089. * @param result the vector3 to store the result
  27090. * @returns this TransformNode.
  27091. */
  27092. getPivotPointToRef(result: Vector3): TransformNode;
  27093. /**
  27094. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  27095. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  27096. */
  27097. getAbsolutePivotPoint(): Vector3;
  27098. /**
  27099. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  27100. * @param result vector3 to store the result
  27101. * @returns this TransformNode.
  27102. */
  27103. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  27104. /**
  27105. * Defines the passed node as the parent of the current node.
  27106. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  27107. * @see https://doc.babylonjs.com/how_to/parenting
  27108. * @param node the node ot set as the parent
  27109. * @returns this TransformNode.
  27110. */
  27111. setParent(node: Nullable<Node>): TransformNode;
  27112. private _nonUniformScaling;
  27113. /**
  27114. * True if the scaling property of this object is non uniform eg. (1,2,1)
  27115. */
  27116. get nonUniformScaling(): boolean;
  27117. /** @hidden */
  27118. _updateNonUniformScalingState(value: boolean): boolean;
  27119. /**
  27120. * Attach the current TransformNode to another TransformNode associated with a bone
  27121. * @param bone Bone affecting the TransformNode
  27122. * @param affectedTransformNode TransformNode associated with the bone
  27123. * @returns this object
  27124. */
  27125. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  27126. /**
  27127. * Detach the transform node if its associated with a bone
  27128. * @returns this object
  27129. */
  27130. detachFromBone(): TransformNode;
  27131. private static _rotationAxisCache;
  27132. /**
  27133. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  27134. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27135. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27136. * The passed axis is also normalized.
  27137. * @param axis the axis to rotate around
  27138. * @param amount the amount to rotate in radians
  27139. * @param space Space to rotate in (Default: local)
  27140. * @returns the TransformNode.
  27141. */
  27142. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27143. /**
  27144. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  27145. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  27146. * The passed axis is also normalized. .
  27147. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  27148. * @param point the point to rotate around
  27149. * @param axis the axis to rotate around
  27150. * @param amount the amount to rotate in radians
  27151. * @returns the TransformNode
  27152. */
  27153. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  27154. /**
  27155. * Translates the mesh along the axis vector for the passed distance in the given space.
  27156. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  27157. * @param axis the axis to translate in
  27158. * @param distance the distance to translate
  27159. * @param space Space to rotate in (Default: local)
  27160. * @returns the TransformNode.
  27161. */
  27162. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27163. /**
  27164. * Adds a rotation step to the mesh current rotation.
  27165. * x, y, z are Euler angles expressed in radians.
  27166. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  27167. * This means this rotation is made in the mesh local space only.
  27168. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  27169. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  27170. * ```javascript
  27171. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  27172. * ```
  27173. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  27174. * 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.
  27175. * @param x Rotation to add
  27176. * @param y Rotation to add
  27177. * @param z Rotation to add
  27178. * @returns the TransformNode.
  27179. */
  27180. addRotation(x: number, y: number, z: number): TransformNode;
  27181. /**
  27182. * @hidden
  27183. */
  27184. protected _getEffectiveParent(): Nullable<Node>;
  27185. /**
  27186. * Computes the world matrix of the node
  27187. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27188. * @returns the world matrix
  27189. */
  27190. computeWorldMatrix(force?: boolean): Matrix;
  27191. /**
  27192. * Resets this nodeTransform's local matrix to Matrix.Identity().
  27193. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  27194. */
  27195. resetLocalMatrix(independentOfChildren?: boolean): void;
  27196. protected _afterComputeWorldMatrix(): void;
  27197. /**
  27198. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  27199. * @param func callback function to add
  27200. *
  27201. * @returns the TransformNode.
  27202. */
  27203. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27204. /**
  27205. * Removes a registered callback function.
  27206. * @param func callback function to remove
  27207. * @returns the TransformNode.
  27208. */
  27209. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  27210. /**
  27211. * Gets the position of the current mesh in camera space
  27212. * @param camera defines the camera to use
  27213. * @returns a position
  27214. */
  27215. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  27216. /**
  27217. * Returns the distance from the mesh to the active camera
  27218. * @param camera defines the camera to use
  27219. * @returns the distance
  27220. */
  27221. getDistanceToCamera(camera?: Nullable<Camera>): number;
  27222. /**
  27223. * Clone the current transform node
  27224. * @param name Name of the new clone
  27225. * @param newParent New parent for the clone
  27226. * @param doNotCloneChildren Do not clone children hierarchy
  27227. * @returns the new transform node
  27228. */
  27229. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  27230. /**
  27231. * Serializes the objects information.
  27232. * @param currentSerializationObject defines the object to serialize in
  27233. * @returns the serialized object
  27234. */
  27235. serialize(currentSerializationObject?: any): any;
  27236. /**
  27237. * Returns a new TransformNode object parsed from the source provided.
  27238. * @param parsedTransformNode is the source.
  27239. * @param scene the scne the object belongs to
  27240. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  27241. * @returns a new TransformNode object parsed from the source provided.
  27242. */
  27243. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  27244. /**
  27245. * Get all child-transformNodes of this node
  27246. * @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
  27247. * @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
  27248. * @returns an array of TransformNode
  27249. */
  27250. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  27251. /**
  27252. * Releases resources associated with this transform node.
  27253. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27254. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27255. */
  27256. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27257. /**
  27258. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27259. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27260. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27261. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27262. * @returns the current mesh
  27263. */
  27264. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27265. private _syncAbsoluteScalingAndRotation;
  27266. }
  27267. }
  27268. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  27269. import { Observable } from "babylonjs/Misc/observable";
  27270. import { Nullable } from "babylonjs/types";
  27271. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27272. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27274. import { Ray } from "babylonjs/Culling/ray";
  27275. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  27276. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  27277. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  27278. /**
  27279. * Defines the types of pose enabled controllers that are supported
  27280. */
  27281. export enum PoseEnabledControllerType {
  27282. /**
  27283. * HTC Vive
  27284. */
  27285. VIVE = 0,
  27286. /**
  27287. * Oculus Rift
  27288. */
  27289. OCULUS = 1,
  27290. /**
  27291. * Windows mixed reality
  27292. */
  27293. WINDOWS = 2,
  27294. /**
  27295. * Samsung gear VR
  27296. */
  27297. GEAR_VR = 3,
  27298. /**
  27299. * Google Daydream
  27300. */
  27301. DAYDREAM = 4,
  27302. /**
  27303. * Generic
  27304. */
  27305. GENERIC = 5
  27306. }
  27307. /**
  27308. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27309. */
  27310. export interface MutableGamepadButton {
  27311. /**
  27312. * Value of the button/trigger
  27313. */
  27314. value: number;
  27315. /**
  27316. * If the button/trigger is currently touched
  27317. */
  27318. touched: boolean;
  27319. /**
  27320. * If the button/trigger is currently pressed
  27321. */
  27322. pressed: boolean;
  27323. }
  27324. /**
  27325. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27326. * @hidden
  27327. */
  27328. export interface ExtendedGamepadButton extends GamepadButton {
  27329. /**
  27330. * If the button/trigger is currently pressed
  27331. */
  27332. readonly pressed: boolean;
  27333. /**
  27334. * If the button/trigger is currently touched
  27335. */
  27336. readonly touched: boolean;
  27337. /**
  27338. * Value of the button/trigger
  27339. */
  27340. readonly value: number;
  27341. }
  27342. /** @hidden */
  27343. export interface _GamePadFactory {
  27344. /**
  27345. * Returns whether or not the current gamepad can be created for this type of controller.
  27346. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27347. * @returns true if it can be created, otherwise false
  27348. */
  27349. canCreate(gamepadInfo: any): boolean;
  27350. /**
  27351. * Creates a new instance of the Gamepad.
  27352. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27353. * @returns the new gamepad instance
  27354. */
  27355. create(gamepadInfo: any): Gamepad;
  27356. }
  27357. /**
  27358. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27359. */
  27360. export class PoseEnabledControllerHelper {
  27361. /** @hidden */
  27362. static _ControllerFactories: _GamePadFactory[];
  27363. /** @hidden */
  27364. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27365. /**
  27366. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27367. * @param vrGamepad the gamepad to initialized
  27368. * @returns a vr controller of the type the gamepad identified as
  27369. */
  27370. static InitiateController(vrGamepad: any): Gamepad;
  27371. }
  27372. /**
  27373. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27374. */
  27375. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27376. /**
  27377. * If the controller is used in a webXR session
  27378. */
  27379. isXR: boolean;
  27380. private _deviceRoomPosition;
  27381. private _deviceRoomRotationQuaternion;
  27382. /**
  27383. * The device position in babylon space
  27384. */
  27385. devicePosition: Vector3;
  27386. /**
  27387. * The device rotation in babylon space
  27388. */
  27389. deviceRotationQuaternion: Quaternion;
  27390. /**
  27391. * The scale factor of the device in babylon space
  27392. */
  27393. deviceScaleFactor: number;
  27394. /**
  27395. * (Likely devicePosition should be used instead) The device position in its room space
  27396. */
  27397. position: Vector3;
  27398. /**
  27399. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27400. */
  27401. rotationQuaternion: Quaternion;
  27402. /**
  27403. * The type of controller (Eg. Windows mixed reality)
  27404. */
  27405. controllerType: PoseEnabledControllerType;
  27406. protected _calculatedPosition: Vector3;
  27407. private _calculatedRotation;
  27408. /**
  27409. * The raw pose from the device
  27410. */
  27411. rawPose: DevicePose;
  27412. private _trackPosition;
  27413. private _maxRotationDistFromHeadset;
  27414. private _draggedRoomRotation;
  27415. /**
  27416. * @hidden
  27417. */
  27418. _disableTrackPosition(fixedPosition: Vector3): void;
  27419. /**
  27420. * Internal, the mesh attached to the controller
  27421. * @hidden
  27422. */
  27423. _mesh: Nullable<AbstractMesh>;
  27424. private _poseControlledCamera;
  27425. private _leftHandSystemQuaternion;
  27426. /**
  27427. * Internal, matrix used to convert room space to babylon space
  27428. * @hidden
  27429. */
  27430. _deviceToWorld: Matrix;
  27431. /**
  27432. * Node to be used when casting a ray from the controller
  27433. * @hidden
  27434. */
  27435. _pointingPoseNode: Nullable<TransformNode>;
  27436. /**
  27437. * Name of the child mesh that can be used to cast a ray from the controller
  27438. */
  27439. static readonly POINTING_POSE: string;
  27440. /**
  27441. * Creates a new PoseEnabledController from a gamepad
  27442. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27443. */
  27444. constructor(browserGamepad: any);
  27445. private _workingMatrix;
  27446. /**
  27447. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27448. */
  27449. update(): void;
  27450. /**
  27451. * Updates only the pose device and mesh without doing any button event checking
  27452. */
  27453. protected _updatePoseAndMesh(): void;
  27454. /**
  27455. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27456. * @param poseData raw pose fromthe device
  27457. */
  27458. updateFromDevice(poseData: DevicePose): void;
  27459. /**
  27460. * @hidden
  27461. */
  27462. _meshAttachedObservable: Observable<AbstractMesh>;
  27463. /**
  27464. * Attaches a mesh to the controller
  27465. * @param mesh the mesh to be attached
  27466. */
  27467. attachToMesh(mesh: AbstractMesh): void;
  27468. /**
  27469. * Attaches the controllers mesh to a camera
  27470. * @param camera the camera the mesh should be attached to
  27471. */
  27472. attachToPoseControlledCamera(camera: TargetCamera): void;
  27473. /**
  27474. * Disposes of the controller
  27475. */
  27476. dispose(): void;
  27477. /**
  27478. * The mesh that is attached to the controller
  27479. */
  27480. get mesh(): Nullable<AbstractMesh>;
  27481. /**
  27482. * Gets the ray of the controller in the direction the controller is pointing
  27483. * @param length the length the resulting ray should be
  27484. * @returns a ray in the direction the controller is pointing
  27485. */
  27486. getForwardRay(length?: number): Ray;
  27487. }
  27488. }
  27489. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  27490. import { Observable } from "babylonjs/Misc/observable";
  27491. import { Scene } from "babylonjs/scene";
  27492. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27493. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  27494. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  27495. import { Nullable } from "babylonjs/types";
  27496. /**
  27497. * Defines the WebVRController object that represents controllers tracked in 3D space
  27498. */
  27499. export abstract class WebVRController extends PoseEnabledController {
  27500. /**
  27501. * Internal, the default controller model for the controller
  27502. */
  27503. protected _defaultModel: Nullable<AbstractMesh>;
  27504. /**
  27505. * Fired when the trigger state has changed
  27506. */
  27507. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27508. /**
  27509. * Fired when the main button state has changed
  27510. */
  27511. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27512. /**
  27513. * Fired when the secondary button state has changed
  27514. */
  27515. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27516. /**
  27517. * Fired when the pad state has changed
  27518. */
  27519. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27520. /**
  27521. * Fired when controllers stick values have changed
  27522. */
  27523. onPadValuesChangedObservable: Observable<StickValues>;
  27524. /**
  27525. * Array of button availible on the controller
  27526. */
  27527. protected _buttons: Array<MutableGamepadButton>;
  27528. private _onButtonStateChange;
  27529. /**
  27530. * Fired when a controller button's state has changed
  27531. * @param callback the callback containing the button that was modified
  27532. */
  27533. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27534. /**
  27535. * X and Y axis corresponding to the controllers joystick
  27536. */
  27537. pad: StickValues;
  27538. /**
  27539. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27540. */
  27541. hand: string;
  27542. /**
  27543. * The default controller model for the controller
  27544. */
  27545. get defaultModel(): Nullable<AbstractMesh>;
  27546. /**
  27547. * Creates a new WebVRController from a gamepad
  27548. * @param vrGamepad the gamepad that the WebVRController should be created from
  27549. */
  27550. constructor(vrGamepad: any);
  27551. /**
  27552. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27553. */
  27554. update(): void;
  27555. /**
  27556. * Function to be called when a button is modified
  27557. */
  27558. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27559. /**
  27560. * Loads a mesh and attaches it to the controller
  27561. * @param scene the scene the mesh should be added to
  27562. * @param meshLoaded callback for when the mesh has been loaded
  27563. */
  27564. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27565. private _setButtonValue;
  27566. private _changes;
  27567. private _checkChanges;
  27568. /**
  27569. * Disposes of th webVRCOntroller
  27570. */
  27571. dispose(): void;
  27572. }
  27573. }
  27574. declare module "babylonjs/Lights/hemisphericLight" {
  27575. import { Nullable } from "babylonjs/types";
  27576. import { Scene } from "babylonjs/scene";
  27577. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27578. import { Color3 } from "babylonjs/Maths/math.color";
  27579. import { Effect } from "babylonjs/Materials/effect";
  27580. import { Light } from "babylonjs/Lights/light";
  27581. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  27582. /**
  27583. * The HemisphericLight simulates the ambient environment light,
  27584. * so the passed direction is the light reflection direction, not the incoming direction.
  27585. */
  27586. export class HemisphericLight extends Light {
  27587. /**
  27588. * The groundColor is the light in the opposite direction to the one specified during creation.
  27589. * 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.
  27590. */
  27591. groundColor: Color3;
  27592. /**
  27593. * The light reflection direction, not the incoming direction.
  27594. */
  27595. direction: Vector3;
  27596. /**
  27597. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27598. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27599. * The HemisphericLight can't cast shadows.
  27600. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27601. * @param name The friendly name of the light
  27602. * @param direction The direction of the light reflection
  27603. * @param scene The scene the light belongs to
  27604. */
  27605. constructor(name: string, direction: Vector3, scene: Scene);
  27606. protected _buildUniformLayout(): void;
  27607. /**
  27608. * Returns the string "HemisphericLight".
  27609. * @return The class name
  27610. */
  27611. getClassName(): string;
  27612. /**
  27613. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27614. * Returns the updated direction.
  27615. * @param target The target the direction should point to
  27616. * @return The computed direction
  27617. */
  27618. setDirectionToTarget(target: Vector3): Vector3;
  27619. /**
  27620. * Returns the shadow generator associated to the light.
  27621. * @returns Always null for hemispheric lights because it does not support shadows.
  27622. */
  27623. getShadowGenerator(): Nullable<IShadowGenerator>;
  27624. /**
  27625. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27626. * @param effect The effect to update
  27627. * @param lightIndex The index of the light in the effect to update
  27628. * @returns The hemispheric light
  27629. */
  27630. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27631. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27632. /**
  27633. * Computes the world matrix of the node
  27634. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27635. * @param useWasUpdatedFlag defines a reserved property
  27636. * @returns the world matrix
  27637. */
  27638. computeWorldMatrix(): Matrix;
  27639. /**
  27640. * Returns the integer 3.
  27641. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27642. */
  27643. getTypeID(): number;
  27644. /**
  27645. * Prepares the list of defines specific to the light type.
  27646. * @param defines the list of defines
  27647. * @param lightIndex defines the index of the light for the effect
  27648. */
  27649. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27650. }
  27651. }
  27652. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  27653. /** @hidden */
  27654. export var vrMultiviewToSingleviewPixelShader: {
  27655. name: string;
  27656. shader: string;
  27657. };
  27658. }
  27659. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  27660. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27661. import { Scene } from "babylonjs/scene";
  27662. /**
  27663. * Renders to multiple views with a single draw call
  27664. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27665. */
  27666. export class MultiviewRenderTarget extends RenderTargetTexture {
  27667. /**
  27668. * Creates a multiview render target
  27669. * @param scene scene used with the render target
  27670. * @param size the size of the render target (used for each view)
  27671. */
  27672. constructor(scene: Scene, size?: number | {
  27673. width: number;
  27674. height: number;
  27675. } | {
  27676. ratio: number;
  27677. });
  27678. /**
  27679. * @hidden
  27680. * @param faceIndex the face index, if its a cube texture
  27681. */
  27682. _bindFrameBuffer(faceIndex?: number): void;
  27683. /**
  27684. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27685. * @returns the view count
  27686. */
  27687. getViewCount(): number;
  27688. }
  27689. }
  27690. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  27691. import { Camera } from "babylonjs/Cameras/camera";
  27692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27693. import { Nullable } from "babylonjs/types";
  27694. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27695. import { Matrix } from "babylonjs/Maths/math.vector";
  27696. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27697. module "babylonjs/Engines/engine" {
  27698. interface Engine {
  27699. /**
  27700. * Creates a new multiview render target
  27701. * @param width defines the width of the texture
  27702. * @param height defines the height of the texture
  27703. * @returns the created multiview texture
  27704. */
  27705. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27706. /**
  27707. * Binds a multiview framebuffer to be drawn to
  27708. * @param multiviewTexture texture to bind
  27709. */
  27710. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27711. }
  27712. }
  27713. module "babylonjs/Cameras/camera" {
  27714. interface Camera {
  27715. /**
  27716. * @hidden
  27717. * 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)
  27718. */
  27719. _useMultiviewToSingleView: boolean;
  27720. /**
  27721. * @hidden
  27722. * 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)
  27723. */
  27724. _multiviewTexture: Nullable<RenderTargetTexture>;
  27725. /**
  27726. * @hidden
  27727. * ensures the multiview texture of the camera exists and has the specified width/height
  27728. * @param width height to set on the multiview texture
  27729. * @param height width to set on the multiview texture
  27730. */
  27731. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27732. }
  27733. }
  27734. module "babylonjs/scene" {
  27735. interface Scene {
  27736. /** @hidden */
  27737. _transformMatrixR: Matrix;
  27738. /** @hidden */
  27739. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27740. /** @hidden */
  27741. _createMultiviewUbo(): void;
  27742. /** @hidden */
  27743. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27744. /** @hidden */
  27745. _renderMultiviewToSingleView(camera: Camera): void;
  27746. }
  27747. }
  27748. }
  27749. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  27750. import { Camera } from "babylonjs/Cameras/camera";
  27751. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27752. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  27753. import "babylonjs/Engines/Extensions/engine.multiview";
  27754. /**
  27755. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27756. * This will not be used for webXR as it supports displaying texture arrays directly
  27757. */
  27758. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27759. /**
  27760. * Gets a string identifying the name of the class
  27761. * @returns "VRMultiviewToSingleviewPostProcess" string
  27762. */
  27763. getClassName(): string;
  27764. /**
  27765. * Initializes a VRMultiviewToSingleview
  27766. * @param name name of the post process
  27767. * @param camera camera to be applied to
  27768. * @param scaleFactor scaling factor to the size of the output texture
  27769. */
  27770. constructor(name: string, camera: Camera, scaleFactor: number);
  27771. }
  27772. }
  27773. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  27774. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  27775. import { Nullable } from "babylonjs/types";
  27776. import { Size } from "babylonjs/Maths/math.size";
  27777. import { Observable } from "babylonjs/Misc/observable";
  27778. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  27779. /**
  27780. * Interface used to define additional presentation attributes
  27781. */
  27782. export interface IVRPresentationAttributes {
  27783. /**
  27784. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27785. */
  27786. highRefreshRate: boolean;
  27787. /**
  27788. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27789. */
  27790. foveationLevel: number;
  27791. }
  27792. module "babylonjs/Engines/engine" {
  27793. interface Engine {
  27794. /** @hidden */
  27795. _vrDisplay: any;
  27796. /** @hidden */
  27797. _vrSupported: boolean;
  27798. /** @hidden */
  27799. _oldSize: Size;
  27800. /** @hidden */
  27801. _oldHardwareScaleFactor: number;
  27802. /** @hidden */
  27803. _vrExclusivePointerMode: boolean;
  27804. /** @hidden */
  27805. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27806. /** @hidden */
  27807. _onVRDisplayPointerRestricted: () => void;
  27808. /** @hidden */
  27809. _onVRDisplayPointerUnrestricted: () => void;
  27810. /** @hidden */
  27811. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27812. /** @hidden */
  27813. _onVrDisplayDisconnect: Nullable<() => void>;
  27814. /** @hidden */
  27815. _onVrDisplayPresentChange: Nullable<() => void>;
  27816. /**
  27817. * Observable signaled when VR display mode changes
  27818. */
  27819. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27820. /**
  27821. * Observable signaled when VR request present is complete
  27822. */
  27823. onVRRequestPresentComplete: Observable<boolean>;
  27824. /**
  27825. * Observable signaled when VR request present starts
  27826. */
  27827. onVRRequestPresentStart: Observable<Engine>;
  27828. /**
  27829. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27830. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27831. */
  27832. isInVRExclusivePointerMode: boolean;
  27833. /**
  27834. * Gets a boolean indicating if a webVR device was detected
  27835. * @returns true if a webVR device was detected
  27836. */
  27837. isVRDevicePresent(): boolean;
  27838. /**
  27839. * Gets the current webVR device
  27840. * @returns the current webVR device (or null)
  27841. */
  27842. getVRDevice(): any;
  27843. /**
  27844. * Initializes a webVR display and starts listening to display change events
  27845. * The onVRDisplayChangedObservable will be notified upon these changes
  27846. * @returns A promise containing a VRDisplay and if vr is supported
  27847. */
  27848. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27849. /** @hidden */
  27850. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27851. /**
  27852. * Gets or sets the presentation attributes used to configure VR rendering
  27853. */
  27854. vrPresentationAttributes?: IVRPresentationAttributes;
  27855. /**
  27856. * Call this function to switch to webVR mode
  27857. * Will do nothing if webVR is not supported or if there is no webVR device
  27858. * @param options the webvr options provided to the camera. mainly used for multiview
  27859. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27860. */
  27861. enableVR(options: WebVROptions): void;
  27862. /** @hidden */
  27863. _onVRFullScreenTriggered(): void;
  27864. }
  27865. }
  27866. }
  27867. declare module "babylonjs/Cameras/VR/webVRCamera" {
  27868. import { Nullable } from "babylonjs/types";
  27869. import { Observable } from "babylonjs/Misc/observable";
  27870. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  27871. import { Scene } from "babylonjs/scene";
  27872. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27873. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  27874. import { Node } from "babylonjs/node";
  27875. import { Ray } from "babylonjs/Culling/ray";
  27876. import "babylonjs/Cameras/RigModes/webVRRigMode";
  27877. import "babylonjs/Engines/Extensions/engine.webVR";
  27878. /**
  27879. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27880. * IMPORTANT!! The data is right-hand data.
  27881. * @export
  27882. * @interface DevicePose
  27883. */
  27884. export interface DevicePose {
  27885. /**
  27886. * The position of the device, values in array are [x,y,z].
  27887. */
  27888. readonly position: Nullable<Float32Array>;
  27889. /**
  27890. * The linearVelocity of the device, values in array are [x,y,z].
  27891. */
  27892. readonly linearVelocity: Nullable<Float32Array>;
  27893. /**
  27894. * The linearAcceleration of the device, values in array are [x,y,z].
  27895. */
  27896. readonly linearAcceleration: Nullable<Float32Array>;
  27897. /**
  27898. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27899. */
  27900. readonly orientation: Nullable<Float32Array>;
  27901. /**
  27902. * The angularVelocity of the device, values in array are [x,y,z].
  27903. */
  27904. readonly angularVelocity: Nullable<Float32Array>;
  27905. /**
  27906. * The angularAcceleration of the device, values in array are [x,y,z].
  27907. */
  27908. readonly angularAcceleration: Nullable<Float32Array>;
  27909. }
  27910. /**
  27911. * Interface representing a pose controlled object in Babylon.
  27912. * A pose controlled object has both regular pose values as well as pose values
  27913. * from an external device such as a VR head mounted display
  27914. */
  27915. export interface PoseControlled {
  27916. /**
  27917. * The position of the object in babylon space.
  27918. */
  27919. position: Vector3;
  27920. /**
  27921. * The rotation quaternion of the object in babylon space.
  27922. */
  27923. rotationQuaternion: Quaternion;
  27924. /**
  27925. * The position of the device in babylon space.
  27926. */
  27927. devicePosition?: Vector3;
  27928. /**
  27929. * The rotation quaternion of the device in babylon space.
  27930. */
  27931. deviceRotationQuaternion: Quaternion;
  27932. /**
  27933. * The raw pose coming from the device.
  27934. */
  27935. rawPose: Nullable<DevicePose>;
  27936. /**
  27937. * The scale of the device to be used when translating from device space to babylon space.
  27938. */
  27939. deviceScaleFactor: number;
  27940. /**
  27941. * Updates the poseControlled values based on the input device pose.
  27942. * @param poseData the pose data to update the object with
  27943. */
  27944. updateFromDevice(poseData: DevicePose): void;
  27945. }
  27946. /**
  27947. * Set of options to customize the webVRCamera
  27948. */
  27949. export interface WebVROptions {
  27950. /**
  27951. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27952. */
  27953. trackPosition?: boolean;
  27954. /**
  27955. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27956. */
  27957. positionScale?: number;
  27958. /**
  27959. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27960. */
  27961. displayName?: string;
  27962. /**
  27963. * Should the native controller meshes be initialized. (default: true)
  27964. */
  27965. controllerMeshes?: boolean;
  27966. /**
  27967. * Creating a default HemiLight only on controllers. (default: true)
  27968. */
  27969. defaultLightingOnControllers?: boolean;
  27970. /**
  27971. * If you don't want to use the default VR button of the helper. (default: false)
  27972. */
  27973. useCustomVRButton?: boolean;
  27974. /**
  27975. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27976. */
  27977. customVRButton?: HTMLButtonElement;
  27978. /**
  27979. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27980. */
  27981. rayLength?: number;
  27982. /**
  27983. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27984. */
  27985. defaultHeight?: number;
  27986. /**
  27987. * If multiview should be used if availible (default: false)
  27988. */
  27989. useMultiview?: boolean;
  27990. }
  27991. /**
  27992. * This represents a WebVR camera.
  27993. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27994. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27995. */
  27996. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27997. private webVROptions;
  27998. /**
  27999. * @hidden
  28000. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  28001. */
  28002. _vrDevice: any;
  28003. /**
  28004. * The rawPose of the vrDevice.
  28005. */
  28006. rawPose: Nullable<DevicePose>;
  28007. private _onVREnabled;
  28008. private _specsVersion;
  28009. private _attached;
  28010. private _frameData;
  28011. protected _descendants: Array<Node>;
  28012. private _deviceRoomPosition;
  28013. /** @hidden */
  28014. _deviceRoomRotationQuaternion: Quaternion;
  28015. private _standingMatrix;
  28016. /**
  28017. * Represents device position in babylon space.
  28018. */
  28019. devicePosition: Vector3;
  28020. /**
  28021. * Represents device rotation in babylon space.
  28022. */
  28023. deviceRotationQuaternion: Quaternion;
  28024. /**
  28025. * The scale of the device to be used when translating from device space to babylon space.
  28026. */
  28027. deviceScaleFactor: number;
  28028. private _deviceToWorld;
  28029. private _worldToDevice;
  28030. /**
  28031. * References to the webVR controllers for the vrDevice.
  28032. */
  28033. controllers: Array<WebVRController>;
  28034. /**
  28035. * Emits an event when a controller is attached.
  28036. */
  28037. onControllersAttachedObservable: Observable<WebVRController[]>;
  28038. /**
  28039. * Emits an event when a controller's mesh has been loaded;
  28040. */
  28041. onControllerMeshLoadedObservable: Observable<WebVRController>;
  28042. /**
  28043. * Emits an event when the HMD's pose has been updated.
  28044. */
  28045. onPoseUpdatedFromDeviceObservable: Observable<any>;
  28046. private _poseSet;
  28047. /**
  28048. * If the rig cameras be used as parent instead of this camera.
  28049. */
  28050. rigParenting: boolean;
  28051. private _lightOnControllers;
  28052. private _defaultHeight?;
  28053. /**
  28054. * Instantiates a WebVRFreeCamera.
  28055. * @param name The name of the WebVRFreeCamera
  28056. * @param position The starting anchor position for the camera
  28057. * @param scene The scene the camera belongs to
  28058. * @param webVROptions a set of customizable options for the webVRCamera
  28059. */
  28060. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  28061. /**
  28062. * Gets the device distance from the ground in meters.
  28063. * @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.
  28064. */
  28065. deviceDistanceToRoomGround(): number;
  28066. /**
  28067. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28068. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  28069. */
  28070. useStandingMatrix(callback?: (bool: boolean) => void): void;
  28071. /**
  28072. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  28073. * @returns A promise with a boolean set to if the standing matrix is supported.
  28074. */
  28075. useStandingMatrixAsync(): Promise<boolean>;
  28076. /**
  28077. * Disposes the camera
  28078. */
  28079. dispose(): void;
  28080. /**
  28081. * Gets a vrController by name.
  28082. * @param name The name of the controller to retreive
  28083. * @returns the controller matching the name specified or null if not found
  28084. */
  28085. getControllerByName(name: string): Nullable<WebVRController>;
  28086. private _leftController;
  28087. /**
  28088. * The controller corresponding to the users left hand.
  28089. */
  28090. get leftController(): Nullable<WebVRController>;
  28091. private _rightController;
  28092. /**
  28093. * The controller corresponding to the users right hand.
  28094. */
  28095. get rightController(): Nullable<WebVRController>;
  28096. /**
  28097. * Casts a ray forward from the vrCamera's gaze.
  28098. * @param length Length of the ray (default: 100)
  28099. * @returns the ray corresponding to the gaze
  28100. */
  28101. getForwardRay(length?: number): Ray;
  28102. /**
  28103. * @hidden
  28104. * Updates the camera based on device's frame data
  28105. */
  28106. _checkInputs(): void;
  28107. /**
  28108. * Updates the poseControlled values based on the input device pose.
  28109. * @param poseData Pose coming from the device
  28110. */
  28111. updateFromDevice(poseData: DevicePose): void;
  28112. private _detachIfAttached;
  28113. /**
  28114. * WebVR's attach control will start broadcasting frames to the device.
  28115. * Note that in certain browsers (chrome for example) this function must be called
  28116. * within a user-interaction callback. Example:
  28117. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  28118. *
  28119. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  28120. */
  28121. attachControl(noPreventDefault?: boolean): void;
  28122. /**
  28123. * Detach the current controls from the specified dom element.
  28124. */
  28125. detachControl(): void;
  28126. /**
  28127. * @returns the name of this class
  28128. */
  28129. getClassName(): string;
  28130. /**
  28131. * Calls resetPose on the vrDisplay
  28132. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  28133. */
  28134. resetToCurrentRotation(): void;
  28135. /**
  28136. * @hidden
  28137. * Updates the rig cameras (left and right eye)
  28138. */
  28139. _updateRigCameras(): void;
  28140. private _workingVector;
  28141. private _oneVector;
  28142. private _workingMatrix;
  28143. private updateCacheCalled;
  28144. private _correctPositionIfNotTrackPosition;
  28145. /**
  28146. * @hidden
  28147. * Updates the cached values of the camera
  28148. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  28149. */
  28150. _updateCache(ignoreParentClass?: boolean): void;
  28151. /**
  28152. * @hidden
  28153. * Get current device position in babylon world
  28154. */
  28155. _computeDevicePosition(): void;
  28156. /**
  28157. * Updates the current device position and rotation in the babylon world
  28158. */
  28159. update(): void;
  28160. /**
  28161. * @hidden
  28162. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  28163. * @returns an identity matrix
  28164. */
  28165. _getViewMatrix(): Matrix;
  28166. private _tmpMatrix;
  28167. /**
  28168. * This function is called by the two RIG cameras.
  28169. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  28170. * @hidden
  28171. */
  28172. _getWebVRViewMatrix(): Matrix;
  28173. /** @hidden */
  28174. _getWebVRProjectionMatrix(): Matrix;
  28175. private _onGamepadConnectedObserver;
  28176. private _onGamepadDisconnectedObserver;
  28177. private _updateCacheWhenTrackingDisabledObserver;
  28178. /**
  28179. * Initializes the controllers and their meshes
  28180. */
  28181. initControllers(): void;
  28182. }
  28183. }
  28184. declare module "babylonjs/Materials/materialHelper" {
  28185. import { Nullable } from "babylonjs/types";
  28186. import { Scene } from "babylonjs/scene";
  28187. import { Engine } from "babylonjs/Engines/engine";
  28188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28189. import { Light } from "babylonjs/Lights/light";
  28190. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  28191. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28192. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  28193. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28194. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  28195. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  28196. /**
  28197. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  28198. *
  28199. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  28200. *
  28201. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  28202. */
  28203. export class MaterialHelper {
  28204. /**
  28205. * Bind the current view position to an effect.
  28206. * @param effect The effect to be bound
  28207. * @param scene The scene the eyes position is used from
  28208. * @param variableName name of the shader variable that will hold the eye position
  28209. */
  28210. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  28211. /**
  28212. * Helps preparing the defines values about the UVs in used in the effect.
  28213. * UVs are shared as much as we can accross channels in the shaders.
  28214. * @param texture The texture we are preparing the UVs for
  28215. * @param defines The defines to update
  28216. * @param key The channel key "diffuse", "specular"... used in the shader
  28217. */
  28218. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  28219. /**
  28220. * Binds a texture matrix value to its corrsponding uniform
  28221. * @param texture The texture to bind the matrix for
  28222. * @param uniformBuffer The uniform buffer receivin the data
  28223. * @param key The channel key "diffuse", "specular"... used in the shader
  28224. */
  28225. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  28226. /**
  28227. * Gets the current status of the fog (should it be enabled?)
  28228. * @param mesh defines the mesh to evaluate for fog support
  28229. * @param scene defines the hosting scene
  28230. * @returns true if fog must be enabled
  28231. */
  28232. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  28233. /**
  28234. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  28235. * @param mesh defines the current mesh
  28236. * @param scene defines the current scene
  28237. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  28238. * @param pointsCloud defines if point cloud rendering has to be turned on
  28239. * @param fogEnabled defines if fog has to be turned on
  28240. * @param alphaTest defines if alpha testing has to be turned on
  28241. * @param defines defines the current list of defines
  28242. */
  28243. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  28244. /**
  28245. * Helper used to prepare the list of defines associated with frame values for shader compilation
  28246. * @param scene defines the current scene
  28247. * @param engine defines the current engine
  28248. * @param defines specifies the list of active defines
  28249. * @param useInstances defines if instances have to be turned on
  28250. * @param useClipPlane defines if clip plane have to be turned on
  28251. * @param useInstances defines if instances have to be turned on
  28252. * @param useThinInstances defines if thin instances have to be turned on
  28253. */
  28254. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  28255. /**
  28256. * Prepares the defines for bones
  28257. * @param mesh The mesh containing the geometry data we will draw
  28258. * @param defines The defines to update
  28259. */
  28260. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  28261. /**
  28262. * Prepares the defines for morph targets
  28263. * @param mesh The mesh containing the geometry data we will draw
  28264. * @param defines The defines to update
  28265. */
  28266. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  28267. /**
  28268. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  28269. * @param mesh The mesh containing the geometry data we will draw
  28270. * @param defines The defines to update
  28271. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  28272. * @param useBones Precise whether bones should be used or not (override mesh info)
  28273. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  28274. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  28275. * @returns false if defines are considered not dirty and have not been checked
  28276. */
  28277. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  28278. /**
  28279. * Prepares the defines related to multiview
  28280. * @param scene The scene we are intending to draw
  28281. * @param defines The defines to update
  28282. */
  28283. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  28284. /**
  28285. * Prepares the defines related to the prepass
  28286. * @param scene The scene we are intending to draw
  28287. * @param defines The defines to update
  28288. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  28289. */
  28290. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  28291. /**
  28292. * Prepares the defines related to the light information passed in parameter
  28293. * @param scene The scene we are intending to draw
  28294. * @param mesh The mesh the effect is compiling for
  28295. * @param light The light the effect is compiling for
  28296. * @param lightIndex The index of the light
  28297. * @param defines The defines to update
  28298. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28299. * @param state Defines the current state regarding what is needed (normals, etc...)
  28300. */
  28301. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  28302. needNormals: boolean;
  28303. needRebuild: boolean;
  28304. shadowEnabled: boolean;
  28305. specularEnabled: boolean;
  28306. lightmapMode: boolean;
  28307. }): void;
  28308. /**
  28309. * Prepares the defines related to the light information passed in parameter
  28310. * @param scene The scene we are intending to draw
  28311. * @param mesh The mesh the effect is compiling for
  28312. * @param defines The defines to update
  28313. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  28314. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  28315. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  28316. * @returns true if normals will be required for the rest of the effect
  28317. */
  28318. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  28319. /**
  28320. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  28321. * @param lightIndex defines the light index
  28322. * @param uniformsList The uniform list
  28323. * @param samplersList The sampler list
  28324. * @param projectedLightTexture defines if projected texture must be used
  28325. * @param uniformBuffersList defines an optional list of uniform buffers
  28326. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28327. */
  28328. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28329. /**
  28330. * Prepares the uniforms and samplers list to be used in the effect
  28331. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28332. * @param samplersList The sampler list
  28333. * @param defines The defines helping in the list generation
  28334. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28335. */
  28336. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28337. /**
  28338. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28339. * @param defines The defines to update while falling back
  28340. * @param fallbacks The authorized effect fallbacks
  28341. * @param maxSimultaneousLights The maximum number of lights allowed
  28342. * @param rank the current rank of the Effect
  28343. * @returns The newly affected rank
  28344. */
  28345. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28346. private static _TmpMorphInfluencers;
  28347. /**
  28348. * Prepares the list of attributes required for morph targets according to the effect defines.
  28349. * @param attribs The current list of supported attribs
  28350. * @param mesh The mesh to prepare the morph targets attributes for
  28351. * @param influencers The number of influencers
  28352. */
  28353. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28354. /**
  28355. * Prepares the list of attributes required for morph targets according to the effect defines.
  28356. * @param attribs The current list of supported attribs
  28357. * @param mesh The mesh to prepare the morph targets attributes for
  28358. * @param defines The current Defines of the effect
  28359. */
  28360. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28361. /**
  28362. * Prepares the list of attributes required for bones according to the effect defines.
  28363. * @param attribs The current list of supported attribs
  28364. * @param mesh The mesh to prepare the bones attributes for
  28365. * @param defines The current Defines of the effect
  28366. * @param fallbacks The current efffect fallback strategy
  28367. */
  28368. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28369. /**
  28370. * Check and prepare the list of attributes required for instances according to the effect defines.
  28371. * @param attribs The current list of supported attribs
  28372. * @param defines The current MaterialDefines of the effect
  28373. */
  28374. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28375. /**
  28376. * Add the list of attributes required for instances to the attribs array.
  28377. * @param attribs The current list of supported attribs
  28378. */
  28379. static PushAttributesForInstances(attribs: string[]): void;
  28380. /**
  28381. * Binds the light information to the effect.
  28382. * @param light The light containing the generator
  28383. * @param effect The effect we are binding the data to
  28384. * @param lightIndex The light index in the effect used to render
  28385. */
  28386. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28387. /**
  28388. * Binds the lights information from the scene to the effect for the given mesh.
  28389. * @param light Light to bind
  28390. * @param lightIndex Light index
  28391. * @param scene The scene where the light belongs to
  28392. * @param effect The effect we are binding the data to
  28393. * @param useSpecular Defines if specular is supported
  28394. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28395. */
  28396. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28397. /**
  28398. * Binds the lights information from the scene to the effect for the given mesh.
  28399. * @param scene The scene the lights belongs to
  28400. * @param mesh The mesh we are binding the information to render
  28401. * @param effect The effect we are binding the data to
  28402. * @param defines The generated defines for the effect
  28403. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28404. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28405. */
  28406. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28407. private static _tempFogColor;
  28408. /**
  28409. * Binds the fog information from the scene to the effect for the given mesh.
  28410. * @param scene The scene the lights belongs to
  28411. * @param mesh The mesh we are binding the information to render
  28412. * @param effect The effect we are binding the data to
  28413. * @param linearSpace Defines if the fog effect is applied in linear space
  28414. */
  28415. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28416. /**
  28417. * Binds the bones information from the mesh to the effect.
  28418. * @param mesh The mesh we are binding the information to render
  28419. * @param effect The effect we are binding the data to
  28420. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28421. */
  28422. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28423. private static _CopyBonesTransformationMatrices;
  28424. /**
  28425. * Binds the morph targets information from the mesh to the effect.
  28426. * @param abstractMesh The mesh we are binding the information to render
  28427. * @param effect The effect we are binding the data to
  28428. */
  28429. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28430. /**
  28431. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28432. * @param defines The generated defines used in the effect
  28433. * @param effect The effect we are binding the data to
  28434. * @param scene The scene we are willing to render with logarithmic scale for
  28435. */
  28436. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28437. /**
  28438. * Binds the clip plane information from the scene to the effect.
  28439. * @param scene The scene the clip plane information are extracted from
  28440. * @param effect The effect we are binding the data to
  28441. */
  28442. static BindClipPlane(effect: Effect, scene: Scene): void;
  28443. }
  28444. }
  28445. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  28446. /** @hidden */
  28447. export var bayerDitherFunctions: {
  28448. name: string;
  28449. shader: string;
  28450. };
  28451. }
  28452. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  28453. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  28454. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  28455. /** @hidden */
  28456. export var shadowMapFragmentDeclaration: {
  28457. name: string;
  28458. shader: string;
  28459. };
  28460. }
  28461. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  28462. /** @hidden */
  28463. export var shadowMapFragment: {
  28464. name: string;
  28465. shader: string;
  28466. };
  28467. }
  28468. declare module "babylonjs/Shaders/shadowMap.fragment" {
  28469. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  28470. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  28471. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  28472. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  28473. /** @hidden */
  28474. export var shadowMapPixelShader: {
  28475. name: string;
  28476. shader: string;
  28477. };
  28478. }
  28479. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  28480. /** @hidden */
  28481. export var shadowMapVertexDeclaration: {
  28482. name: string;
  28483. shader: string;
  28484. };
  28485. }
  28486. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  28487. /** @hidden */
  28488. export var shadowMapVertexNormalBias: {
  28489. name: string;
  28490. shader: string;
  28491. };
  28492. }
  28493. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  28494. /** @hidden */
  28495. export var shadowMapVertexMetric: {
  28496. name: string;
  28497. shader: string;
  28498. };
  28499. }
  28500. declare module "babylonjs/Shaders/shadowMap.vertex" {
  28501. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28502. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28503. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28504. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  28506. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  28507. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  28508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28509. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28510. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28511. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  28512. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  28513. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  28514. /** @hidden */
  28515. export var shadowMapVertexShader: {
  28516. name: string;
  28517. shader: string;
  28518. };
  28519. }
  28520. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  28521. /** @hidden */
  28522. export var depthBoxBlurPixelShader: {
  28523. name: string;
  28524. shader: string;
  28525. };
  28526. }
  28527. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  28528. /** @hidden */
  28529. export var shadowMapFragmentSoftTransparentShadow: {
  28530. name: string;
  28531. shader: string;
  28532. };
  28533. }
  28534. declare module "babylonjs/Meshes/instancedMesh" {
  28535. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28536. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  28537. import { Camera } from "babylonjs/Cameras/camera";
  28538. import { Node } from "babylonjs/node";
  28539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28540. import { Mesh } from "babylonjs/Meshes/mesh";
  28541. import { Material } from "babylonjs/Materials/material";
  28542. import { Skeleton } from "babylonjs/Bones/skeleton";
  28543. import { Light } from "babylonjs/Lights/light";
  28544. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28545. /**
  28546. * Creates an instance based on a source mesh.
  28547. */
  28548. export class InstancedMesh extends AbstractMesh {
  28549. private _sourceMesh;
  28550. private _currentLOD;
  28551. /** @hidden */
  28552. _indexInSourceMeshInstanceArray: number;
  28553. constructor(name: string, source: Mesh);
  28554. /**
  28555. * Returns the string "InstancedMesh".
  28556. */
  28557. getClassName(): string;
  28558. /** Gets the list of lights affecting that mesh */
  28559. get lightSources(): Light[];
  28560. _resyncLightSources(): void;
  28561. _resyncLightSource(light: Light): void;
  28562. _removeLightSource(light: Light, dispose: boolean): void;
  28563. /**
  28564. * If the source mesh receives shadows
  28565. */
  28566. get receiveShadows(): boolean;
  28567. /**
  28568. * The material of the source mesh
  28569. */
  28570. get material(): Nullable<Material>;
  28571. /**
  28572. * Visibility of the source mesh
  28573. */
  28574. get visibility(): number;
  28575. /**
  28576. * Skeleton of the source mesh
  28577. */
  28578. get skeleton(): Nullable<Skeleton>;
  28579. /**
  28580. * Rendering ground id of the source mesh
  28581. */
  28582. get renderingGroupId(): number;
  28583. set renderingGroupId(value: number);
  28584. /**
  28585. * Returns the total number of vertices (integer).
  28586. */
  28587. getTotalVertices(): number;
  28588. /**
  28589. * Returns a positive integer : the total number of indices in this mesh geometry.
  28590. * @returns the numner of indices or zero if the mesh has no geometry.
  28591. */
  28592. getTotalIndices(): number;
  28593. /**
  28594. * The source mesh of the instance
  28595. */
  28596. get sourceMesh(): Mesh;
  28597. /**
  28598. * Creates a new InstancedMesh object from the mesh model.
  28599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28600. * @param name defines the name of the new instance
  28601. * @returns a new InstancedMesh
  28602. */
  28603. createInstance(name: string): InstancedMesh;
  28604. /**
  28605. * Is this node ready to be used/rendered
  28606. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28607. * @return {boolean} is it ready
  28608. */
  28609. isReady(completeCheck?: boolean): boolean;
  28610. /**
  28611. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28612. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28613. * @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.
  28614. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28615. */
  28616. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28617. /**
  28618. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28619. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28620. * The `data` are either a numeric array either a Float32Array.
  28621. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28622. * 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).
  28623. * Note that a new underlying VertexBuffer object is created each call.
  28624. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28625. *
  28626. * Possible `kind` values :
  28627. * - VertexBuffer.PositionKind
  28628. * - VertexBuffer.UVKind
  28629. * - VertexBuffer.UV2Kind
  28630. * - VertexBuffer.UV3Kind
  28631. * - VertexBuffer.UV4Kind
  28632. * - VertexBuffer.UV5Kind
  28633. * - VertexBuffer.UV6Kind
  28634. * - VertexBuffer.ColorKind
  28635. * - VertexBuffer.MatricesIndicesKind
  28636. * - VertexBuffer.MatricesIndicesExtraKind
  28637. * - VertexBuffer.MatricesWeightsKind
  28638. * - VertexBuffer.MatricesWeightsExtraKind
  28639. *
  28640. * Returns the Mesh.
  28641. */
  28642. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28643. /**
  28644. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28645. * If the mesh has no geometry, it is simply returned as it is.
  28646. * The `data` are either a numeric array either a Float32Array.
  28647. * No new underlying VertexBuffer object is created.
  28648. * 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.
  28649. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28650. *
  28651. * Possible `kind` values :
  28652. * - VertexBuffer.PositionKind
  28653. * - VertexBuffer.UVKind
  28654. * - VertexBuffer.UV2Kind
  28655. * - VertexBuffer.UV3Kind
  28656. * - VertexBuffer.UV4Kind
  28657. * - VertexBuffer.UV5Kind
  28658. * - VertexBuffer.UV6Kind
  28659. * - VertexBuffer.ColorKind
  28660. * - VertexBuffer.MatricesIndicesKind
  28661. * - VertexBuffer.MatricesIndicesExtraKind
  28662. * - VertexBuffer.MatricesWeightsKind
  28663. * - VertexBuffer.MatricesWeightsExtraKind
  28664. *
  28665. * Returns the Mesh.
  28666. */
  28667. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28668. /**
  28669. * Sets the mesh indices.
  28670. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28671. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28672. * This method creates a new index buffer each call.
  28673. * Returns the Mesh.
  28674. */
  28675. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28676. /**
  28677. * Boolean : True if the mesh owns the requested kind of data.
  28678. */
  28679. isVerticesDataPresent(kind: string): boolean;
  28680. /**
  28681. * Returns an array of indices (IndicesArray).
  28682. */
  28683. getIndices(): Nullable<IndicesArray>;
  28684. get _positions(): Nullable<Vector3[]>;
  28685. /**
  28686. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28687. * This means the mesh underlying bounding box and sphere are recomputed.
  28688. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28689. * @returns the current mesh
  28690. */
  28691. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28692. /** @hidden */
  28693. _preActivate(): InstancedMesh;
  28694. /** @hidden */
  28695. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28696. /** @hidden */
  28697. _postActivate(): void;
  28698. getWorldMatrix(): Matrix;
  28699. get isAnInstance(): boolean;
  28700. /**
  28701. * Returns the current associated LOD AbstractMesh.
  28702. */
  28703. getLOD(camera: Camera): AbstractMesh;
  28704. /** @hidden */
  28705. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28706. /** @hidden */
  28707. _syncSubMeshes(): InstancedMesh;
  28708. /** @hidden */
  28709. _generatePointsArray(): boolean;
  28710. /** @hidden */
  28711. _updateBoundingInfo(): AbstractMesh;
  28712. /**
  28713. * Creates a new InstancedMesh from the current mesh.
  28714. * - name (string) : the cloned mesh name
  28715. * - newParent (optional Node) : the optional Node to parent the clone to.
  28716. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28717. *
  28718. * Returns the clone.
  28719. */
  28720. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28721. /**
  28722. * Disposes the InstancedMesh.
  28723. * Returns nothing.
  28724. */
  28725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28726. }
  28727. module "babylonjs/Meshes/mesh" {
  28728. interface Mesh {
  28729. /**
  28730. * Register a custom buffer that will be instanced
  28731. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28732. * @param kind defines the buffer kind
  28733. * @param stride defines the stride in floats
  28734. */
  28735. registerInstancedBuffer(kind: string, stride: number): void;
  28736. /**
  28737. * true to use the edge renderer for all instances of this mesh
  28738. */
  28739. edgesShareWithInstances: boolean;
  28740. /** @hidden */
  28741. _userInstancedBuffersStorage: {
  28742. data: {
  28743. [key: string]: Float32Array;
  28744. };
  28745. sizes: {
  28746. [key: string]: number;
  28747. };
  28748. vertexBuffers: {
  28749. [key: string]: Nullable<VertexBuffer>;
  28750. };
  28751. strides: {
  28752. [key: string]: number;
  28753. };
  28754. };
  28755. }
  28756. }
  28757. module "babylonjs/Meshes/abstractMesh" {
  28758. interface AbstractMesh {
  28759. /**
  28760. * Object used to store instanced buffers defined by user
  28761. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28762. */
  28763. instancedBuffers: {
  28764. [key: string]: any;
  28765. };
  28766. }
  28767. }
  28768. }
  28769. declare module "babylonjs/Materials/shaderMaterial" {
  28770. import { Nullable } from "babylonjs/types";
  28771. import { Scene } from "babylonjs/scene";
  28772. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28774. import { Mesh } from "babylonjs/Meshes/mesh";
  28775. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28776. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28777. import { Effect } from "babylonjs/Materials/effect";
  28778. import { Material } from "babylonjs/Materials/material";
  28779. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28780. /**
  28781. * Defines the options associated with the creation of a shader material.
  28782. */
  28783. export interface IShaderMaterialOptions {
  28784. /**
  28785. * Does the material work in alpha blend mode
  28786. */
  28787. needAlphaBlending: boolean;
  28788. /**
  28789. * Does the material work in alpha test mode
  28790. */
  28791. needAlphaTesting: boolean;
  28792. /**
  28793. * The list of attribute names used in the shader
  28794. */
  28795. attributes: string[];
  28796. /**
  28797. * The list of unifrom names used in the shader
  28798. */
  28799. uniforms: string[];
  28800. /**
  28801. * The list of UBO names used in the shader
  28802. */
  28803. uniformBuffers: string[];
  28804. /**
  28805. * The list of sampler names used in the shader
  28806. */
  28807. samplers: string[];
  28808. /**
  28809. * The list of defines used in the shader
  28810. */
  28811. defines: string[];
  28812. }
  28813. /**
  28814. * 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.
  28815. *
  28816. * This returned material effects how the mesh will look based on the code in the shaders.
  28817. *
  28818. * @see https://doc.babylonjs.com/how_to/shader_material
  28819. */
  28820. export class ShaderMaterial extends Material {
  28821. private _shaderPath;
  28822. private _options;
  28823. private _textures;
  28824. private _textureArrays;
  28825. private _floats;
  28826. private _ints;
  28827. private _floatsArrays;
  28828. private _colors3;
  28829. private _colors3Arrays;
  28830. private _colors4;
  28831. private _colors4Arrays;
  28832. private _vectors2;
  28833. private _vectors3;
  28834. private _vectors4;
  28835. private _matrices;
  28836. private _matrixArrays;
  28837. private _matrices3x3;
  28838. private _matrices2x2;
  28839. private _vectors2Arrays;
  28840. private _vectors3Arrays;
  28841. private _vectors4Arrays;
  28842. private _cachedWorldViewMatrix;
  28843. private _cachedWorldViewProjectionMatrix;
  28844. private _renderId;
  28845. private _multiview;
  28846. private _cachedDefines;
  28847. /** Define the Url to load snippets */
  28848. static SnippetUrl: string;
  28849. /** Snippet ID if the material was created from the snippet server */
  28850. snippetId: string;
  28851. /**
  28852. * Instantiate a new shader material.
  28853. * 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.
  28854. * This returned material effects how the mesh will look based on the code in the shaders.
  28855. * @see https://doc.babylonjs.com/how_to/shader_material
  28856. * @param name Define the name of the material in the scene
  28857. * @param scene Define the scene the material belongs to
  28858. * @param shaderPath Defines the route to the shader code in one of three ways:
  28859. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28860. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28861. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28862. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28863. * @param options Define the options used to create the shader
  28864. */
  28865. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28866. /**
  28867. * Gets the shader path used to define the shader code
  28868. * It can be modified to trigger a new compilation
  28869. */
  28870. get shaderPath(): any;
  28871. /**
  28872. * Sets the shader path used to define the shader code
  28873. * It can be modified to trigger a new compilation
  28874. */
  28875. set shaderPath(shaderPath: any);
  28876. /**
  28877. * Gets the options used to compile the shader.
  28878. * They can be modified to trigger a new compilation
  28879. */
  28880. get options(): IShaderMaterialOptions;
  28881. /**
  28882. * Gets the current class name of the material e.g. "ShaderMaterial"
  28883. * Mainly use in serialization.
  28884. * @returns the class name
  28885. */
  28886. getClassName(): string;
  28887. /**
  28888. * Specifies if the material will require alpha blending
  28889. * @returns a boolean specifying if alpha blending is needed
  28890. */
  28891. needAlphaBlending(): boolean;
  28892. /**
  28893. * Specifies if this material should be rendered in alpha test mode
  28894. * @returns a boolean specifying if an alpha test is needed.
  28895. */
  28896. needAlphaTesting(): boolean;
  28897. private _checkUniform;
  28898. /**
  28899. * Set a texture in the shader.
  28900. * @param name Define the name of the uniform samplers as defined in the shader
  28901. * @param texture Define the texture to bind to this sampler
  28902. * @return the material itself allowing "fluent" like uniform updates
  28903. */
  28904. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28905. /**
  28906. * Set a texture array in the shader.
  28907. * @param name Define the name of the uniform sampler array as defined in the shader
  28908. * @param textures Define the list of textures to bind to this sampler
  28909. * @return the material itself allowing "fluent" like uniform updates
  28910. */
  28911. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28912. /**
  28913. * Set a float in the shader.
  28914. * @param name Define the name of the uniform as defined in the shader
  28915. * @param value Define the value to give to the uniform
  28916. * @return the material itself allowing "fluent" like uniform updates
  28917. */
  28918. setFloat(name: string, value: number): ShaderMaterial;
  28919. /**
  28920. * Set a int in the shader.
  28921. * @param name Define the name of the uniform as defined in the shader
  28922. * @param value Define the value to give to the uniform
  28923. * @return the material itself allowing "fluent" like uniform updates
  28924. */
  28925. setInt(name: string, value: number): ShaderMaterial;
  28926. /**
  28927. * Set an array of floats in the shader.
  28928. * @param name Define the name of the uniform as defined in the shader
  28929. * @param value Define the value to give to the uniform
  28930. * @return the material itself allowing "fluent" like uniform updates
  28931. */
  28932. setFloats(name: string, value: number[]): ShaderMaterial;
  28933. /**
  28934. * Set a vec3 in the shader from a Color3.
  28935. * @param name Define the name of the uniform as defined in the shader
  28936. * @param value Define the value to give to the uniform
  28937. * @return the material itself allowing "fluent" like uniform updates
  28938. */
  28939. setColor3(name: string, value: Color3): ShaderMaterial;
  28940. /**
  28941. * Set a vec3 array in the shader from a Color3 array.
  28942. * @param name Define the name of the uniform as defined in the shader
  28943. * @param value Define the value to give to the uniform
  28944. * @return the material itself allowing "fluent" like uniform updates
  28945. */
  28946. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28947. /**
  28948. * Set a vec4 in the shader from a Color4.
  28949. * @param name Define the name of the uniform as defined in the shader
  28950. * @param value Define the value to give to the uniform
  28951. * @return the material itself allowing "fluent" like uniform updates
  28952. */
  28953. setColor4(name: string, value: Color4): ShaderMaterial;
  28954. /**
  28955. * Set a vec4 array in the shader from a Color4 array.
  28956. * @param name Define the name of the uniform as defined in the shader
  28957. * @param value Define the value to give to the uniform
  28958. * @return the material itself allowing "fluent" like uniform updates
  28959. */
  28960. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28961. /**
  28962. * Set a vec2 in the shader from a Vector2.
  28963. * @param name Define the name of the uniform as defined in the shader
  28964. * @param value Define the value to give to the uniform
  28965. * @return the material itself allowing "fluent" like uniform updates
  28966. */
  28967. setVector2(name: string, value: Vector2): ShaderMaterial;
  28968. /**
  28969. * Set a vec3 in the shader from a Vector3.
  28970. * @param name Define the name of the uniform as defined in the shader
  28971. * @param value Define the value to give to the uniform
  28972. * @return the material itself allowing "fluent" like uniform updates
  28973. */
  28974. setVector3(name: string, value: Vector3): ShaderMaterial;
  28975. /**
  28976. * Set a vec4 in the shader from a Vector4.
  28977. * @param name Define the name of the uniform as defined in the shader
  28978. * @param value Define the value to give to the uniform
  28979. * @return the material itself allowing "fluent" like uniform updates
  28980. */
  28981. setVector4(name: string, value: Vector4): ShaderMaterial;
  28982. /**
  28983. * Set a mat4 in the shader from a Matrix.
  28984. * @param name Define the name of the uniform as defined in the shader
  28985. * @param value Define the value to give to the uniform
  28986. * @return the material itself allowing "fluent" like uniform updates
  28987. */
  28988. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28989. /**
  28990. * Set a float32Array in the shader from a matrix array.
  28991. * @param name Define the name of the uniform as defined in the shader
  28992. * @param value Define the value to give to the uniform
  28993. * @return the material itself allowing "fluent" like uniform updates
  28994. */
  28995. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28996. /**
  28997. * Set a mat3 in the shader from a Float32Array.
  28998. * @param name Define the name of the uniform as defined in the shader
  28999. * @param value Define the value to give to the uniform
  29000. * @return the material itself allowing "fluent" like uniform updates
  29001. */
  29002. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29003. /**
  29004. * Set a mat2 in the shader from a Float32Array.
  29005. * @param name Define the name of the uniform as defined in the shader
  29006. * @param value Define the value to give to the uniform
  29007. * @return the material itself allowing "fluent" like uniform updates
  29008. */
  29009. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  29010. /**
  29011. * Set a vec2 array in the shader from a number array.
  29012. * @param name Define the name of the uniform as defined in the shader
  29013. * @param value Define the value to give to the uniform
  29014. * @return the material itself allowing "fluent" like uniform updates
  29015. */
  29016. setArray2(name: string, value: number[]): ShaderMaterial;
  29017. /**
  29018. * Set a vec3 array in the shader from a number array.
  29019. * @param name Define the name of the uniform as defined in the shader
  29020. * @param value Define the value to give to the uniform
  29021. * @return the material itself allowing "fluent" like uniform updates
  29022. */
  29023. setArray3(name: string, value: number[]): ShaderMaterial;
  29024. /**
  29025. * Set a vec4 array in the shader from a number array.
  29026. * @param name Define the name of the uniform as defined in the shader
  29027. * @param value Define the value to give to the uniform
  29028. * @return the material itself allowing "fluent" like uniform updates
  29029. */
  29030. setArray4(name: string, value: number[]): ShaderMaterial;
  29031. private _checkCache;
  29032. /**
  29033. * Specifies that the submesh is ready to be used
  29034. * @param mesh defines the mesh to check
  29035. * @param subMesh defines which submesh to check
  29036. * @param useInstances specifies that instances should be used
  29037. * @returns a boolean indicating that the submesh is ready or not
  29038. */
  29039. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29040. /**
  29041. * Checks if the material is ready to render the requested mesh
  29042. * @param mesh Define the mesh to render
  29043. * @param useInstances Define whether or not the material is used with instances
  29044. * @returns true if ready, otherwise false
  29045. */
  29046. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29047. /**
  29048. * Binds the world matrix to the material
  29049. * @param world defines the world transformation matrix
  29050. * @param effectOverride - If provided, use this effect instead of internal effect
  29051. */
  29052. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  29053. /**
  29054. * Binds the submesh to this material by preparing the effect and shader to draw
  29055. * @param world defines the world transformation matrix
  29056. * @param mesh defines the mesh containing the submesh
  29057. * @param subMesh defines the submesh to bind the material to
  29058. */
  29059. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29060. /**
  29061. * Binds the material to the mesh
  29062. * @param world defines the world transformation matrix
  29063. * @param mesh defines the mesh to bind the material to
  29064. * @param effectOverride - If provided, use this effect instead of internal effect
  29065. */
  29066. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  29067. protected _afterBind(mesh?: Mesh): void;
  29068. /**
  29069. * Gets the active textures from the material
  29070. * @returns an array of textures
  29071. */
  29072. getActiveTextures(): BaseTexture[];
  29073. /**
  29074. * Specifies if the material uses a texture
  29075. * @param texture defines the texture to check against the material
  29076. * @returns a boolean specifying if the material uses the texture
  29077. */
  29078. hasTexture(texture: BaseTexture): boolean;
  29079. /**
  29080. * Makes a duplicate of the material, and gives it a new name
  29081. * @param name defines the new name for the duplicated material
  29082. * @returns the cloned material
  29083. */
  29084. clone(name: string): ShaderMaterial;
  29085. /**
  29086. * Disposes the material
  29087. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29088. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29089. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29090. */
  29091. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29092. /**
  29093. * Serializes this material in a JSON representation
  29094. * @returns the serialized material object
  29095. */
  29096. serialize(): any;
  29097. /**
  29098. * Creates a shader material from parsed shader material data
  29099. * @param source defines the JSON represnetation of the material
  29100. * @param scene defines the hosting scene
  29101. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29102. * @returns a new material
  29103. */
  29104. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  29105. /**
  29106. * Creates a new ShaderMaterial from a snippet saved in a remote file
  29107. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  29108. * @param url defines the url to load from
  29109. * @param scene defines the hosting scene
  29110. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29111. * @returns a promise that will resolve to the new ShaderMaterial
  29112. */
  29113. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29114. /**
  29115. * Creates a ShaderMaterial from a snippet saved by the Inspector
  29116. * @param snippetId defines the snippet to load
  29117. * @param scene defines the hosting scene
  29118. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  29119. * @returns a promise that will resolve to the new ShaderMaterial
  29120. */
  29121. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  29122. }
  29123. }
  29124. declare module "babylonjs/Shaders/color.fragment" {
  29125. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  29126. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  29127. /** @hidden */
  29128. export var colorPixelShader: {
  29129. name: string;
  29130. shader: string;
  29131. };
  29132. }
  29133. declare module "babylonjs/Shaders/color.vertex" {
  29134. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  29135. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  29136. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29137. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29138. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  29139. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  29140. /** @hidden */
  29141. export var colorVertexShader: {
  29142. name: string;
  29143. shader: string;
  29144. };
  29145. }
  29146. declare module "babylonjs/Meshes/linesMesh" {
  29147. import { Nullable } from "babylonjs/types";
  29148. import { Scene } from "babylonjs/scene";
  29149. import { Color3 } from "babylonjs/Maths/math.color";
  29150. import { Node } from "babylonjs/node";
  29151. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29152. import { Mesh } from "babylonjs/Meshes/mesh";
  29153. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29154. import { Effect } from "babylonjs/Materials/effect";
  29155. import { Material } from "babylonjs/Materials/material";
  29156. import "babylonjs/Shaders/color.fragment";
  29157. import "babylonjs/Shaders/color.vertex";
  29158. /**
  29159. * Line mesh
  29160. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  29161. */
  29162. export class LinesMesh extends Mesh {
  29163. /**
  29164. * If vertex color should be applied to the mesh
  29165. */
  29166. readonly useVertexColor?: boolean | undefined;
  29167. /**
  29168. * If vertex alpha should be applied to the mesh
  29169. */
  29170. readonly useVertexAlpha?: boolean | undefined;
  29171. /**
  29172. * Color of the line (Default: White)
  29173. */
  29174. color: Color3;
  29175. /**
  29176. * Alpha of the line (Default: 1)
  29177. */
  29178. alpha: number;
  29179. /**
  29180. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29181. * This margin is expressed in world space coordinates, so its value may vary.
  29182. * Default value is 0.1
  29183. */
  29184. intersectionThreshold: number;
  29185. private _colorShader;
  29186. private color4;
  29187. /**
  29188. * Creates a new LinesMesh
  29189. * @param name defines the name
  29190. * @param scene defines the hosting scene
  29191. * @param parent defines the parent mesh if any
  29192. * @param source defines the optional source LinesMesh used to clone data from
  29193. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29194. * When false, achieved by calling a clone(), also passing False.
  29195. * This will make creation of children, recursive.
  29196. * @param useVertexColor defines if this LinesMesh supports vertex color
  29197. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  29198. */
  29199. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  29200. /**
  29201. * If vertex color should be applied to the mesh
  29202. */
  29203. useVertexColor?: boolean | undefined,
  29204. /**
  29205. * If vertex alpha should be applied to the mesh
  29206. */
  29207. useVertexAlpha?: boolean | undefined);
  29208. private _addClipPlaneDefine;
  29209. private _removeClipPlaneDefine;
  29210. isReady(): boolean;
  29211. /**
  29212. * Returns the string "LineMesh"
  29213. */
  29214. getClassName(): string;
  29215. /**
  29216. * @hidden
  29217. */
  29218. get material(): Material;
  29219. /**
  29220. * @hidden
  29221. */
  29222. set material(value: Material);
  29223. /**
  29224. * @hidden
  29225. */
  29226. get checkCollisions(): boolean;
  29227. /** @hidden */
  29228. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29229. /** @hidden */
  29230. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29231. /**
  29232. * Disposes of the line mesh
  29233. * @param doNotRecurse If children should be disposed
  29234. */
  29235. dispose(doNotRecurse?: boolean): void;
  29236. /**
  29237. * Returns a new LineMesh object cloned from the current one.
  29238. */
  29239. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  29240. /**
  29241. * Creates a new InstancedLinesMesh object from the mesh model.
  29242. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29243. * @param name defines the name of the new instance
  29244. * @returns a new InstancedLinesMesh
  29245. */
  29246. createInstance(name: string): InstancedLinesMesh;
  29247. }
  29248. /**
  29249. * Creates an instance based on a source LinesMesh
  29250. */
  29251. export class InstancedLinesMesh extends InstancedMesh {
  29252. /**
  29253. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  29254. * This margin is expressed in world space coordinates, so its value may vary.
  29255. * Initilized with the intersectionThreshold value of the source LinesMesh
  29256. */
  29257. intersectionThreshold: number;
  29258. constructor(name: string, source: LinesMesh);
  29259. /**
  29260. * Returns the string "InstancedLinesMesh".
  29261. */
  29262. getClassName(): string;
  29263. }
  29264. }
  29265. declare module "babylonjs/Shaders/line.fragment" {
  29266. /** @hidden */
  29267. export var linePixelShader: {
  29268. name: string;
  29269. shader: string;
  29270. };
  29271. }
  29272. declare module "babylonjs/Shaders/line.vertex" {
  29273. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  29274. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  29275. /** @hidden */
  29276. export var lineVertexShader: {
  29277. name: string;
  29278. shader: string;
  29279. };
  29280. }
  29281. declare module "babylonjs/Rendering/edgesRenderer" {
  29282. import { Immutable, Nullable } from "babylonjs/types";
  29283. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29285. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  29286. import { IDisposable } from "babylonjs/scene";
  29287. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  29288. import "babylonjs/Shaders/line.fragment";
  29289. import "babylonjs/Shaders/line.vertex";
  29290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29291. import { SmartArray } from "babylonjs/Misc/smartArray";
  29292. module "babylonjs/scene" {
  29293. interface Scene {
  29294. /** @hidden */
  29295. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  29296. }
  29297. }
  29298. module "babylonjs/Meshes/abstractMesh" {
  29299. interface AbstractMesh {
  29300. /**
  29301. * Gets the edgesRenderer associated with the mesh
  29302. */
  29303. edgesRenderer: Nullable<EdgesRenderer>;
  29304. }
  29305. }
  29306. module "babylonjs/Meshes/linesMesh" {
  29307. interface LinesMesh {
  29308. /**
  29309. * Enables the edge rendering mode on the mesh.
  29310. * This mode makes the mesh edges visible
  29311. * @param epsilon defines the maximal distance between two angles to detect a face
  29312. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29313. * @returns the currentAbstractMesh
  29314. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29315. */
  29316. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29317. }
  29318. }
  29319. module "babylonjs/Meshes/linesMesh" {
  29320. interface InstancedLinesMesh {
  29321. /**
  29322. * Enables the edge rendering mode on the mesh.
  29323. * This mode makes the mesh edges visible
  29324. * @param epsilon defines the maximal distance between two angles to detect a face
  29325. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29326. * @returns the current InstancedLinesMesh
  29327. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29328. */
  29329. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  29330. }
  29331. }
  29332. /**
  29333. * Defines the minimum contract an Edges renderer should follow.
  29334. */
  29335. export interface IEdgesRenderer extends IDisposable {
  29336. /**
  29337. * Gets or sets a boolean indicating if the edgesRenderer is active
  29338. */
  29339. isEnabled: boolean;
  29340. /**
  29341. * Renders the edges of the attached mesh,
  29342. */
  29343. render(): void;
  29344. /**
  29345. * Checks wether or not the edges renderer is ready to render.
  29346. * @return true if ready, otherwise false.
  29347. */
  29348. isReady(): boolean;
  29349. /**
  29350. * List of instances to render in case the source mesh has instances
  29351. */
  29352. customInstances: SmartArray<Matrix>;
  29353. }
  29354. /**
  29355. * Defines the additional options of the edges renderer
  29356. */
  29357. export interface IEdgesRendererOptions {
  29358. /**
  29359. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  29360. * If not defined, the default value is true
  29361. */
  29362. useAlternateEdgeFinder?: boolean;
  29363. /**
  29364. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  29365. * If not defined, the default value is true.
  29366. * 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)
  29367. * This option is used only if useAlternateEdgeFinder = true
  29368. */
  29369. useFastVertexMerger?: boolean;
  29370. /**
  29371. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  29372. * The default value is 1e-6
  29373. * This option is used only if useAlternateEdgeFinder = true
  29374. */
  29375. epsilonVertexMerge?: number;
  29376. /**
  29377. * 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
  29378. * 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.
  29379. * This option is used only if useAlternateEdgeFinder = true
  29380. */
  29381. applyTessellation?: boolean;
  29382. /**
  29383. * 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
  29384. * The default value is 1e-6
  29385. * This option is used only if useAlternateEdgeFinder = true
  29386. */
  29387. epsilonVertexAligned?: number;
  29388. }
  29389. /**
  29390. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  29391. */
  29392. export class EdgesRenderer implements IEdgesRenderer {
  29393. /**
  29394. * Define the size of the edges with an orthographic camera
  29395. */
  29396. edgesWidthScalerForOrthographic: number;
  29397. /**
  29398. * Define the size of the edges with a perspective camera
  29399. */
  29400. edgesWidthScalerForPerspective: number;
  29401. protected _source: AbstractMesh;
  29402. protected _linesPositions: number[];
  29403. protected _linesNormals: number[];
  29404. protected _linesIndices: number[];
  29405. protected _epsilon: number;
  29406. protected _indicesCount: number;
  29407. protected _lineShader: ShaderMaterial;
  29408. protected _ib: DataBuffer;
  29409. protected _buffers: {
  29410. [key: string]: Nullable<VertexBuffer>;
  29411. };
  29412. protected _buffersForInstances: {
  29413. [key: string]: Nullable<VertexBuffer>;
  29414. };
  29415. protected _checkVerticesInsteadOfIndices: boolean;
  29416. protected _options: Nullable<IEdgesRendererOptions>;
  29417. private _meshRebuildObserver;
  29418. private _meshDisposeObserver;
  29419. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29420. isEnabled: boolean;
  29421. /** Gets the vertices generated by the edge renderer */
  29422. get linesPositions(): Immutable<Array<number>>;
  29423. /** Gets the normals generated by the edge renderer */
  29424. get linesNormals(): Immutable<Array<number>>;
  29425. /** Gets the indices generated by the edge renderer */
  29426. get linesIndices(): Immutable<Array<number>>;
  29427. /**
  29428. * List of instances to render in case the source mesh has instances
  29429. */
  29430. customInstances: SmartArray<Matrix>;
  29431. private static GetShader;
  29432. /**
  29433. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29434. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29435. * @param source Mesh used to create edges
  29436. * @param epsilon sum of angles in adjacency to check for edge
  29437. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29438. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29439. * @param options The options to apply when generating the edges
  29440. */
  29441. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29442. protected _prepareRessources(): void;
  29443. /** @hidden */
  29444. _rebuild(): void;
  29445. /**
  29446. * Releases the required resources for the edges renderer
  29447. */
  29448. dispose(): void;
  29449. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29450. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29451. /**
  29452. * Checks if the pair of p0 and p1 is en edge
  29453. * @param faceIndex
  29454. * @param edge
  29455. * @param faceNormals
  29456. * @param p0
  29457. * @param p1
  29458. * @private
  29459. */
  29460. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29461. /**
  29462. * push line into the position, normal and index buffer
  29463. * @protected
  29464. */
  29465. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29466. /**
  29467. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29468. */
  29469. private _tessellateTriangle;
  29470. private _generateEdgesLinesAlternate;
  29471. /**
  29472. * Generates lines edges from adjacencjes
  29473. * @private
  29474. */
  29475. _generateEdgesLines(): void;
  29476. /**
  29477. * Checks wether or not the edges renderer is ready to render.
  29478. * @return true if ready, otherwise false.
  29479. */
  29480. isReady(): boolean;
  29481. /**
  29482. * Renders the edges of the attached mesh,
  29483. */
  29484. render(): void;
  29485. }
  29486. /**
  29487. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29488. */
  29489. export class LineEdgesRenderer extends EdgesRenderer {
  29490. /**
  29491. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29492. * @param source LineMesh used to generate edges
  29493. * @param epsilon not important (specified angle for edge detection)
  29494. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29495. */
  29496. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29497. /**
  29498. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29499. */
  29500. _generateEdgesLines(): void;
  29501. }
  29502. }
  29503. declare module "babylonjs/Rendering/renderingGroup" {
  29504. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  29505. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29507. import { Nullable } from "babylonjs/types";
  29508. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29509. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  29510. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29511. import { Material } from "babylonjs/Materials/material";
  29512. import { Scene } from "babylonjs/scene";
  29513. /**
  29514. * This represents the object necessary to create a rendering group.
  29515. * This is exclusively used and created by the rendering manager.
  29516. * To modify the behavior, you use the available helpers in your scene or meshes.
  29517. * @hidden
  29518. */
  29519. export class RenderingGroup {
  29520. index: number;
  29521. private static _zeroVector;
  29522. private _scene;
  29523. private _opaqueSubMeshes;
  29524. private _transparentSubMeshes;
  29525. private _alphaTestSubMeshes;
  29526. private _depthOnlySubMeshes;
  29527. private _particleSystems;
  29528. private _spriteManagers;
  29529. private _opaqueSortCompareFn;
  29530. private _alphaTestSortCompareFn;
  29531. private _transparentSortCompareFn;
  29532. private _renderOpaque;
  29533. private _renderAlphaTest;
  29534. private _renderTransparent;
  29535. /** @hidden */
  29536. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29537. onBeforeTransparentRendering: () => void;
  29538. /**
  29539. * Set the opaque sort comparison function.
  29540. * If null the sub meshes will be render in the order they were created
  29541. */
  29542. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29543. /**
  29544. * Set the alpha test sort comparison function.
  29545. * If null the sub meshes will be render in the order they were created
  29546. */
  29547. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29548. /**
  29549. * Set the transparent sort comparison function.
  29550. * If null the sub meshes will be render in the order they were created
  29551. */
  29552. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29553. /**
  29554. * Creates a new rendering group.
  29555. * @param index The rendering group index
  29556. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29557. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29558. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29559. */
  29560. 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>);
  29561. /**
  29562. * Render all the sub meshes contained in the group.
  29563. * @param customRenderFunction Used to override the default render behaviour of the group.
  29564. * @returns true if rendered some submeshes.
  29565. */
  29566. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29567. /**
  29568. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29569. * @param subMeshes The submeshes to render
  29570. */
  29571. private renderOpaqueSorted;
  29572. /**
  29573. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29574. * @param subMeshes The submeshes to render
  29575. */
  29576. private renderAlphaTestSorted;
  29577. /**
  29578. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29579. * @param subMeshes The submeshes to render
  29580. */
  29581. private renderTransparentSorted;
  29582. /**
  29583. * Renders the submeshes in a specified order.
  29584. * @param subMeshes The submeshes to sort before render
  29585. * @param sortCompareFn The comparison function use to sort
  29586. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29587. * @param transparent Specifies to activate blending if true
  29588. */
  29589. private static renderSorted;
  29590. /**
  29591. * Renders the submeshes in the order they were dispatched (no sort applied).
  29592. * @param subMeshes The submeshes to render
  29593. */
  29594. private static renderUnsorted;
  29595. /**
  29596. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29597. * are rendered back to front if in the same alpha index.
  29598. *
  29599. * @param a The first submesh
  29600. * @param b The second submesh
  29601. * @returns The result of the comparison
  29602. */
  29603. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29604. /**
  29605. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29606. * are rendered back to front.
  29607. *
  29608. * @param a The first submesh
  29609. * @param b The second submesh
  29610. * @returns The result of the comparison
  29611. */
  29612. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29613. /**
  29614. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29615. * are rendered front to back (prevent overdraw).
  29616. *
  29617. * @param a The first submesh
  29618. * @param b The second submesh
  29619. * @returns The result of the comparison
  29620. */
  29621. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29622. /**
  29623. * Resets the different lists of submeshes to prepare a new frame.
  29624. */
  29625. prepare(): void;
  29626. dispose(): void;
  29627. /**
  29628. * Inserts the submesh in its correct queue depending on its material.
  29629. * @param subMesh The submesh to dispatch
  29630. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29631. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29632. */
  29633. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29634. dispatchSprites(spriteManager: ISpriteManager): void;
  29635. dispatchParticles(particleSystem: IParticleSystem): void;
  29636. private _renderParticles;
  29637. private _renderSprites;
  29638. }
  29639. }
  29640. declare module "babylonjs/Rendering/renderingManager" {
  29641. import { Nullable } from "babylonjs/types";
  29642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29643. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29644. import { SmartArray } from "babylonjs/Misc/smartArray";
  29645. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  29646. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  29647. import { Material } from "babylonjs/Materials/material";
  29648. import { Scene } from "babylonjs/scene";
  29649. import { Camera } from "babylonjs/Cameras/camera";
  29650. /**
  29651. * Interface describing the different options available in the rendering manager
  29652. * regarding Auto Clear between groups.
  29653. */
  29654. export interface IRenderingManagerAutoClearSetup {
  29655. /**
  29656. * Defines whether or not autoclear is enable.
  29657. */
  29658. autoClear: boolean;
  29659. /**
  29660. * Defines whether or not to autoclear the depth buffer.
  29661. */
  29662. depth: boolean;
  29663. /**
  29664. * Defines whether or not to autoclear the stencil buffer.
  29665. */
  29666. stencil: boolean;
  29667. }
  29668. /**
  29669. * This class is used by the onRenderingGroupObservable
  29670. */
  29671. export class RenderingGroupInfo {
  29672. /**
  29673. * The Scene that being rendered
  29674. */
  29675. scene: Scene;
  29676. /**
  29677. * The camera currently used for the rendering pass
  29678. */
  29679. camera: Nullable<Camera>;
  29680. /**
  29681. * The ID of the renderingGroup being processed
  29682. */
  29683. renderingGroupId: number;
  29684. }
  29685. /**
  29686. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29687. * It is enable to manage the different groups as well as the different necessary sort functions.
  29688. * This should not be used directly aside of the few static configurations
  29689. */
  29690. export class RenderingManager {
  29691. /**
  29692. * The max id used for rendering groups (not included)
  29693. */
  29694. static MAX_RENDERINGGROUPS: number;
  29695. /**
  29696. * The min id used for rendering groups (included)
  29697. */
  29698. static MIN_RENDERINGGROUPS: number;
  29699. /**
  29700. * Used to globally prevent autoclearing scenes.
  29701. */
  29702. static AUTOCLEAR: boolean;
  29703. /**
  29704. * @hidden
  29705. */
  29706. _useSceneAutoClearSetup: boolean;
  29707. private _scene;
  29708. private _renderingGroups;
  29709. private _depthStencilBufferAlreadyCleaned;
  29710. private _autoClearDepthStencil;
  29711. private _customOpaqueSortCompareFn;
  29712. private _customAlphaTestSortCompareFn;
  29713. private _customTransparentSortCompareFn;
  29714. private _renderingGroupInfo;
  29715. /**
  29716. * Instantiates a new rendering group for a particular scene
  29717. * @param scene Defines the scene the groups belongs to
  29718. */
  29719. constructor(scene: Scene);
  29720. private _clearDepthStencilBuffer;
  29721. /**
  29722. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29723. * @hidden
  29724. */
  29725. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29726. /**
  29727. * Resets the different information of the group to prepare a new frame
  29728. * @hidden
  29729. */
  29730. reset(): void;
  29731. /**
  29732. * Dispose and release the group and its associated resources.
  29733. * @hidden
  29734. */
  29735. dispose(): void;
  29736. /**
  29737. * Clear the info related to rendering groups preventing retention points during dispose.
  29738. */
  29739. freeRenderingGroups(): void;
  29740. private _prepareRenderingGroup;
  29741. /**
  29742. * Add a sprite manager to the rendering manager in order to render it this frame.
  29743. * @param spriteManager Define the sprite manager to render
  29744. */
  29745. dispatchSprites(spriteManager: ISpriteManager): void;
  29746. /**
  29747. * Add a particle system to the rendering manager in order to render it this frame.
  29748. * @param particleSystem Define the particle system to render
  29749. */
  29750. dispatchParticles(particleSystem: IParticleSystem): void;
  29751. /**
  29752. * Add a submesh to the manager in order to render it this frame
  29753. * @param subMesh The submesh to dispatch
  29754. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29755. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29756. */
  29757. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29758. /**
  29759. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29760. * This allowed control for front to back rendering or reversly depending of the special needs.
  29761. *
  29762. * @param renderingGroupId The rendering group id corresponding to its index
  29763. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29764. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29765. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29766. */
  29767. 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;
  29768. /**
  29769. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29770. *
  29771. * @param renderingGroupId The rendering group id corresponding to its index
  29772. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29773. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29774. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29775. */
  29776. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29777. /**
  29778. * Gets the current auto clear configuration for one rendering group of the rendering
  29779. * manager.
  29780. * @param index the rendering group index to get the information for
  29781. * @returns The auto clear setup for the requested rendering group
  29782. */
  29783. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29784. }
  29785. }
  29786. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  29787. import { SmartArray } from "babylonjs/Misc/smartArray";
  29788. import { Nullable } from "babylonjs/types";
  29789. import { Scene } from "babylonjs/scene";
  29790. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29791. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29793. import { Mesh } from "babylonjs/Meshes/mesh";
  29794. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  29795. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29796. import { Effect } from "babylonjs/Materials/effect";
  29797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29798. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29799. import "babylonjs/Shaders/shadowMap.fragment";
  29800. import "babylonjs/Shaders/shadowMap.vertex";
  29801. import "babylonjs/Shaders/depthBoxBlur.fragment";
  29802. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  29803. import { Observable } from "babylonjs/Misc/observable";
  29804. /**
  29805. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29806. */
  29807. export interface ICustomShaderOptions {
  29808. /**
  29809. * Gets or sets the custom shader name to use
  29810. */
  29811. shaderName: string;
  29812. /**
  29813. * The list of attribute names used in the shader
  29814. */
  29815. attributes?: string[];
  29816. /**
  29817. * The list of unifrom names used in the shader
  29818. */
  29819. uniforms?: string[];
  29820. /**
  29821. * The list of sampler names used in the shader
  29822. */
  29823. samplers?: string[];
  29824. /**
  29825. * The list of defines used in the shader
  29826. */
  29827. defines?: string[];
  29828. }
  29829. /**
  29830. * Interface to implement to create a shadow generator compatible with BJS.
  29831. */
  29832. export interface IShadowGenerator {
  29833. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29834. id: string;
  29835. /**
  29836. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29837. * @returns The render target texture if present otherwise, null
  29838. */
  29839. getShadowMap(): Nullable<RenderTargetTexture>;
  29840. /**
  29841. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29842. * @param subMesh The submesh we want to render in the shadow map
  29843. * @param useInstances Defines wether will draw in the map using instances
  29844. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29845. * @returns true if ready otherwise, false
  29846. */
  29847. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29848. /**
  29849. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29850. * @param defines Defines of the material we want to update
  29851. * @param lightIndex Index of the light in the enabled light list of the material
  29852. */
  29853. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29854. /**
  29855. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29856. * defined in the generator but impacting the effect).
  29857. * It implies the unifroms available on the materials are the standard BJS ones.
  29858. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29859. * @param effect The effect we are binfing the information for
  29860. */
  29861. bindShadowLight(lightIndex: string, effect: Effect): void;
  29862. /**
  29863. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29864. * (eq to shadow prjection matrix * light transform matrix)
  29865. * @returns The transform matrix used to create the shadow map
  29866. */
  29867. getTransformMatrix(): Matrix;
  29868. /**
  29869. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29870. * Cube and 2D textures for instance.
  29871. */
  29872. recreateShadowMap(): void;
  29873. /**
  29874. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29875. * @param onCompiled Callback triggered at the and of the effects compilation
  29876. * @param options Sets of optional options forcing the compilation with different modes
  29877. */
  29878. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29879. useInstances: boolean;
  29880. }>): void;
  29881. /**
  29882. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29883. * @param options Sets of optional options forcing the compilation with different modes
  29884. * @returns A promise that resolves when the compilation completes
  29885. */
  29886. forceCompilationAsync(options?: Partial<{
  29887. useInstances: boolean;
  29888. }>): Promise<void>;
  29889. /**
  29890. * Serializes the shadow generator setup to a json object.
  29891. * @returns The serialized JSON object
  29892. */
  29893. serialize(): any;
  29894. /**
  29895. * Disposes the Shadow map and related Textures and effects.
  29896. */
  29897. dispose(): void;
  29898. }
  29899. /**
  29900. * Default implementation IShadowGenerator.
  29901. * This is the main object responsible of generating shadows in the framework.
  29902. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29903. */
  29904. export class ShadowGenerator implements IShadowGenerator {
  29905. /**
  29906. * Name of the shadow generator class
  29907. */
  29908. static CLASSNAME: string;
  29909. /**
  29910. * Shadow generator mode None: no filtering applied.
  29911. */
  29912. static readonly FILTER_NONE: number;
  29913. /**
  29914. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29915. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29916. */
  29917. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29918. /**
  29919. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29920. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29921. */
  29922. static readonly FILTER_POISSONSAMPLING: number;
  29923. /**
  29924. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29925. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29926. */
  29927. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29928. /**
  29929. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29930. * edge artifacts on steep falloff.
  29931. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29932. */
  29933. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29934. /**
  29935. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29936. * edge artifacts on steep falloff.
  29937. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29938. */
  29939. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29940. /**
  29941. * Shadow generator mode PCF: Percentage Closer Filtering
  29942. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29943. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29944. */
  29945. static readonly FILTER_PCF: number;
  29946. /**
  29947. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29948. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29949. * Contact Hardening
  29950. */
  29951. static readonly FILTER_PCSS: number;
  29952. /**
  29953. * Reserved for PCF and PCSS
  29954. * Highest Quality.
  29955. *
  29956. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29957. *
  29958. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29959. */
  29960. static readonly QUALITY_HIGH: number;
  29961. /**
  29962. * Reserved for PCF and PCSS
  29963. * Good tradeoff for quality/perf cross devices
  29964. *
  29965. * Execute PCF on a 3*3 kernel.
  29966. *
  29967. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29968. */
  29969. static readonly QUALITY_MEDIUM: number;
  29970. /**
  29971. * Reserved for PCF and PCSS
  29972. * The lowest quality but the fastest.
  29973. *
  29974. * Execute PCF on a 1*1 kernel.
  29975. *
  29976. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29977. */
  29978. static readonly QUALITY_LOW: number;
  29979. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29980. id: string;
  29981. /** Gets or sets the custom shader name to use */
  29982. customShaderOptions: ICustomShaderOptions;
  29983. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29984. customAllowRendering: (subMesh: SubMesh) => boolean;
  29985. /**
  29986. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29987. */
  29988. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29989. /**
  29990. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29991. */
  29992. onAfterShadowMapRenderObservable: Observable<Effect>;
  29993. /**
  29994. * Observable triggered before a mesh is rendered in the shadow map.
  29995. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29996. */
  29997. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29998. /**
  29999. * Observable triggered after a mesh is rendered in the shadow map.
  30000. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  30001. */
  30002. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  30003. protected _bias: number;
  30004. /**
  30005. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  30006. */
  30007. get bias(): number;
  30008. /**
  30009. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  30010. */
  30011. set bias(bias: number);
  30012. protected _normalBias: number;
  30013. /**
  30014. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30015. */
  30016. get normalBias(): number;
  30017. /**
  30018. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  30019. */
  30020. set normalBias(normalBias: number);
  30021. protected _blurBoxOffset: number;
  30022. /**
  30023. * Gets the blur box offset: offset applied during the blur pass.
  30024. * Only useful if useKernelBlur = false
  30025. */
  30026. get blurBoxOffset(): number;
  30027. /**
  30028. * Sets the blur box offset: offset applied during the blur pass.
  30029. * Only useful if useKernelBlur = false
  30030. */
  30031. set blurBoxOffset(value: number);
  30032. protected _blurScale: number;
  30033. /**
  30034. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  30035. * 2 means half of the size.
  30036. */
  30037. get blurScale(): number;
  30038. /**
  30039. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  30040. * 2 means half of the size.
  30041. */
  30042. set blurScale(value: number);
  30043. protected _blurKernel: number;
  30044. /**
  30045. * Gets the blur kernel: kernel size of the blur pass.
  30046. * Only useful if useKernelBlur = true
  30047. */
  30048. get blurKernel(): number;
  30049. /**
  30050. * Sets the blur kernel: kernel size of the blur pass.
  30051. * Only useful if useKernelBlur = true
  30052. */
  30053. set blurKernel(value: number);
  30054. protected _useKernelBlur: boolean;
  30055. /**
  30056. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  30057. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30058. */
  30059. get useKernelBlur(): boolean;
  30060. /**
  30061. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  30062. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  30063. */
  30064. set useKernelBlur(value: boolean);
  30065. protected _depthScale: number;
  30066. /**
  30067. * Gets the depth scale used in ESM mode.
  30068. */
  30069. get depthScale(): number;
  30070. /**
  30071. * Sets the depth scale used in ESM mode.
  30072. * This can override the scale stored on the light.
  30073. */
  30074. set depthScale(value: number);
  30075. protected _validateFilter(filter: number): number;
  30076. protected _filter: number;
  30077. /**
  30078. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  30079. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30080. */
  30081. get filter(): number;
  30082. /**
  30083. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  30084. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  30085. */
  30086. set filter(value: number);
  30087. /**
  30088. * Gets if the current filter is set to Poisson Sampling.
  30089. */
  30090. get usePoissonSampling(): boolean;
  30091. /**
  30092. * Sets the current filter to Poisson Sampling.
  30093. */
  30094. set usePoissonSampling(value: boolean);
  30095. /**
  30096. * Gets if the current filter is set to ESM.
  30097. */
  30098. get useExponentialShadowMap(): boolean;
  30099. /**
  30100. * Sets the current filter is to ESM.
  30101. */
  30102. set useExponentialShadowMap(value: boolean);
  30103. /**
  30104. * Gets if the current filter is set to filtered ESM.
  30105. */
  30106. get useBlurExponentialShadowMap(): boolean;
  30107. /**
  30108. * Gets if the current filter is set to filtered ESM.
  30109. */
  30110. set useBlurExponentialShadowMap(value: boolean);
  30111. /**
  30112. * Gets if the current filter is set to "close ESM" (using the inverse of the
  30113. * exponential to prevent steep falloff artifacts).
  30114. */
  30115. get useCloseExponentialShadowMap(): boolean;
  30116. /**
  30117. * Sets the current filter to "close ESM" (using the inverse of the
  30118. * exponential to prevent steep falloff artifacts).
  30119. */
  30120. set useCloseExponentialShadowMap(value: boolean);
  30121. /**
  30122. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  30123. * exponential to prevent steep falloff artifacts).
  30124. */
  30125. get useBlurCloseExponentialShadowMap(): boolean;
  30126. /**
  30127. * Sets the current filter to filtered "close ESM" (using the inverse of the
  30128. * exponential to prevent steep falloff artifacts).
  30129. */
  30130. set useBlurCloseExponentialShadowMap(value: boolean);
  30131. /**
  30132. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  30133. */
  30134. get usePercentageCloserFiltering(): boolean;
  30135. /**
  30136. * Sets the current filter to "PCF" (percentage closer filtering).
  30137. */
  30138. set usePercentageCloserFiltering(value: boolean);
  30139. protected _filteringQuality: number;
  30140. /**
  30141. * Gets the PCF or PCSS Quality.
  30142. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30143. */
  30144. get filteringQuality(): number;
  30145. /**
  30146. * Sets the PCF or PCSS Quality.
  30147. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  30148. */
  30149. set filteringQuality(filteringQuality: number);
  30150. /**
  30151. * Gets if the current filter is set to "PCSS" (contact hardening).
  30152. */
  30153. get useContactHardeningShadow(): boolean;
  30154. /**
  30155. * Sets the current filter to "PCSS" (contact hardening).
  30156. */
  30157. set useContactHardeningShadow(value: boolean);
  30158. protected _contactHardeningLightSizeUVRatio: number;
  30159. /**
  30160. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30161. * Using a ratio helps keeping shape stability independently of the map size.
  30162. *
  30163. * It does not account for the light projection as it was having too much
  30164. * instability during the light setup or during light position changes.
  30165. *
  30166. * Only valid if useContactHardeningShadow is true.
  30167. */
  30168. get contactHardeningLightSizeUVRatio(): number;
  30169. /**
  30170. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  30171. * Using a ratio helps keeping shape stability independently of the map size.
  30172. *
  30173. * It does not account for the light projection as it was having too much
  30174. * instability during the light setup or during light position changes.
  30175. *
  30176. * Only valid if useContactHardeningShadow is true.
  30177. */
  30178. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  30179. protected _darkness: number;
  30180. /** Gets or sets the actual darkness of a shadow */
  30181. get darkness(): number;
  30182. set darkness(value: number);
  30183. /**
  30184. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  30185. * 0 means strongest and 1 would means no shadow.
  30186. * @returns the darkness.
  30187. */
  30188. getDarkness(): number;
  30189. /**
  30190. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  30191. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  30192. * @returns the shadow generator allowing fluent coding.
  30193. */
  30194. setDarkness(darkness: number): ShadowGenerator;
  30195. protected _transparencyShadow: boolean;
  30196. /** Gets or sets the ability to have transparent shadow */
  30197. get transparencyShadow(): boolean;
  30198. set transparencyShadow(value: boolean);
  30199. /**
  30200. * Sets the ability to have transparent shadow (boolean).
  30201. * @param transparent True if transparent else False
  30202. * @returns the shadow generator allowing fluent coding
  30203. */
  30204. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  30205. /**
  30206. * Enables or disables shadows with varying strength based on the transparency
  30207. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  30208. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  30209. * mesh.visibility * alphaTexture.a
  30210. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  30211. */
  30212. enableSoftTransparentShadow: boolean;
  30213. protected _shadowMap: Nullable<RenderTargetTexture>;
  30214. protected _shadowMap2: Nullable<RenderTargetTexture>;
  30215. /**
  30216. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  30217. * @returns The render target texture if present otherwise, null
  30218. */
  30219. getShadowMap(): Nullable<RenderTargetTexture>;
  30220. /**
  30221. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  30222. * @returns The render target texture if the shadow map is present otherwise, null
  30223. */
  30224. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  30225. /**
  30226. * Gets the class name of that object
  30227. * @returns "ShadowGenerator"
  30228. */
  30229. getClassName(): string;
  30230. /**
  30231. * Helper function to add a mesh and its descendants to the list of shadow casters.
  30232. * @param mesh Mesh to add
  30233. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  30234. * @returns the Shadow Generator itself
  30235. */
  30236. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30237. /**
  30238. * Helper function to remove a mesh and its descendants from the list of shadow casters
  30239. * @param mesh Mesh to remove
  30240. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  30241. * @returns the Shadow Generator itself
  30242. */
  30243. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  30244. /**
  30245. * Controls the extent to which the shadows fade out at the edge of the frustum
  30246. */
  30247. frustumEdgeFalloff: number;
  30248. protected _light: IShadowLight;
  30249. /**
  30250. * Returns the associated light object.
  30251. * @returns the light generating the shadow
  30252. */
  30253. getLight(): IShadowLight;
  30254. /**
  30255. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  30256. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  30257. * It might on the other hand introduce peter panning.
  30258. */
  30259. forceBackFacesOnly: boolean;
  30260. protected _scene: Scene;
  30261. protected _lightDirection: Vector3;
  30262. protected _effect: Effect;
  30263. protected _viewMatrix: Matrix;
  30264. protected _projectionMatrix: Matrix;
  30265. protected _transformMatrix: Matrix;
  30266. protected _cachedPosition: Vector3;
  30267. protected _cachedDirection: Vector3;
  30268. protected _cachedDefines: string;
  30269. protected _currentRenderID: number;
  30270. protected _boxBlurPostprocess: Nullable<PostProcess>;
  30271. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  30272. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  30273. protected _blurPostProcesses: PostProcess[];
  30274. protected _mapSize: number;
  30275. protected _currentFaceIndex: number;
  30276. protected _currentFaceIndexCache: number;
  30277. protected _textureType: number;
  30278. protected _defaultTextureMatrix: Matrix;
  30279. protected _storedUniqueId: Nullable<number>;
  30280. /** @hidden */
  30281. static _SceneComponentInitialization: (scene: Scene) => void;
  30282. /**
  30283. * Gets or sets the size of the texture what stores the shadows
  30284. */
  30285. get mapSize(): number;
  30286. set mapSize(size: number);
  30287. /**
  30288. * Creates a ShadowGenerator object.
  30289. * A ShadowGenerator is the required tool to use the shadows.
  30290. * Each light casting shadows needs to use its own ShadowGenerator.
  30291. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  30292. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  30293. * @param light The light object generating the shadows.
  30294. * @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.
  30295. */
  30296. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  30297. protected _initializeGenerator(): void;
  30298. protected _createTargetRenderTexture(): void;
  30299. protected _initializeShadowMap(): void;
  30300. protected _initializeBlurRTTAndPostProcesses(): void;
  30301. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  30302. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  30303. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  30304. protected _applyFilterValues(): void;
  30305. /**
  30306. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30307. * @param onCompiled Callback triggered at the and of the effects compilation
  30308. * @param options Sets of optional options forcing the compilation with different modes
  30309. */
  30310. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  30311. useInstances: boolean;
  30312. }>): void;
  30313. /**
  30314. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  30315. * @param options Sets of optional options forcing the compilation with different modes
  30316. * @returns A promise that resolves when the compilation completes
  30317. */
  30318. forceCompilationAsync(options?: Partial<{
  30319. useInstances: boolean;
  30320. }>): Promise<void>;
  30321. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  30322. private _prepareShadowDefines;
  30323. /**
  30324. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  30325. * @param subMesh The submesh we want to render in the shadow map
  30326. * @param useInstances Defines wether will draw in the map using instances
  30327. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  30328. * @returns true if ready otherwise, false
  30329. */
  30330. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  30331. /**
  30332. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  30333. * @param defines Defines of the material we want to update
  30334. * @param lightIndex Index of the light in the enabled light list of the material
  30335. */
  30336. prepareDefines(defines: any, lightIndex: number): void;
  30337. /**
  30338. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  30339. * defined in the generator but impacting the effect).
  30340. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  30341. * @param effect The effect we are binfing the information for
  30342. */
  30343. bindShadowLight(lightIndex: string, effect: Effect): void;
  30344. /**
  30345. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  30346. * (eq to shadow prjection matrix * light transform matrix)
  30347. * @returns The transform matrix used to create the shadow map
  30348. */
  30349. getTransformMatrix(): Matrix;
  30350. /**
  30351. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  30352. * Cube and 2D textures for instance.
  30353. */
  30354. recreateShadowMap(): void;
  30355. protected _disposeBlurPostProcesses(): void;
  30356. protected _disposeRTTandPostProcesses(): void;
  30357. /**
  30358. * Disposes the ShadowGenerator.
  30359. * Returns nothing.
  30360. */
  30361. dispose(): void;
  30362. /**
  30363. * Serializes the shadow generator setup to a json object.
  30364. * @returns The serialized JSON object
  30365. */
  30366. serialize(): any;
  30367. /**
  30368. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  30369. * @param parsedShadowGenerator The JSON object to parse
  30370. * @param scene The scene to create the shadow map for
  30371. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  30372. * @returns The parsed shadow generator
  30373. */
  30374. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  30375. }
  30376. }
  30377. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30378. import { Nullable } from "babylonjs/types";
  30379. import { Scene } from "babylonjs/scene";
  30380. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30381. import { Material } from "babylonjs/Materials/material";
  30382. import { Effect } from "babylonjs/Materials/effect";
  30383. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30384. /**
  30385. * Options to be used when creating a shadow depth material
  30386. */
  30387. export interface IIOptionShadowDepthMaterial {
  30388. /** Variables in the vertex shader code that need to have their names remapped.
  30389. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30390. * "var_name" should be either: worldPos or vNormalW
  30391. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30392. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30393. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30394. */
  30395. remappedVariables?: string[];
  30396. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30397. standalone?: boolean;
  30398. }
  30399. /**
  30400. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30401. */
  30402. export class ShadowDepthWrapper {
  30403. private _scene;
  30404. private _options?;
  30405. private _baseMaterial;
  30406. private _onEffectCreatedObserver;
  30407. private _subMeshToEffect;
  30408. private _subMeshToDepthEffect;
  30409. private _meshes;
  30410. /** @hidden */
  30411. _matriceNames: any;
  30412. /** Gets the standalone status of the wrapper */
  30413. get standalone(): boolean;
  30414. /** Gets the base material the wrapper is built upon */
  30415. get baseMaterial(): Material;
  30416. /**
  30417. * Instantiate a new shadow depth wrapper.
  30418. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30419. * generate the shadow depth map. For more information, please refer to the documentation:
  30420. * https://doc.babylonjs.com/babylon101/shadows
  30421. * @param baseMaterial Material to wrap
  30422. * @param scene Define the scene the material belongs to
  30423. * @param options Options used to create the wrapper
  30424. */
  30425. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30426. /**
  30427. * Gets the effect to use to generate the depth map
  30428. * @param subMesh subMesh to get the effect for
  30429. * @param shadowGenerator shadow generator to get the effect for
  30430. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30431. */
  30432. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30433. /**
  30434. * Specifies that the submesh is ready to be used for depth rendering
  30435. * @param subMesh submesh to check
  30436. * @param defines the list of defines to take into account when checking the effect
  30437. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30438. * @param useInstances specifies that instances should be used
  30439. * @returns a boolean indicating that the submesh is ready or not
  30440. */
  30441. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30442. /**
  30443. * Disposes the resources
  30444. */
  30445. dispose(): void;
  30446. private _makeEffect;
  30447. }
  30448. }
  30449. declare module "babylonjs/Materials/material" {
  30450. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30451. import { SmartArray } from "babylonjs/Misc/smartArray";
  30452. import { Observable } from "babylonjs/Misc/observable";
  30453. import { Nullable } from "babylonjs/types";
  30454. import { Scene } from "babylonjs/scene";
  30455. import { Matrix } from "babylonjs/Maths/math.vector";
  30456. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30458. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30459. import { Effect } from "babylonjs/Materials/effect";
  30460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30461. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30462. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30463. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30464. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30465. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30466. import { Mesh } from "babylonjs/Meshes/mesh";
  30467. import { Animation } from "babylonjs/Animations/animation";
  30468. /**
  30469. * Options for compiling materials.
  30470. */
  30471. export interface IMaterialCompilationOptions {
  30472. /**
  30473. * Defines whether clip planes are enabled.
  30474. */
  30475. clipPlane: boolean;
  30476. /**
  30477. * Defines whether instances are enabled.
  30478. */
  30479. useInstances: boolean;
  30480. }
  30481. /**
  30482. * Options passed when calling customShaderNameResolve
  30483. */
  30484. export interface ICustomShaderNameResolveOptions {
  30485. /**
  30486. * 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
  30487. */
  30488. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30489. }
  30490. /**
  30491. * Base class for the main features of a material in Babylon.js
  30492. */
  30493. export class Material implements IAnimatable {
  30494. /**
  30495. * Returns the triangle fill mode
  30496. */
  30497. static readonly TriangleFillMode: number;
  30498. /**
  30499. * Returns the wireframe mode
  30500. */
  30501. static readonly WireFrameFillMode: number;
  30502. /**
  30503. * Returns the point fill mode
  30504. */
  30505. static readonly PointFillMode: number;
  30506. /**
  30507. * Returns the point list draw mode
  30508. */
  30509. static readonly PointListDrawMode: number;
  30510. /**
  30511. * Returns the line list draw mode
  30512. */
  30513. static readonly LineListDrawMode: number;
  30514. /**
  30515. * Returns the line loop draw mode
  30516. */
  30517. static readonly LineLoopDrawMode: number;
  30518. /**
  30519. * Returns the line strip draw mode
  30520. */
  30521. static readonly LineStripDrawMode: number;
  30522. /**
  30523. * Returns the triangle strip draw mode
  30524. */
  30525. static readonly TriangleStripDrawMode: number;
  30526. /**
  30527. * Returns the triangle fan draw mode
  30528. */
  30529. static readonly TriangleFanDrawMode: number;
  30530. /**
  30531. * Stores the clock-wise side orientation
  30532. */
  30533. static readonly ClockWiseSideOrientation: number;
  30534. /**
  30535. * Stores the counter clock-wise side orientation
  30536. */
  30537. static readonly CounterClockWiseSideOrientation: number;
  30538. /**
  30539. * The dirty texture flag value
  30540. */
  30541. static readonly TextureDirtyFlag: number;
  30542. /**
  30543. * The dirty light flag value
  30544. */
  30545. static readonly LightDirtyFlag: number;
  30546. /**
  30547. * The dirty fresnel flag value
  30548. */
  30549. static readonly FresnelDirtyFlag: number;
  30550. /**
  30551. * The dirty attribute flag value
  30552. */
  30553. static readonly AttributesDirtyFlag: number;
  30554. /**
  30555. * The dirty misc flag value
  30556. */
  30557. static readonly MiscDirtyFlag: number;
  30558. /**
  30559. * The dirty prepass flag value
  30560. */
  30561. static readonly PrePassDirtyFlag: number;
  30562. /**
  30563. * The all dirty flag value
  30564. */
  30565. static readonly AllDirtyFlag: number;
  30566. /**
  30567. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30568. */
  30569. static readonly MATERIAL_OPAQUE: number;
  30570. /**
  30571. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30572. */
  30573. static readonly MATERIAL_ALPHATEST: number;
  30574. /**
  30575. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30576. */
  30577. static readonly MATERIAL_ALPHABLEND: number;
  30578. /**
  30579. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30580. * They are also discarded below the alpha cutoff threshold to improve performances.
  30581. */
  30582. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30583. /**
  30584. * The Whiteout method is used to blend normals.
  30585. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30586. */
  30587. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30588. /**
  30589. * The Reoriented Normal Mapping method is used to blend normals.
  30590. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30591. */
  30592. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30593. /**
  30594. * Custom callback helping to override the default shader used in the material.
  30595. */
  30596. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30597. /**
  30598. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30599. */
  30600. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30601. /**
  30602. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30603. * This means that the material can keep using a previous shader while a new one is being compiled.
  30604. * This is mostly used when shader parallel compilation is supported (true by default)
  30605. */
  30606. allowShaderHotSwapping: boolean;
  30607. /**
  30608. * The ID of the material
  30609. */
  30610. id: string;
  30611. /**
  30612. * Gets or sets the unique id of the material
  30613. */
  30614. uniqueId: number;
  30615. /**
  30616. * The name of the material
  30617. */
  30618. name: string;
  30619. /**
  30620. * Gets or sets user defined metadata
  30621. */
  30622. metadata: any;
  30623. /**
  30624. * For internal use only. Please do not use.
  30625. */
  30626. reservedDataStore: any;
  30627. /**
  30628. * Specifies if the ready state should be checked on each call
  30629. */
  30630. checkReadyOnEveryCall: boolean;
  30631. /**
  30632. * Specifies if the ready state should be checked once
  30633. */
  30634. checkReadyOnlyOnce: boolean;
  30635. /**
  30636. * The state of the material
  30637. */
  30638. state: string;
  30639. /**
  30640. * If the material can be rendered to several textures with MRT extension
  30641. */
  30642. get canRenderToMRT(): boolean;
  30643. /**
  30644. * The alpha value of the material
  30645. */
  30646. protected _alpha: number;
  30647. /**
  30648. * List of inspectable custom properties (used by the Inspector)
  30649. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30650. */
  30651. inspectableCustomProperties: IInspectable[];
  30652. /**
  30653. * Sets the alpha value of the material
  30654. */
  30655. set alpha(value: number);
  30656. /**
  30657. * Gets the alpha value of the material
  30658. */
  30659. get alpha(): number;
  30660. /**
  30661. * Specifies if back face culling is enabled
  30662. */
  30663. protected _backFaceCulling: boolean;
  30664. /**
  30665. * Sets the back-face culling state
  30666. */
  30667. set backFaceCulling(value: boolean);
  30668. /**
  30669. * Gets the back-face culling state
  30670. */
  30671. get backFaceCulling(): boolean;
  30672. /**
  30673. * Stores the value for side orientation
  30674. */
  30675. sideOrientation: number;
  30676. /**
  30677. * Callback triggered when the material is compiled
  30678. */
  30679. onCompiled: Nullable<(effect: Effect) => void>;
  30680. /**
  30681. * Callback triggered when an error occurs
  30682. */
  30683. onError: Nullable<(effect: Effect, errors: string) => void>;
  30684. /**
  30685. * Callback triggered to get the render target textures
  30686. */
  30687. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30688. /**
  30689. * Gets a boolean indicating that current material needs to register RTT
  30690. */
  30691. get hasRenderTargetTextures(): boolean;
  30692. /**
  30693. * Specifies if the material should be serialized
  30694. */
  30695. doNotSerialize: boolean;
  30696. /**
  30697. * @hidden
  30698. */
  30699. _storeEffectOnSubMeshes: boolean;
  30700. /**
  30701. * Stores the animations for the material
  30702. */
  30703. animations: Nullable<Array<Animation>>;
  30704. /**
  30705. * An event triggered when the material is disposed
  30706. */
  30707. onDisposeObservable: Observable<Material>;
  30708. /**
  30709. * An observer which watches for dispose events
  30710. */
  30711. private _onDisposeObserver;
  30712. private _onUnBindObservable;
  30713. /**
  30714. * Called during a dispose event
  30715. */
  30716. set onDispose(callback: () => void);
  30717. private _onBindObservable;
  30718. /**
  30719. * An event triggered when the material is bound
  30720. */
  30721. get onBindObservable(): Observable<AbstractMesh>;
  30722. /**
  30723. * An observer which watches for bind events
  30724. */
  30725. private _onBindObserver;
  30726. /**
  30727. * Called during a bind event
  30728. */
  30729. set onBind(callback: (Mesh: AbstractMesh) => void);
  30730. /**
  30731. * An event triggered when the material is unbound
  30732. */
  30733. get onUnBindObservable(): Observable<Material>;
  30734. protected _onEffectCreatedObservable: Nullable<Observable<{
  30735. effect: Effect;
  30736. subMesh: Nullable<SubMesh>;
  30737. }>>;
  30738. /**
  30739. * An event triggered when the effect is (re)created
  30740. */
  30741. get onEffectCreatedObservable(): Observable<{
  30742. effect: Effect;
  30743. subMesh: Nullable<SubMesh>;
  30744. }>;
  30745. /**
  30746. * Stores the value of the alpha mode
  30747. */
  30748. private _alphaMode;
  30749. /**
  30750. * Sets the value of the alpha mode.
  30751. *
  30752. * | Value | Type | Description |
  30753. * | --- | --- | --- |
  30754. * | 0 | ALPHA_DISABLE | |
  30755. * | 1 | ALPHA_ADD | |
  30756. * | 2 | ALPHA_COMBINE | |
  30757. * | 3 | ALPHA_SUBTRACT | |
  30758. * | 4 | ALPHA_MULTIPLY | |
  30759. * | 5 | ALPHA_MAXIMIZED | |
  30760. * | 6 | ALPHA_ONEONE | |
  30761. * | 7 | ALPHA_PREMULTIPLIED | |
  30762. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30763. * | 9 | ALPHA_INTERPOLATE | |
  30764. * | 10 | ALPHA_SCREENMODE | |
  30765. *
  30766. */
  30767. set alphaMode(value: number);
  30768. /**
  30769. * Gets the value of the alpha mode
  30770. */
  30771. get alphaMode(): number;
  30772. /**
  30773. * Stores the state of the need depth pre-pass value
  30774. */
  30775. private _needDepthPrePass;
  30776. /**
  30777. * Sets the need depth pre-pass value
  30778. */
  30779. set needDepthPrePass(value: boolean);
  30780. /**
  30781. * Gets the depth pre-pass value
  30782. */
  30783. get needDepthPrePass(): boolean;
  30784. /**
  30785. * Specifies if depth writing should be disabled
  30786. */
  30787. disableDepthWrite: boolean;
  30788. /**
  30789. * Specifies if color writing should be disabled
  30790. */
  30791. disableColorWrite: boolean;
  30792. /**
  30793. * Specifies if depth writing should be forced
  30794. */
  30795. forceDepthWrite: boolean;
  30796. /**
  30797. * Specifies the depth function that should be used. 0 means the default engine function
  30798. */
  30799. depthFunction: number;
  30800. /**
  30801. * Specifies if there should be a separate pass for culling
  30802. */
  30803. separateCullingPass: boolean;
  30804. /**
  30805. * Stores the state specifing if fog should be enabled
  30806. */
  30807. private _fogEnabled;
  30808. /**
  30809. * Sets the state for enabling fog
  30810. */
  30811. set fogEnabled(value: boolean);
  30812. /**
  30813. * Gets the value of the fog enabled state
  30814. */
  30815. get fogEnabled(): boolean;
  30816. /**
  30817. * Stores the size of points
  30818. */
  30819. pointSize: number;
  30820. /**
  30821. * Stores the z offset value
  30822. */
  30823. zOffset: number;
  30824. get wireframe(): boolean;
  30825. /**
  30826. * Sets the state of wireframe mode
  30827. */
  30828. set wireframe(value: boolean);
  30829. /**
  30830. * Gets the value specifying if point clouds are enabled
  30831. */
  30832. get pointsCloud(): boolean;
  30833. /**
  30834. * Sets the state of point cloud mode
  30835. */
  30836. set pointsCloud(value: boolean);
  30837. /**
  30838. * Gets the material fill mode
  30839. */
  30840. get fillMode(): number;
  30841. /**
  30842. * Sets the material fill mode
  30843. */
  30844. set fillMode(value: number);
  30845. /**
  30846. * @hidden
  30847. * Stores the effects for the material
  30848. */
  30849. _effect: Nullable<Effect>;
  30850. /**
  30851. * Specifies if uniform buffers should be used
  30852. */
  30853. private _useUBO;
  30854. /**
  30855. * Stores a reference to the scene
  30856. */
  30857. private _scene;
  30858. /**
  30859. * Stores the fill mode state
  30860. */
  30861. private _fillMode;
  30862. /**
  30863. * Specifies if the depth write state should be cached
  30864. */
  30865. private _cachedDepthWriteState;
  30866. /**
  30867. * Specifies if the color write state should be cached
  30868. */
  30869. private _cachedColorWriteState;
  30870. /**
  30871. * Specifies if the depth function state should be cached
  30872. */
  30873. private _cachedDepthFunctionState;
  30874. /**
  30875. * Stores the uniform buffer
  30876. */
  30877. protected _uniformBuffer: UniformBuffer;
  30878. /** @hidden */
  30879. _indexInSceneMaterialArray: number;
  30880. /** @hidden */
  30881. meshMap: Nullable<{
  30882. [id: string]: AbstractMesh | undefined;
  30883. }>;
  30884. /**
  30885. * Creates a material instance
  30886. * @param name defines the name of the material
  30887. * @param scene defines the scene to reference
  30888. * @param doNotAdd specifies if the material should be added to the scene
  30889. */
  30890. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30891. /**
  30892. * Returns a string representation of the current material
  30893. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30894. * @returns a string with material information
  30895. */
  30896. toString(fullDetails?: boolean): string;
  30897. /**
  30898. * Gets the class name of the material
  30899. * @returns a string with the class name of the material
  30900. */
  30901. getClassName(): string;
  30902. /**
  30903. * Specifies if updates for the material been locked
  30904. */
  30905. get isFrozen(): boolean;
  30906. /**
  30907. * Locks updates for the material
  30908. */
  30909. freeze(): void;
  30910. /**
  30911. * Unlocks updates for the material
  30912. */
  30913. unfreeze(): void;
  30914. /**
  30915. * Specifies if the material is ready to be used
  30916. * @param mesh defines the mesh to check
  30917. * @param useInstances specifies if instances should be used
  30918. * @returns a boolean indicating if the material is ready to be used
  30919. */
  30920. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30921. /**
  30922. * Specifies that the submesh is ready to be used
  30923. * @param mesh defines the mesh to check
  30924. * @param subMesh defines which submesh to check
  30925. * @param useInstances specifies that instances should be used
  30926. * @returns a boolean indicating that the submesh is ready or not
  30927. */
  30928. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30929. /**
  30930. * Returns the material effect
  30931. * @returns the effect associated with the material
  30932. */
  30933. getEffect(): Nullable<Effect>;
  30934. /**
  30935. * Returns the current scene
  30936. * @returns a Scene
  30937. */
  30938. getScene(): Scene;
  30939. /**
  30940. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30941. */
  30942. protected _forceAlphaTest: boolean;
  30943. /**
  30944. * The transparency mode of the material.
  30945. */
  30946. protected _transparencyMode: Nullable<number>;
  30947. /**
  30948. * Gets the current transparency mode.
  30949. */
  30950. get transparencyMode(): Nullable<number>;
  30951. /**
  30952. * Sets the transparency mode of the material.
  30953. *
  30954. * | Value | Type | Description |
  30955. * | ----- | ----------------------------------- | ----------- |
  30956. * | 0 | OPAQUE | |
  30957. * | 1 | ALPHATEST | |
  30958. * | 2 | ALPHABLEND | |
  30959. * | 3 | ALPHATESTANDBLEND | |
  30960. *
  30961. */
  30962. set transparencyMode(value: Nullable<number>);
  30963. /**
  30964. * Returns true if alpha blending should be disabled.
  30965. */
  30966. protected get _disableAlphaBlending(): boolean;
  30967. /**
  30968. * Specifies whether or not this material should be rendered in alpha blend mode.
  30969. * @returns a boolean specifying if alpha blending is needed
  30970. */
  30971. needAlphaBlending(): boolean;
  30972. /**
  30973. * Specifies if the mesh will require alpha blending
  30974. * @param mesh defines the mesh to check
  30975. * @returns a boolean specifying if alpha blending is needed for the mesh
  30976. */
  30977. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30978. /**
  30979. * Specifies whether or not this material should be rendered in alpha test mode.
  30980. * @returns a boolean specifying if an alpha test is needed.
  30981. */
  30982. needAlphaTesting(): boolean;
  30983. /**
  30984. * Specifies if material alpha testing should be turned on for the mesh
  30985. * @param mesh defines the mesh to check
  30986. */
  30987. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30988. /**
  30989. * Gets the texture used for the alpha test
  30990. * @returns the texture to use for alpha testing
  30991. */
  30992. getAlphaTestTexture(): Nullable<BaseTexture>;
  30993. /**
  30994. * Marks the material to indicate that it needs to be re-calculated
  30995. */
  30996. markDirty(): void;
  30997. /** @hidden */
  30998. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30999. /**
  31000. * Binds the material to the mesh
  31001. * @param world defines the world transformation matrix
  31002. * @param mesh defines the mesh to bind the material to
  31003. */
  31004. bind(world: Matrix, mesh?: Mesh): void;
  31005. /**
  31006. * Binds the submesh to the material
  31007. * @param world defines the world transformation matrix
  31008. * @param mesh defines the mesh containing the submesh
  31009. * @param subMesh defines the submesh to bind the material to
  31010. */
  31011. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31012. /**
  31013. * Binds the world matrix to the material
  31014. * @param world defines the world transformation matrix
  31015. */
  31016. bindOnlyWorldMatrix(world: Matrix): void;
  31017. /**
  31018. * Binds the scene's uniform buffer to the effect.
  31019. * @param effect defines the effect to bind to the scene uniform buffer
  31020. * @param sceneUbo defines the uniform buffer storing scene data
  31021. */
  31022. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  31023. /**
  31024. * Binds the view matrix to the effect
  31025. * @param effect defines the effect to bind the view matrix to
  31026. */
  31027. bindView(effect: Effect): void;
  31028. /**
  31029. * Binds the view projection matrix to the effect
  31030. * @param effect defines the effect to bind the view projection matrix to
  31031. */
  31032. bindViewProjection(effect: Effect): void;
  31033. /**
  31034. * Processes to execute after binding the material to a mesh
  31035. * @param mesh defines the rendered mesh
  31036. */
  31037. protected _afterBind(mesh?: Mesh): void;
  31038. /**
  31039. * Unbinds the material from the mesh
  31040. */
  31041. unbind(): void;
  31042. /**
  31043. * Gets the active textures from the material
  31044. * @returns an array of textures
  31045. */
  31046. getActiveTextures(): BaseTexture[];
  31047. /**
  31048. * Specifies if the material uses a texture
  31049. * @param texture defines the texture to check against the material
  31050. * @returns a boolean specifying if the material uses the texture
  31051. */
  31052. hasTexture(texture: BaseTexture): boolean;
  31053. /**
  31054. * Makes a duplicate of the material, and gives it a new name
  31055. * @param name defines the new name for the duplicated material
  31056. * @returns the cloned material
  31057. */
  31058. clone(name: string): Nullable<Material>;
  31059. /**
  31060. * Gets the meshes bound to the material
  31061. * @returns an array of meshes bound to the material
  31062. */
  31063. getBindedMeshes(): AbstractMesh[];
  31064. /**
  31065. * Force shader compilation
  31066. * @param mesh defines the mesh associated with this material
  31067. * @param onCompiled defines a function to execute once the material is compiled
  31068. * @param options defines the options to configure the compilation
  31069. * @param onError defines a function to execute if the material fails compiling
  31070. */
  31071. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  31072. /**
  31073. * Force shader compilation
  31074. * @param mesh defines the mesh that will use this material
  31075. * @param options defines additional options for compiling the shaders
  31076. * @returns a promise that resolves when the compilation completes
  31077. */
  31078. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  31079. private static readonly _AllDirtyCallBack;
  31080. private static readonly _ImageProcessingDirtyCallBack;
  31081. private static readonly _TextureDirtyCallBack;
  31082. private static readonly _FresnelDirtyCallBack;
  31083. private static readonly _MiscDirtyCallBack;
  31084. private static readonly _PrePassDirtyCallBack;
  31085. private static readonly _LightsDirtyCallBack;
  31086. private static readonly _AttributeDirtyCallBack;
  31087. private static _FresnelAndMiscDirtyCallBack;
  31088. private static _TextureAndMiscDirtyCallBack;
  31089. private static readonly _DirtyCallbackArray;
  31090. private static readonly _RunDirtyCallBacks;
  31091. /**
  31092. * Marks a define in the material to indicate that it needs to be re-computed
  31093. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  31094. */
  31095. markAsDirty(flag: number): void;
  31096. /**
  31097. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  31098. * @param func defines a function which checks material defines against the submeshes
  31099. */
  31100. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  31101. /**
  31102. * Indicates that the scene should check if the rendering now needs a prepass
  31103. */
  31104. protected _markScenePrePassDirty(): void;
  31105. /**
  31106. * Indicates that we need to re-calculated for all submeshes
  31107. */
  31108. protected _markAllSubMeshesAsAllDirty(): void;
  31109. /**
  31110. * Indicates that image processing needs to be re-calculated for all submeshes
  31111. */
  31112. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  31113. /**
  31114. * Indicates that textures need to be re-calculated for all submeshes
  31115. */
  31116. protected _markAllSubMeshesAsTexturesDirty(): void;
  31117. /**
  31118. * Indicates that fresnel needs to be re-calculated for all submeshes
  31119. */
  31120. protected _markAllSubMeshesAsFresnelDirty(): void;
  31121. /**
  31122. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  31123. */
  31124. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  31125. /**
  31126. * Indicates that lights need to be re-calculated for all submeshes
  31127. */
  31128. protected _markAllSubMeshesAsLightsDirty(): void;
  31129. /**
  31130. * Indicates that attributes need to be re-calculated for all submeshes
  31131. */
  31132. protected _markAllSubMeshesAsAttributesDirty(): void;
  31133. /**
  31134. * Indicates that misc needs to be re-calculated for all submeshes
  31135. */
  31136. protected _markAllSubMeshesAsMiscDirty(): void;
  31137. /**
  31138. * Indicates that prepass needs to be re-calculated for all submeshes
  31139. */
  31140. protected _markAllSubMeshesAsPrePassDirty(): void;
  31141. /**
  31142. * Indicates that textures and misc need to be re-calculated for all submeshes
  31143. */
  31144. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  31145. /**
  31146. * Sets the required values to the prepass renderer.
  31147. * @param prePassRenderer defines the prepass renderer to setup.
  31148. * @returns true if the pre pass is needed.
  31149. */
  31150. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  31151. /**
  31152. * Disposes the material
  31153. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31154. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31155. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  31156. */
  31157. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  31158. /** @hidden */
  31159. private releaseVertexArrayObject;
  31160. /**
  31161. * Serializes this material
  31162. * @returns the serialized material object
  31163. */
  31164. serialize(): any;
  31165. /**
  31166. * Creates a material from parsed material data
  31167. * @param parsedMaterial defines parsed material data
  31168. * @param scene defines the hosting scene
  31169. * @param rootUrl defines the root URL to use to load textures
  31170. * @returns a new material
  31171. */
  31172. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  31173. }
  31174. }
  31175. declare module "babylonjs/Materials/multiMaterial" {
  31176. import { Nullable } from "babylonjs/types";
  31177. import { Scene } from "babylonjs/scene";
  31178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31179. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31181. import { Material } from "babylonjs/Materials/material";
  31182. /**
  31183. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31184. * separate meshes. This can be use to improve performances.
  31185. * @see https://doc.babylonjs.com/how_to/multi_materials
  31186. */
  31187. export class MultiMaterial extends Material {
  31188. private _subMaterials;
  31189. /**
  31190. * Gets or Sets the list of Materials used within the multi material.
  31191. * They need to be ordered according to the submeshes order in the associated mesh
  31192. */
  31193. get subMaterials(): Nullable<Material>[];
  31194. set subMaterials(value: Nullable<Material>[]);
  31195. /**
  31196. * Function used to align with Node.getChildren()
  31197. * @returns the list of Materials used within the multi material
  31198. */
  31199. getChildren(): Nullable<Material>[];
  31200. /**
  31201. * Instantiates a new Multi Material
  31202. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31203. * separate meshes. This can be use to improve performances.
  31204. * @see https://doc.babylonjs.com/how_to/multi_materials
  31205. * @param name Define the name in the scene
  31206. * @param scene Define the scene the material belongs to
  31207. */
  31208. constructor(name: string, scene: Scene);
  31209. private _hookArray;
  31210. /**
  31211. * Get one of the submaterial by its index in the submaterials array
  31212. * @param index The index to look the sub material at
  31213. * @returns The Material if the index has been defined
  31214. */
  31215. getSubMaterial(index: number): Nullable<Material>;
  31216. /**
  31217. * Get the list of active textures for the whole sub materials list.
  31218. * @returns All the textures that will be used during the rendering
  31219. */
  31220. getActiveTextures(): BaseTexture[];
  31221. /**
  31222. * Specifies if any sub-materials of this multi-material use a given texture.
  31223. * @param texture Defines the texture to check against this multi-material's sub-materials.
  31224. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  31225. */
  31226. hasTexture(texture: BaseTexture): boolean;
  31227. /**
  31228. * Gets the current class name of the material e.g. "MultiMaterial"
  31229. * Mainly use in serialization.
  31230. * @returns the class name
  31231. */
  31232. getClassName(): string;
  31233. /**
  31234. * Checks if the material is ready to render the requested sub mesh
  31235. * @param mesh Define the mesh the submesh belongs to
  31236. * @param subMesh Define the sub mesh to look readyness for
  31237. * @param useInstances Define whether or not the material is used with instances
  31238. * @returns true if ready, otherwise false
  31239. */
  31240. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31241. /**
  31242. * Clones the current material and its related sub materials
  31243. * @param name Define the name of the newly cloned material
  31244. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31245. * @returns the cloned material
  31246. */
  31247. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31248. /**
  31249. * Serializes the materials into a JSON representation.
  31250. * @returns the JSON representation
  31251. */
  31252. serialize(): any;
  31253. /**
  31254. * Dispose the material and release its associated resources
  31255. * @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)
  31256. * @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)
  31257. * @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)
  31258. */
  31259. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31260. /**
  31261. * Creates a MultiMaterial from parsed MultiMaterial data.
  31262. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31263. * @param scene defines the hosting scene
  31264. * @returns a new MultiMaterial
  31265. */
  31266. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31267. }
  31268. }
  31269. declare module "babylonjs/Meshes/subMesh" {
  31270. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31271. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31272. import { Engine } from "babylonjs/Engines/engine";
  31273. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31274. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31275. import { Effect } from "babylonjs/Materials/effect";
  31276. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31277. import { Plane } from "babylonjs/Maths/math.plane";
  31278. import { Collider } from "babylonjs/Collisions/collider";
  31279. import { Material } from "babylonjs/Materials/material";
  31280. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31282. import { Mesh } from "babylonjs/Meshes/mesh";
  31283. import { Ray } from "babylonjs/Culling/ray";
  31284. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31285. /**
  31286. * Defines a subdivision inside a mesh
  31287. */
  31288. export class SubMesh implements ICullable {
  31289. /** the material index to use */
  31290. materialIndex: number;
  31291. /** vertex index start */
  31292. verticesStart: number;
  31293. /** vertices count */
  31294. verticesCount: number;
  31295. /** index start */
  31296. indexStart: number;
  31297. /** indices count */
  31298. indexCount: number;
  31299. /** @hidden */
  31300. _materialDefines: Nullable<MaterialDefines>;
  31301. /** @hidden */
  31302. _materialEffect: Nullable<Effect>;
  31303. /** @hidden */
  31304. _effectOverride: Nullable<Effect>;
  31305. /**
  31306. * Gets material defines used by the effect associated to the sub mesh
  31307. */
  31308. get materialDefines(): Nullable<MaterialDefines>;
  31309. /**
  31310. * Sets material defines used by the effect associated to the sub mesh
  31311. */
  31312. set materialDefines(defines: Nullable<MaterialDefines>);
  31313. /**
  31314. * Gets associated effect
  31315. */
  31316. get effect(): Nullable<Effect>;
  31317. /**
  31318. * Sets associated effect (effect used to render this submesh)
  31319. * @param effect defines the effect to associate with
  31320. * @param defines defines the set of defines used to compile this effect
  31321. */
  31322. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31323. /** @hidden */
  31324. _linesIndexCount: number;
  31325. private _mesh;
  31326. private _renderingMesh;
  31327. private _boundingInfo;
  31328. private _linesIndexBuffer;
  31329. /** @hidden */
  31330. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31331. /** @hidden */
  31332. _trianglePlanes: Plane[];
  31333. /** @hidden */
  31334. _lastColliderTransformMatrix: Nullable<Matrix>;
  31335. /** @hidden */
  31336. _renderId: number;
  31337. /** @hidden */
  31338. _alphaIndex: number;
  31339. /** @hidden */
  31340. _distanceToCamera: number;
  31341. /** @hidden */
  31342. _id: number;
  31343. private _currentMaterial;
  31344. /**
  31345. * Add a new submesh to a mesh
  31346. * @param materialIndex defines the material index to use
  31347. * @param verticesStart defines vertex index start
  31348. * @param verticesCount defines vertices count
  31349. * @param indexStart defines index start
  31350. * @param indexCount defines indices count
  31351. * @param mesh defines the parent mesh
  31352. * @param renderingMesh defines an optional rendering mesh
  31353. * @param createBoundingBox defines if bounding box should be created for this submesh
  31354. * @returns the new submesh
  31355. */
  31356. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31357. /**
  31358. * Creates a new submesh
  31359. * @param materialIndex defines the material index to use
  31360. * @param verticesStart defines vertex index start
  31361. * @param verticesCount defines vertices count
  31362. * @param indexStart defines index start
  31363. * @param indexCount defines indices count
  31364. * @param mesh defines the parent mesh
  31365. * @param renderingMesh defines an optional rendering mesh
  31366. * @param createBoundingBox defines if bounding box should be created for this submesh
  31367. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31368. */
  31369. constructor(
  31370. /** the material index to use */
  31371. materialIndex: number,
  31372. /** vertex index start */
  31373. verticesStart: number,
  31374. /** vertices count */
  31375. verticesCount: number,
  31376. /** index start */
  31377. indexStart: number,
  31378. /** indices count */
  31379. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31380. /**
  31381. * Returns true if this submesh covers the entire parent mesh
  31382. * @ignorenaming
  31383. */
  31384. get IsGlobal(): boolean;
  31385. /**
  31386. * Returns the submesh BoudingInfo object
  31387. * @returns current bounding info (or mesh's one if the submesh is global)
  31388. */
  31389. getBoundingInfo(): BoundingInfo;
  31390. /**
  31391. * Sets the submesh BoundingInfo
  31392. * @param boundingInfo defines the new bounding info to use
  31393. * @returns the SubMesh
  31394. */
  31395. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31396. /**
  31397. * Returns the mesh of the current submesh
  31398. * @return the parent mesh
  31399. */
  31400. getMesh(): AbstractMesh;
  31401. /**
  31402. * Returns the rendering mesh of the submesh
  31403. * @returns the rendering mesh (could be different from parent mesh)
  31404. */
  31405. getRenderingMesh(): Mesh;
  31406. /**
  31407. * Returns the replacement mesh of the submesh
  31408. * @returns the replacement mesh (could be different from parent mesh)
  31409. */
  31410. getReplacementMesh(): Nullable<AbstractMesh>;
  31411. /**
  31412. * Returns the effective mesh of the submesh
  31413. * @returns the effective mesh (could be different from parent mesh)
  31414. */
  31415. getEffectiveMesh(): AbstractMesh;
  31416. /**
  31417. * Returns the submesh material
  31418. * @returns null or the current material
  31419. */
  31420. getMaterial(): Nullable<Material>;
  31421. private _IsMultiMaterial;
  31422. /**
  31423. * Sets a new updated BoundingInfo object to the submesh
  31424. * @param data defines an optional position array to use to determine the bounding info
  31425. * @returns the SubMesh
  31426. */
  31427. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31428. /** @hidden */
  31429. _checkCollision(collider: Collider): boolean;
  31430. /**
  31431. * Updates the submesh BoundingInfo
  31432. * @param world defines the world matrix to use to update the bounding info
  31433. * @returns the submesh
  31434. */
  31435. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31436. /**
  31437. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31438. * @param frustumPlanes defines the frustum planes
  31439. * @returns true if the submesh is intersecting with the frustum
  31440. */
  31441. isInFrustum(frustumPlanes: Plane[]): boolean;
  31442. /**
  31443. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31444. * @param frustumPlanes defines the frustum planes
  31445. * @returns true if the submesh is inside the frustum
  31446. */
  31447. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31448. /**
  31449. * Renders the submesh
  31450. * @param enableAlphaMode defines if alpha needs to be used
  31451. * @returns the submesh
  31452. */
  31453. render(enableAlphaMode: boolean): SubMesh;
  31454. /**
  31455. * @hidden
  31456. */
  31457. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31458. /**
  31459. * Checks if the submesh intersects with a ray
  31460. * @param ray defines the ray to test
  31461. * @returns true is the passed ray intersects the submesh bounding box
  31462. */
  31463. canIntersects(ray: Ray): boolean;
  31464. /**
  31465. * Intersects current submesh with a ray
  31466. * @param ray defines the ray to test
  31467. * @param positions defines mesh's positions array
  31468. * @param indices defines mesh's indices array
  31469. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31470. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31471. * @returns intersection info or null if no intersection
  31472. */
  31473. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31474. /** @hidden */
  31475. private _intersectLines;
  31476. /** @hidden */
  31477. private _intersectUnIndexedLines;
  31478. /** @hidden */
  31479. private _intersectTriangles;
  31480. /** @hidden */
  31481. private _intersectUnIndexedTriangles;
  31482. /** @hidden */
  31483. _rebuild(): void;
  31484. /**
  31485. * Creates a new submesh from the passed mesh
  31486. * @param newMesh defines the new hosting mesh
  31487. * @param newRenderingMesh defines an optional rendering mesh
  31488. * @returns the new submesh
  31489. */
  31490. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31491. /**
  31492. * Release associated resources
  31493. */
  31494. dispose(): void;
  31495. /**
  31496. * Gets the class name
  31497. * @returns the string "SubMesh".
  31498. */
  31499. getClassName(): string;
  31500. /**
  31501. * Creates a new submesh from indices data
  31502. * @param materialIndex the index of the main mesh material
  31503. * @param startIndex the index where to start the copy in the mesh indices array
  31504. * @param indexCount the number of indices to copy then from the startIndex
  31505. * @param mesh the main mesh to create the submesh from
  31506. * @param renderingMesh the optional rendering mesh
  31507. * @returns a new submesh
  31508. */
  31509. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31510. }
  31511. }
  31512. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31513. /**
  31514. * Class used to represent data loading progression
  31515. */
  31516. export class SceneLoaderFlags {
  31517. private static _ForceFullSceneLoadingForIncremental;
  31518. private static _ShowLoadingScreen;
  31519. private static _CleanBoneMatrixWeights;
  31520. private static _loggingLevel;
  31521. /**
  31522. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31523. */
  31524. static get ForceFullSceneLoadingForIncremental(): boolean;
  31525. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31526. /**
  31527. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31528. */
  31529. static get ShowLoadingScreen(): boolean;
  31530. static set ShowLoadingScreen(value: boolean);
  31531. /**
  31532. * Defines the current logging level (while loading the scene)
  31533. * @ignorenaming
  31534. */
  31535. static get loggingLevel(): number;
  31536. static set loggingLevel(value: number);
  31537. /**
  31538. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31539. */
  31540. static get CleanBoneMatrixWeights(): boolean;
  31541. static set CleanBoneMatrixWeights(value: boolean);
  31542. }
  31543. }
  31544. declare module "babylonjs/Meshes/geometry" {
  31545. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31546. import { Scene } from "babylonjs/scene";
  31547. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31548. import { Engine } from "babylonjs/Engines/engine";
  31549. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31550. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31551. import { Effect } from "babylonjs/Materials/effect";
  31552. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31553. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31554. import { Mesh } from "babylonjs/Meshes/mesh";
  31555. /**
  31556. * Class used to store geometry data (vertex buffers + index buffer)
  31557. */
  31558. export class Geometry implements IGetSetVerticesData {
  31559. /**
  31560. * Gets or sets the ID of the geometry
  31561. */
  31562. id: string;
  31563. /**
  31564. * Gets or sets the unique ID of the geometry
  31565. */
  31566. uniqueId: number;
  31567. /**
  31568. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31569. */
  31570. delayLoadState: number;
  31571. /**
  31572. * Gets the file containing the data to load when running in delay load state
  31573. */
  31574. delayLoadingFile: Nullable<string>;
  31575. /**
  31576. * Callback called when the geometry is updated
  31577. */
  31578. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31579. private _scene;
  31580. private _engine;
  31581. private _meshes;
  31582. private _totalVertices;
  31583. /** @hidden */
  31584. _indices: IndicesArray;
  31585. /** @hidden */
  31586. _vertexBuffers: {
  31587. [key: string]: VertexBuffer;
  31588. };
  31589. private _isDisposed;
  31590. private _extend;
  31591. private _boundingBias;
  31592. /** @hidden */
  31593. _delayInfo: Array<string>;
  31594. private _indexBuffer;
  31595. private _indexBufferIsUpdatable;
  31596. /** @hidden */
  31597. _boundingInfo: Nullable<BoundingInfo>;
  31598. /** @hidden */
  31599. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31600. /** @hidden */
  31601. _softwareSkinningFrameId: number;
  31602. private _vertexArrayObjects;
  31603. private _updatable;
  31604. /** @hidden */
  31605. _positions: Nullable<Vector3[]>;
  31606. private _positionsCache;
  31607. /**
  31608. * 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
  31609. */
  31610. get boundingBias(): Vector2;
  31611. /**
  31612. * 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
  31613. */
  31614. set boundingBias(value: Vector2);
  31615. /**
  31616. * Static function used to attach a new empty geometry to a mesh
  31617. * @param mesh defines the mesh to attach the geometry to
  31618. * @returns the new Geometry
  31619. */
  31620. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31621. /** Get the list of meshes using this geometry */
  31622. get meshes(): Mesh[];
  31623. /**
  31624. * 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
  31625. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31626. */
  31627. useBoundingInfoFromGeometry: boolean;
  31628. /**
  31629. * Creates a new geometry
  31630. * @param id defines the unique ID
  31631. * @param scene defines the hosting scene
  31632. * @param vertexData defines the VertexData used to get geometry data
  31633. * @param updatable defines if geometry must be updatable (false by default)
  31634. * @param mesh defines the mesh that will be associated with the geometry
  31635. */
  31636. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31637. /**
  31638. * Gets the current extend of the geometry
  31639. */
  31640. get extend(): {
  31641. minimum: Vector3;
  31642. maximum: Vector3;
  31643. };
  31644. /**
  31645. * Gets the hosting scene
  31646. * @returns the hosting Scene
  31647. */
  31648. getScene(): Scene;
  31649. /**
  31650. * Gets the hosting engine
  31651. * @returns the hosting Engine
  31652. */
  31653. getEngine(): Engine;
  31654. /**
  31655. * Defines if the geometry is ready to use
  31656. * @returns true if the geometry is ready to be used
  31657. */
  31658. isReady(): boolean;
  31659. /**
  31660. * Gets a value indicating that the geometry should not be serialized
  31661. */
  31662. get doNotSerialize(): boolean;
  31663. /** @hidden */
  31664. _rebuild(): void;
  31665. /**
  31666. * Affects all geometry data in one call
  31667. * @param vertexData defines the geometry data
  31668. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31669. */
  31670. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31671. /**
  31672. * Set specific vertex data
  31673. * @param kind defines the data kind (Position, normal, etc...)
  31674. * @param data defines the vertex data to use
  31675. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31676. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31677. */
  31678. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31679. /**
  31680. * Removes a specific vertex data
  31681. * @param kind defines the data kind (Position, normal, etc...)
  31682. */
  31683. removeVerticesData(kind: string): void;
  31684. /**
  31685. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31686. * @param buffer defines the vertex buffer to use
  31687. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31688. */
  31689. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31690. /**
  31691. * Update a specific vertex buffer
  31692. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31693. * It will do nothing if the buffer is not updatable
  31694. * @param kind defines the data kind (Position, normal, etc...)
  31695. * @param data defines the data to use
  31696. * @param offset defines the offset in the target buffer where to store the data
  31697. * @param useBytes set to true if the offset is in bytes
  31698. */
  31699. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31700. /**
  31701. * Update a specific vertex buffer
  31702. * This function will create a new buffer if the current one is not updatable
  31703. * @param kind defines the data kind (Position, normal, etc...)
  31704. * @param data defines the data to use
  31705. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31706. */
  31707. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31708. private _updateBoundingInfo;
  31709. /** @hidden */
  31710. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31711. /**
  31712. * Gets total number of vertices
  31713. * @returns the total number of vertices
  31714. */
  31715. getTotalVertices(): number;
  31716. /**
  31717. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31718. * @param kind defines the data kind (Position, normal, etc...)
  31719. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31720. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31721. * @returns a float array containing vertex data
  31722. */
  31723. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31724. /**
  31725. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31726. * @param kind defines the data kind (Position, normal, etc...)
  31727. * @returns true if the vertex buffer with the specified kind is updatable
  31728. */
  31729. isVertexBufferUpdatable(kind: string): boolean;
  31730. /**
  31731. * Gets a specific vertex buffer
  31732. * @param kind defines the data kind (Position, normal, etc...)
  31733. * @returns a VertexBuffer
  31734. */
  31735. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31736. /**
  31737. * Returns all vertex buffers
  31738. * @return an object holding all vertex buffers indexed by kind
  31739. */
  31740. getVertexBuffers(): Nullable<{
  31741. [key: string]: VertexBuffer;
  31742. }>;
  31743. /**
  31744. * Gets a boolean indicating if specific vertex buffer is present
  31745. * @param kind defines the data kind (Position, normal, etc...)
  31746. * @returns true if data is present
  31747. */
  31748. isVerticesDataPresent(kind: string): boolean;
  31749. /**
  31750. * Gets a list of all attached data kinds (Position, normal, etc...)
  31751. * @returns a list of string containing all kinds
  31752. */
  31753. getVerticesDataKinds(): string[];
  31754. /**
  31755. * Update index buffer
  31756. * @param indices defines the indices to store in the index buffer
  31757. * @param offset defines the offset in the target buffer where to store the data
  31758. * @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)
  31759. */
  31760. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31761. /**
  31762. * Creates a new index buffer
  31763. * @param indices defines the indices to store in the index buffer
  31764. * @param totalVertices defines the total number of vertices (could be null)
  31765. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31766. */
  31767. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31768. /**
  31769. * Return the total number of indices
  31770. * @returns the total number of indices
  31771. */
  31772. getTotalIndices(): number;
  31773. /**
  31774. * Gets the index buffer array
  31775. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31776. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31777. * @returns the index buffer array
  31778. */
  31779. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31780. /**
  31781. * Gets the index buffer
  31782. * @return the index buffer
  31783. */
  31784. getIndexBuffer(): Nullable<DataBuffer>;
  31785. /** @hidden */
  31786. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31787. /**
  31788. * Release the associated resources for a specific mesh
  31789. * @param mesh defines the source mesh
  31790. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31791. */
  31792. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31793. /**
  31794. * Apply current geometry to a given mesh
  31795. * @param mesh defines the mesh to apply geometry to
  31796. */
  31797. applyToMesh(mesh: Mesh): void;
  31798. private _updateExtend;
  31799. private _applyToMesh;
  31800. private notifyUpdate;
  31801. /**
  31802. * Load the geometry if it was flagged as delay loaded
  31803. * @param scene defines the hosting scene
  31804. * @param onLoaded defines a callback called when the geometry is loaded
  31805. */
  31806. load(scene: Scene, onLoaded?: () => void): void;
  31807. private _queueLoad;
  31808. /**
  31809. * Invert the geometry to move from a right handed system to a left handed one.
  31810. */
  31811. toLeftHanded(): void;
  31812. /** @hidden */
  31813. _resetPointsArrayCache(): void;
  31814. /** @hidden */
  31815. _generatePointsArray(): boolean;
  31816. /**
  31817. * Gets a value indicating if the geometry is disposed
  31818. * @returns true if the geometry was disposed
  31819. */
  31820. isDisposed(): boolean;
  31821. private _disposeVertexArrayObjects;
  31822. /**
  31823. * Free all associated resources
  31824. */
  31825. dispose(): void;
  31826. /**
  31827. * Clone the current geometry into a new geometry
  31828. * @param id defines the unique ID of the new geometry
  31829. * @returns a new geometry object
  31830. */
  31831. copy(id: string): Geometry;
  31832. /**
  31833. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31834. * @return a JSON representation of the current geometry data (without the vertices data)
  31835. */
  31836. serialize(): any;
  31837. private toNumberArray;
  31838. /**
  31839. * Serialize all vertices data into a JSON oject
  31840. * @returns a JSON representation of the current geometry data
  31841. */
  31842. serializeVerticeData(): any;
  31843. /**
  31844. * Extracts a clone of a mesh geometry
  31845. * @param mesh defines the source mesh
  31846. * @param id defines the unique ID of the new geometry object
  31847. * @returns the new geometry object
  31848. */
  31849. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31850. /**
  31851. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31852. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31853. * Be aware Math.random() could cause collisions, but:
  31854. * "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"
  31855. * @returns a string containing a new GUID
  31856. */
  31857. static RandomId(): string;
  31858. /** @hidden */
  31859. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31860. private static _CleanMatricesWeights;
  31861. /**
  31862. * Create a new geometry from persisted data (Using .babylon file format)
  31863. * @param parsedVertexData defines the persisted data
  31864. * @param scene defines the hosting scene
  31865. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31866. * @returns the new geometry object
  31867. */
  31868. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31869. }
  31870. }
  31871. declare module "babylonjs/Morph/morphTarget" {
  31872. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31873. import { Observable } from "babylonjs/Misc/observable";
  31874. import { Nullable, FloatArray } from "babylonjs/types";
  31875. import { Scene } from "babylonjs/scene";
  31876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31877. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31878. /**
  31879. * Defines a target to use with MorphTargetManager
  31880. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31881. */
  31882. export class MorphTarget implements IAnimatable {
  31883. /** defines the name of the target */
  31884. name: string;
  31885. /**
  31886. * Gets or sets the list of animations
  31887. */
  31888. animations: import("babylonjs/Animations/animation").Animation[];
  31889. private _scene;
  31890. private _positions;
  31891. private _normals;
  31892. private _tangents;
  31893. private _uvs;
  31894. private _influence;
  31895. private _uniqueId;
  31896. /**
  31897. * Observable raised when the influence changes
  31898. */
  31899. onInfluenceChanged: Observable<boolean>;
  31900. /** @hidden */
  31901. _onDataLayoutChanged: Observable<void>;
  31902. /**
  31903. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31904. */
  31905. get influence(): number;
  31906. set influence(influence: number);
  31907. /**
  31908. * Gets or sets the id of the morph Target
  31909. */
  31910. id: string;
  31911. private _animationPropertiesOverride;
  31912. /**
  31913. * Gets or sets the animation properties override
  31914. */
  31915. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31916. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31917. /**
  31918. * Creates a new MorphTarget
  31919. * @param name defines the name of the target
  31920. * @param influence defines the influence to use
  31921. * @param scene defines the scene the morphtarget belongs to
  31922. */
  31923. constructor(
  31924. /** defines the name of the target */
  31925. name: string, influence?: number, scene?: Nullable<Scene>);
  31926. /**
  31927. * Gets the unique ID of this manager
  31928. */
  31929. get uniqueId(): number;
  31930. /**
  31931. * Gets a boolean defining if the target contains position data
  31932. */
  31933. get hasPositions(): boolean;
  31934. /**
  31935. * Gets a boolean defining if the target contains normal data
  31936. */
  31937. get hasNormals(): boolean;
  31938. /**
  31939. * Gets a boolean defining if the target contains tangent data
  31940. */
  31941. get hasTangents(): boolean;
  31942. /**
  31943. * Gets a boolean defining if the target contains texture coordinates data
  31944. */
  31945. get hasUVs(): boolean;
  31946. /**
  31947. * Affects position data to this target
  31948. * @param data defines the position data to use
  31949. */
  31950. setPositions(data: Nullable<FloatArray>): void;
  31951. /**
  31952. * Gets the position data stored in this target
  31953. * @returns a FloatArray containing the position data (or null if not present)
  31954. */
  31955. getPositions(): Nullable<FloatArray>;
  31956. /**
  31957. * Affects normal data to this target
  31958. * @param data defines the normal data to use
  31959. */
  31960. setNormals(data: Nullable<FloatArray>): void;
  31961. /**
  31962. * Gets the normal data stored in this target
  31963. * @returns a FloatArray containing the normal data (or null if not present)
  31964. */
  31965. getNormals(): Nullable<FloatArray>;
  31966. /**
  31967. * Affects tangent data to this target
  31968. * @param data defines the tangent data to use
  31969. */
  31970. setTangents(data: Nullable<FloatArray>): void;
  31971. /**
  31972. * Gets the tangent data stored in this target
  31973. * @returns a FloatArray containing the tangent data (or null if not present)
  31974. */
  31975. getTangents(): Nullable<FloatArray>;
  31976. /**
  31977. * Affects texture coordinates data to this target
  31978. * @param data defines the texture coordinates data to use
  31979. */
  31980. setUVs(data: Nullable<FloatArray>): void;
  31981. /**
  31982. * Gets the texture coordinates data stored in this target
  31983. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31984. */
  31985. getUVs(): Nullable<FloatArray>;
  31986. /**
  31987. * Clone the current target
  31988. * @returns a new MorphTarget
  31989. */
  31990. clone(): MorphTarget;
  31991. /**
  31992. * Serializes the current target into a Serialization object
  31993. * @returns the serialized object
  31994. */
  31995. serialize(): any;
  31996. /**
  31997. * Returns the string "MorphTarget"
  31998. * @returns "MorphTarget"
  31999. */
  32000. getClassName(): string;
  32001. /**
  32002. * Creates a new target from serialized data
  32003. * @param serializationObject defines the serialized data to use
  32004. * @returns a new MorphTarget
  32005. */
  32006. static Parse(serializationObject: any): MorphTarget;
  32007. /**
  32008. * Creates a MorphTarget from mesh data
  32009. * @param mesh defines the source mesh
  32010. * @param name defines the name to use for the new target
  32011. * @param influence defines the influence to attach to the target
  32012. * @returns a new MorphTarget
  32013. */
  32014. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32015. }
  32016. }
  32017. declare module "babylonjs/Morph/morphTargetManager" {
  32018. import { Nullable } from "babylonjs/types";
  32019. import { Scene } from "babylonjs/scene";
  32020. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32021. /**
  32022. * This class is used to deform meshes using morphing between different targets
  32023. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32024. */
  32025. export class MorphTargetManager {
  32026. private _targets;
  32027. private _targetInfluenceChangedObservers;
  32028. private _targetDataLayoutChangedObservers;
  32029. private _activeTargets;
  32030. private _scene;
  32031. private _influences;
  32032. private _supportsNormals;
  32033. private _supportsTangents;
  32034. private _supportsUVs;
  32035. private _vertexCount;
  32036. private _uniqueId;
  32037. private _tempInfluences;
  32038. /**
  32039. * Gets or sets a boolean indicating if normals must be morphed
  32040. */
  32041. enableNormalMorphing: boolean;
  32042. /**
  32043. * Gets or sets a boolean indicating if tangents must be morphed
  32044. */
  32045. enableTangentMorphing: boolean;
  32046. /**
  32047. * Gets or sets a boolean indicating if UV must be morphed
  32048. */
  32049. enableUVMorphing: boolean;
  32050. /**
  32051. * Creates a new MorphTargetManager
  32052. * @param scene defines the current scene
  32053. */
  32054. constructor(scene?: Nullable<Scene>);
  32055. /**
  32056. * Gets the unique ID of this manager
  32057. */
  32058. get uniqueId(): number;
  32059. /**
  32060. * Gets the number of vertices handled by this manager
  32061. */
  32062. get vertexCount(): number;
  32063. /**
  32064. * Gets a boolean indicating if this manager supports morphing of normals
  32065. */
  32066. get supportsNormals(): boolean;
  32067. /**
  32068. * Gets a boolean indicating if this manager supports morphing of tangents
  32069. */
  32070. get supportsTangents(): boolean;
  32071. /**
  32072. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32073. */
  32074. get supportsUVs(): boolean;
  32075. /**
  32076. * Gets the number of targets stored in this manager
  32077. */
  32078. get numTargets(): number;
  32079. /**
  32080. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32081. */
  32082. get numInfluencers(): number;
  32083. /**
  32084. * Gets the list of influences (one per target)
  32085. */
  32086. get influences(): Float32Array;
  32087. /**
  32088. * Gets the active target at specified index. An active target is a target with an influence > 0
  32089. * @param index defines the index to check
  32090. * @returns the requested target
  32091. */
  32092. getActiveTarget(index: number): MorphTarget;
  32093. /**
  32094. * Gets the target at specified index
  32095. * @param index defines the index to check
  32096. * @returns the requested target
  32097. */
  32098. getTarget(index: number): MorphTarget;
  32099. /**
  32100. * Add a new target to this manager
  32101. * @param target defines the target to add
  32102. */
  32103. addTarget(target: MorphTarget): void;
  32104. /**
  32105. * Removes a target from the manager
  32106. * @param target defines the target to remove
  32107. */
  32108. removeTarget(target: MorphTarget): void;
  32109. /**
  32110. * Clone the current manager
  32111. * @returns a new MorphTargetManager
  32112. */
  32113. clone(): MorphTargetManager;
  32114. /**
  32115. * Serializes the current manager into a Serialization object
  32116. * @returns the serialized object
  32117. */
  32118. serialize(): any;
  32119. private _syncActiveTargets;
  32120. /**
  32121. * Syncrhonize the targets with all the meshes using this morph target manager
  32122. */
  32123. synchronize(): void;
  32124. /**
  32125. * Creates a new MorphTargetManager from serialized data
  32126. * @param serializationObject defines the serialized data
  32127. * @param scene defines the hosting scene
  32128. * @returns the new MorphTargetManager
  32129. */
  32130. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32131. }
  32132. }
  32133. declare module "babylonjs/Meshes/meshLODLevel" {
  32134. import { Mesh } from "babylonjs/Meshes/mesh";
  32135. import { Nullable } from "babylonjs/types";
  32136. /**
  32137. * Class used to represent a specific level of detail of a mesh
  32138. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32139. */
  32140. export class MeshLODLevel {
  32141. /** Defines the distance where this level should start being displayed */
  32142. distance: number;
  32143. /** Defines the mesh to use to render this level */
  32144. mesh: Nullable<Mesh>;
  32145. /**
  32146. * Creates a new LOD level
  32147. * @param distance defines the distance where this level should star being displayed
  32148. * @param mesh defines the mesh to use to render this level
  32149. */
  32150. constructor(
  32151. /** Defines the distance where this level should start being displayed */
  32152. distance: number,
  32153. /** Defines the mesh to use to render this level */
  32154. mesh: Nullable<Mesh>);
  32155. }
  32156. }
  32157. declare module "babylonjs/Misc/canvasGenerator" {
  32158. /**
  32159. * Helper class used to generate a canvas to manipulate images
  32160. */
  32161. export class CanvasGenerator {
  32162. /**
  32163. * Create a new canvas (or offscreen canvas depending on the context)
  32164. * @param width defines the expected width
  32165. * @param height defines the expected height
  32166. * @return a new canvas or offscreen canvas
  32167. */
  32168. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32169. }
  32170. }
  32171. declare module "babylonjs/Meshes/groundMesh" {
  32172. import { Scene } from "babylonjs/scene";
  32173. import { Vector3 } from "babylonjs/Maths/math.vector";
  32174. import { Mesh } from "babylonjs/Meshes/mesh";
  32175. /**
  32176. * Mesh representing the gorund
  32177. */
  32178. export class GroundMesh extends Mesh {
  32179. /** If octree should be generated */
  32180. generateOctree: boolean;
  32181. private _heightQuads;
  32182. /** @hidden */
  32183. _subdivisionsX: number;
  32184. /** @hidden */
  32185. _subdivisionsY: number;
  32186. /** @hidden */
  32187. _width: number;
  32188. /** @hidden */
  32189. _height: number;
  32190. /** @hidden */
  32191. _minX: number;
  32192. /** @hidden */
  32193. _maxX: number;
  32194. /** @hidden */
  32195. _minZ: number;
  32196. /** @hidden */
  32197. _maxZ: number;
  32198. constructor(name: string, scene: Scene);
  32199. /**
  32200. * "GroundMesh"
  32201. * @returns "GroundMesh"
  32202. */
  32203. getClassName(): string;
  32204. /**
  32205. * The minimum of x and y subdivisions
  32206. */
  32207. get subdivisions(): number;
  32208. /**
  32209. * X subdivisions
  32210. */
  32211. get subdivisionsX(): number;
  32212. /**
  32213. * Y subdivisions
  32214. */
  32215. get subdivisionsY(): number;
  32216. /**
  32217. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32218. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32219. * @param chunksCount the number of subdivisions for x and y
  32220. * @param octreeBlocksSize (Default: 32)
  32221. */
  32222. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32223. /**
  32224. * Returns a height (y) value in the Worl system :
  32225. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32226. * @param x x coordinate
  32227. * @param z z coordinate
  32228. * @returns the ground y position if (x, z) are outside the ground surface.
  32229. */
  32230. getHeightAtCoordinates(x: number, z: number): number;
  32231. /**
  32232. * Returns a normalized vector (Vector3) orthogonal to the ground
  32233. * at the ground coordinates (x, z) expressed in the World system.
  32234. * @param x x coordinate
  32235. * @param z z coordinate
  32236. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32237. */
  32238. getNormalAtCoordinates(x: number, z: number): Vector3;
  32239. /**
  32240. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32241. * at the ground coordinates (x, z) expressed in the World system.
  32242. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32243. * @param x x coordinate
  32244. * @param z z coordinate
  32245. * @param ref vector to store the result
  32246. * @returns the GroundMesh.
  32247. */
  32248. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32249. /**
  32250. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32251. * if the ground has been updated.
  32252. * This can be used in the render loop.
  32253. * @returns the GroundMesh.
  32254. */
  32255. updateCoordinateHeights(): GroundMesh;
  32256. private _getFacetAt;
  32257. private _initHeightQuads;
  32258. private _computeHeightQuads;
  32259. /**
  32260. * Serializes this ground mesh
  32261. * @param serializationObject object to write serialization to
  32262. */
  32263. serialize(serializationObject: any): void;
  32264. /**
  32265. * Parses a serialized ground mesh
  32266. * @param parsedMesh the serialized mesh
  32267. * @param scene the scene to create the ground mesh in
  32268. * @returns the created ground mesh
  32269. */
  32270. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32271. }
  32272. }
  32273. declare module "babylonjs/Physics/physicsJoint" {
  32274. import { Vector3 } from "babylonjs/Maths/math.vector";
  32275. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32276. /**
  32277. * Interface for Physics-Joint data
  32278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32279. */
  32280. export interface PhysicsJointData {
  32281. /**
  32282. * The main pivot of the joint
  32283. */
  32284. mainPivot?: Vector3;
  32285. /**
  32286. * The connected pivot of the joint
  32287. */
  32288. connectedPivot?: Vector3;
  32289. /**
  32290. * The main axis of the joint
  32291. */
  32292. mainAxis?: Vector3;
  32293. /**
  32294. * The connected axis of the joint
  32295. */
  32296. connectedAxis?: Vector3;
  32297. /**
  32298. * The collision of the joint
  32299. */
  32300. collision?: boolean;
  32301. /**
  32302. * Native Oimo/Cannon/Energy data
  32303. */
  32304. nativeParams?: any;
  32305. }
  32306. /**
  32307. * This is a holder class for the physics joint created by the physics plugin
  32308. * It holds a set of functions to control the underlying joint
  32309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32310. */
  32311. export class PhysicsJoint {
  32312. /**
  32313. * The type of the physics joint
  32314. */
  32315. type: number;
  32316. /**
  32317. * The data for the physics joint
  32318. */
  32319. jointData: PhysicsJointData;
  32320. private _physicsJoint;
  32321. protected _physicsPlugin: IPhysicsEnginePlugin;
  32322. /**
  32323. * Initializes the physics joint
  32324. * @param type The type of the physics joint
  32325. * @param jointData The data for the physics joint
  32326. */
  32327. constructor(
  32328. /**
  32329. * The type of the physics joint
  32330. */
  32331. type: number,
  32332. /**
  32333. * The data for the physics joint
  32334. */
  32335. jointData: PhysicsJointData);
  32336. /**
  32337. * Gets the physics joint
  32338. */
  32339. get physicsJoint(): any;
  32340. /**
  32341. * Sets the physics joint
  32342. */
  32343. set physicsJoint(newJoint: any);
  32344. /**
  32345. * Sets the physics plugin
  32346. */
  32347. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32348. /**
  32349. * Execute a function that is physics-plugin specific.
  32350. * @param {Function} func the function that will be executed.
  32351. * It accepts two parameters: the physics world and the physics joint
  32352. */
  32353. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32354. /**
  32355. * Distance-Joint type
  32356. */
  32357. static DistanceJoint: number;
  32358. /**
  32359. * Hinge-Joint type
  32360. */
  32361. static HingeJoint: number;
  32362. /**
  32363. * Ball-and-Socket joint type
  32364. */
  32365. static BallAndSocketJoint: number;
  32366. /**
  32367. * Wheel-Joint type
  32368. */
  32369. static WheelJoint: number;
  32370. /**
  32371. * Slider-Joint type
  32372. */
  32373. static SliderJoint: number;
  32374. /**
  32375. * Prismatic-Joint type
  32376. */
  32377. static PrismaticJoint: number;
  32378. /**
  32379. * Universal-Joint type
  32380. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32381. */
  32382. static UniversalJoint: number;
  32383. /**
  32384. * Hinge-Joint 2 type
  32385. */
  32386. static Hinge2Joint: number;
  32387. /**
  32388. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32389. */
  32390. static PointToPointJoint: number;
  32391. /**
  32392. * Spring-Joint type
  32393. */
  32394. static SpringJoint: number;
  32395. /**
  32396. * Lock-Joint type
  32397. */
  32398. static LockJoint: number;
  32399. }
  32400. /**
  32401. * A class representing a physics distance joint
  32402. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32403. */
  32404. export class DistanceJoint extends PhysicsJoint {
  32405. /**
  32406. *
  32407. * @param jointData The data for the Distance-Joint
  32408. */
  32409. constructor(jointData: DistanceJointData);
  32410. /**
  32411. * Update the predefined distance.
  32412. * @param maxDistance The maximum preferred distance
  32413. * @param minDistance The minimum preferred distance
  32414. */
  32415. updateDistance(maxDistance: number, minDistance?: number): void;
  32416. }
  32417. /**
  32418. * Represents a Motor-Enabled Joint
  32419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32420. */
  32421. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32422. /**
  32423. * Initializes the Motor-Enabled Joint
  32424. * @param type The type of the joint
  32425. * @param jointData The physica joint data for the joint
  32426. */
  32427. constructor(type: number, jointData: PhysicsJointData);
  32428. /**
  32429. * Set the motor values.
  32430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32431. * @param force the force to apply
  32432. * @param maxForce max force for this motor.
  32433. */
  32434. setMotor(force?: number, maxForce?: number): void;
  32435. /**
  32436. * Set the motor's limits.
  32437. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32438. * @param upperLimit The upper limit of the motor
  32439. * @param lowerLimit The lower limit of the motor
  32440. */
  32441. setLimit(upperLimit: number, lowerLimit?: number): void;
  32442. }
  32443. /**
  32444. * This class represents a single physics Hinge-Joint
  32445. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32446. */
  32447. export class HingeJoint extends MotorEnabledJoint {
  32448. /**
  32449. * Initializes the Hinge-Joint
  32450. * @param jointData The joint data for the Hinge-Joint
  32451. */
  32452. constructor(jointData: PhysicsJointData);
  32453. /**
  32454. * Set the motor values.
  32455. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32456. * @param {number} force the force to apply
  32457. * @param {number} maxForce max force for this motor.
  32458. */
  32459. setMotor(force?: number, maxForce?: number): void;
  32460. /**
  32461. * Set the motor's limits.
  32462. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32463. * @param upperLimit The upper limit of the motor
  32464. * @param lowerLimit The lower limit of the motor
  32465. */
  32466. setLimit(upperLimit: number, lowerLimit?: number): void;
  32467. }
  32468. /**
  32469. * This class represents a dual hinge physics joint (same as wheel joint)
  32470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32471. */
  32472. export class Hinge2Joint extends MotorEnabledJoint {
  32473. /**
  32474. * Initializes the Hinge2-Joint
  32475. * @param jointData The joint data for the Hinge2-Joint
  32476. */
  32477. constructor(jointData: PhysicsJointData);
  32478. /**
  32479. * Set the motor values.
  32480. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32481. * @param {number} targetSpeed the speed the motor is to reach
  32482. * @param {number} maxForce max force for this motor.
  32483. * @param {motorIndex} the motor's index, 0 or 1.
  32484. */
  32485. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32486. /**
  32487. * Set the motor limits.
  32488. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32489. * @param {number} upperLimit the upper limit
  32490. * @param {number} lowerLimit lower limit
  32491. * @param {motorIndex} the motor's index, 0 or 1.
  32492. */
  32493. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32494. }
  32495. /**
  32496. * Interface for a motor enabled joint
  32497. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32498. */
  32499. export interface IMotorEnabledJoint {
  32500. /**
  32501. * Physics joint
  32502. */
  32503. physicsJoint: any;
  32504. /**
  32505. * Sets the motor of the motor-enabled joint
  32506. * @param force The force of the motor
  32507. * @param maxForce The maximum force of the motor
  32508. * @param motorIndex The index of the motor
  32509. */
  32510. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32511. /**
  32512. * Sets the limit of the motor
  32513. * @param upperLimit The upper limit of the motor
  32514. * @param lowerLimit The lower limit of the motor
  32515. * @param motorIndex The index of the motor
  32516. */
  32517. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32518. }
  32519. /**
  32520. * Joint data for a Distance-Joint
  32521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32522. */
  32523. export interface DistanceJointData extends PhysicsJointData {
  32524. /**
  32525. * Max distance the 2 joint objects can be apart
  32526. */
  32527. maxDistance: number;
  32528. }
  32529. /**
  32530. * Joint data from a spring joint
  32531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32532. */
  32533. export interface SpringJointData extends PhysicsJointData {
  32534. /**
  32535. * Length of the spring
  32536. */
  32537. length: number;
  32538. /**
  32539. * Stiffness of the spring
  32540. */
  32541. stiffness: number;
  32542. /**
  32543. * Damping of the spring
  32544. */
  32545. damping: number;
  32546. /** this callback will be called when applying the force to the impostors. */
  32547. forceApplicationCallback: () => void;
  32548. }
  32549. }
  32550. declare module "babylonjs/Physics/physicsRaycastResult" {
  32551. import { Vector3 } from "babylonjs/Maths/math.vector";
  32552. /**
  32553. * Holds the data for the raycast result
  32554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32555. */
  32556. export class PhysicsRaycastResult {
  32557. private _hasHit;
  32558. private _hitDistance;
  32559. private _hitNormalWorld;
  32560. private _hitPointWorld;
  32561. private _rayFromWorld;
  32562. private _rayToWorld;
  32563. /**
  32564. * Gets if there was a hit
  32565. */
  32566. get hasHit(): boolean;
  32567. /**
  32568. * Gets the distance from the hit
  32569. */
  32570. get hitDistance(): number;
  32571. /**
  32572. * Gets the hit normal/direction in the world
  32573. */
  32574. get hitNormalWorld(): Vector3;
  32575. /**
  32576. * Gets the hit point in the world
  32577. */
  32578. get hitPointWorld(): Vector3;
  32579. /**
  32580. * Gets the ray "start point" of the ray in the world
  32581. */
  32582. get rayFromWorld(): Vector3;
  32583. /**
  32584. * Gets the ray "end point" of the ray in the world
  32585. */
  32586. get rayToWorld(): Vector3;
  32587. /**
  32588. * Sets the hit data (normal & point in world space)
  32589. * @param hitNormalWorld defines the normal in world space
  32590. * @param hitPointWorld defines the point in world space
  32591. */
  32592. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32593. /**
  32594. * Sets the distance from the start point to the hit point
  32595. * @param distance
  32596. */
  32597. setHitDistance(distance: number): void;
  32598. /**
  32599. * Calculates the distance manually
  32600. */
  32601. calculateHitDistance(): void;
  32602. /**
  32603. * Resets all the values to default
  32604. * @param from The from point on world space
  32605. * @param to The to point on world space
  32606. */
  32607. reset(from?: Vector3, to?: Vector3): void;
  32608. }
  32609. /**
  32610. * Interface for the size containing width and height
  32611. */
  32612. interface IXYZ {
  32613. /**
  32614. * X
  32615. */
  32616. x: number;
  32617. /**
  32618. * Y
  32619. */
  32620. y: number;
  32621. /**
  32622. * Z
  32623. */
  32624. z: number;
  32625. }
  32626. }
  32627. declare module "babylonjs/Physics/IPhysicsEngine" {
  32628. import { Nullable } from "babylonjs/types";
  32629. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  32630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32631. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  32632. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  32633. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  32634. /**
  32635. * Interface used to describe a physics joint
  32636. */
  32637. export interface PhysicsImpostorJoint {
  32638. /** Defines the main impostor to which the joint is linked */
  32639. mainImpostor: PhysicsImpostor;
  32640. /** Defines the impostor that is connected to the main impostor using this joint */
  32641. connectedImpostor: PhysicsImpostor;
  32642. /** Defines the joint itself */
  32643. joint: PhysicsJoint;
  32644. }
  32645. /** @hidden */
  32646. export interface IPhysicsEnginePlugin {
  32647. world: any;
  32648. name: string;
  32649. setGravity(gravity: Vector3): void;
  32650. setTimeStep(timeStep: number): void;
  32651. getTimeStep(): number;
  32652. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32653. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32654. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32655. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32656. removePhysicsBody(impostor: PhysicsImpostor): void;
  32657. generateJoint(joint: PhysicsImpostorJoint): void;
  32658. removeJoint(joint: PhysicsImpostorJoint): void;
  32659. isSupported(): boolean;
  32660. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32661. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32662. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32663. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32664. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32665. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32666. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32667. getBodyMass(impostor: PhysicsImpostor): number;
  32668. getBodyFriction(impostor: PhysicsImpostor): number;
  32669. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32670. getBodyRestitution(impostor: PhysicsImpostor): number;
  32671. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32672. getBodyPressure?(impostor: PhysicsImpostor): number;
  32673. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32674. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32675. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32676. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32677. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32678. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32679. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32680. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32681. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32682. sleepBody(impostor: PhysicsImpostor): void;
  32683. wakeUpBody(impostor: PhysicsImpostor): void;
  32684. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32685. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32686. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32687. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32688. getRadius(impostor: PhysicsImpostor): number;
  32689. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32690. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32691. dispose(): void;
  32692. }
  32693. /**
  32694. * Interface used to define a physics engine
  32695. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32696. */
  32697. export interface IPhysicsEngine {
  32698. /**
  32699. * Gets the gravity vector used by the simulation
  32700. */
  32701. gravity: Vector3;
  32702. /**
  32703. * Sets the gravity vector used by the simulation
  32704. * @param gravity defines the gravity vector to use
  32705. */
  32706. setGravity(gravity: Vector3): void;
  32707. /**
  32708. * Set the time step of the physics engine.
  32709. * Default is 1/60.
  32710. * To slow it down, enter 1/600 for example.
  32711. * To speed it up, 1/30
  32712. * @param newTimeStep the new timestep to apply to this world.
  32713. */
  32714. setTimeStep(newTimeStep: number): void;
  32715. /**
  32716. * Get the time step of the physics engine.
  32717. * @returns the current time step
  32718. */
  32719. getTimeStep(): number;
  32720. /**
  32721. * Set the sub time step of the physics engine.
  32722. * Default is 0 meaning there is no sub steps
  32723. * To increase physics resolution precision, set a small value (like 1 ms)
  32724. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32725. */
  32726. setSubTimeStep(subTimeStep: number): void;
  32727. /**
  32728. * Get the sub time step of the physics engine.
  32729. * @returns the current sub time step
  32730. */
  32731. getSubTimeStep(): number;
  32732. /**
  32733. * Release all resources
  32734. */
  32735. dispose(): void;
  32736. /**
  32737. * Gets the name of the current physics plugin
  32738. * @returns the name of the plugin
  32739. */
  32740. getPhysicsPluginName(): string;
  32741. /**
  32742. * Adding a new impostor for the impostor tracking.
  32743. * This will be done by the impostor itself.
  32744. * @param impostor the impostor to add
  32745. */
  32746. addImpostor(impostor: PhysicsImpostor): void;
  32747. /**
  32748. * Remove an impostor from the engine.
  32749. * This impostor and its mesh will not longer be updated by the physics engine.
  32750. * @param impostor the impostor to remove
  32751. */
  32752. removeImpostor(impostor: PhysicsImpostor): void;
  32753. /**
  32754. * Add a joint to the physics engine
  32755. * @param mainImpostor defines the main impostor to which the joint is added.
  32756. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32757. * @param joint defines the joint that will connect both impostors.
  32758. */
  32759. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32760. /**
  32761. * Removes a joint from the simulation
  32762. * @param mainImpostor defines the impostor used with the joint
  32763. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32764. * @param joint defines the joint to remove
  32765. */
  32766. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32767. /**
  32768. * Gets the current plugin used to run the simulation
  32769. * @returns current plugin
  32770. */
  32771. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32772. /**
  32773. * Gets the list of physic impostors
  32774. * @returns an array of PhysicsImpostor
  32775. */
  32776. getImpostors(): Array<PhysicsImpostor>;
  32777. /**
  32778. * Gets the impostor for a physics enabled object
  32779. * @param object defines the object impersonated by the impostor
  32780. * @returns the PhysicsImpostor or null if not found
  32781. */
  32782. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32783. /**
  32784. * Gets the impostor for a physics body object
  32785. * @param body defines physics body used by the impostor
  32786. * @returns the PhysicsImpostor or null if not found
  32787. */
  32788. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32789. /**
  32790. * Does a raycast in the physics world
  32791. * @param from when should the ray start?
  32792. * @param to when should the ray end?
  32793. * @returns PhysicsRaycastResult
  32794. */
  32795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32796. /**
  32797. * Called by the scene. No need to call it.
  32798. * @param delta defines the timespam between frames
  32799. */
  32800. _step(delta: number): void;
  32801. }
  32802. }
  32803. declare module "babylonjs/Physics/physicsImpostor" {
  32804. import { Nullable, IndicesArray } from "babylonjs/types";
  32805. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  32806. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32808. import { Scene } from "babylonjs/scene";
  32809. import { Bone } from "babylonjs/Bones/bone";
  32810. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32811. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  32812. import { Space } from "babylonjs/Maths/math.axis";
  32813. /**
  32814. * The interface for the physics imposter parameters
  32815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32816. */
  32817. export interface PhysicsImpostorParameters {
  32818. /**
  32819. * The mass of the physics imposter
  32820. */
  32821. mass: number;
  32822. /**
  32823. * The friction of the physics imposter
  32824. */
  32825. friction?: number;
  32826. /**
  32827. * The coefficient of restitution of the physics imposter
  32828. */
  32829. restitution?: number;
  32830. /**
  32831. * The native options of the physics imposter
  32832. */
  32833. nativeOptions?: any;
  32834. /**
  32835. * Specifies if the parent should be ignored
  32836. */
  32837. ignoreParent?: boolean;
  32838. /**
  32839. * Specifies if bi-directional transformations should be disabled
  32840. */
  32841. disableBidirectionalTransformation?: boolean;
  32842. /**
  32843. * The pressure inside the physics imposter, soft object only
  32844. */
  32845. pressure?: number;
  32846. /**
  32847. * The stiffness the physics imposter, soft object only
  32848. */
  32849. stiffness?: number;
  32850. /**
  32851. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32852. */
  32853. velocityIterations?: number;
  32854. /**
  32855. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32856. */
  32857. positionIterations?: number;
  32858. /**
  32859. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32860. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32861. * Add to fix multiple points
  32862. */
  32863. fixedPoints?: number;
  32864. /**
  32865. * The collision margin around a soft object
  32866. */
  32867. margin?: number;
  32868. /**
  32869. * The collision margin around a soft object
  32870. */
  32871. damping?: number;
  32872. /**
  32873. * The path for a rope based on an extrusion
  32874. */
  32875. path?: any;
  32876. /**
  32877. * The shape of an extrusion used for a rope based on an extrusion
  32878. */
  32879. shape?: any;
  32880. }
  32881. /**
  32882. * Interface for a physics-enabled object
  32883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32884. */
  32885. export interface IPhysicsEnabledObject {
  32886. /**
  32887. * The position of the physics-enabled object
  32888. */
  32889. position: Vector3;
  32890. /**
  32891. * The rotation of the physics-enabled object
  32892. */
  32893. rotationQuaternion: Nullable<Quaternion>;
  32894. /**
  32895. * The scale of the physics-enabled object
  32896. */
  32897. scaling: Vector3;
  32898. /**
  32899. * The rotation of the physics-enabled object
  32900. */
  32901. rotation?: Vector3;
  32902. /**
  32903. * The parent of the physics-enabled object
  32904. */
  32905. parent?: any;
  32906. /**
  32907. * The bounding info of the physics-enabled object
  32908. * @returns The bounding info of the physics-enabled object
  32909. */
  32910. getBoundingInfo(): BoundingInfo;
  32911. /**
  32912. * Computes the world matrix
  32913. * @param force Specifies if the world matrix should be computed by force
  32914. * @returns A world matrix
  32915. */
  32916. computeWorldMatrix(force: boolean): Matrix;
  32917. /**
  32918. * Gets the world matrix
  32919. * @returns A world matrix
  32920. */
  32921. getWorldMatrix?(): Matrix;
  32922. /**
  32923. * Gets the child meshes
  32924. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32925. * @returns An array of abstract meshes
  32926. */
  32927. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32928. /**
  32929. * Gets the vertex data
  32930. * @param kind The type of vertex data
  32931. * @returns A nullable array of numbers, or a float32 array
  32932. */
  32933. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32934. /**
  32935. * Gets the indices from the mesh
  32936. * @returns A nullable array of index arrays
  32937. */
  32938. getIndices?(): Nullable<IndicesArray>;
  32939. /**
  32940. * Gets the scene from the mesh
  32941. * @returns the indices array or null
  32942. */
  32943. getScene?(): Scene;
  32944. /**
  32945. * Gets the absolute position from the mesh
  32946. * @returns the absolute position
  32947. */
  32948. getAbsolutePosition(): Vector3;
  32949. /**
  32950. * Gets the absolute pivot point from the mesh
  32951. * @returns the absolute pivot point
  32952. */
  32953. getAbsolutePivotPoint(): Vector3;
  32954. /**
  32955. * Rotates the mesh
  32956. * @param axis The axis of rotation
  32957. * @param amount The amount of rotation
  32958. * @param space The space of the rotation
  32959. * @returns The rotation transform node
  32960. */
  32961. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32962. /**
  32963. * Translates the mesh
  32964. * @param axis The axis of translation
  32965. * @param distance The distance of translation
  32966. * @param space The space of the translation
  32967. * @returns The transform node
  32968. */
  32969. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32970. /**
  32971. * Sets the absolute position of the mesh
  32972. * @param absolutePosition The absolute position of the mesh
  32973. * @returns The transform node
  32974. */
  32975. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32976. /**
  32977. * Gets the class name of the mesh
  32978. * @returns The class name
  32979. */
  32980. getClassName(): string;
  32981. }
  32982. /**
  32983. * Represents a physics imposter
  32984. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32985. */
  32986. export class PhysicsImpostor {
  32987. /**
  32988. * The physics-enabled object used as the physics imposter
  32989. */
  32990. object: IPhysicsEnabledObject;
  32991. /**
  32992. * The type of the physics imposter
  32993. */
  32994. type: number;
  32995. private _options;
  32996. private _scene?;
  32997. /**
  32998. * The default object size of the imposter
  32999. */
  33000. static DEFAULT_OBJECT_SIZE: Vector3;
  33001. /**
  33002. * The identity quaternion of the imposter
  33003. */
  33004. static IDENTITY_QUATERNION: Quaternion;
  33005. /** @hidden */
  33006. _pluginData: any;
  33007. private _physicsEngine;
  33008. private _physicsBody;
  33009. private _bodyUpdateRequired;
  33010. private _onBeforePhysicsStepCallbacks;
  33011. private _onAfterPhysicsStepCallbacks;
  33012. /** @hidden */
  33013. _onPhysicsCollideCallbacks: Array<{
  33014. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33015. otherImpostors: Array<PhysicsImpostor>;
  33016. }>;
  33017. private _deltaPosition;
  33018. private _deltaRotation;
  33019. private _deltaRotationConjugated;
  33020. /** @hidden */
  33021. _isFromLine: boolean;
  33022. private _parent;
  33023. private _isDisposed;
  33024. private static _tmpVecs;
  33025. private static _tmpQuat;
  33026. /**
  33027. * Specifies if the physics imposter is disposed
  33028. */
  33029. get isDisposed(): boolean;
  33030. /**
  33031. * Gets the mass of the physics imposter
  33032. */
  33033. get mass(): number;
  33034. set mass(value: number);
  33035. /**
  33036. * Gets the coefficient of friction
  33037. */
  33038. get friction(): number;
  33039. /**
  33040. * Sets the coefficient of friction
  33041. */
  33042. set friction(value: number);
  33043. /**
  33044. * Gets the coefficient of restitution
  33045. */
  33046. get restitution(): number;
  33047. /**
  33048. * Sets the coefficient of restitution
  33049. */
  33050. set restitution(value: number);
  33051. /**
  33052. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33053. */
  33054. get pressure(): number;
  33055. /**
  33056. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33057. */
  33058. set pressure(value: number);
  33059. /**
  33060. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33061. */
  33062. get stiffness(): number;
  33063. /**
  33064. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33065. */
  33066. set stiffness(value: number);
  33067. /**
  33068. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33069. */
  33070. get velocityIterations(): number;
  33071. /**
  33072. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33073. */
  33074. set velocityIterations(value: number);
  33075. /**
  33076. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33077. */
  33078. get positionIterations(): number;
  33079. /**
  33080. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33081. */
  33082. set positionIterations(value: number);
  33083. /**
  33084. * The unique id of the physics imposter
  33085. * set by the physics engine when adding this impostor to the array
  33086. */
  33087. uniqueId: number;
  33088. /**
  33089. * @hidden
  33090. */
  33091. soft: boolean;
  33092. /**
  33093. * @hidden
  33094. */
  33095. segments: number;
  33096. private _joints;
  33097. /**
  33098. * Initializes the physics imposter
  33099. * @param object The physics-enabled object used as the physics imposter
  33100. * @param type The type of the physics imposter
  33101. * @param _options The options for the physics imposter
  33102. * @param _scene The Babylon scene
  33103. */
  33104. constructor(
  33105. /**
  33106. * The physics-enabled object used as the physics imposter
  33107. */
  33108. object: IPhysicsEnabledObject,
  33109. /**
  33110. * The type of the physics imposter
  33111. */
  33112. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33113. /**
  33114. * This function will completly initialize this impostor.
  33115. * It will create a new body - but only if this mesh has no parent.
  33116. * If it has, this impostor will not be used other than to define the impostor
  33117. * of the child mesh.
  33118. * @hidden
  33119. */
  33120. _init(): void;
  33121. private _getPhysicsParent;
  33122. /**
  33123. * Should a new body be generated.
  33124. * @returns boolean specifying if body initialization is required
  33125. */
  33126. isBodyInitRequired(): boolean;
  33127. /**
  33128. * Sets the updated scaling
  33129. * @param updated Specifies if the scaling is updated
  33130. */
  33131. setScalingUpdated(): void;
  33132. /**
  33133. * Force a regeneration of this or the parent's impostor's body.
  33134. * Use under cautious - This will remove all joints already implemented.
  33135. */
  33136. forceUpdate(): void;
  33137. /**
  33138. * Gets the body that holds this impostor. Either its own, or its parent.
  33139. */
  33140. get physicsBody(): any;
  33141. /**
  33142. * Get the parent of the physics imposter
  33143. * @returns Physics imposter or null
  33144. */
  33145. get parent(): Nullable<PhysicsImpostor>;
  33146. /**
  33147. * Sets the parent of the physics imposter
  33148. */
  33149. set parent(value: Nullable<PhysicsImpostor>);
  33150. /**
  33151. * Set the physics body. Used mainly by the physics engine/plugin
  33152. */
  33153. set physicsBody(physicsBody: any);
  33154. /**
  33155. * Resets the update flags
  33156. */
  33157. resetUpdateFlags(): void;
  33158. /**
  33159. * Gets the object extend size
  33160. * @returns the object extend size
  33161. */
  33162. getObjectExtendSize(): Vector3;
  33163. /**
  33164. * Gets the object center
  33165. * @returns The object center
  33166. */
  33167. getObjectCenter(): Vector3;
  33168. /**
  33169. * Get a specific parameter from the options parameters
  33170. * @param paramName The object parameter name
  33171. * @returns The object parameter
  33172. */
  33173. getParam(paramName: string): any;
  33174. /**
  33175. * Sets a specific parameter in the options given to the physics plugin
  33176. * @param paramName The parameter name
  33177. * @param value The value of the parameter
  33178. */
  33179. setParam(paramName: string, value: number): void;
  33180. /**
  33181. * Specifically change the body's mass option. Won't recreate the physics body object
  33182. * @param mass The mass of the physics imposter
  33183. */
  33184. setMass(mass: number): void;
  33185. /**
  33186. * Gets the linear velocity
  33187. * @returns linear velocity or null
  33188. */
  33189. getLinearVelocity(): Nullable<Vector3>;
  33190. /**
  33191. * Sets the linear velocity
  33192. * @param velocity linear velocity or null
  33193. */
  33194. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33195. /**
  33196. * Gets the angular velocity
  33197. * @returns angular velocity or null
  33198. */
  33199. getAngularVelocity(): Nullable<Vector3>;
  33200. /**
  33201. * Sets the angular velocity
  33202. * @param velocity The velocity or null
  33203. */
  33204. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33205. /**
  33206. * Execute a function with the physics plugin native code
  33207. * Provide a function the will have two variables - the world object and the physics body object
  33208. * @param func The function to execute with the physics plugin native code
  33209. */
  33210. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33211. /**
  33212. * Register a function that will be executed before the physics world is stepping forward
  33213. * @param func The function to execute before the physics world is stepped forward
  33214. */
  33215. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33216. /**
  33217. * Unregister a function that will be executed before the physics world is stepping forward
  33218. * @param func The function to execute before the physics world is stepped forward
  33219. */
  33220. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33221. /**
  33222. * Register a function that will be executed after the physics step
  33223. * @param func The function to execute after physics step
  33224. */
  33225. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33226. /**
  33227. * Unregisters a function that will be executed after the physics step
  33228. * @param func The function to execute after physics step
  33229. */
  33230. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33231. /**
  33232. * register a function that will be executed when this impostor collides against a different body
  33233. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33234. * @param func Callback that is executed on collision
  33235. */
  33236. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33237. /**
  33238. * Unregisters the physics imposter on contact
  33239. * @param collideAgainst The physics object to collide against
  33240. * @param func Callback to execute on collision
  33241. */
  33242. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33243. private _tmpQuat;
  33244. private _tmpQuat2;
  33245. /**
  33246. * Get the parent rotation
  33247. * @returns The parent rotation
  33248. */
  33249. getParentsRotation(): Quaternion;
  33250. /**
  33251. * this function is executed by the physics engine.
  33252. */
  33253. beforeStep: () => void;
  33254. /**
  33255. * this function is executed by the physics engine
  33256. */
  33257. afterStep: () => void;
  33258. /**
  33259. * Legacy collision detection event support
  33260. */
  33261. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33262. /**
  33263. * event and body object due to cannon's event-based architecture.
  33264. */
  33265. onCollide: (e: {
  33266. body: any;
  33267. point: Nullable<Vector3>;
  33268. }) => void;
  33269. /**
  33270. * Apply a force
  33271. * @param force The force to apply
  33272. * @param contactPoint The contact point for the force
  33273. * @returns The physics imposter
  33274. */
  33275. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33276. /**
  33277. * Apply an impulse
  33278. * @param force The impulse force
  33279. * @param contactPoint The contact point for the impulse force
  33280. * @returns The physics imposter
  33281. */
  33282. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33283. /**
  33284. * A help function to create a joint
  33285. * @param otherImpostor A physics imposter used to create a joint
  33286. * @param jointType The type of joint
  33287. * @param jointData The data for the joint
  33288. * @returns The physics imposter
  33289. */
  33290. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33291. /**
  33292. * Add a joint to this impostor with a different impostor
  33293. * @param otherImpostor A physics imposter used to add a joint
  33294. * @param joint The joint to add
  33295. * @returns The physics imposter
  33296. */
  33297. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33298. /**
  33299. * Add an anchor to a cloth impostor
  33300. * @param otherImpostor rigid impostor to anchor to
  33301. * @param width ratio across width from 0 to 1
  33302. * @param height ratio up height from 0 to 1
  33303. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33304. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33305. * @returns impostor the soft imposter
  33306. */
  33307. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33308. /**
  33309. * Add a hook to a rope impostor
  33310. * @param otherImpostor rigid impostor to anchor to
  33311. * @param length ratio across rope from 0 to 1
  33312. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33313. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33314. * @returns impostor the rope imposter
  33315. */
  33316. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33317. /**
  33318. * Will keep this body still, in a sleep mode.
  33319. * @returns the physics imposter
  33320. */
  33321. sleep(): PhysicsImpostor;
  33322. /**
  33323. * Wake the body up.
  33324. * @returns The physics imposter
  33325. */
  33326. wakeUp(): PhysicsImpostor;
  33327. /**
  33328. * Clones the physics imposter
  33329. * @param newObject The physics imposter clones to this physics-enabled object
  33330. * @returns A nullable physics imposter
  33331. */
  33332. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33333. /**
  33334. * Disposes the physics imposter
  33335. */
  33336. dispose(): void;
  33337. /**
  33338. * Sets the delta position
  33339. * @param position The delta position amount
  33340. */
  33341. setDeltaPosition(position: Vector3): void;
  33342. /**
  33343. * Sets the delta rotation
  33344. * @param rotation The delta rotation amount
  33345. */
  33346. setDeltaRotation(rotation: Quaternion): void;
  33347. /**
  33348. * Gets the box size of the physics imposter and stores the result in the input parameter
  33349. * @param result Stores the box size
  33350. * @returns The physics imposter
  33351. */
  33352. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33353. /**
  33354. * Gets the radius of the physics imposter
  33355. * @returns Radius of the physics imposter
  33356. */
  33357. getRadius(): number;
  33358. /**
  33359. * Sync a bone with this impostor
  33360. * @param bone The bone to sync to the impostor.
  33361. * @param boneMesh The mesh that the bone is influencing.
  33362. * @param jointPivot The pivot of the joint / bone in local space.
  33363. * @param distToJoint Optional distance from the impostor to the joint.
  33364. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33365. */
  33366. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33367. /**
  33368. * Sync impostor to a bone
  33369. * @param bone The bone that the impostor will be synced to.
  33370. * @param boneMesh The mesh that the bone is influencing.
  33371. * @param jointPivot The pivot of the joint / bone in local space.
  33372. * @param distToJoint Optional distance from the impostor to the joint.
  33373. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33374. * @param boneAxis Optional vector3 axis the bone is aligned with
  33375. */
  33376. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33377. /**
  33378. * No-Imposter type
  33379. */
  33380. static NoImpostor: number;
  33381. /**
  33382. * Sphere-Imposter type
  33383. */
  33384. static SphereImpostor: number;
  33385. /**
  33386. * Box-Imposter type
  33387. */
  33388. static BoxImpostor: number;
  33389. /**
  33390. * Plane-Imposter type
  33391. */
  33392. static PlaneImpostor: number;
  33393. /**
  33394. * Mesh-imposter type
  33395. */
  33396. static MeshImpostor: number;
  33397. /**
  33398. * Capsule-Impostor type (Ammo.js plugin only)
  33399. */
  33400. static CapsuleImpostor: number;
  33401. /**
  33402. * Cylinder-Imposter type
  33403. */
  33404. static CylinderImpostor: number;
  33405. /**
  33406. * Particle-Imposter type
  33407. */
  33408. static ParticleImpostor: number;
  33409. /**
  33410. * Heightmap-Imposter type
  33411. */
  33412. static HeightmapImpostor: number;
  33413. /**
  33414. * ConvexHull-Impostor type (Ammo.js plugin only)
  33415. */
  33416. static ConvexHullImpostor: number;
  33417. /**
  33418. * Custom-Imposter type (Ammo.js plugin only)
  33419. */
  33420. static CustomImpostor: number;
  33421. /**
  33422. * Rope-Imposter type
  33423. */
  33424. static RopeImpostor: number;
  33425. /**
  33426. * Cloth-Imposter type
  33427. */
  33428. static ClothImpostor: number;
  33429. /**
  33430. * Softbody-Imposter type
  33431. */
  33432. static SoftbodyImpostor: number;
  33433. }
  33434. }
  33435. declare module "babylonjs/Meshes/mesh" {
  33436. import { Observable } from "babylonjs/Misc/observable";
  33437. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33438. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33439. import { Camera } from "babylonjs/Cameras/camera";
  33440. import { Scene } from "babylonjs/scene";
  33441. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33442. import { Color4 } from "babylonjs/Maths/math.color";
  33443. import { Engine } from "babylonjs/Engines/engine";
  33444. import { Node } from "babylonjs/node";
  33445. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33446. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33447. import { Buffer } from "babylonjs/Meshes/buffer";
  33448. import { Geometry } from "babylonjs/Meshes/geometry";
  33449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33451. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33452. import { Effect } from "babylonjs/Materials/effect";
  33453. import { Material } from "babylonjs/Materials/material";
  33454. import { Skeleton } from "babylonjs/Bones/skeleton";
  33455. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33456. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33457. import { Path3D } from "babylonjs/Maths/math.path";
  33458. import { Plane } from "babylonjs/Maths/math.plane";
  33459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33460. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33461. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33462. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33463. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33464. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33465. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33466. /**
  33467. * @hidden
  33468. **/
  33469. export class _CreationDataStorage {
  33470. closePath?: boolean;
  33471. closeArray?: boolean;
  33472. idx: number[];
  33473. dashSize: number;
  33474. gapSize: number;
  33475. path3D: Path3D;
  33476. pathArray: Vector3[][];
  33477. arc: number;
  33478. radius: number;
  33479. cap: number;
  33480. tessellation: number;
  33481. }
  33482. /**
  33483. * @hidden
  33484. **/
  33485. class _InstanceDataStorage {
  33486. visibleInstances: any;
  33487. batchCache: _InstancesBatch;
  33488. instancesBufferSize: number;
  33489. instancesBuffer: Nullable<Buffer>;
  33490. instancesData: Float32Array;
  33491. overridenInstanceCount: number;
  33492. isFrozen: boolean;
  33493. previousBatch: Nullable<_InstancesBatch>;
  33494. hardwareInstancedRendering: boolean;
  33495. sideOrientation: number;
  33496. manualUpdate: boolean;
  33497. previousRenderId: number;
  33498. }
  33499. /**
  33500. * @hidden
  33501. **/
  33502. export class _InstancesBatch {
  33503. mustReturn: boolean;
  33504. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33505. renderSelf: boolean[];
  33506. hardwareInstancedRendering: boolean[];
  33507. }
  33508. /**
  33509. * @hidden
  33510. **/
  33511. class _ThinInstanceDataStorage {
  33512. instancesCount: number;
  33513. matrixBuffer: Nullable<Buffer>;
  33514. matrixBufferSize: number;
  33515. matrixData: Nullable<Float32Array>;
  33516. boundingVectors: Array<Vector3>;
  33517. worldMatrices: Nullable<Matrix[]>;
  33518. }
  33519. /**
  33520. * Class used to represent renderable models
  33521. */
  33522. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  33523. /**
  33524. * Mesh side orientation : usually the external or front surface
  33525. */
  33526. static readonly FRONTSIDE: number;
  33527. /**
  33528. * Mesh side orientation : usually the internal or back surface
  33529. */
  33530. static readonly BACKSIDE: number;
  33531. /**
  33532. * Mesh side orientation : both internal and external or front and back surfaces
  33533. */
  33534. static readonly DOUBLESIDE: number;
  33535. /**
  33536. * Mesh side orientation : by default, `FRONTSIDE`
  33537. */
  33538. static readonly DEFAULTSIDE: number;
  33539. /**
  33540. * Mesh cap setting : no cap
  33541. */
  33542. static readonly NO_CAP: number;
  33543. /**
  33544. * Mesh cap setting : one cap at the beginning of the mesh
  33545. */
  33546. static readonly CAP_START: number;
  33547. /**
  33548. * Mesh cap setting : one cap at the end of the mesh
  33549. */
  33550. static readonly CAP_END: number;
  33551. /**
  33552. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33553. */
  33554. static readonly CAP_ALL: number;
  33555. /**
  33556. * Mesh pattern setting : no flip or rotate
  33557. */
  33558. static readonly NO_FLIP: number;
  33559. /**
  33560. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33561. */
  33562. static readonly FLIP_TILE: number;
  33563. /**
  33564. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33565. */
  33566. static readonly ROTATE_TILE: number;
  33567. /**
  33568. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33569. */
  33570. static readonly FLIP_ROW: number;
  33571. /**
  33572. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33573. */
  33574. static readonly ROTATE_ROW: number;
  33575. /**
  33576. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33577. */
  33578. static readonly FLIP_N_ROTATE_TILE: number;
  33579. /**
  33580. * Mesh pattern setting : rotate pattern and rotate
  33581. */
  33582. static readonly FLIP_N_ROTATE_ROW: number;
  33583. /**
  33584. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33585. */
  33586. static readonly CENTER: number;
  33587. /**
  33588. * Mesh tile positioning : part tiles on left
  33589. */
  33590. static readonly LEFT: number;
  33591. /**
  33592. * Mesh tile positioning : part tiles on right
  33593. */
  33594. static readonly RIGHT: number;
  33595. /**
  33596. * Mesh tile positioning : part tiles on top
  33597. */
  33598. static readonly TOP: number;
  33599. /**
  33600. * Mesh tile positioning : part tiles on bottom
  33601. */
  33602. static readonly BOTTOM: number;
  33603. /**
  33604. * Gets the default side orientation.
  33605. * @param orientation the orientation to value to attempt to get
  33606. * @returns the default orientation
  33607. * @hidden
  33608. */
  33609. static _GetDefaultSideOrientation(orientation?: number): number;
  33610. private _internalMeshDataInfo;
  33611. get computeBonesUsingShaders(): boolean;
  33612. set computeBonesUsingShaders(value: boolean);
  33613. /**
  33614. * An event triggered before rendering the mesh
  33615. */
  33616. get onBeforeRenderObservable(): Observable<Mesh>;
  33617. /**
  33618. * An event triggered before binding the mesh
  33619. */
  33620. get onBeforeBindObservable(): Observable<Mesh>;
  33621. /**
  33622. * An event triggered after rendering the mesh
  33623. */
  33624. get onAfterRenderObservable(): Observable<Mesh>;
  33625. /**
  33626. * An event triggered before drawing the mesh
  33627. */
  33628. get onBeforeDrawObservable(): Observable<Mesh>;
  33629. private _onBeforeDrawObserver;
  33630. /**
  33631. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33632. */
  33633. set onBeforeDraw(callback: () => void);
  33634. get hasInstances(): boolean;
  33635. get hasThinInstances(): boolean;
  33636. /**
  33637. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33638. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33639. */
  33640. delayLoadState: number;
  33641. /**
  33642. * Gets the list of instances created from this mesh
  33643. * it is not supposed to be modified manually.
  33644. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33645. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33646. */
  33647. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  33648. /**
  33649. * Gets the file containing delay loading data for this mesh
  33650. */
  33651. delayLoadingFile: string;
  33652. /** @hidden */
  33653. _binaryInfo: any;
  33654. /**
  33655. * User defined function used to change how LOD level selection is done
  33656. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33657. */
  33658. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33659. /**
  33660. * Gets or sets the morph target manager
  33661. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33662. */
  33663. get morphTargetManager(): Nullable<MorphTargetManager>;
  33664. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33665. /** @hidden */
  33666. _creationDataStorage: Nullable<_CreationDataStorage>;
  33667. /** @hidden */
  33668. _geometry: Nullable<Geometry>;
  33669. /** @hidden */
  33670. _delayInfo: Array<string>;
  33671. /** @hidden */
  33672. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33673. /** @hidden */
  33674. _instanceDataStorage: _InstanceDataStorage;
  33675. /** @hidden */
  33676. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33677. private _effectiveMaterial;
  33678. /** @hidden */
  33679. _shouldGenerateFlatShading: boolean;
  33680. /** @hidden */
  33681. _originalBuilderSideOrientation: number;
  33682. /**
  33683. * Use this property to change the original side orientation defined at construction time
  33684. */
  33685. overrideMaterialSideOrientation: Nullable<number>;
  33686. /**
  33687. * Gets the source mesh (the one used to clone this one from)
  33688. */
  33689. get source(): Nullable<Mesh>;
  33690. /**
  33691. * Gets the list of clones of this mesh
  33692. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33693. * Note that useClonedMeshMap=true is the default setting
  33694. */
  33695. get cloneMeshMap(): Nullable<{
  33696. [id: string]: Mesh | undefined;
  33697. }>;
  33698. /**
  33699. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33700. */
  33701. get isUnIndexed(): boolean;
  33702. set isUnIndexed(value: boolean);
  33703. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33704. get worldMatrixInstancedBuffer(): Float32Array;
  33705. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33706. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33707. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33708. /**
  33709. * @constructor
  33710. * @param name The value used by scene.getMeshByName() to do a lookup.
  33711. * @param scene The scene to add this mesh to.
  33712. * @param parent The parent of this mesh, if it has one
  33713. * @param source An optional Mesh from which geometry is shared, cloned.
  33714. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33715. * When false, achieved by calling a clone(), also passing False.
  33716. * This will make creation of children, recursive.
  33717. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33718. */
  33719. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33720. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33721. doNotInstantiate: boolean;
  33722. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33723. /**
  33724. * Gets the class name
  33725. * @returns the string "Mesh".
  33726. */
  33727. getClassName(): string;
  33728. /** @hidden */
  33729. get _isMesh(): boolean;
  33730. /**
  33731. * Returns a description of this mesh
  33732. * @param fullDetails define if full details about this mesh must be used
  33733. * @returns a descriptive string representing this mesh
  33734. */
  33735. toString(fullDetails?: boolean): string;
  33736. /** @hidden */
  33737. _unBindEffect(): void;
  33738. /**
  33739. * Gets a boolean indicating if this mesh has LOD
  33740. */
  33741. get hasLODLevels(): boolean;
  33742. /**
  33743. * Gets the list of MeshLODLevel associated with the current mesh
  33744. * @returns an array of MeshLODLevel
  33745. */
  33746. getLODLevels(): MeshLODLevel[];
  33747. private _sortLODLevels;
  33748. /**
  33749. * Add a mesh as LOD level triggered at the given distance.
  33750. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33751. * @param distance The distance from the center of the object to show this level
  33752. * @param mesh The mesh to be added as LOD level (can be null)
  33753. * @return This mesh (for chaining)
  33754. */
  33755. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33756. /**
  33757. * Returns the LOD level mesh at the passed distance or null if not found.
  33758. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33759. * @param distance The distance from the center of the object to show this level
  33760. * @returns a Mesh or `null`
  33761. */
  33762. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33763. /**
  33764. * Remove a mesh from the LOD array
  33765. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33766. * @param mesh defines the mesh to be removed
  33767. * @return This mesh (for chaining)
  33768. */
  33769. removeLODLevel(mesh: Mesh): Mesh;
  33770. /**
  33771. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33772. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33773. * @param camera defines the camera to use to compute distance
  33774. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33775. * @return This mesh (for chaining)
  33776. */
  33777. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33778. /**
  33779. * Gets the mesh internal Geometry object
  33780. */
  33781. get geometry(): Nullable<Geometry>;
  33782. /**
  33783. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33784. * @returns the total number of vertices
  33785. */
  33786. getTotalVertices(): number;
  33787. /**
  33788. * Returns the content of an associated vertex buffer
  33789. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33790. * - VertexBuffer.PositionKind
  33791. * - VertexBuffer.UVKind
  33792. * - VertexBuffer.UV2Kind
  33793. * - VertexBuffer.UV3Kind
  33794. * - VertexBuffer.UV4Kind
  33795. * - VertexBuffer.UV5Kind
  33796. * - VertexBuffer.UV6Kind
  33797. * - VertexBuffer.ColorKind
  33798. * - VertexBuffer.MatricesIndicesKind
  33799. * - VertexBuffer.MatricesIndicesExtraKind
  33800. * - VertexBuffer.MatricesWeightsKind
  33801. * - VertexBuffer.MatricesWeightsExtraKind
  33802. * @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
  33803. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33804. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33805. */
  33806. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33807. /**
  33808. * Returns the mesh VertexBuffer object from the requested `kind`
  33809. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33810. * - VertexBuffer.PositionKind
  33811. * - VertexBuffer.NormalKind
  33812. * - VertexBuffer.UVKind
  33813. * - VertexBuffer.UV2Kind
  33814. * - VertexBuffer.UV3Kind
  33815. * - VertexBuffer.UV4Kind
  33816. * - VertexBuffer.UV5Kind
  33817. * - VertexBuffer.UV6Kind
  33818. * - VertexBuffer.ColorKind
  33819. * - VertexBuffer.MatricesIndicesKind
  33820. * - VertexBuffer.MatricesIndicesExtraKind
  33821. * - VertexBuffer.MatricesWeightsKind
  33822. * - VertexBuffer.MatricesWeightsExtraKind
  33823. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33824. */
  33825. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33826. /**
  33827. * Tests if a specific vertex buffer is associated with this mesh
  33828. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33829. * - VertexBuffer.PositionKind
  33830. * - VertexBuffer.NormalKind
  33831. * - VertexBuffer.UVKind
  33832. * - VertexBuffer.UV2Kind
  33833. * - VertexBuffer.UV3Kind
  33834. * - VertexBuffer.UV4Kind
  33835. * - VertexBuffer.UV5Kind
  33836. * - VertexBuffer.UV6Kind
  33837. * - VertexBuffer.ColorKind
  33838. * - VertexBuffer.MatricesIndicesKind
  33839. * - VertexBuffer.MatricesIndicesExtraKind
  33840. * - VertexBuffer.MatricesWeightsKind
  33841. * - VertexBuffer.MatricesWeightsExtraKind
  33842. * @returns a boolean
  33843. */
  33844. isVerticesDataPresent(kind: string): boolean;
  33845. /**
  33846. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33847. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33848. * - VertexBuffer.PositionKind
  33849. * - VertexBuffer.UVKind
  33850. * - VertexBuffer.UV2Kind
  33851. * - VertexBuffer.UV3Kind
  33852. * - VertexBuffer.UV4Kind
  33853. * - VertexBuffer.UV5Kind
  33854. * - VertexBuffer.UV6Kind
  33855. * - VertexBuffer.ColorKind
  33856. * - VertexBuffer.MatricesIndicesKind
  33857. * - VertexBuffer.MatricesIndicesExtraKind
  33858. * - VertexBuffer.MatricesWeightsKind
  33859. * - VertexBuffer.MatricesWeightsExtraKind
  33860. * @returns a boolean
  33861. */
  33862. isVertexBufferUpdatable(kind: string): boolean;
  33863. /**
  33864. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33865. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33866. * - VertexBuffer.PositionKind
  33867. * - VertexBuffer.NormalKind
  33868. * - VertexBuffer.UVKind
  33869. * - VertexBuffer.UV2Kind
  33870. * - VertexBuffer.UV3Kind
  33871. * - VertexBuffer.UV4Kind
  33872. * - VertexBuffer.UV5Kind
  33873. * - VertexBuffer.UV6Kind
  33874. * - VertexBuffer.ColorKind
  33875. * - VertexBuffer.MatricesIndicesKind
  33876. * - VertexBuffer.MatricesIndicesExtraKind
  33877. * - VertexBuffer.MatricesWeightsKind
  33878. * - VertexBuffer.MatricesWeightsExtraKind
  33879. * @returns an array of strings
  33880. */
  33881. getVerticesDataKinds(): string[];
  33882. /**
  33883. * Returns a positive integer : the total number of indices in this mesh geometry.
  33884. * @returns the numner of indices or zero if the mesh has no geometry.
  33885. */
  33886. getTotalIndices(): number;
  33887. /**
  33888. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33889. * @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.
  33890. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33891. * @returns the indices array or an empty array if the mesh has no geometry
  33892. */
  33893. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33894. get isBlocked(): boolean;
  33895. /**
  33896. * Determine if the current mesh is ready to be rendered
  33897. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33898. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33899. * @returns true if all associated assets are ready (material, textures, shaders)
  33900. */
  33901. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33902. /**
  33903. * 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.
  33904. */
  33905. get areNormalsFrozen(): boolean;
  33906. /**
  33907. * 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.
  33908. * @returns the current mesh
  33909. */
  33910. freezeNormals(): Mesh;
  33911. /**
  33912. * 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
  33913. * @returns the current mesh
  33914. */
  33915. unfreezeNormals(): Mesh;
  33916. /**
  33917. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33918. */
  33919. set overridenInstanceCount(count: number);
  33920. /** @hidden */
  33921. _preActivate(): Mesh;
  33922. /** @hidden */
  33923. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33924. /** @hidden */
  33925. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33926. protected _afterComputeWorldMatrix(): void;
  33927. /** @hidden */
  33928. _postActivate(): void;
  33929. /**
  33930. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33931. * This means the mesh underlying bounding box and sphere are recomputed.
  33932. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33933. * @returns the current mesh
  33934. */
  33935. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33936. /** @hidden */
  33937. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33938. /**
  33939. * This function will subdivide the mesh into multiple submeshes
  33940. * @param count defines the expected number of submeshes
  33941. */
  33942. subdivide(count: number): void;
  33943. /**
  33944. * Copy a FloatArray into a specific associated vertex buffer
  33945. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33946. * - VertexBuffer.PositionKind
  33947. * - VertexBuffer.UVKind
  33948. * - VertexBuffer.UV2Kind
  33949. * - VertexBuffer.UV3Kind
  33950. * - VertexBuffer.UV4Kind
  33951. * - VertexBuffer.UV5Kind
  33952. * - VertexBuffer.UV6Kind
  33953. * - VertexBuffer.ColorKind
  33954. * - VertexBuffer.MatricesIndicesKind
  33955. * - VertexBuffer.MatricesIndicesExtraKind
  33956. * - VertexBuffer.MatricesWeightsKind
  33957. * - VertexBuffer.MatricesWeightsExtraKind
  33958. * @param data defines the data source
  33959. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33960. * @param stride defines the data stride size (can be null)
  33961. * @returns the current mesh
  33962. */
  33963. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33964. /**
  33965. * Delete a vertex buffer associated with this mesh
  33966. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33967. * - VertexBuffer.PositionKind
  33968. * - VertexBuffer.UVKind
  33969. * - VertexBuffer.UV2Kind
  33970. * - VertexBuffer.UV3Kind
  33971. * - VertexBuffer.UV4Kind
  33972. * - VertexBuffer.UV5Kind
  33973. * - VertexBuffer.UV6Kind
  33974. * - VertexBuffer.ColorKind
  33975. * - VertexBuffer.MatricesIndicesKind
  33976. * - VertexBuffer.MatricesIndicesExtraKind
  33977. * - VertexBuffer.MatricesWeightsKind
  33978. * - VertexBuffer.MatricesWeightsExtraKind
  33979. */
  33980. removeVerticesData(kind: string): void;
  33981. /**
  33982. * Flags an associated vertex buffer as updatable
  33983. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33984. * - VertexBuffer.PositionKind
  33985. * - VertexBuffer.UVKind
  33986. * - VertexBuffer.UV2Kind
  33987. * - VertexBuffer.UV3Kind
  33988. * - VertexBuffer.UV4Kind
  33989. * - VertexBuffer.UV5Kind
  33990. * - VertexBuffer.UV6Kind
  33991. * - VertexBuffer.ColorKind
  33992. * - VertexBuffer.MatricesIndicesKind
  33993. * - VertexBuffer.MatricesIndicesExtraKind
  33994. * - VertexBuffer.MatricesWeightsKind
  33995. * - VertexBuffer.MatricesWeightsExtraKind
  33996. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33997. */
  33998. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33999. /**
  34000. * Sets the mesh global Vertex Buffer
  34001. * @param buffer defines the buffer to use
  34002. * @returns the current mesh
  34003. */
  34004. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34005. /**
  34006. * Update a specific associated vertex buffer
  34007. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34008. * - VertexBuffer.PositionKind
  34009. * - VertexBuffer.UVKind
  34010. * - VertexBuffer.UV2Kind
  34011. * - VertexBuffer.UV3Kind
  34012. * - VertexBuffer.UV4Kind
  34013. * - VertexBuffer.UV5Kind
  34014. * - VertexBuffer.UV6Kind
  34015. * - VertexBuffer.ColorKind
  34016. * - VertexBuffer.MatricesIndicesKind
  34017. * - VertexBuffer.MatricesIndicesExtraKind
  34018. * - VertexBuffer.MatricesWeightsKind
  34019. * - VertexBuffer.MatricesWeightsExtraKind
  34020. * @param data defines the data source
  34021. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34022. * @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)
  34023. * @returns the current mesh
  34024. */
  34025. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34026. /**
  34027. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34028. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34029. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34030. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34031. * @returns the current mesh
  34032. */
  34033. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34034. /**
  34035. * Creates a un-shared specific occurence of the geometry for the mesh.
  34036. * @returns the current mesh
  34037. */
  34038. makeGeometryUnique(): Mesh;
  34039. /**
  34040. * Set the index buffer of this mesh
  34041. * @param indices defines the source data
  34042. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34043. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34044. * @returns the current mesh
  34045. */
  34046. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34047. /**
  34048. * Update the current index buffer
  34049. * @param indices defines the source data
  34050. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34051. * @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)
  34052. * @returns the current mesh
  34053. */
  34054. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34055. /**
  34056. * Invert the geometry to move from a right handed system to a left handed one.
  34057. * @returns the current mesh
  34058. */
  34059. toLeftHanded(): Mesh;
  34060. /** @hidden */
  34061. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34062. /** @hidden */
  34063. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34064. /**
  34065. * Registers for this mesh a javascript function called just before the rendering process
  34066. * @param func defines the function to call before rendering this mesh
  34067. * @returns the current mesh
  34068. */
  34069. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34070. /**
  34071. * Disposes a previously registered javascript function called before the rendering
  34072. * @param func defines the function to remove
  34073. * @returns the current mesh
  34074. */
  34075. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34076. /**
  34077. * Registers for this mesh a javascript function called just after the rendering is complete
  34078. * @param func defines the function to call after rendering this mesh
  34079. * @returns the current mesh
  34080. */
  34081. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34082. /**
  34083. * Disposes a previously registered javascript function called after the rendering.
  34084. * @param func defines the function to remove
  34085. * @returns the current mesh
  34086. */
  34087. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34088. /** @hidden */
  34089. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34090. /** @hidden */
  34091. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34092. /** @hidden */
  34093. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34094. /** @hidden */
  34095. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34096. /** @hidden */
  34097. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34098. /** @hidden */
  34099. _rebuild(): void;
  34100. /** @hidden */
  34101. _freeze(): void;
  34102. /** @hidden */
  34103. _unFreeze(): void;
  34104. /**
  34105. * 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
  34106. * @param subMesh defines the subMesh to render
  34107. * @param enableAlphaMode defines if alpha mode can be changed
  34108. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34109. * @returns the current mesh
  34110. */
  34111. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34112. private _onBeforeDraw;
  34113. /**
  34114. * Renormalize the mesh and patch it up if there are no weights
  34115. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34116. * However in the case of zero weights then we set just a single influence to 1.
  34117. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34118. */
  34119. cleanMatrixWeights(): void;
  34120. private normalizeSkinFourWeights;
  34121. private normalizeSkinWeightsAndExtra;
  34122. /**
  34123. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34124. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34125. * the user know there was an issue with importing the mesh
  34126. * @returns a validation object with skinned, valid and report string
  34127. */
  34128. validateSkinning(): {
  34129. skinned: boolean;
  34130. valid: boolean;
  34131. report: string;
  34132. };
  34133. /** @hidden */
  34134. _checkDelayState(): Mesh;
  34135. private _queueLoad;
  34136. /**
  34137. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34138. * A mesh is in the frustum if its bounding box intersects the frustum
  34139. * @param frustumPlanes defines the frustum to test
  34140. * @returns true if the mesh is in the frustum planes
  34141. */
  34142. isInFrustum(frustumPlanes: Plane[]): boolean;
  34143. /**
  34144. * Sets the mesh material by the material or multiMaterial `id` property
  34145. * @param id is a string identifying the material or the multiMaterial
  34146. * @returns the current mesh
  34147. */
  34148. setMaterialByID(id: string): Mesh;
  34149. /**
  34150. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34151. * @returns an array of IAnimatable
  34152. */
  34153. getAnimatables(): IAnimatable[];
  34154. /**
  34155. * Modifies the mesh geometry according to the passed transformation matrix.
  34156. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34157. * The mesh normals are modified using the same transformation.
  34158. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34159. * @param transform defines the transform matrix to use
  34160. * @see https://doc.babylonjs.com/resources/baking_transformations
  34161. * @returns the current mesh
  34162. */
  34163. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34164. /**
  34165. * Modifies the mesh geometry according to its own current World Matrix.
  34166. * The mesh World Matrix is then reset.
  34167. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34168. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34169. * @see https://doc.babylonjs.com/resources/baking_transformations
  34170. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34171. * @returns the current mesh
  34172. */
  34173. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34174. /** @hidden */
  34175. get _positions(): Nullable<Vector3[]>;
  34176. /** @hidden */
  34177. _resetPointsArrayCache(): Mesh;
  34178. /** @hidden */
  34179. _generatePointsArray(): boolean;
  34180. /**
  34181. * Returns a new Mesh object generated from the current mesh properties.
  34182. * This method must not get confused with createInstance()
  34183. * @param name is a string, the name given to the new mesh
  34184. * @param newParent can be any Node object (default `null`)
  34185. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34186. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34187. * @returns a new mesh
  34188. */
  34189. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34190. /**
  34191. * Releases resources associated with this mesh.
  34192. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34193. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34194. */
  34195. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34196. /** @hidden */
  34197. _disposeInstanceSpecificData(): void;
  34198. /** @hidden */
  34199. _disposeThinInstanceSpecificData(): void;
  34200. /**
  34201. * Modifies the mesh geometry according to a displacement map.
  34202. * 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.
  34203. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34204. * @param url is a string, the URL from the image file is to be downloaded.
  34205. * @param minHeight is the lower limit of the displacement.
  34206. * @param maxHeight is the upper limit of the displacement.
  34207. * @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.
  34208. * @param uvOffset is an optional vector2 used to offset UV.
  34209. * @param uvScale is an optional vector2 used to scale UV.
  34210. * @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.
  34211. * @returns the Mesh.
  34212. */
  34213. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34214. /**
  34215. * Modifies the mesh geometry according to a displacementMap buffer.
  34216. * 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.
  34217. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34218. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34219. * @param heightMapWidth is the width of the buffer image.
  34220. * @param heightMapHeight is the height of the buffer image.
  34221. * @param minHeight is the lower limit of the displacement.
  34222. * @param maxHeight is the upper limit of the displacement.
  34223. * @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.
  34224. * @param uvOffset is an optional vector2 used to offset UV.
  34225. * @param uvScale is an optional vector2 used to scale UV.
  34226. * @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.
  34227. * @returns the Mesh.
  34228. */
  34229. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34230. /**
  34231. * Modify the mesh to get a flat shading rendering.
  34232. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34233. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34234. * @returns current mesh
  34235. */
  34236. convertToFlatShadedMesh(): Mesh;
  34237. /**
  34238. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34239. * In other words, more vertices, no more indices and a single bigger VBO.
  34240. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34241. * @returns current mesh
  34242. */
  34243. convertToUnIndexedMesh(): Mesh;
  34244. /**
  34245. * Inverses facet orientations.
  34246. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34247. * @param flipNormals will also inverts the normals
  34248. * @returns current mesh
  34249. */
  34250. flipFaces(flipNormals?: boolean): Mesh;
  34251. /**
  34252. * Increase the number of facets and hence vertices in a mesh
  34253. * Vertex normals are interpolated from existing vertex normals
  34254. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34255. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34256. */
  34257. increaseVertices(numberPerEdge: number): void;
  34258. /**
  34259. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34260. * This will undo any application of covertToFlatShadedMesh
  34261. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34262. */
  34263. forceSharedVertices(): void;
  34264. /** @hidden */
  34265. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34266. /** @hidden */
  34267. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34268. /**
  34269. * Creates a new InstancedMesh object from the mesh model.
  34270. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34271. * @param name defines the name of the new instance
  34272. * @returns a new InstancedMesh
  34273. */
  34274. createInstance(name: string): InstancedMesh;
  34275. /**
  34276. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34277. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34278. * @returns the current mesh
  34279. */
  34280. synchronizeInstances(): Mesh;
  34281. /**
  34282. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34283. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34284. * This should be used together with the simplification to avoid disappearing triangles.
  34285. * @param successCallback an optional success callback to be called after the optimization finished.
  34286. * @returns the current mesh
  34287. */
  34288. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34289. /**
  34290. * Serialize current mesh
  34291. * @param serializationObject defines the object which will receive the serialization data
  34292. */
  34293. serialize(serializationObject: any): void;
  34294. /** @hidden */
  34295. _syncGeometryWithMorphTargetManager(): void;
  34296. /** @hidden */
  34297. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34298. /**
  34299. * Returns a new Mesh object parsed from the source provided.
  34300. * @param parsedMesh is the source
  34301. * @param scene defines the hosting scene
  34302. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34303. * @returns a new Mesh
  34304. */
  34305. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34306. /**
  34307. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34308. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34309. * @param name defines the name of the mesh to create
  34310. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34311. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34312. * @param closePath creates a seam between the first and the last points of each path of the path array
  34313. * @param offset is taken in account only if the `pathArray` is containing a single path
  34314. * @param scene defines the hosting scene
  34315. * @param updatable defines if the mesh must be flagged as updatable
  34316. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34317. * @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)
  34318. * @returns a new Mesh
  34319. */
  34320. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34321. /**
  34322. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34323. * @param name defines the name of the mesh to create
  34324. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34325. * @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
  34326. * @param scene defines the hosting scene
  34327. * @param updatable defines if the mesh must be flagged as updatable
  34328. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34329. * @returns a new Mesh
  34330. */
  34331. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34332. /**
  34333. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34334. * @param name defines the name of the mesh to create
  34335. * @param size sets the size (float) of each box side (default 1)
  34336. * @param scene defines the hosting scene
  34337. * @param updatable defines if the mesh must be flagged as updatable
  34338. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34339. * @returns a new Mesh
  34340. */
  34341. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34342. /**
  34343. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34344. * @param name defines the name of the mesh to create
  34345. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34346. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34347. * @param scene defines the hosting scene
  34348. * @param updatable defines if the mesh must be flagged as updatable
  34349. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34350. * @returns a new Mesh
  34351. */
  34352. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34353. /**
  34354. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34355. * @param name defines the name of the mesh to create
  34356. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34357. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34358. * @param scene defines the hosting scene
  34359. * @returns a new Mesh
  34360. */
  34361. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34362. /**
  34363. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34364. * @param name defines the name of the mesh to create
  34365. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34366. * @param diameterTop set the top cap diameter (floats, default 1)
  34367. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34368. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34369. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34370. * @param scene defines the hosting scene
  34371. * @param updatable defines if the mesh must be flagged as updatable
  34372. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34373. * @returns a new Mesh
  34374. */
  34375. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34376. /**
  34377. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34378. * @param name defines the name of the mesh to create
  34379. * @param diameter sets the diameter size (float) of the torus (default 1)
  34380. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34381. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34382. * @param scene defines the hosting scene
  34383. * @param updatable defines if the mesh must be flagged as updatable
  34384. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34385. * @returns a new Mesh
  34386. */
  34387. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34388. /**
  34389. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34390. * @param name defines the name of the mesh to create
  34391. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34392. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34393. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34394. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34395. * @param p the number of windings on X axis (positive integers, default 2)
  34396. * @param q the number of windings on Y axis (positive integers, default 3)
  34397. * @param scene defines the hosting scene
  34398. * @param updatable defines if the mesh must be flagged as updatable
  34399. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34400. * @returns a new Mesh
  34401. */
  34402. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34403. /**
  34404. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34405. * @param name defines the name of the mesh to create
  34406. * @param points is an array successive Vector3
  34407. * @param scene defines the hosting scene
  34408. * @param updatable defines if the mesh must be flagged as updatable
  34409. * @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).
  34410. * @returns a new Mesh
  34411. */
  34412. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34413. /**
  34414. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34415. * @param name defines the name of the mesh to create
  34416. * @param points is an array successive Vector3
  34417. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34418. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34419. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34420. * @param scene defines the hosting scene
  34421. * @param updatable defines if the mesh must be flagged as updatable
  34422. * @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)
  34423. * @returns a new Mesh
  34424. */
  34425. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34426. /**
  34427. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34428. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34429. * 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.
  34430. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34431. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34432. * Remember you can only change the shape positions, not their number when updating a polygon.
  34433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34434. * @param name defines the name of the mesh to create
  34435. * @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
  34436. * @param scene defines the hosting scene
  34437. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34438. * @param updatable defines if the mesh must be flagged as updatable
  34439. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34440. * @param earcutInjection can be used to inject your own earcut reference
  34441. * @returns a new Mesh
  34442. */
  34443. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34444. /**
  34445. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34447. * @param name defines the name of the mesh to create
  34448. * @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
  34449. * @param depth defines the height of extrusion
  34450. * @param scene defines the hosting scene
  34451. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34452. * @param updatable defines if the mesh must be flagged as updatable
  34453. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34454. * @param earcutInjection can be used to inject your own earcut reference
  34455. * @returns a new Mesh
  34456. */
  34457. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34458. /**
  34459. * Creates an extruded shape mesh.
  34460. * 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
  34461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34463. * @param name defines the name of the mesh to create
  34464. * @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
  34465. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34466. * @param scale is the value to scale the shape
  34467. * @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
  34468. * @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
  34469. * @param scene defines the hosting scene
  34470. * @param updatable defines if the mesh must be flagged as updatable
  34471. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34472. * @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)
  34473. * @returns a new Mesh
  34474. */
  34475. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34476. /**
  34477. * Creates an custom extruded shape mesh.
  34478. * The custom extrusion is a parametric shape.
  34479. * It has no predefined shape. Its final shape will depend on the input parameters.
  34480. * Please consider using the same method from the MeshBuilder class instead
  34481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34482. * @param name defines the name of the mesh to create
  34483. * @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
  34484. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34485. * @param scaleFunction is a custom Javascript function called on each path point
  34486. * @param rotationFunction is a custom Javascript function called on each path point
  34487. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34488. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34489. * @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
  34490. * @param scene defines the hosting scene
  34491. * @param updatable defines if the mesh must be flagged as updatable
  34492. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34493. * @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)
  34494. * @returns a new Mesh
  34495. */
  34496. 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;
  34497. /**
  34498. * Creates lathe mesh.
  34499. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34500. * Please consider using the same method from the MeshBuilder class instead
  34501. * @param name defines the name of the mesh to create
  34502. * @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
  34503. * @param radius is the radius value of the lathe
  34504. * @param tessellation is the side number of the lathe.
  34505. * @param scene defines the hosting scene
  34506. * @param updatable defines if the mesh must be flagged as updatable
  34507. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34508. * @returns a new Mesh
  34509. */
  34510. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34511. /**
  34512. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  34513. * @param name defines the name of the mesh to create
  34514. * @param size sets the size (float) of both sides of the plane at once (default 1)
  34515. * @param scene defines the hosting scene
  34516. * @param updatable defines if the mesh must be flagged as updatable
  34517. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34518. * @returns a new Mesh
  34519. */
  34520. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34521. /**
  34522. * Creates a ground mesh.
  34523. * Please consider using the same method from the MeshBuilder class instead
  34524. * @param name defines the name of the mesh to create
  34525. * @param width set the width of the ground
  34526. * @param height set the height of the ground
  34527. * @param subdivisions sets the number of subdivisions per side
  34528. * @param scene defines the hosting scene
  34529. * @param updatable defines if the mesh must be flagged as updatable
  34530. * @returns a new Mesh
  34531. */
  34532. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34533. /**
  34534. * Creates a tiled ground mesh.
  34535. * Please consider using the same method from the MeshBuilder class instead
  34536. * @param name defines the name of the mesh to create
  34537. * @param xmin set the ground minimum X coordinate
  34538. * @param zmin set the ground minimum Y coordinate
  34539. * @param xmax set the ground maximum X coordinate
  34540. * @param zmax set the ground maximum Z coordinate
  34541. * @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
  34542. * @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
  34543. * @param scene defines the hosting scene
  34544. * @param updatable defines if the mesh must be flagged as updatable
  34545. * @returns a new Mesh
  34546. */
  34547. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34548. w: number;
  34549. h: number;
  34550. }, precision: {
  34551. w: number;
  34552. h: number;
  34553. }, scene: Scene, updatable?: boolean): Mesh;
  34554. /**
  34555. * Creates a ground mesh from a height map.
  34556. * Please consider using the same method from the MeshBuilder class instead
  34557. * @see https://doc.babylonjs.com/babylon101/height_map
  34558. * @param name defines the name of the mesh to create
  34559. * @param url sets the URL of the height map image resource
  34560. * @param width set the ground width size
  34561. * @param height set the ground height size
  34562. * @param subdivisions sets the number of subdivision per side
  34563. * @param minHeight is the minimum altitude on the ground
  34564. * @param maxHeight is the maximum altitude on the ground
  34565. * @param scene defines the hosting scene
  34566. * @param updatable defines if the mesh must be flagged as updatable
  34567. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34568. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34569. * @returns a new Mesh
  34570. */
  34571. 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;
  34572. /**
  34573. * Creates a tube mesh.
  34574. * The tube is a parametric shape.
  34575. * It has no predefined shape. Its final shape will depend on the input parameters.
  34576. * Please consider using the same method from the MeshBuilder class instead
  34577. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34578. * @param name defines the name of the mesh to create
  34579. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34580. * @param radius sets the tube radius size
  34581. * @param tessellation is the number of sides on the tubular surface
  34582. * @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
  34583. * @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
  34584. * @param scene defines the hosting scene
  34585. * @param updatable defines if the mesh must be flagged as updatable
  34586. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34587. * @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)
  34588. * @returns a new Mesh
  34589. */
  34590. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34591. (i: number, distance: number): number;
  34592. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34593. /**
  34594. * Creates a polyhedron mesh.
  34595. * Please consider using the same method from the MeshBuilder class instead.
  34596. * * 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
  34597. * * The parameter `size` (positive float, default 1) sets the polygon size
  34598. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34599. * * 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`
  34600. * * 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
  34601. * * 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)`)
  34602. * * 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
  34603. * * 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
  34604. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34605. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34606. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34607. * @param name defines the name of the mesh to create
  34608. * @param options defines the options used to create the mesh
  34609. * @param scene defines the hosting scene
  34610. * @returns a new Mesh
  34611. */
  34612. static CreatePolyhedron(name: string, options: {
  34613. type?: number;
  34614. size?: number;
  34615. sizeX?: number;
  34616. sizeY?: number;
  34617. sizeZ?: number;
  34618. custom?: any;
  34619. faceUV?: Vector4[];
  34620. faceColors?: Color4[];
  34621. updatable?: boolean;
  34622. sideOrientation?: number;
  34623. }, scene: Scene): Mesh;
  34624. /**
  34625. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34626. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34627. * * 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`)
  34628. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34629. * * 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
  34630. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34631. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  34632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34633. * @param name defines the name of the mesh
  34634. * @param options defines the options used to create the mesh
  34635. * @param scene defines the hosting scene
  34636. * @returns a new Mesh
  34637. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34638. */
  34639. static CreateIcoSphere(name: string, options: {
  34640. radius?: number;
  34641. flat?: boolean;
  34642. subdivisions?: number;
  34643. sideOrientation?: number;
  34644. updatable?: boolean;
  34645. }, scene: Scene): Mesh;
  34646. /**
  34647. * Creates a decal mesh.
  34648. * Please consider using the same method from the MeshBuilder class instead.
  34649. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34650. * @param name defines the name of the mesh
  34651. * @param sourceMesh defines the mesh receiving the decal
  34652. * @param position sets the position of the decal in world coordinates
  34653. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34654. * @param size sets the decal scaling
  34655. * @param angle sets the angle to rotate the decal
  34656. * @returns a new Mesh
  34657. */
  34658. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34659. /** Creates a Capsule Mesh
  34660. * @param name defines the name of the mesh.
  34661. * @param options the constructors options used to shape the mesh.
  34662. * @param scene defines the scene the mesh is scoped to.
  34663. * @returns the capsule mesh
  34664. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34665. */
  34666. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34667. /**
  34668. * Prepare internal position array for software CPU skinning
  34669. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34670. */
  34671. setPositionsForCPUSkinning(): Float32Array;
  34672. /**
  34673. * Prepare internal normal array for software CPU skinning
  34674. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34675. */
  34676. setNormalsForCPUSkinning(): Float32Array;
  34677. /**
  34678. * Updates the vertex buffer by applying transformation from the bones
  34679. * @param skeleton defines the skeleton to apply to current mesh
  34680. * @returns the current mesh
  34681. */
  34682. applySkeleton(skeleton: Skeleton): Mesh;
  34683. /**
  34684. * 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
  34685. * @param meshes defines the list of meshes to scan
  34686. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34687. */
  34688. static MinMax(meshes: AbstractMesh[]): {
  34689. min: Vector3;
  34690. max: Vector3;
  34691. };
  34692. /**
  34693. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34694. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34695. * @returns a vector3
  34696. */
  34697. static Center(meshesOrMinMaxVector: {
  34698. min: Vector3;
  34699. max: Vector3;
  34700. } | AbstractMesh[]): Vector3;
  34701. /**
  34702. * Merge the array of meshes into a single mesh for performance reasons.
  34703. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34704. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34705. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34706. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34707. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34708. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34709. * @returns a new mesh
  34710. */
  34711. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34712. /** @hidden */
  34713. addInstance(instance: InstancedMesh): void;
  34714. /** @hidden */
  34715. removeInstance(instance: InstancedMesh): void;
  34716. }
  34717. }
  34718. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  34719. import { Vector3 } from "babylonjs/Maths/math.vector";
  34720. import { Mesh } from "babylonjs/Meshes/mesh";
  34721. /**
  34722. * The options Interface for creating a Capsule Mesh
  34723. */
  34724. export interface ICreateCapsuleOptions {
  34725. /** The Orientation of the capsule. Default : Vector3.Up() */
  34726. orientation?: Vector3;
  34727. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34728. subdivisions: number;
  34729. /** Number of cylindrical segments on the capsule. */
  34730. tessellation: number;
  34731. /** Height or Length of the capsule. */
  34732. height: number;
  34733. /** Radius of the capsule. */
  34734. radius: number;
  34735. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34736. capSubdivisions: number;
  34737. /** Overwrite for the top radius. */
  34738. radiusTop?: number;
  34739. /** Overwrite for the bottom radius. */
  34740. radiusBottom?: number;
  34741. /** Overwrite for the top capSubdivisions. */
  34742. topCapSubdivisions?: number;
  34743. /** Overwrite for the bottom capSubdivisions. */
  34744. bottomCapSubdivisions?: number;
  34745. }
  34746. /**
  34747. * Class containing static functions to help procedurally build meshes
  34748. */
  34749. export class CapsuleBuilder {
  34750. /**
  34751. * Creates a capsule or a pill mesh
  34752. * @param name defines the name of the mesh
  34753. * @param options The constructors options.
  34754. * @param scene The scene the mesh is scoped to.
  34755. * @returns Capsule Mesh
  34756. */
  34757. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34758. }
  34759. }
  34760. declare module "babylonjs/Meshes/mesh.vertexData" {
  34761. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  34762. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  34763. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  34764. import { Geometry } from "babylonjs/Meshes/geometry";
  34765. import { Mesh } from "babylonjs/Meshes/mesh";
  34766. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  34767. /**
  34768. * Define an interface for all classes that will get and set the data on vertices
  34769. */
  34770. export interface IGetSetVerticesData {
  34771. /**
  34772. * Gets a boolean indicating if specific vertex data is present
  34773. * @param kind defines the vertex data kind to use
  34774. * @returns true is data kind is present
  34775. */
  34776. isVerticesDataPresent(kind: string): boolean;
  34777. /**
  34778. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34779. * @param kind defines the data kind (Position, normal, etc...)
  34780. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34781. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34782. * @returns a float array containing vertex data
  34783. */
  34784. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34785. /**
  34786. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34787. * @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.
  34788. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34789. * @returns the indices array or an empty array if the mesh has no geometry
  34790. */
  34791. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34792. /**
  34793. * Set specific vertex data
  34794. * @param kind defines the data kind (Position, normal, etc...)
  34795. * @param data defines the vertex data to use
  34796. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34797. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34798. */
  34799. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34800. /**
  34801. * Update a specific associated vertex buffer
  34802. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34803. * - VertexBuffer.PositionKind
  34804. * - VertexBuffer.UVKind
  34805. * - VertexBuffer.UV2Kind
  34806. * - VertexBuffer.UV3Kind
  34807. * - VertexBuffer.UV4Kind
  34808. * - VertexBuffer.UV5Kind
  34809. * - VertexBuffer.UV6Kind
  34810. * - VertexBuffer.ColorKind
  34811. * - VertexBuffer.MatricesIndicesKind
  34812. * - VertexBuffer.MatricesIndicesExtraKind
  34813. * - VertexBuffer.MatricesWeightsKind
  34814. * - VertexBuffer.MatricesWeightsExtraKind
  34815. * @param data defines the data source
  34816. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34817. * @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)
  34818. */
  34819. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34820. /**
  34821. * Creates a new index buffer
  34822. * @param indices defines the indices to store in the index buffer
  34823. * @param totalVertices defines the total number of vertices (could be null)
  34824. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34825. */
  34826. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34827. }
  34828. /**
  34829. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34830. */
  34831. export class VertexData {
  34832. /**
  34833. * Mesh side orientation : usually the external or front surface
  34834. */
  34835. static readonly FRONTSIDE: number;
  34836. /**
  34837. * Mesh side orientation : usually the internal or back surface
  34838. */
  34839. static readonly BACKSIDE: number;
  34840. /**
  34841. * Mesh side orientation : both internal and external or front and back surfaces
  34842. */
  34843. static readonly DOUBLESIDE: number;
  34844. /**
  34845. * Mesh side orientation : by default, `FRONTSIDE`
  34846. */
  34847. static readonly DEFAULTSIDE: number;
  34848. /**
  34849. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34850. */
  34851. positions: Nullable<FloatArray>;
  34852. /**
  34853. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34854. */
  34855. normals: Nullable<FloatArray>;
  34856. /**
  34857. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34858. */
  34859. tangents: Nullable<FloatArray>;
  34860. /**
  34861. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34862. */
  34863. uvs: Nullable<FloatArray>;
  34864. /**
  34865. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34866. */
  34867. uvs2: Nullable<FloatArray>;
  34868. /**
  34869. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34870. */
  34871. uvs3: Nullable<FloatArray>;
  34872. /**
  34873. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34874. */
  34875. uvs4: Nullable<FloatArray>;
  34876. /**
  34877. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34878. */
  34879. uvs5: Nullable<FloatArray>;
  34880. /**
  34881. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34882. */
  34883. uvs6: Nullable<FloatArray>;
  34884. /**
  34885. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34886. */
  34887. colors: Nullable<FloatArray>;
  34888. /**
  34889. * 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).
  34890. */
  34891. matricesIndices: Nullable<FloatArray>;
  34892. /**
  34893. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34894. */
  34895. matricesWeights: Nullable<FloatArray>;
  34896. /**
  34897. * An array extending the number of possible indices
  34898. */
  34899. matricesIndicesExtra: Nullable<FloatArray>;
  34900. /**
  34901. * An array extending the number of possible weights when the number of indices is extended
  34902. */
  34903. matricesWeightsExtra: Nullable<FloatArray>;
  34904. /**
  34905. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34906. */
  34907. indices: Nullable<IndicesArray>;
  34908. /**
  34909. * Uses the passed data array to set the set the values for the specified kind of data
  34910. * @param data a linear array of floating numbers
  34911. * @param kind the type of data that is being set, eg positions, colors etc
  34912. */
  34913. set(data: FloatArray, kind: string): void;
  34914. /**
  34915. * Associates the vertexData to the passed Mesh.
  34916. * Sets it as updatable or not (default `false`)
  34917. * @param mesh the mesh the vertexData is applied to
  34918. * @param updatable when used and having the value true allows new data to update the vertexData
  34919. * @returns the VertexData
  34920. */
  34921. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34922. /**
  34923. * Associates the vertexData to the passed Geometry.
  34924. * Sets it as updatable or not (default `false`)
  34925. * @param geometry the geometry the vertexData is applied to
  34926. * @param updatable when used and having the value true allows new data to update the vertexData
  34927. * @returns VertexData
  34928. */
  34929. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34930. /**
  34931. * Updates the associated mesh
  34932. * @param mesh the mesh to be updated
  34933. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34934. * @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
  34935. * @returns VertexData
  34936. */
  34937. updateMesh(mesh: Mesh): VertexData;
  34938. /**
  34939. * Updates the associated geometry
  34940. * @param geometry the geometry to be updated
  34941. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34942. * @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
  34943. * @returns VertexData.
  34944. */
  34945. updateGeometry(geometry: Geometry): VertexData;
  34946. private _applyTo;
  34947. private _update;
  34948. /**
  34949. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34950. * @param matrix the transforming matrix
  34951. * @returns the VertexData
  34952. */
  34953. transform(matrix: Matrix): VertexData;
  34954. /**
  34955. * Merges the passed VertexData into the current one
  34956. * @param other the VertexData to be merged into the current one
  34957. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34958. * @returns the modified VertexData
  34959. */
  34960. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34961. private _mergeElement;
  34962. private _validate;
  34963. /**
  34964. * Serializes the VertexData
  34965. * @returns a serialized object
  34966. */
  34967. serialize(): any;
  34968. /**
  34969. * Extracts the vertexData from a mesh
  34970. * @param mesh the mesh from which to extract the VertexData
  34971. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34972. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34973. * @returns the object VertexData associated to the passed mesh
  34974. */
  34975. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34976. /**
  34977. * Extracts the vertexData from the geometry
  34978. * @param geometry the geometry from which to extract the VertexData
  34979. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34980. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34981. * @returns the object VertexData associated to the passed mesh
  34982. */
  34983. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34984. private static _ExtractFrom;
  34985. /**
  34986. * Creates the VertexData for a Ribbon
  34987. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34988. * * pathArray array of paths, each of which an array of successive Vector3
  34989. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34990. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34991. * * 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
  34992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34993. * * 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)
  34994. * * 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)
  34995. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34996. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34997. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34998. * @returns the VertexData of the ribbon
  34999. */
  35000. static CreateRibbon(options: {
  35001. pathArray: Vector3[][];
  35002. closeArray?: boolean;
  35003. closePath?: boolean;
  35004. offset?: number;
  35005. sideOrientation?: number;
  35006. frontUVs?: Vector4;
  35007. backUVs?: Vector4;
  35008. invertUV?: boolean;
  35009. uvs?: Vector2[];
  35010. colors?: Color4[];
  35011. }): VertexData;
  35012. /**
  35013. * Creates the VertexData for a box
  35014. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35015. * * size sets the width, height and depth of the box to the value of size, optional default 1
  35016. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  35017. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  35018. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  35019. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35020. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35021. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35022. * * 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)
  35023. * * 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)
  35024. * @returns the VertexData of the box
  35025. */
  35026. static CreateBox(options: {
  35027. size?: number;
  35028. width?: number;
  35029. height?: number;
  35030. depth?: number;
  35031. faceUV?: Vector4[];
  35032. faceColors?: Color4[];
  35033. sideOrientation?: number;
  35034. frontUVs?: Vector4;
  35035. backUVs?: Vector4;
  35036. }): VertexData;
  35037. /**
  35038. * Creates the VertexData for a tiled box
  35039. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35040. * * faceTiles sets the pattern, tile size and number of tiles for a face
  35041. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  35042. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  35043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35044. * @returns the VertexData of the box
  35045. */
  35046. static CreateTiledBox(options: {
  35047. pattern?: number;
  35048. width?: number;
  35049. height?: number;
  35050. depth?: number;
  35051. tileSize?: number;
  35052. tileWidth?: number;
  35053. tileHeight?: number;
  35054. alignHorizontal?: number;
  35055. alignVertical?: number;
  35056. faceUV?: Vector4[];
  35057. faceColors?: Color4[];
  35058. sideOrientation?: number;
  35059. }): VertexData;
  35060. /**
  35061. * Creates the VertexData for a tiled plane
  35062. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35063. * * pattern a limited pattern arrangement depending on the number
  35064. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  35065. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  35066. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  35067. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35068. * * 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)
  35069. * * 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)
  35070. * @returns the VertexData of the tiled plane
  35071. */
  35072. static CreateTiledPlane(options: {
  35073. pattern?: number;
  35074. tileSize?: number;
  35075. tileWidth?: number;
  35076. tileHeight?: number;
  35077. size?: number;
  35078. width?: number;
  35079. height?: number;
  35080. alignHorizontal?: number;
  35081. alignVertical?: number;
  35082. sideOrientation?: number;
  35083. frontUVs?: Vector4;
  35084. backUVs?: Vector4;
  35085. }): VertexData;
  35086. /**
  35087. * Creates the VertexData for an ellipsoid, defaults to a sphere
  35088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35089. * * segments sets the number of horizontal strips optional, default 32
  35090. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  35091. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  35092. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  35093. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  35094. * * 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
  35095. * * 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
  35096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35097. * * 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)
  35098. * * 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)
  35099. * @returns the VertexData of the ellipsoid
  35100. */
  35101. static CreateSphere(options: {
  35102. segments?: number;
  35103. diameter?: number;
  35104. diameterX?: number;
  35105. diameterY?: number;
  35106. diameterZ?: number;
  35107. arc?: number;
  35108. slice?: number;
  35109. sideOrientation?: number;
  35110. frontUVs?: Vector4;
  35111. backUVs?: Vector4;
  35112. }): VertexData;
  35113. /**
  35114. * Creates the VertexData for a cylinder, cone or prism
  35115. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35116. * * height sets the height (y direction) of the cylinder, optional, default 2
  35117. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  35118. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  35119. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  35120. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35121. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  35122. * * 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
  35123. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35124. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35125. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  35126. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  35127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35128. * * 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)
  35129. * * 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)
  35130. * @returns the VertexData of the cylinder, cone or prism
  35131. */
  35132. static CreateCylinder(options: {
  35133. height?: number;
  35134. diameterTop?: number;
  35135. diameterBottom?: number;
  35136. diameter?: number;
  35137. tessellation?: number;
  35138. subdivisions?: number;
  35139. arc?: number;
  35140. faceColors?: Color4[];
  35141. faceUV?: Vector4[];
  35142. hasRings?: boolean;
  35143. enclose?: boolean;
  35144. sideOrientation?: number;
  35145. frontUVs?: Vector4;
  35146. backUVs?: Vector4;
  35147. }): VertexData;
  35148. /**
  35149. * Creates the VertexData for a torus
  35150. * @param options an object used to set the following optional parameters for the box, required but can be empty
  35151. * * diameter the diameter of the torus, optional default 1
  35152. * * thickness the diameter of the tube forming the torus, optional default 0.5
  35153. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  35154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35155. * * 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)
  35156. * * 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)
  35157. * @returns the VertexData of the torus
  35158. */
  35159. static CreateTorus(options: {
  35160. diameter?: number;
  35161. thickness?: number;
  35162. tessellation?: number;
  35163. sideOrientation?: number;
  35164. frontUVs?: Vector4;
  35165. backUVs?: Vector4;
  35166. }): VertexData;
  35167. /**
  35168. * Creates the VertexData of the LineSystem
  35169. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  35170. * - lines an array of lines, each line being an array of successive Vector3
  35171. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  35172. * @returns the VertexData of the LineSystem
  35173. */
  35174. static CreateLineSystem(options: {
  35175. lines: Vector3[][];
  35176. colors?: Nullable<Color4[][]>;
  35177. }): VertexData;
  35178. /**
  35179. * Create the VertexData for a DashedLines
  35180. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  35181. * - points an array successive Vector3
  35182. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  35183. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  35184. * - dashNb the intended total number of dashes, optional, default 200
  35185. * @returns the VertexData for the DashedLines
  35186. */
  35187. static CreateDashedLines(options: {
  35188. points: Vector3[];
  35189. dashSize?: number;
  35190. gapSize?: number;
  35191. dashNb?: number;
  35192. }): VertexData;
  35193. /**
  35194. * Creates the VertexData for a Ground
  35195. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35196. * - width the width (x direction) of the ground, optional, default 1
  35197. * - height the height (z direction) of the ground, optional, default 1
  35198. * - subdivisions the number of subdivisions per side, optional, default 1
  35199. * @returns the VertexData of the Ground
  35200. */
  35201. static CreateGround(options: {
  35202. width?: number;
  35203. height?: number;
  35204. subdivisions?: number;
  35205. subdivisionsX?: number;
  35206. subdivisionsY?: number;
  35207. }): VertexData;
  35208. /**
  35209. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  35210. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  35211. * * xmin the ground minimum X coordinate, optional, default -1
  35212. * * zmin the ground minimum Z coordinate, optional, default -1
  35213. * * xmax the ground maximum X coordinate, optional, default 1
  35214. * * zmax the ground maximum Z coordinate, optional, default 1
  35215. * * 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}
  35216. * * 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}
  35217. * @returns the VertexData of the TiledGround
  35218. */
  35219. static CreateTiledGround(options: {
  35220. xmin: number;
  35221. zmin: number;
  35222. xmax: number;
  35223. zmax: number;
  35224. subdivisions?: {
  35225. w: number;
  35226. h: number;
  35227. };
  35228. precision?: {
  35229. w: number;
  35230. h: number;
  35231. };
  35232. }): VertexData;
  35233. /**
  35234. * Creates the VertexData of the Ground designed from a heightmap
  35235. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  35236. * * width the width (x direction) of the ground
  35237. * * height the height (z direction) of the ground
  35238. * * subdivisions the number of subdivisions per side
  35239. * * minHeight the minimum altitude on the ground, optional, default 0
  35240. * * maxHeight the maximum altitude on the ground, optional default 1
  35241. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  35242. * * buffer the array holding the image color data
  35243. * * bufferWidth the width of image
  35244. * * bufferHeight the height of image
  35245. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  35246. * @returns the VertexData of the Ground designed from a heightmap
  35247. */
  35248. static CreateGroundFromHeightMap(options: {
  35249. width: number;
  35250. height: number;
  35251. subdivisions: number;
  35252. minHeight: number;
  35253. maxHeight: number;
  35254. colorFilter: Color3;
  35255. buffer: Uint8Array;
  35256. bufferWidth: number;
  35257. bufferHeight: number;
  35258. alphaFilter: number;
  35259. }): VertexData;
  35260. /**
  35261. * Creates the VertexData for a Plane
  35262. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  35263. * * size sets the width and height of the plane to the value of size, optional default 1
  35264. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  35265. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  35266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35267. * * 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)
  35268. * * 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)
  35269. * @returns the VertexData of the box
  35270. */
  35271. static CreatePlane(options: {
  35272. size?: number;
  35273. width?: number;
  35274. height?: number;
  35275. sideOrientation?: number;
  35276. frontUVs?: Vector4;
  35277. backUVs?: Vector4;
  35278. }): VertexData;
  35279. /**
  35280. * Creates the VertexData of the Disc or regular Polygon
  35281. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  35282. * * radius the radius of the disc, optional default 0.5
  35283. * * tessellation the number of polygon sides, optional, default 64
  35284. * * 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
  35285. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35286. * * 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)
  35287. * * 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)
  35288. * @returns the VertexData of the box
  35289. */
  35290. static CreateDisc(options: {
  35291. radius?: number;
  35292. tessellation?: number;
  35293. arc?: number;
  35294. sideOrientation?: number;
  35295. frontUVs?: Vector4;
  35296. backUVs?: Vector4;
  35297. }): VertexData;
  35298. /**
  35299. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  35300. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  35301. * @param polygon a mesh built from polygonTriangulation.build()
  35302. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35303. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35304. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35305. * @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)
  35306. * @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)
  35307. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  35308. * @returns the VertexData of the Polygon
  35309. */
  35310. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  35311. /**
  35312. * Creates the VertexData of the IcoSphere
  35313. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  35314. * * radius the radius of the IcoSphere, optional default 1
  35315. * * radiusX allows stretching in the x direction, optional, default radius
  35316. * * radiusY allows stretching in the y direction, optional, default radius
  35317. * * radiusZ allows stretching in the z direction, optional, default radius
  35318. * * flat when true creates a flat shaded mesh, optional, default true
  35319. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35320. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35321. * * 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)
  35322. * * 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)
  35323. * @returns the VertexData of the IcoSphere
  35324. */
  35325. static CreateIcoSphere(options: {
  35326. radius?: number;
  35327. radiusX?: number;
  35328. radiusY?: number;
  35329. radiusZ?: number;
  35330. flat?: boolean;
  35331. subdivisions?: number;
  35332. sideOrientation?: number;
  35333. frontUVs?: Vector4;
  35334. backUVs?: Vector4;
  35335. }): VertexData;
  35336. /**
  35337. * Creates the VertexData for a Polyhedron
  35338. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  35339. * * type provided types are:
  35340. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  35341. * * 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)
  35342. * * size the size of the IcoSphere, optional default 1
  35343. * * sizeX allows stretching in the x direction, optional, default size
  35344. * * sizeY allows stretching in the y direction, optional, default size
  35345. * * sizeZ allows stretching in the z direction, optional, default size
  35346. * * 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
  35347. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  35348. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  35349. * * flat when true creates a flat shaded mesh, optional, default true
  35350. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  35351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35352. * * 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)
  35353. * * 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)
  35354. * @returns the VertexData of the Polyhedron
  35355. */
  35356. static CreatePolyhedron(options: {
  35357. type?: number;
  35358. size?: number;
  35359. sizeX?: number;
  35360. sizeY?: number;
  35361. sizeZ?: number;
  35362. custom?: any;
  35363. faceUV?: Vector4[];
  35364. faceColors?: Color4[];
  35365. flat?: boolean;
  35366. sideOrientation?: number;
  35367. frontUVs?: Vector4;
  35368. backUVs?: Vector4;
  35369. }): VertexData;
  35370. /**
  35371. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  35372. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  35373. * @returns the VertexData of the Capsule
  35374. */
  35375. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  35376. /**
  35377. * Creates the VertexData for a TorusKnot
  35378. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  35379. * * radius the radius of the torus knot, optional, default 2
  35380. * * tube the thickness of the tube, optional, default 0.5
  35381. * * radialSegments the number of sides on each tube segments, optional, default 32
  35382. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  35383. * * p the number of windings around the z axis, optional, default 2
  35384. * * q the number of windings around the x axis, optional, default 3
  35385. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35386. * * 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)
  35387. * * 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)
  35388. * @returns the VertexData of the Torus Knot
  35389. */
  35390. static CreateTorusKnot(options: {
  35391. radius?: number;
  35392. tube?: number;
  35393. radialSegments?: number;
  35394. tubularSegments?: number;
  35395. p?: number;
  35396. q?: number;
  35397. sideOrientation?: number;
  35398. frontUVs?: Vector4;
  35399. backUVs?: Vector4;
  35400. }): VertexData;
  35401. /**
  35402. * Compute normals for given positions and indices
  35403. * @param positions an array of vertex positions, [...., x, y, z, ......]
  35404. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  35405. * @param normals an array of vertex normals, [...., x, y, z, ......]
  35406. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  35407. * * facetNormals : optional array of facet normals (vector3)
  35408. * * facetPositions : optional array of facet positions (vector3)
  35409. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  35410. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  35411. * * bInfo : optional bounding info, required for facetPartitioning computation
  35412. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  35413. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  35414. * * useRightHandedSystem: optional boolean to for right handed system computation
  35415. * * depthSort : optional boolean to enable the facet depth sort computation
  35416. * * distanceTo : optional Vector3 to compute the facet depth from this location
  35417. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  35418. */
  35419. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  35420. facetNormals?: any;
  35421. facetPositions?: any;
  35422. facetPartitioning?: any;
  35423. ratio?: number;
  35424. bInfo?: any;
  35425. bbSize?: Vector3;
  35426. subDiv?: any;
  35427. useRightHandedSystem?: boolean;
  35428. depthSort?: boolean;
  35429. distanceTo?: Vector3;
  35430. depthSortedFacets?: any;
  35431. }): void;
  35432. /** @hidden */
  35433. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  35434. /**
  35435. * Applies VertexData created from the imported parameters to the geometry
  35436. * @param parsedVertexData the parsed data from an imported file
  35437. * @param geometry the geometry to apply the VertexData to
  35438. */
  35439. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  35440. }
  35441. }
  35442. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35443. import { Nullable } from "babylonjs/types";
  35444. import { Scene } from "babylonjs/scene";
  35445. import { Vector4 } from "babylonjs/Maths/math.vector";
  35446. import { Mesh } from "babylonjs/Meshes/mesh";
  35447. /**
  35448. * Class containing static functions to help procedurally build meshes
  35449. */
  35450. export class DiscBuilder {
  35451. /**
  35452. * Creates a plane polygonal mesh. By default, this is a disc
  35453. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35454. * * 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
  35455. * * 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
  35456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35459. * @param name defines the name of the mesh
  35460. * @param options defines the options used to create the mesh
  35461. * @param scene defines the hosting scene
  35462. * @returns the plane polygonal mesh
  35463. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35464. */
  35465. static CreateDisc(name: string, options: {
  35466. radius?: number;
  35467. tessellation?: number;
  35468. arc?: number;
  35469. updatable?: boolean;
  35470. sideOrientation?: number;
  35471. frontUVs?: Vector4;
  35472. backUVs?: Vector4;
  35473. }, scene?: Nullable<Scene>): Mesh;
  35474. }
  35475. }
  35476. declare module "babylonjs/Particles/solidParticleSystem" {
  35477. import { Nullable } from "babylonjs/types";
  35478. import { Mesh } from "babylonjs/Meshes/mesh";
  35479. import { Scene, IDisposable } from "babylonjs/scene";
  35480. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35481. import { Material } from "babylonjs/Materials/material";
  35482. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35483. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35484. /**
  35485. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35486. *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.
  35487. * The SPS is also a particle system. It provides some methods to manage the particles.
  35488. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35489. *
  35490. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35491. */
  35492. export class SolidParticleSystem implements IDisposable {
  35493. /**
  35494. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35495. * Example : var p = SPS.particles[i];
  35496. */
  35497. particles: SolidParticle[];
  35498. /**
  35499. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35500. */
  35501. nbParticles: number;
  35502. /**
  35503. * If the particles must ever face the camera (default false). Useful for planar particles.
  35504. */
  35505. billboard: boolean;
  35506. /**
  35507. * Recompute normals when adding a shape
  35508. */
  35509. recomputeNormals: boolean;
  35510. /**
  35511. * This a counter ofr your own usage. It's not set by any SPS functions.
  35512. */
  35513. counter: number;
  35514. /**
  35515. * The SPS name. This name is also given to the underlying mesh.
  35516. */
  35517. name: string;
  35518. /**
  35519. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35520. */
  35521. mesh: Mesh;
  35522. /**
  35523. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35524. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35525. */
  35526. vars: any;
  35527. /**
  35528. * This array is populated when the SPS is set as 'pickable'.
  35529. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35530. * Each element of this array is an object `{idx: int, faceId: int}`.
  35531. * `idx` is the picked particle index in the `SPS.particles` array
  35532. * `faceId` is the picked face index counted within this particle.
  35533. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35534. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35535. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35536. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35537. */
  35538. pickedParticles: {
  35539. idx: number;
  35540. faceId: number;
  35541. }[];
  35542. /**
  35543. * This array is populated when the SPS is set as 'pickable'
  35544. * Each key of this array is a submesh index.
  35545. * Each element of this array is a second array defined like this :
  35546. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35547. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35548. * `idx` is the picked particle index in the `SPS.particles` array
  35549. * `faceId` is the picked face index counted within this particle.
  35550. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35551. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35552. */
  35553. pickedBySubMesh: {
  35554. idx: number;
  35555. faceId: number;
  35556. }[][];
  35557. /**
  35558. * This array is populated when `enableDepthSort` is set to true.
  35559. * Each element of this array is an instance of the class DepthSortedParticle.
  35560. */
  35561. depthSortedParticles: DepthSortedParticle[];
  35562. /**
  35563. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35564. * @hidden
  35565. */
  35566. _bSphereOnly: boolean;
  35567. /**
  35568. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35569. * @hidden
  35570. */
  35571. _bSphereRadiusFactor: number;
  35572. private _scene;
  35573. private _positions;
  35574. private _indices;
  35575. private _normals;
  35576. private _colors;
  35577. private _uvs;
  35578. private _indices32;
  35579. private _positions32;
  35580. private _normals32;
  35581. private _fixedNormal32;
  35582. private _colors32;
  35583. private _uvs32;
  35584. private _index;
  35585. private _updatable;
  35586. private _pickable;
  35587. private _isVisibilityBoxLocked;
  35588. private _alwaysVisible;
  35589. private _depthSort;
  35590. private _expandable;
  35591. private _shapeCounter;
  35592. private _copy;
  35593. private _color;
  35594. private _computeParticleColor;
  35595. private _computeParticleTexture;
  35596. private _computeParticleRotation;
  35597. private _computeParticleVertex;
  35598. private _computeBoundingBox;
  35599. private _depthSortParticles;
  35600. private _camera;
  35601. private _mustUnrotateFixedNormals;
  35602. private _particlesIntersect;
  35603. private _needs32Bits;
  35604. private _isNotBuilt;
  35605. private _lastParticleId;
  35606. private _idxOfId;
  35607. private _multimaterialEnabled;
  35608. private _useModelMaterial;
  35609. private _indicesByMaterial;
  35610. private _materialIndexes;
  35611. private _depthSortFunction;
  35612. private _materialSortFunction;
  35613. private _materials;
  35614. private _multimaterial;
  35615. private _materialIndexesById;
  35616. private _defaultMaterial;
  35617. private _autoUpdateSubMeshes;
  35618. private _tmpVertex;
  35619. /**
  35620. * Creates a SPS (Solid Particle System) object.
  35621. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35622. * @param scene (Scene) is the scene in which the SPS is added.
  35623. * @param options defines the options of the sps e.g.
  35624. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35625. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35626. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35627. * * 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.
  35628. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35629. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35630. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35631. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35632. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35633. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35634. */
  35635. constructor(name: string, scene: Scene, options?: {
  35636. updatable?: boolean;
  35637. isPickable?: boolean;
  35638. enableDepthSort?: boolean;
  35639. particleIntersection?: boolean;
  35640. boundingSphereOnly?: boolean;
  35641. bSphereRadiusFactor?: number;
  35642. expandable?: boolean;
  35643. useModelMaterial?: boolean;
  35644. enableMultiMaterial?: boolean;
  35645. });
  35646. /**
  35647. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35648. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35649. * @returns the created mesh
  35650. */
  35651. buildMesh(): Mesh;
  35652. /**
  35653. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35654. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35655. * Thus the particles generated from `digest()` have their property `position` set yet.
  35656. * @param mesh ( Mesh ) is the mesh to be digested
  35657. * @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
  35658. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35659. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35660. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35661. * @returns the current SPS
  35662. */
  35663. digest(mesh: Mesh, options?: {
  35664. facetNb?: number;
  35665. number?: number;
  35666. delta?: number;
  35667. storage?: [];
  35668. }): SolidParticleSystem;
  35669. /**
  35670. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35671. * @hidden
  35672. */
  35673. private _unrotateFixedNormals;
  35674. /**
  35675. * Resets the temporary working copy particle
  35676. * @hidden
  35677. */
  35678. private _resetCopy;
  35679. /**
  35680. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35681. * @param p the current index in the positions array to be updated
  35682. * @param ind the current index in the indices array
  35683. * @param shape a Vector3 array, the shape geometry
  35684. * @param positions the positions array to be updated
  35685. * @param meshInd the shape indices array
  35686. * @param indices the indices array to be updated
  35687. * @param meshUV the shape uv array
  35688. * @param uvs the uv array to be updated
  35689. * @param meshCol the shape color array
  35690. * @param colors the color array to be updated
  35691. * @param meshNor the shape normals array
  35692. * @param normals the normals array to be updated
  35693. * @param idx the particle index
  35694. * @param idxInShape the particle index in its shape
  35695. * @param options the addShape() method passed options
  35696. * @model the particle model
  35697. * @hidden
  35698. */
  35699. private _meshBuilder;
  35700. /**
  35701. * Returns a shape Vector3 array from positions float array
  35702. * @param positions float array
  35703. * @returns a vector3 array
  35704. * @hidden
  35705. */
  35706. private _posToShape;
  35707. /**
  35708. * Returns a shapeUV array from a float uvs (array deep copy)
  35709. * @param uvs as a float array
  35710. * @returns a shapeUV array
  35711. * @hidden
  35712. */
  35713. private _uvsToShapeUV;
  35714. /**
  35715. * Adds a new particle object in the particles array
  35716. * @param idx particle index in particles array
  35717. * @param id particle id
  35718. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35719. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35720. * @param model particle ModelShape object
  35721. * @param shapeId model shape identifier
  35722. * @param idxInShape index of the particle in the current model
  35723. * @param bInfo model bounding info object
  35724. * @param storage target storage array, if any
  35725. * @hidden
  35726. */
  35727. private _addParticle;
  35728. /**
  35729. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35730. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35731. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35732. * @param nb (positive integer) the number of particles to be created from this model
  35733. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35734. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35735. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35736. * @returns the number of shapes in the system
  35737. */
  35738. addShape(mesh: Mesh, nb: number, options?: {
  35739. positionFunction?: any;
  35740. vertexFunction?: any;
  35741. storage?: [];
  35742. }): number;
  35743. /**
  35744. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35745. * @hidden
  35746. */
  35747. private _rebuildParticle;
  35748. /**
  35749. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35750. * @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.
  35751. * @returns the SPS.
  35752. */
  35753. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35754. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35755. * Returns an array with the removed particles.
  35756. * 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.
  35757. * The SPS can't be empty so at least one particle needs to remain in place.
  35758. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35759. * @param start index of the first particle to remove
  35760. * @param end index of the last particle to remove (included)
  35761. * @returns an array populated with the removed particles
  35762. */
  35763. removeParticles(start: number, end: number): SolidParticle[];
  35764. /**
  35765. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35766. * @param solidParticleArray an array populated with Solid Particles objects
  35767. * @returns the SPS
  35768. */
  35769. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35770. /**
  35771. * Creates a new particle and modifies the SPS mesh geometry :
  35772. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35773. * - calls _addParticle() to populate the particle array
  35774. * factorized code from addShape() and insertParticlesFromArray()
  35775. * @param idx particle index in the particles array
  35776. * @param i particle index in its shape
  35777. * @param modelShape particle ModelShape object
  35778. * @param shape shape vertex array
  35779. * @param meshInd shape indices array
  35780. * @param meshUV shape uv array
  35781. * @param meshCol shape color array
  35782. * @param meshNor shape normals array
  35783. * @param bbInfo shape bounding info
  35784. * @param storage target particle storage
  35785. * @options addShape() passed options
  35786. * @hidden
  35787. */
  35788. private _insertNewParticle;
  35789. /**
  35790. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35791. * This method calls `updateParticle()` for each particle of the SPS.
  35792. * For an animated SPS, it is usually called within the render loop.
  35793. * 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.
  35794. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35795. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35796. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35797. * @returns the SPS.
  35798. */
  35799. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35800. /**
  35801. * Disposes the SPS.
  35802. */
  35803. dispose(): void;
  35804. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35805. * idx is the particle index in the SPS
  35806. * faceId is the picked face index counted within this particle.
  35807. * Returns null if the pickInfo can't identify a picked particle.
  35808. * @param pickingInfo (PickingInfo object)
  35809. * @returns {idx: number, faceId: number} or null
  35810. */
  35811. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35812. idx: number;
  35813. faceId: number;
  35814. }>;
  35815. /**
  35816. * Returns a SolidParticle object from its identifier : particle.id
  35817. * @param id (integer) the particle Id
  35818. * @returns the searched particle or null if not found in the SPS.
  35819. */
  35820. getParticleById(id: number): Nullable<SolidParticle>;
  35821. /**
  35822. * Returns a new array populated with the particles having the passed shapeId.
  35823. * @param shapeId (integer) the shape identifier
  35824. * @returns a new solid particle array
  35825. */
  35826. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35827. /**
  35828. * Populates the passed array "ref" with the particles having the passed shapeId.
  35829. * @param shapeId the shape identifier
  35830. * @returns the SPS
  35831. * @param ref
  35832. */
  35833. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35834. /**
  35835. * Computes the required SubMeshes according the materials assigned to the particles.
  35836. * @returns the solid particle system.
  35837. * Does nothing if called before the SPS mesh is built.
  35838. */
  35839. computeSubMeshes(): SolidParticleSystem;
  35840. /**
  35841. * Sorts the solid particles by material when MultiMaterial is enabled.
  35842. * Updates the indices32 array.
  35843. * Updates the indicesByMaterial array.
  35844. * Updates the mesh indices array.
  35845. * @returns the SPS
  35846. * @hidden
  35847. */
  35848. private _sortParticlesByMaterial;
  35849. /**
  35850. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35851. * @hidden
  35852. */
  35853. private _setMaterialIndexesById;
  35854. /**
  35855. * Returns an array with unique values of Materials from the passed array
  35856. * @param array the material array to be checked and filtered
  35857. * @hidden
  35858. */
  35859. private _filterUniqueMaterialId;
  35860. /**
  35861. * Sets a new Standard Material as _defaultMaterial if not already set.
  35862. * @hidden
  35863. */
  35864. private _setDefaultMaterial;
  35865. /**
  35866. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35867. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35868. * @returns the SPS.
  35869. */
  35870. refreshVisibleSize(): SolidParticleSystem;
  35871. /**
  35872. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35873. * @param size the size (float) of the visibility box
  35874. * note : this doesn't lock the SPS mesh bounding box.
  35875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35876. */
  35877. setVisibilityBox(size: number): void;
  35878. /**
  35879. * Gets whether the SPS as always visible or not
  35880. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35881. */
  35882. get isAlwaysVisible(): boolean;
  35883. /**
  35884. * Sets the SPS as always visible or not
  35885. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35886. */
  35887. set isAlwaysVisible(val: boolean);
  35888. /**
  35889. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35890. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35891. */
  35892. set isVisibilityBoxLocked(val: boolean);
  35893. /**
  35894. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35895. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35896. */
  35897. get isVisibilityBoxLocked(): boolean;
  35898. /**
  35899. * Tells to `setParticles()` to compute the particle rotations or not.
  35900. * Default value : true. The SPS is faster when it's set to false.
  35901. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35902. */
  35903. set computeParticleRotation(val: boolean);
  35904. /**
  35905. * Tells to `setParticles()` to compute the particle colors or not.
  35906. * Default value : true. The SPS is faster when it's set to false.
  35907. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35908. */
  35909. set computeParticleColor(val: boolean);
  35910. set computeParticleTexture(val: boolean);
  35911. /**
  35912. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35913. * Default value : false. The SPS is faster when it's set to false.
  35914. * Note : the particle custom vertex positions aren't stored values.
  35915. */
  35916. set computeParticleVertex(val: boolean);
  35917. /**
  35918. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35919. */
  35920. set computeBoundingBox(val: boolean);
  35921. /**
  35922. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35923. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35924. * Default : `true`
  35925. */
  35926. set depthSortParticles(val: boolean);
  35927. /**
  35928. * Gets if `setParticles()` computes the particle rotations or not.
  35929. * Default value : true. The SPS is faster when it's set to false.
  35930. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35931. */
  35932. get computeParticleRotation(): boolean;
  35933. /**
  35934. * Gets if `setParticles()` computes the particle colors or not.
  35935. * Default value : true. The SPS is faster when it's set to false.
  35936. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35937. */
  35938. get computeParticleColor(): boolean;
  35939. /**
  35940. * Gets if `setParticles()` computes the particle textures or not.
  35941. * Default value : true. The SPS is faster when it's set to false.
  35942. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35943. */
  35944. get computeParticleTexture(): boolean;
  35945. /**
  35946. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35947. * Default value : false. The SPS is faster when it's set to false.
  35948. * Note : the particle custom vertex positions aren't stored values.
  35949. */
  35950. get computeParticleVertex(): boolean;
  35951. /**
  35952. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35953. */
  35954. get computeBoundingBox(): boolean;
  35955. /**
  35956. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35957. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35958. * Default : `true`
  35959. */
  35960. get depthSortParticles(): boolean;
  35961. /**
  35962. * Gets if the SPS is created as expandable at construction time.
  35963. * Default : `false`
  35964. */
  35965. get expandable(): boolean;
  35966. /**
  35967. * Gets if the SPS supports the Multi Materials
  35968. */
  35969. get multimaterialEnabled(): boolean;
  35970. /**
  35971. * Gets if the SPS uses the model materials for its own multimaterial.
  35972. */
  35973. get useModelMaterial(): boolean;
  35974. /**
  35975. * The SPS used material array.
  35976. */
  35977. get materials(): Material[];
  35978. /**
  35979. * Sets the SPS MultiMaterial from the passed materials.
  35980. * Note : the passed array is internally copied and not used then by reference.
  35981. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35982. */
  35983. setMultiMaterial(materials: Material[]): void;
  35984. /**
  35985. * The SPS computed multimaterial object
  35986. */
  35987. get multimaterial(): MultiMaterial;
  35988. set multimaterial(mm: MultiMaterial);
  35989. /**
  35990. * If the subMeshes must be updated on the next call to setParticles()
  35991. */
  35992. get autoUpdateSubMeshes(): boolean;
  35993. set autoUpdateSubMeshes(val: boolean);
  35994. /**
  35995. * This function does nothing. It may be overwritten to set all the particle first values.
  35996. * The SPS doesn't call this function, you may have to call it by your own.
  35997. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35998. */
  35999. initParticles(): void;
  36000. /**
  36001. * This function does nothing. It may be overwritten to recycle a particle.
  36002. * The SPS doesn't call this function, you may have to call it by your own.
  36003. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36004. * @param particle The particle to recycle
  36005. * @returns the recycled particle
  36006. */
  36007. recycleParticle(particle: SolidParticle): SolidParticle;
  36008. /**
  36009. * Updates a particle : this function should be overwritten by the user.
  36010. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36011. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36012. * @example : just set a particle position or velocity and recycle conditions
  36013. * @param particle The particle to update
  36014. * @returns the updated particle
  36015. */
  36016. updateParticle(particle: SolidParticle): SolidParticle;
  36017. /**
  36018. * Updates a vertex of a particle : it can be overwritten by the user.
  36019. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36020. * @param particle the current particle
  36021. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36022. * @param pt the index of the current vertex in the particle shape
  36023. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36024. * @example : just set a vertex particle position or color
  36025. * @returns the sps
  36026. */
  36027. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36028. /**
  36029. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36030. * This does nothing and may be overwritten by the user.
  36031. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36032. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36033. * @param update the boolean update value actually passed to setParticles()
  36034. */
  36035. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36036. /**
  36037. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36038. * This will be passed three parameters.
  36039. * This does nothing and may be overwritten by the user.
  36040. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36041. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36042. * @param update the boolean update value actually passed to setParticles()
  36043. */
  36044. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36045. }
  36046. }
  36047. declare module "babylonjs/Particles/solidParticle" {
  36048. import { Nullable } from "babylonjs/types";
  36049. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36050. import { Color4 } from "babylonjs/Maths/math.color";
  36051. import { Mesh } from "babylonjs/Meshes/mesh";
  36052. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36053. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36054. import { Plane } from "babylonjs/Maths/math.plane";
  36055. import { Material } from "babylonjs/Materials/material";
  36056. /**
  36057. * Represents one particle of a solid particle system.
  36058. */
  36059. export class SolidParticle {
  36060. /**
  36061. * particle global index
  36062. */
  36063. idx: number;
  36064. /**
  36065. * particle identifier
  36066. */
  36067. id: number;
  36068. /**
  36069. * The color of the particle
  36070. */
  36071. color: Nullable<Color4>;
  36072. /**
  36073. * The world space position of the particle.
  36074. */
  36075. position: Vector3;
  36076. /**
  36077. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36078. */
  36079. rotation: Vector3;
  36080. /**
  36081. * The world space rotation quaternion of the particle.
  36082. */
  36083. rotationQuaternion: Nullable<Quaternion>;
  36084. /**
  36085. * The scaling of the particle.
  36086. */
  36087. scaling: Vector3;
  36088. /**
  36089. * The uvs of the particle.
  36090. */
  36091. uvs: Vector4;
  36092. /**
  36093. * The current speed of the particle.
  36094. */
  36095. velocity: Vector3;
  36096. /**
  36097. * The pivot point in the particle local space.
  36098. */
  36099. pivot: Vector3;
  36100. /**
  36101. * Must the particle be translated from its pivot point in its local space ?
  36102. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36103. * Default : false
  36104. */
  36105. translateFromPivot: boolean;
  36106. /**
  36107. * Is the particle active or not ?
  36108. */
  36109. alive: boolean;
  36110. /**
  36111. * Is the particle visible or not ?
  36112. */
  36113. isVisible: boolean;
  36114. /**
  36115. * Index of this particle in the global "positions" array (Internal use)
  36116. * @hidden
  36117. */
  36118. _pos: number;
  36119. /**
  36120. * @hidden Index of this particle in the global "indices" array (Internal use)
  36121. */
  36122. _ind: number;
  36123. /**
  36124. * @hidden ModelShape of this particle (Internal use)
  36125. */
  36126. _model: ModelShape;
  36127. /**
  36128. * ModelShape id of this particle
  36129. */
  36130. shapeId: number;
  36131. /**
  36132. * Index of the particle in its shape id
  36133. */
  36134. idxInShape: number;
  36135. /**
  36136. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36137. */
  36138. _modelBoundingInfo: BoundingInfo;
  36139. /**
  36140. * @hidden Particle BoundingInfo object (Internal use)
  36141. */
  36142. _boundingInfo: BoundingInfo;
  36143. /**
  36144. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36145. */
  36146. _sps: SolidParticleSystem;
  36147. /**
  36148. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36149. */
  36150. _stillInvisible: boolean;
  36151. /**
  36152. * @hidden Last computed particle rotation matrix
  36153. */
  36154. _rotationMatrix: number[];
  36155. /**
  36156. * Parent particle Id, if any.
  36157. * Default null.
  36158. */
  36159. parentId: Nullable<number>;
  36160. /**
  36161. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36162. */
  36163. materialIndex: Nullable<number>;
  36164. /**
  36165. * Custom object or properties.
  36166. */
  36167. props: Nullable<any>;
  36168. /**
  36169. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36170. * The possible values are :
  36171. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36172. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36173. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36174. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36175. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36176. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36177. * */
  36178. cullingStrategy: number;
  36179. /**
  36180. * @hidden Internal global position in the SPS.
  36181. */
  36182. _globalPosition: Vector3;
  36183. /**
  36184. * Creates a Solid Particle object.
  36185. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36186. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36187. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36188. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36189. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36190. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36191. * @param shapeId (integer) is the model shape identifier in the SPS.
  36192. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36193. * @param sps defines the sps it is associated to
  36194. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36195. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36196. */
  36197. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36198. /**
  36199. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36200. * @param target the particle target
  36201. * @returns the current particle
  36202. */
  36203. copyToRef(target: SolidParticle): SolidParticle;
  36204. /**
  36205. * Legacy support, changed scale to scaling
  36206. */
  36207. get scale(): Vector3;
  36208. /**
  36209. * Legacy support, changed scale to scaling
  36210. */
  36211. set scale(scale: Vector3);
  36212. /**
  36213. * Legacy support, changed quaternion to rotationQuaternion
  36214. */
  36215. get quaternion(): Nullable<Quaternion>;
  36216. /**
  36217. * Legacy support, changed quaternion to rotationQuaternion
  36218. */
  36219. set quaternion(q: Nullable<Quaternion>);
  36220. /**
  36221. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36222. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36223. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36224. * @returns true if it intersects
  36225. */
  36226. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36227. /**
  36228. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36229. * A particle is in the frustum if its bounding box intersects the frustum
  36230. * @param frustumPlanes defines the frustum to test
  36231. * @returns true if the particle is in the frustum planes
  36232. */
  36233. isInFrustum(frustumPlanes: Plane[]): boolean;
  36234. /**
  36235. * get the rotation matrix of the particle
  36236. * @hidden
  36237. */
  36238. getRotationMatrix(m: Matrix): void;
  36239. }
  36240. /**
  36241. * Represents the shape of the model used by one particle of a solid particle system.
  36242. * SPS internal tool, don't use it manually.
  36243. */
  36244. export class ModelShape {
  36245. /**
  36246. * The shape id
  36247. * @hidden
  36248. */
  36249. shapeID: number;
  36250. /**
  36251. * flat array of model positions (internal use)
  36252. * @hidden
  36253. */
  36254. _shape: Vector3[];
  36255. /**
  36256. * flat array of model UVs (internal use)
  36257. * @hidden
  36258. */
  36259. _shapeUV: number[];
  36260. /**
  36261. * color array of the model
  36262. * @hidden
  36263. */
  36264. _shapeColors: number[];
  36265. /**
  36266. * indices array of the model
  36267. * @hidden
  36268. */
  36269. _indices: number[];
  36270. /**
  36271. * normals array of the model
  36272. * @hidden
  36273. */
  36274. _normals: number[];
  36275. /**
  36276. * length of the shape in the model indices array (internal use)
  36277. * @hidden
  36278. */
  36279. _indicesLength: number;
  36280. /**
  36281. * Custom position function (internal use)
  36282. * @hidden
  36283. */
  36284. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36285. /**
  36286. * Custom vertex function (internal use)
  36287. * @hidden
  36288. */
  36289. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36290. /**
  36291. * Model material (internal use)
  36292. * @hidden
  36293. */
  36294. _material: Nullable<Material>;
  36295. /**
  36296. * 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.
  36297. * SPS internal tool, don't use it manually.
  36298. * @hidden
  36299. */
  36300. 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>);
  36301. }
  36302. /**
  36303. * Represents a Depth Sorted Particle in the solid particle system.
  36304. * @hidden
  36305. */
  36306. export class DepthSortedParticle {
  36307. /**
  36308. * Particle index
  36309. */
  36310. idx: number;
  36311. /**
  36312. * Index of the particle in the "indices" array
  36313. */
  36314. ind: number;
  36315. /**
  36316. * Length of the particle shape in the "indices" array
  36317. */
  36318. indicesLength: number;
  36319. /**
  36320. * Squared distance from the particle to the camera
  36321. */
  36322. sqDistance: number;
  36323. /**
  36324. * Material index when used with MultiMaterials
  36325. */
  36326. materialIndex: number;
  36327. /**
  36328. * Creates a new sorted particle
  36329. * @param materialIndex
  36330. */
  36331. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36332. }
  36333. /**
  36334. * Represents a solid particle vertex
  36335. */
  36336. export class SolidParticleVertex {
  36337. /**
  36338. * Vertex position
  36339. */
  36340. position: Vector3;
  36341. /**
  36342. * Vertex color
  36343. */
  36344. color: Color4;
  36345. /**
  36346. * Vertex UV
  36347. */
  36348. uv: Vector2;
  36349. /**
  36350. * Creates a new solid particle vertex
  36351. */
  36352. constructor();
  36353. /** Vertex x coordinate */
  36354. get x(): number;
  36355. set x(val: number);
  36356. /** Vertex y coordinate */
  36357. get y(): number;
  36358. set y(val: number);
  36359. /** Vertex z coordinate */
  36360. get z(): number;
  36361. set z(val: number);
  36362. }
  36363. }
  36364. declare module "babylonjs/Collisions/meshCollisionData" {
  36365. import { Collider } from "babylonjs/Collisions/collider";
  36366. import { Vector3 } from "babylonjs/Maths/math.vector";
  36367. import { Nullable } from "babylonjs/types";
  36368. import { Observer } from "babylonjs/Misc/observable";
  36369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36370. /**
  36371. * @hidden
  36372. */
  36373. export class _MeshCollisionData {
  36374. _checkCollisions: boolean;
  36375. _collisionMask: number;
  36376. _collisionGroup: number;
  36377. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36378. _collider: Nullable<Collider>;
  36379. _oldPositionForCollisions: Vector3;
  36380. _diffPositionForCollisions: Vector3;
  36381. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36382. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36383. _collisionResponse: boolean;
  36384. }
  36385. }
  36386. declare module "babylonjs/Meshes/abstractMesh" {
  36387. import { Observable } from "babylonjs/Misc/observable";
  36388. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36389. import { Camera } from "babylonjs/Cameras/camera";
  36390. import { Scene, IDisposable } from "babylonjs/scene";
  36391. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36392. import { Node } from "babylonjs/node";
  36393. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36394. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36395. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36396. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36397. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36398. import { Material } from "babylonjs/Materials/material";
  36399. import { Light } from "babylonjs/Lights/light";
  36400. import { Skeleton } from "babylonjs/Bones/skeleton";
  36401. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36402. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36403. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36404. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36405. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36406. import { Plane } from "babylonjs/Maths/math.plane";
  36407. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36408. import { Ray } from "babylonjs/Culling/ray";
  36409. import { Collider } from "babylonjs/Collisions/collider";
  36410. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36411. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36412. import { IEdgesRendererOptions } from "babylonjs/Rendering/edgesRenderer";
  36413. /** @hidden */
  36414. class _FacetDataStorage {
  36415. facetPositions: Vector3[];
  36416. facetNormals: Vector3[];
  36417. facetPartitioning: number[][];
  36418. facetNb: number;
  36419. partitioningSubdivisions: number;
  36420. partitioningBBoxRatio: number;
  36421. facetDataEnabled: boolean;
  36422. facetParameters: any;
  36423. bbSize: Vector3;
  36424. subDiv: {
  36425. max: number;
  36426. X: number;
  36427. Y: number;
  36428. Z: number;
  36429. };
  36430. facetDepthSort: boolean;
  36431. facetDepthSortEnabled: boolean;
  36432. depthSortedIndices: IndicesArray;
  36433. depthSortedFacets: {
  36434. ind: number;
  36435. sqDistance: number;
  36436. }[];
  36437. facetDepthSortFunction: (f1: {
  36438. ind: number;
  36439. sqDistance: number;
  36440. }, f2: {
  36441. ind: number;
  36442. sqDistance: number;
  36443. }) => number;
  36444. facetDepthSortFrom: Vector3;
  36445. facetDepthSortOrigin: Vector3;
  36446. invertedMatrix: Matrix;
  36447. }
  36448. /**
  36449. * @hidden
  36450. **/
  36451. class _InternalAbstractMeshDataInfo {
  36452. _hasVertexAlpha: boolean;
  36453. _useVertexColors: boolean;
  36454. _numBoneInfluencers: number;
  36455. _applyFog: boolean;
  36456. _receiveShadows: boolean;
  36457. _facetData: _FacetDataStorage;
  36458. _visibility: number;
  36459. _skeleton: Nullable<Skeleton>;
  36460. _layerMask: number;
  36461. _computeBonesUsingShaders: boolean;
  36462. _isActive: boolean;
  36463. _onlyForInstances: boolean;
  36464. _isActiveIntermediate: boolean;
  36465. _onlyForInstancesIntermediate: boolean;
  36466. _actAsRegularMesh: boolean;
  36467. _currentLOD: Nullable<AbstractMesh>;
  36468. _currentLODIsUpToDate: boolean;
  36469. }
  36470. /**
  36471. * Class used to store all common mesh properties
  36472. */
  36473. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36474. /** No occlusion */
  36475. static OCCLUSION_TYPE_NONE: number;
  36476. /** Occlusion set to optimisitic */
  36477. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36478. /** Occlusion set to strict */
  36479. static OCCLUSION_TYPE_STRICT: number;
  36480. /** Use an accurante occlusion algorithm */
  36481. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36482. /** Use a conservative occlusion algorithm */
  36483. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36484. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36485. * Test order :
  36486. * Is the bounding sphere outside the frustum ?
  36487. * If not, are the bounding box vertices outside the frustum ?
  36488. * It not, then the cullable object is in the frustum.
  36489. */
  36490. static readonly CULLINGSTRATEGY_STANDARD: number;
  36491. /** Culling strategy : Bounding Sphere Only.
  36492. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36493. * It's also less accurate than the standard because some not visible objects can still be selected.
  36494. * Test : is the bounding sphere outside the frustum ?
  36495. * If not, then the cullable object is in the frustum.
  36496. */
  36497. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36498. /** Culling strategy : Optimistic Inclusion.
  36499. * This in an inclusion test first, then the standard exclusion test.
  36500. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36501. * 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.
  36502. * Anyway, it's as accurate as the standard strategy.
  36503. * Test :
  36504. * Is the cullable object bounding sphere center in the frustum ?
  36505. * If not, apply the default culling strategy.
  36506. */
  36507. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36508. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36509. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36510. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36511. * 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.
  36512. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36513. * Test :
  36514. * Is the cullable object bounding sphere center in the frustum ?
  36515. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36516. */
  36517. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36518. /**
  36519. * No billboard
  36520. */
  36521. static get BILLBOARDMODE_NONE(): number;
  36522. /** Billboard on X axis */
  36523. static get BILLBOARDMODE_X(): number;
  36524. /** Billboard on Y axis */
  36525. static get BILLBOARDMODE_Y(): number;
  36526. /** Billboard on Z axis */
  36527. static get BILLBOARDMODE_Z(): number;
  36528. /** Billboard on all axes */
  36529. static get BILLBOARDMODE_ALL(): number;
  36530. /** Billboard on using position instead of orientation */
  36531. static get BILLBOARDMODE_USE_POSITION(): number;
  36532. /** @hidden */
  36533. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36534. /**
  36535. * The culling strategy to use to check whether the mesh must be rendered or not.
  36536. * This value can be changed at any time and will be used on the next render mesh selection.
  36537. * The possible values are :
  36538. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36539. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36540. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36541. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36542. * Please read each static variable documentation to get details about the culling process.
  36543. * */
  36544. cullingStrategy: number;
  36545. /**
  36546. * Gets the number of facets in the mesh
  36547. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36548. */
  36549. get facetNb(): number;
  36550. /**
  36551. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36552. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36553. */
  36554. get partitioningSubdivisions(): number;
  36555. set partitioningSubdivisions(nb: number);
  36556. /**
  36557. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36558. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36559. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36560. */
  36561. get partitioningBBoxRatio(): number;
  36562. set partitioningBBoxRatio(ratio: number);
  36563. /**
  36564. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36565. * Works only for updatable meshes.
  36566. * Doesn't work with multi-materials
  36567. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36568. */
  36569. get mustDepthSortFacets(): boolean;
  36570. set mustDepthSortFacets(sort: boolean);
  36571. /**
  36572. * The location (Vector3) where the facet depth sort must be computed from.
  36573. * By default, the active camera position.
  36574. * Used only when facet depth sort is enabled
  36575. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36576. */
  36577. get facetDepthSortFrom(): Vector3;
  36578. set facetDepthSortFrom(location: Vector3);
  36579. /**
  36580. * gets a boolean indicating if facetData is enabled
  36581. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36582. */
  36583. get isFacetDataEnabled(): boolean;
  36584. /** @hidden */
  36585. _updateNonUniformScalingState(value: boolean): boolean;
  36586. /**
  36587. * An event triggered when this mesh collides with another one
  36588. */
  36589. onCollideObservable: Observable<AbstractMesh>;
  36590. /** Set a function to call when this mesh collides with another one */
  36591. set onCollide(callback: () => void);
  36592. /**
  36593. * An event triggered when the collision's position changes
  36594. */
  36595. onCollisionPositionChangeObservable: Observable<Vector3>;
  36596. /** Set a function to call when the collision's position changes */
  36597. set onCollisionPositionChange(callback: () => void);
  36598. /**
  36599. * An event triggered when material is changed
  36600. */
  36601. onMaterialChangedObservable: Observable<AbstractMesh>;
  36602. /**
  36603. * Gets or sets the orientation for POV movement & rotation
  36604. */
  36605. definedFacingForward: boolean;
  36606. /** @hidden */
  36607. _occlusionQuery: Nullable<WebGLQuery>;
  36608. /** @hidden */
  36609. _renderingGroup: Nullable<RenderingGroup>;
  36610. /**
  36611. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36612. */
  36613. get visibility(): number;
  36614. /**
  36615. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36616. */
  36617. set visibility(value: number);
  36618. /** Gets or sets the alpha index used to sort transparent meshes
  36619. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36620. */
  36621. alphaIndex: number;
  36622. /**
  36623. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36624. */
  36625. isVisible: boolean;
  36626. /**
  36627. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36628. */
  36629. isPickable: boolean;
  36630. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36631. showSubMeshesBoundingBox: boolean;
  36632. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36633. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36634. */
  36635. isBlocker: boolean;
  36636. /**
  36637. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36638. */
  36639. enablePointerMoveEvents: boolean;
  36640. private _renderingGroupId;
  36641. /**
  36642. * Specifies the rendering group id for this mesh (0 by default)
  36643. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36644. */
  36645. get renderingGroupId(): number;
  36646. set renderingGroupId(value: number);
  36647. private _material;
  36648. /** Gets or sets current material */
  36649. get material(): Nullable<Material>;
  36650. set material(value: Nullable<Material>);
  36651. /**
  36652. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36653. * @see https://doc.babylonjs.com/babylon101/shadows
  36654. */
  36655. get receiveShadows(): boolean;
  36656. set receiveShadows(value: boolean);
  36657. /** Defines color to use when rendering outline */
  36658. outlineColor: Color3;
  36659. /** Define width to use when rendering outline */
  36660. outlineWidth: number;
  36661. /** Defines color to use when rendering overlay */
  36662. overlayColor: Color3;
  36663. /** Defines alpha to use when rendering overlay */
  36664. overlayAlpha: number;
  36665. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36666. get hasVertexAlpha(): boolean;
  36667. set hasVertexAlpha(value: boolean);
  36668. /** 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) */
  36669. get useVertexColors(): boolean;
  36670. set useVertexColors(value: boolean);
  36671. /**
  36672. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36673. */
  36674. get computeBonesUsingShaders(): boolean;
  36675. set computeBonesUsingShaders(value: boolean);
  36676. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36677. get numBoneInfluencers(): number;
  36678. set numBoneInfluencers(value: number);
  36679. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36680. get applyFog(): boolean;
  36681. set applyFog(value: boolean);
  36682. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36683. useOctreeForRenderingSelection: boolean;
  36684. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36685. useOctreeForPicking: boolean;
  36686. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36687. useOctreeForCollisions: boolean;
  36688. /**
  36689. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36690. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36691. */
  36692. get layerMask(): number;
  36693. set layerMask(value: number);
  36694. /**
  36695. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36696. */
  36697. alwaysSelectAsActiveMesh: boolean;
  36698. /**
  36699. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36700. */
  36701. doNotSyncBoundingInfo: boolean;
  36702. /**
  36703. * Gets or sets the current action manager
  36704. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36705. */
  36706. actionManager: Nullable<AbstractActionManager>;
  36707. private _meshCollisionData;
  36708. /**
  36709. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36710. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36711. */
  36712. ellipsoid: Vector3;
  36713. /**
  36714. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36715. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36716. */
  36717. ellipsoidOffset: Vector3;
  36718. /**
  36719. * Gets or sets a collision mask used to mask collisions (default is -1).
  36720. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36721. */
  36722. get collisionMask(): number;
  36723. set collisionMask(mask: number);
  36724. /**
  36725. * Gets or sets a collision response flag (default is true).
  36726. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36727. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36728. * to respond to the collision.
  36729. */
  36730. get collisionResponse(): boolean;
  36731. set collisionResponse(response: boolean);
  36732. /**
  36733. * Gets or sets the current collision group mask (-1 by default).
  36734. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36735. */
  36736. get collisionGroup(): number;
  36737. set collisionGroup(mask: number);
  36738. /**
  36739. * Gets or sets current surrounding meshes (null by default).
  36740. *
  36741. * By default collision detection is tested against every mesh in the scene.
  36742. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36743. * meshes will be tested for the collision.
  36744. *
  36745. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36746. */
  36747. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36748. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36749. /**
  36750. * Defines edge width used when edgesRenderer is enabled
  36751. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36752. */
  36753. edgesWidth: number;
  36754. /**
  36755. * Defines edge color used when edgesRenderer is enabled
  36756. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36757. */
  36758. edgesColor: Color4;
  36759. /** @hidden */
  36760. _edgesRenderer: Nullable<IEdgesRenderer>;
  36761. /** @hidden */
  36762. _masterMesh: Nullable<AbstractMesh>;
  36763. /** @hidden */
  36764. _boundingInfo: Nullable<BoundingInfo>;
  36765. /** @hidden */
  36766. _renderId: number;
  36767. /**
  36768. * Gets or sets the list of subMeshes
  36769. * @see https://doc.babylonjs.com/how_to/multi_materials
  36770. */
  36771. subMeshes: SubMesh[];
  36772. /** @hidden */
  36773. _intersectionsInProgress: AbstractMesh[];
  36774. /** @hidden */
  36775. _unIndexed: boolean;
  36776. /** @hidden */
  36777. _lightSources: Light[];
  36778. /** Gets the list of lights affecting that mesh */
  36779. get lightSources(): Light[];
  36780. /** @hidden */
  36781. get _positions(): Nullable<Vector3[]>;
  36782. /** @hidden */
  36783. _waitingData: {
  36784. lods: Nullable<any>;
  36785. actions: Nullable<any>;
  36786. freezeWorldMatrix: Nullable<boolean>;
  36787. };
  36788. /** @hidden */
  36789. _bonesTransformMatrices: Nullable<Float32Array>;
  36790. /** @hidden */
  36791. _transformMatrixTexture: Nullable<RawTexture>;
  36792. /**
  36793. * Gets or sets a skeleton to apply skining transformations
  36794. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36795. */
  36796. set skeleton(value: Nullable<Skeleton>);
  36797. get skeleton(): Nullable<Skeleton>;
  36798. /**
  36799. * An event triggered when the mesh is rebuilt.
  36800. */
  36801. onRebuildObservable: Observable<AbstractMesh>;
  36802. /**
  36803. * Creates a new AbstractMesh
  36804. * @param name defines the name of the mesh
  36805. * @param scene defines the hosting scene
  36806. */
  36807. constructor(name: string, scene?: Nullable<Scene>);
  36808. /**
  36809. * Returns the string "AbstractMesh"
  36810. * @returns "AbstractMesh"
  36811. */
  36812. getClassName(): string;
  36813. /**
  36814. * Gets a string representation of the current mesh
  36815. * @param fullDetails defines a boolean indicating if full details must be included
  36816. * @returns a string representation of the current mesh
  36817. */
  36818. toString(fullDetails?: boolean): string;
  36819. /**
  36820. * @hidden
  36821. */
  36822. protected _getEffectiveParent(): Nullable<Node>;
  36823. /** @hidden */
  36824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36825. /** @hidden */
  36826. _rebuild(): void;
  36827. /** @hidden */
  36828. _resyncLightSources(): void;
  36829. /** @hidden */
  36830. _resyncLightSource(light: Light): void;
  36831. /** @hidden */
  36832. _unBindEffect(): void;
  36833. /** @hidden */
  36834. _removeLightSource(light: Light, dispose: boolean): void;
  36835. private _markSubMeshesAsDirty;
  36836. /** @hidden */
  36837. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36838. /** @hidden */
  36839. _markSubMeshesAsAttributesDirty(): void;
  36840. /** @hidden */
  36841. _markSubMeshesAsMiscDirty(): void;
  36842. /**
  36843. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36844. */
  36845. get scaling(): Vector3;
  36846. set scaling(newScaling: Vector3);
  36847. /**
  36848. * Returns true if the mesh is blocked. Implemented by child classes
  36849. */
  36850. get isBlocked(): boolean;
  36851. /**
  36852. * Returns the mesh itself by default. Implemented by child classes
  36853. * @param camera defines the camera to use to pick the right LOD level
  36854. * @returns the currentAbstractMesh
  36855. */
  36856. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36857. /**
  36858. * Returns 0 by default. Implemented by child classes
  36859. * @returns an integer
  36860. */
  36861. getTotalVertices(): number;
  36862. /**
  36863. * Returns a positive integer : the total number of indices in this mesh geometry.
  36864. * @returns the numner of indices or zero if the mesh has no geometry.
  36865. */
  36866. getTotalIndices(): number;
  36867. /**
  36868. * Returns null by default. Implemented by child classes
  36869. * @returns null
  36870. */
  36871. getIndices(): Nullable<IndicesArray>;
  36872. /**
  36873. * Returns the array of the requested vertex data kind. Implemented by child classes
  36874. * @param kind defines the vertex data kind to use
  36875. * @returns null
  36876. */
  36877. getVerticesData(kind: string): Nullable<FloatArray>;
  36878. /**
  36879. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36880. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36881. * Note that a new underlying VertexBuffer object is created each call.
  36882. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36883. * @param kind defines vertex data kind:
  36884. * * VertexBuffer.PositionKind
  36885. * * VertexBuffer.UVKind
  36886. * * VertexBuffer.UV2Kind
  36887. * * VertexBuffer.UV3Kind
  36888. * * VertexBuffer.UV4Kind
  36889. * * VertexBuffer.UV5Kind
  36890. * * VertexBuffer.UV6Kind
  36891. * * VertexBuffer.ColorKind
  36892. * * VertexBuffer.MatricesIndicesKind
  36893. * * VertexBuffer.MatricesIndicesExtraKind
  36894. * * VertexBuffer.MatricesWeightsKind
  36895. * * VertexBuffer.MatricesWeightsExtraKind
  36896. * @param data defines the data source
  36897. * @param updatable defines if the data must be flagged as updatable (or static)
  36898. * @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
  36899. * @returns the current mesh
  36900. */
  36901. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36902. /**
  36903. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36904. * If the mesh has no geometry, it is simply returned as it is.
  36905. * @param kind defines vertex data kind:
  36906. * * VertexBuffer.PositionKind
  36907. * * VertexBuffer.UVKind
  36908. * * VertexBuffer.UV2Kind
  36909. * * VertexBuffer.UV3Kind
  36910. * * VertexBuffer.UV4Kind
  36911. * * VertexBuffer.UV5Kind
  36912. * * VertexBuffer.UV6Kind
  36913. * * VertexBuffer.ColorKind
  36914. * * VertexBuffer.MatricesIndicesKind
  36915. * * VertexBuffer.MatricesIndicesExtraKind
  36916. * * VertexBuffer.MatricesWeightsKind
  36917. * * VertexBuffer.MatricesWeightsExtraKind
  36918. * @param data defines the data source
  36919. * @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
  36920. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36921. * @returns the current mesh
  36922. */
  36923. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36924. /**
  36925. * Sets the mesh indices,
  36926. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36927. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36928. * @param totalVertices Defines the total number of vertices
  36929. * @returns the current mesh
  36930. */
  36931. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36932. /**
  36933. * Gets a boolean indicating if specific vertex data is present
  36934. * @param kind defines the vertex data kind to use
  36935. * @returns true is data kind is present
  36936. */
  36937. isVerticesDataPresent(kind: string): boolean;
  36938. /**
  36939. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36940. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36941. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36942. * @returns a BoundingInfo
  36943. */
  36944. getBoundingInfo(): BoundingInfo;
  36945. /**
  36946. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36947. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36948. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36949. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36950. * @returns the current mesh
  36951. */
  36952. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36953. /**
  36954. * Overwrite the current bounding info
  36955. * @param boundingInfo defines the new bounding info
  36956. * @returns the current mesh
  36957. */
  36958. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36959. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36960. get useBones(): boolean;
  36961. /** @hidden */
  36962. _preActivate(): void;
  36963. /** @hidden */
  36964. _preActivateForIntermediateRendering(renderId: number): void;
  36965. /** @hidden */
  36966. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36967. /** @hidden */
  36968. _postActivate(): void;
  36969. /** @hidden */
  36970. _freeze(): void;
  36971. /** @hidden */
  36972. _unFreeze(): void;
  36973. /**
  36974. * Gets the current world matrix
  36975. * @returns a Matrix
  36976. */
  36977. getWorldMatrix(): Matrix;
  36978. /** @hidden */
  36979. _getWorldMatrixDeterminant(): number;
  36980. /**
  36981. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36982. */
  36983. get isAnInstance(): boolean;
  36984. /**
  36985. * Gets a boolean indicating if this mesh has instances
  36986. */
  36987. get hasInstances(): boolean;
  36988. /**
  36989. * Gets a boolean indicating if this mesh has thin instances
  36990. */
  36991. get hasThinInstances(): boolean;
  36992. /**
  36993. * Perform relative position change from the point of view of behind the front of the mesh.
  36994. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36995. * Supports definition of mesh facing forward or backward
  36996. * @param amountRight defines the distance on the right axis
  36997. * @param amountUp defines the distance on the up axis
  36998. * @param amountForward defines the distance on the forward axis
  36999. * @returns the current mesh
  37000. */
  37001. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37002. /**
  37003. * Calculate relative position change from the point of view of behind the front of the mesh.
  37004. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37005. * Supports definition of mesh facing forward or backward
  37006. * @param amountRight defines the distance on the right axis
  37007. * @param amountUp defines the distance on the up axis
  37008. * @param amountForward defines the distance on the forward axis
  37009. * @returns the new displacement vector
  37010. */
  37011. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37012. /**
  37013. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37014. * Supports definition of mesh facing forward or backward
  37015. * @param flipBack defines the flip
  37016. * @param twirlClockwise defines the twirl
  37017. * @param tiltRight defines the tilt
  37018. * @returns the current mesh
  37019. */
  37020. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37021. /**
  37022. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37023. * Supports definition of mesh facing forward or backward.
  37024. * @param flipBack defines the flip
  37025. * @param twirlClockwise defines the twirl
  37026. * @param tiltRight defines the tilt
  37027. * @returns the new rotation vector
  37028. */
  37029. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37030. /**
  37031. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37032. * This means the mesh underlying bounding box and sphere are recomputed.
  37033. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37034. * @returns the current mesh
  37035. */
  37036. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37037. /** @hidden */
  37038. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37039. /** @hidden */
  37040. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37041. /** @hidden */
  37042. _updateBoundingInfo(): AbstractMesh;
  37043. /** @hidden */
  37044. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37045. /** @hidden */
  37046. protected _afterComputeWorldMatrix(): void;
  37047. /** @hidden */
  37048. get _effectiveMesh(): AbstractMesh;
  37049. /**
  37050. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37051. * A mesh is in the frustum if its bounding box intersects the frustum
  37052. * @param frustumPlanes defines the frustum to test
  37053. * @returns true if the mesh is in the frustum planes
  37054. */
  37055. isInFrustum(frustumPlanes: Plane[]): boolean;
  37056. /**
  37057. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37058. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37059. * @param frustumPlanes defines the frustum to test
  37060. * @returns true if the mesh is completely in the frustum planes
  37061. */
  37062. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37063. /**
  37064. * True if the mesh intersects another mesh or a SolidParticle object
  37065. * @param mesh defines a target mesh or SolidParticle to test
  37066. * @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)
  37067. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37068. * @returns true if there is an intersection
  37069. */
  37070. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37071. /**
  37072. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37073. * @param point defines the point to test
  37074. * @returns true if there is an intersection
  37075. */
  37076. intersectsPoint(point: Vector3): boolean;
  37077. /**
  37078. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37079. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37080. */
  37081. get checkCollisions(): boolean;
  37082. set checkCollisions(collisionEnabled: boolean);
  37083. /**
  37084. * Gets Collider object used to compute collisions (not physics)
  37085. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37086. */
  37087. get collider(): Nullable<Collider>;
  37088. /**
  37089. * Move the mesh using collision engine
  37090. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37091. * @param displacement defines the requested displacement vector
  37092. * @returns the current mesh
  37093. */
  37094. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37095. private _onCollisionPositionChange;
  37096. /** @hidden */
  37097. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37098. /** @hidden */
  37099. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37100. /** @hidden */
  37101. _checkCollision(collider: Collider): AbstractMesh;
  37102. /** @hidden */
  37103. _generatePointsArray(): boolean;
  37104. /**
  37105. * Checks if the passed Ray intersects with the mesh
  37106. * @param ray defines the ray to use
  37107. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37108. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37109. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37110. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37111. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  37112. * @returns the picking info
  37113. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37114. */
  37115. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  37116. /**
  37117. * Clones the current mesh
  37118. * @param name defines the mesh name
  37119. * @param newParent defines the new mesh parent
  37120. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37121. * @returns the new mesh
  37122. */
  37123. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37124. /**
  37125. * Disposes all the submeshes of the current meshnp
  37126. * @returns the current mesh
  37127. */
  37128. releaseSubMeshes(): AbstractMesh;
  37129. /**
  37130. * Releases resources associated with this abstract mesh.
  37131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37133. */
  37134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37135. /**
  37136. * Adds the passed mesh as a child to the current mesh
  37137. * @param mesh defines the child mesh
  37138. * @returns the current mesh
  37139. */
  37140. addChild(mesh: AbstractMesh): AbstractMesh;
  37141. /**
  37142. * Removes the passed mesh from the current mesh children list
  37143. * @param mesh defines the child mesh
  37144. * @returns the current mesh
  37145. */
  37146. removeChild(mesh: AbstractMesh): AbstractMesh;
  37147. /** @hidden */
  37148. private _initFacetData;
  37149. /**
  37150. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37151. * This method can be called within the render loop.
  37152. * 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
  37153. * @returns the current mesh
  37154. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37155. */
  37156. updateFacetData(): AbstractMesh;
  37157. /**
  37158. * Returns the facetLocalNormals array.
  37159. * The normals are expressed in the mesh local spac
  37160. * @returns an array of Vector3
  37161. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37162. */
  37163. getFacetLocalNormals(): Vector3[];
  37164. /**
  37165. * Returns the facetLocalPositions array.
  37166. * The facet positions are expressed in the mesh local space
  37167. * @returns an array of Vector3
  37168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37169. */
  37170. getFacetLocalPositions(): Vector3[];
  37171. /**
  37172. * Returns the facetLocalPartioning array
  37173. * @returns an array of array of numbers
  37174. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37175. */
  37176. getFacetLocalPartitioning(): number[][];
  37177. /**
  37178. * Returns the i-th facet position in the world system.
  37179. * This method allocates a new Vector3 per call
  37180. * @param i defines the facet index
  37181. * @returns a new Vector3
  37182. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37183. */
  37184. getFacetPosition(i: number): Vector3;
  37185. /**
  37186. * Sets the reference Vector3 with the i-th facet position in the world system
  37187. * @param i defines the facet index
  37188. * @param ref defines the target vector
  37189. * @returns the current mesh
  37190. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37191. */
  37192. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37193. /**
  37194. * Returns the i-th facet normal in the world system.
  37195. * This method allocates a new Vector3 per call
  37196. * @param i defines the facet index
  37197. * @returns a new Vector3
  37198. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37199. */
  37200. getFacetNormal(i: number): Vector3;
  37201. /**
  37202. * Sets the reference Vector3 with the i-th facet normal in the world system
  37203. * @param i defines the facet index
  37204. * @param ref defines the target vector
  37205. * @returns the current mesh
  37206. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37207. */
  37208. getFacetNormalToRef(i: number, ref: Vector3): this;
  37209. /**
  37210. * 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)
  37211. * @param x defines x coordinate
  37212. * @param y defines y coordinate
  37213. * @param z defines z coordinate
  37214. * @returns the array of facet indexes
  37215. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37216. */
  37217. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37218. /**
  37219. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37220. * @param projected sets as the (x,y,z) world projection on the facet
  37221. * @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
  37222. * @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
  37223. * @param x defines x coordinate
  37224. * @param y defines y coordinate
  37225. * @param z defines z coordinate
  37226. * @returns the face index if found (or null instead)
  37227. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37228. */
  37229. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37230. /**
  37231. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37232. * @param projected sets as the (x,y,z) local projection on the facet
  37233. * @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
  37234. * @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
  37235. * @param x defines x coordinate
  37236. * @param y defines y coordinate
  37237. * @param z defines z coordinate
  37238. * @returns the face index if found (or null instead)
  37239. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37240. */
  37241. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37242. /**
  37243. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37244. * @returns the parameters
  37245. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37246. */
  37247. getFacetDataParameters(): any;
  37248. /**
  37249. * Disables the feature FacetData and frees the related memory
  37250. * @returns the current mesh
  37251. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37252. */
  37253. disableFacetData(): AbstractMesh;
  37254. /**
  37255. * Updates the AbstractMesh indices array
  37256. * @param indices defines the data source
  37257. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37258. * @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)
  37259. * @returns the current mesh
  37260. */
  37261. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37262. /**
  37263. * Creates new normals data for the mesh
  37264. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37265. * @returns the current mesh
  37266. */
  37267. createNormals(updatable: boolean): AbstractMesh;
  37268. /**
  37269. * Align the mesh with a normal
  37270. * @param normal defines the normal to use
  37271. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37272. * @returns the current mesh
  37273. */
  37274. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37275. /** @hidden */
  37276. _checkOcclusionQuery(): boolean;
  37277. /**
  37278. * Disables the mesh edge rendering mode
  37279. * @returns the currentAbstractMesh
  37280. */
  37281. disableEdgesRendering(): AbstractMesh;
  37282. /**
  37283. * Enables the edge rendering mode on the mesh.
  37284. * This mode makes the mesh edges visible
  37285. * @param epsilon defines the maximal distance between two angles to detect a face
  37286. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37287. * @param options options to the edge renderer
  37288. * @returns the currentAbstractMesh
  37289. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37290. */
  37291. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  37292. /**
  37293. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37294. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37295. */
  37296. getConnectedParticleSystems(): IParticleSystem[];
  37297. }
  37298. }
  37299. declare module "babylonjs/Actions/actionEvent" {
  37300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37301. import { Nullable } from "babylonjs/types";
  37302. import { Sprite } from "babylonjs/Sprites/sprite";
  37303. import { Scene } from "babylonjs/scene";
  37304. import { Vector2 } from "babylonjs/Maths/math.vector";
  37305. /**
  37306. * Interface used to define ActionEvent
  37307. */
  37308. export interface IActionEvent {
  37309. /** The mesh or sprite that triggered the action */
  37310. source: any;
  37311. /** The X mouse cursor position at the time of the event */
  37312. pointerX: number;
  37313. /** The Y mouse cursor position at the time of the event */
  37314. pointerY: number;
  37315. /** The mesh that is currently pointed at (can be null) */
  37316. meshUnderPointer: Nullable<AbstractMesh>;
  37317. /** the original (browser) event that triggered the ActionEvent */
  37318. sourceEvent?: any;
  37319. /** additional data for the event */
  37320. additionalData?: any;
  37321. }
  37322. /**
  37323. * ActionEvent is the event being sent when an action is triggered.
  37324. */
  37325. export class ActionEvent implements IActionEvent {
  37326. /** The mesh or sprite that triggered the action */
  37327. source: any;
  37328. /** The X mouse cursor position at the time of the event */
  37329. pointerX: number;
  37330. /** The Y mouse cursor position at the time of the event */
  37331. pointerY: number;
  37332. /** The mesh that is currently pointed at (can be null) */
  37333. meshUnderPointer: Nullable<AbstractMesh>;
  37334. /** the original (browser) event that triggered the ActionEvent */
  37335. sourceEvent?: any;
  37336. /** additional data for the event */
  37337. additionalData?: any;
  37338. /**
  37339. * Creates a new ActionEvent
  37340. * @param source The mesh or sprite that triggered the action
  37341. * @param pointerX The X mouse cursor position at the time of the event
  37342. * @param pointerY The Y mouse cursor position at the time of the event
  37343. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37344. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37345. * @param additionalData additional data for the event
  37346. */
  37347. constructor(
  37348. /** The mesh or sprite that triggered the action */
  37349. source: any,
  37350. /** The X mouse cursor position at the time of the event */
  37351. pointerX: number,
  37352. /** The Y mouse cursor position at the time of the event */
  37353. pointerY: number,
  37354. /** The mesh that is currently pointed at (can be null) */
  37355. meshUnderPointer: Nullable<AbstractMesh>,
  37356. /** the original (browser) event that triggered the ActionEvent */
  37357. sourceEvent?: any,
  37358. /** additional data for the event */
  37359. additionalData?: any);
  37360. /**
  37361. * Helper function to auto-create an ActionEvent from a source mesh.
  37362. * @param source The source mesh that triggered the event
  37363. * @param evt The original (browser) event
  37364. * @param additionalData additional data for the event
  37365. * @returns the new ActionEvent
  37366. */
  37367. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37368. /**
  37369. * Helper function to auto-create an ActionEvent from a source sprite
  37370. * @param source The source sprite that triggered the event
  37371. * @param scene Scene associated with the sprite
  37372. * @param evt The original (browser) event
  37373. * @param additionalData additional data for the event
  37374. * @returns the new ActionEvent
  37375. */
  37376. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37377. /**
  37378. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37379. * @param scene the scene where the event occurred
  37380. * @param evt The original (browser) event
  37381. * @returns the new ActionEvent
  37382. */
  37383. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37384. /**
  37385. * Helper function to auto-create an ActionEvent from a primitive
  37386. * @param prim defines the target primitive
  37387. * @param pointerPos defines the pointer position
  37388. * @param evt The original (browser) event
  37389. * @param additionalData additional data for the event
  37390. * @returns the new ActionEvent
  37391. */
  37392. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37393. }
  37394. }
  37395. declare module "babylonjs/Actions/abstractActionManager" {
  37396. import { IDisposable } from "babylonjs/scene";
  37397. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37398. import { IAction } from "babylonjs/Actions/action";
  37399. import { Nullable } from "babylonjs/types";
  37400. /**
  37401. * Abstract class used to decouple action Manager from scene and meshes.
  37402. * Do not instantiate.
  37403. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37404. */
  37405. export abstract class AbstractActionManager implements IDisposable {
  37406. /** Gets the list of active triggers */
  37407. static Triggers: {
  37408. [key: string]: number;
  37409. };
  37410. /** Gets the cursor to use when hovering items */
  37411. hoverCursor: string;
  37412. /** Gets the list of actions */
  37413. actions: IAction[];
  37414. /**
  37415. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37416. */
  37417. isRecursive: boolean;
  37418. /**
  37419. * Releases all associated resources
  37420. */
  37421. abstract dispose(): void;
  37422. /**
  37423. * Does this action manager has pointer triggers
  37424. */
  37425. abstract get hasPointerTriggers(): boolean;
  37426. /**
  37427. * Does this action manager has pick triggers
  37428. */
  37429. abstract get hasPickTriggers(): boolean;
  37430. /**
  37431. * Process a specific trigger
  37432. * @param trigger defines the trigger to process
  37433. * @param evt defines the event details to be processed
  37434. */
  37435. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37436. /**
  37437. * Does this action manager handles actions of any of the given triggers
  37438. * @param triggers defines the triggers to be tested
  37439. * @return a boolean indicating whether one (or more) of the triggers is handled
  37440. */
  37441. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37442. /**
  37443. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37444. * speed.
  37445. * @param triggerA defines the trigger to be tested
  37446. * @param triggerB defines the trigger to be tested
  37447. * @return a boolean indicating whether one (or more) of the triggers is handled
  37448. */
  37449. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37450. /**
  37451. * Does this action manager handles actions of a given trigger
  37452. * @param trigger defines the trigger to be tested
  37453. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37454. * @return whether the trigger is handled
  37455. */
  37456. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37457. /**
  37458. * Serialize this manager to a JSON object
  37459. * @param name defines the property name to store this manager
  37460. * @returns a JSON representation of this manager
  37461. */
  37462. abstract serialize(name: string): any;
  37463. /**
  37464. * Registers an action to this action manager
  37465. * @param action defines the action to be registered
  37466. * @return the action amended (prepared) after registration
  37467. */
  37468. abstract registerAction(action: IAction): Nullable<IAction>;
  37469. /**
  37470. * Unregisters an action to this action manager
  37471. * @param action defines the action to be unregistered
  37472. * @return a boolean indicating whether the action has been unregistered
  37473. */
  37474. abstract unregisterAction(action: IAction): Boolean;
  37475. /**
  37476. * Does exist one action manager with at least one trigger
  37477. **/
  37478. static get HasTriggers(): boolean;
  37479. /**
  37480. * Does exist one action manager with at least one pick trigger
  37481. **/
  37482. static get HasPickTriggers(): boolean;
  37483. /**
  37484. * Does exist one action manager that handles actions of a given trigger
  37485. * @param trigger defines the trigger to be tested
  37486. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37487. **/
  37488. static HasSpecificTrigger(trigger: number): boolean;
  37489. }
  37490. }
  37491. declare module "babylonjs/node" {
  37492. import { Scene } from "babylonjs/scene";
  37493. import { Nullable } from "babylonjs/types";
  37494. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37495. import { Engine } from "babylonjs/Engines/engine";
  37496. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37497. import { Observable } from "babylonjs/Misc/observable";
  37498. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37499. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37500. import { Animatable } from "babylonjs/Animations/animatable";
  37501. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37502. import { Animation } from "babylonjs/Animations/animation";
  37503. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37505. /**
  37506. * Defines how a node can be built from a string name.
  37507. */
  37508. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37509. /**
  37510. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37511. */
  37512. export class Node implements IBehaviorAware<Node> {
  37513. /** @hidden */
  37514. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37515. private static _NodeConstructors;
  37516. /**
  37517. * Add a new node constructor
  37518. * @param type defines the type name of the node to construct
  37519. * @param constructorFunc defines the constructor function
  37520. */
  37521. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37522. /**
  37523. * Returns a node constructor based on type name
  37524. * @param type defines the type name
  37525. * @param name defines the new node name
  37526. * @param scene defines the hosting scene
  37527. * @param options defines optional options to transmit to constructors
  37528. * @returns the new constructor or null
  37529. */
  37530. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37531. /**
  37532. * Gets or sets the name of the node
  37533. */
  37534. name: string;
  37535. /**
  37536. * Gets or sets the id of the node
  37537. */
  37538. id: string;
  37539. /**
  37540. * Gets or sets the unique id of the node
  37541. */
  37542. uniqueId: number;
  37543. /**
  37544. * Gets or sets a string used to store user defined state for the node
  37545. */
  37546. state: string;
  37547. /**
  37548. * Gets or sets an object used to store user defined information for the node
  37549. */
  37550. metadata: any;
  37551. /**
  37552. * For internal use only. Please do not use.
  37553. */
  37554. reservedDataStore: any;
  37555. /**
  37556. * List of inspectable custom properties (used by the Inspector)
  37557. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37558. */
  37559. inspectableCustomProperties: IInspectable[];
  37560. private _doNotSerialize;
  37561. /**
  37562. * Gets or sets a boolean used to define if the node must be serialized
  37563. */
  37564. get doNotSerialize(): boolean;
  37565. set doNotSerialize(value: boolean);
  37566. /** @hidden */
  37567. _isDisposed: boolean;
  37568. /**
  37569. * Gets a list of Animations associated with the node
  37570. */
  37571. animations: import("babylonjs/Animations/animation").Animation[];
  37572. protected _ranges: {
  37573. [name: string]: Nullable<AnimationRange>;
  37574. };
  37575. /**
  37576. * Callback raised when the node is ready to be used
  37577. */
  37578. onReady: Nullable<(node: Node) => void>;
  37579. private _isEnabled;
  37580. private _isParentEnabled;
  37581. private _isReady;
  37582. /** @hidden */
  37583. _currentRenderId: number;
  37584. private _parentUpdateId;
  37585. /** @hidden */
  37586. _childUpdateId: number;
  37587. /** @hidden */
  37588. _waitingParentId: Nullable<string>;
  37589. /** @hidden */
  37590. _scene: Scene;
  37591. /** @hidden */
  37592. _cache: any;
  37593. private _parentNode;
  37594. private _children;
  37595. /** @hidden */
  37596. _worldMatrix: Matrix;
  37597. /** @hidden */
  37598. _worldMatrixDeterminant: number;
  37599. /** @hidden */
  37600. _worldMatrixDeterminantIsDirty: boolean;
  37601. /** @hidden */
  37602. private _sceneRootNodesIndex;
  37603. /**
  37604. * Gets a boolean indicating if the node has been disposed
  37605. * @returns true if the node was disposed
  37606. */
  37607. isDisposed(): boolean;
  37608. /**
  37609. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37610. * @see https://doc.babylonjs.com/how_to/parenting
  37611. */
  37612. set parent(parent: Nullable<Node>);
  37613. get parent(): Nullable<Node>;
  37614. /** @hidden */
  37615. _addToSceneRootNodes(): void;
  37616. /** @hidden */
  37617. _removeFromSceneRootNodes(): void;
  37618. private _animationPropertiesOverride;
  37619. /**
  37620. * Gets or sets the animation properties override
  37621. */
  37622. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37623. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37624. /**
  37625. * Gets a string identifying the name of the class
  37626. * @returns "Node" string
  37627. */
  37628. getClassName(): string;
  37629. /** @hidden */
  37630. readonly _isNode: boolean;
  37631. /**
  37632. * An event triggered when the mesh is disposed
  37633. */
  37634. onDisposeObservable: Observable<Node>;
  37635. private _onDisposeObserver;
  37636. /**
  37637. * Sets a callback that will be raised when the node will be disposed
  37638. */
  37639. set onDispose(callback: () => void);
  37640. /**
  37641. * Creates a new Node
  37642. * @param name the name and id to be given to this node
  37643. * @param scene the scene this node will be added to
  37644. */
  37645. constructor(name: string, scene?: Nullable<Scene>);
  37646. /**
  37647. * Gets the scene of the node
  37648. * @returns a scene
  37649. */
  37650. getScene(): Scene;
  37651. /**
  37652. * Gets the engine of the node
  37653. * @returns a Engine
  37654. */
  37655. getEngine(): Engine;
  37656. private _behaviors;
  37657. /**
  37658. * Attach a behavior to the node
  37659. * @see https://doc.babylonjs.com/features/behaviour
  37660. * @param behavior defines the behavior to attach
  37661. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37662. * @returns the current Node
  37663. */
  37664. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37665. /**
  37666. * Remove an attached behavior
  37667. * @see https://doc.babylonjs.com/features/behaviour
  37668. * @param behavior defines the behavior to attach
  37669. * @returns the current Node
  37670. */
  37671. removeBehavior(behavior: Behavior<Node>): Node;
  37672. /**
  37673. * Gets the list of attached behaviors
  37674. * @see https://doc.babylonjs.com/features/behaviour
  37675. */
  37676. get behaviors(): Behavior<Node>[];
  37677. /**
  37678. * Gets an attached behavior by name
  37679. * @param name defines the name of the behavior to look for
  37680. * @see https://doc.babylonjs.com/features/behaviour
  37681. * @returns null if behavior was not found else the requested behavior
  37682. */
  37683. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37684. /**
  37685. * Returns the latest update of the World matrix
  37686. * @returns a Matrix
  37687. */
  37688. getWorldMatrix(): Matrix;
  37689. /** @hidden */
  37690. _getWorldMatrixDeterminant(): number;
  37691. /**
  37692. * Returns directly the latest state of the mesh World matrix.
  37693. * A Matrix is returned.
  37694. */
  37695. get worldMatrixFromCache(): Matrix;
  37696. /** @hidden */
  37697. _initCache(): void;
  37698. /** @hidden */
  37699. updateCache(force?: boolean): void;
  37700. /** @hidden */
  37701. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37702. /** @hidden */
  37703. _updateCache(ignoreParentClass?: boolean): void;
  37704. /** @hidden */
  37705. _isSynchronized(): boolean;
  37706. /** @hidden */
  37707. _markSyncedWithParent(): void;
  37708. /** @hidden */
  37709. isSynchronizedWithParent(): boolean;
  37710. /** @hidden */
  37711. isSynchronized(): boolean;
  37712. /**
  37713. * Is this node ready to be used/rendered
  37714. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37715. * @return true if the node is ready
  37716. */
  37717. isReady(completeCheck?: boolean): boolean;
  37718. /**
  37719. * Is this node enabled?
  37720. * 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
  37721. * @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
  37722. * @return whether this node (and its parent) is enabled
  37723. */
  37724. isEnabled(checkAncestors?: boolean): boolean;
  37725. /** @hidden */
  37726. protected _syncParentEnabledState(): void;
  37727. /**
  37728. * Set the enabled state of this node
  37729. * @param value defines the new enabled state
  37730. */
  37731. setEnabled(value: boolean): void;
  37732. /**
  37733. * Is this node a descendant of the given node?
  37734. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37735. * @param ancestor defines the parent node to inspect
  37736. * @returns a boolean indicating if this node is a descendant of the given node
  37737. */
  37738. isDescendantOf(ancestor: Node): boolean;
  37739. /** @hidden */
  37740. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37741. /**
  37742. * Will return all nodes that have this node as ascendant
  37743. * @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
  37744. * @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
  37745. * @return all children nodes of all types
  37746. */
  37747. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37748. /**
  37749. * Get all child-meshes of this node
  37750. * @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)
  37751. * @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
  37752. * @returns an array of AbstractMesh
  37753. */
  37754. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37755. /**
  37756. * Get all direct children of this node
  37757. * @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
  37758. * @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)
  37759. * @returns an array of Node
  37760. */
  37761. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37762. /** @hidden */
  37763. _setReady(state: boolean): void;
  37764. /**
  37765. * Get an animation by name
  37766. * @param name defines the name of the animation to look for
  37767. * @returns null if not found else the requested animation
  37768. */
  37769. getAnimationByName(name: string): Nullable<Animation>;
  37770. /**
  37771. * Creates an animation range for this node
  37772. * @param name defines the name of the range
  37773. * @param from defines the starting key
  37774. * @param to defines the end key
  37775. */
  37776. createAnimationRange(name: string, from: number, to: number): void;
  37777. /**
  37778. * Delete a specific animation range
  37779. * @param name defines the name of the range to delete
  37780. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37781. */
  37782. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37783. /**
  37784. * Get an animation range by name
  37785. * @param name defines the name of the animation range to look for
  37786. * @returns null if not found else the requested animation range
  37787. */
  37788. getAnimationRange(name: string): Nullable<AnimationRange>;
  37789. /**
  37790. * Gets the list of all animation ranges defined on this node
  37791. * @returns an array
  37792. */
  37793. getAnimationRanges(): Nullable<AnimationRange>[];
  37794. /**
  37795. * Will start the animation sequence
  37796. * @param name defines the range frames for animation sequence
  37797. * @param loop defines if the animation should loop (false by default)
  37798. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37799. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37800. * @returns the object created for this animation. If range does not exist, it will return null
  37801. */
  37802. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37803. /**
  37804. * Serialize animation ranges into a JSON compatible object
  37805. * @returns serialization object
  37806. */
  37807. serializeAnimationRanges(): any;
  37808. /**
  37809. * Computes the world matrix of the node
  37810. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37811. * @returns the world matrix
  37812. */
  37813. computeWorldMatrix(force?: boolean): Matrix;
  37814. /**
  37815. * Releases resources associated with this node.
  37816. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37817. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37818. */
  37819. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37820. /**
  37821. * Parse animation range data from a serialization object and store them into a given node
  37822. * @param node defines where to store the animation ranges
  37823. * @param parsedNode defines the serialization object to read data from
  37824. * @param scene defines the hosting scene
  37825. */
  37826. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37827. /**
  37828. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37829. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37830. * @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
  37831. * @returns the new bounding vectors
  37832. */
  37833. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37834. min: Vector3;
  37835. max: Vector3;
  37836. };
  37837. }
  37838. }
  37839. declare module "babylonjs/Animations/animation" {
  37840. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  37841. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  37842. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  37843. import { Nullable } from "babylonjs/types";
  37844. import { Scene } from "babylonjs/scene";
  37845. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  37846. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37847. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  37848. import { Node } from "babylonjs/node";
  37849. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  37850. import { Size } from "babylonjs/Maths/math.size";
  37851. import { Animatable } from "babylonjs/Animations/animatable";
  37852. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  37853. /**
  37854. * @hidden
  37855. */
  37856. export class _IAnimationState {
  37857. key: number;
  37858. repeatCount: number;
  37859. workValue?: any;
  37860. loopMode?: number;
  37861. offsetValue?: any;
  37862. highLimitValue?: any;
  37863. }
  37864. /**
  37865. * Class used to store any kind of animation
  37866. */
  37867. export class Animation {
  37868. /**Name of the animation */
  37869. name: string;
  37870. /**Property to animate */
  37871. targetProperty: string;
  37872. /**The frames per second of the animation */
  37873. framePerSecond: number;
  37874. /**The data type of the animation */
  37875. dataType: number;
  37876. /**The loop mode of the animation */
  37877. loopMode?: number | undefined;
  37878. /**Specifies if blending should be enabled */
  37879. enableBlending?: boolean | undefined;
  37880. /**
  37881. * Use matrix interpolation instead of using direct key value when animating matrices
  37882. */
  37883. static AllowMatricesInterpolation: boolean;
  37884. /**
  37885. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37886. */
  37887. static AllowMatrixDecomposeForInterpolation: boolean;
  37888. /** Define the Url to load snippets */
  37889. static SnippetUrl: string;
  37890. /** Snippet ID if the animation was created from the snippet server */
  37891. snippetId: string;
  37892. /**
  37893. * Stores the key frames of the animation
  37894. */
  37895. private _keys;
  37896. /**
  37897. * Stores the easing function of the animation
  37898. */
  37899. private _easingFunction;
  37900. /**
  37901. * @hidden Internal use only
  37902. */
  37903. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  37904. /**
  37905. * The set of event that will be linked to this animation
  37906. */
  37907. private _events;
  37908. /**
  37909. * Stores an array of target property paths
  37910. */
  37911. targetPropertyPath: string[];
  37912. /**
  37913. * Stores the blending speed of the animation
  37914. */
  37915. blendingSpeed: number;
  37916. /**
  37917. * Stores the animation ranges for the animation
  37918. */
  37919. private _ranges;
  37920. /**
  37921. * @hidden Internal use
  37922. */
  37923. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37924. /**
  37925. * Sets up an animation
  37926. * @param property The property to animate
  37927. * @param animationType The animation type to apply
  37928. * @param framePerSecond The frames per second of the animation
  37929. * @param easingFunction The easing function used in the animation
  37930. * @returns The created animation
  37931. */
  37932. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37933. /**
  37934. * Create and start an animation on a node
  37935. * @param name defines the name of the global animation that will be run on all nodes
  37936. * @param node defines the root node where the animation will take place
  37937. * @param targetProperty defines property to animate
  37938. * @param framePerSecond defines the number of frame per second yo use
  37939. * @param totalFrame defines the number of frames in total
  37940. * @param from defines the initial value
  37941. * @param to defines the final value
  37942. * @param loopMode defines which loop mode you want to use (off by default)
  37943. * @param easingFunction defines the easing function to use (linear by default)
  37944. * @param onAnimationEnd defines the callback to call when animation end
  37945. * @returns the animatable created for this animation
  37946. */
  37947. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37948. /**
  37949. * Create and start an animation on a node and its descendants
  37950. * @param name defines the name of the global animation that will be run on all nodes
  37951. * @param node defines the root node where the animation will take place
  37952. * @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
  37953. * @param targetProperty defines property to animate
  37954. * @param framePerSecond defines the number of frame per second to use
  37955. * @param totalFrame defines the number of frames in total
  37956. * @param from defines the initial value
  37957. * @param to defines the final value
  37958. * @param loopMode defines which loop mode you want to use (off by default)
  37959. * @param easingFunction defines the easing function to use (linear by default)
  37960. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37961. * @returns the list of animatables created for all nodes
  37962. * @example https://www.babylonjs-playground.com/#MH0VLI
  37963. */
  37964. 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[]>;
  37965. /**
  37966. * Creates a new animation, merges it with the existing animations and starts it
  37967. * @param name Name of the animation
  37968. * @param node Node which contains the scene that begins the animations
  37969. * @param targetProperty Specifies which property to animate
  37970. * @param framePerSecond The frames per second of the animation
  37971. * @param totalFrame The total number of frames
  37972. * @param from The frame at the beginning of the animation
  37973. * @param to The frame at the end of the animation
  37974. * @param loopMode Specifies the loop mode of the animation
  37975. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37976. * @param onAnimationEnd Callback to run once the animation is complete
  37977. * @returns Nullable animation
  37978. */
  37979. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37980. /**
  37981. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37982. * @param sourceAnimation defines the Animation containing keyframes to convert
  37983. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37984. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37985. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37986. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37987. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37988. */
  37989. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37990. /**
  37991. * Transition property of an host to the target Value
  37992. * @param property The property to transition
  37993. * @param targetValue The target Value of the property
  37994. * @param host The object where the property to animate belongs
  37995. * @param scene Scene used to run the animation
  37996. * @param frameRate Framerate (in frame/s) to use
  37997. * @param transition The transition type we want to use
  37998. * @param duration The duration of the animation, in milliseconds
  37999. * @param onAnimationEnd Callback trigger at the end of the animation
  38000. * @returns Nullable animation
  38001. */
  38002. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38003. /**
  38004. * Return the array of runtime animations currently using this animation
  38005. */
  38006. get runtimeAnimations(): RuntimeAnimation[];
  38007. /**
  38008. * Specifies if any of the runtime animations are currently running
  38009. */
  38010. get hasRunningRuntimeAnimations(): boolean;
  38011. /**
  38012. * Initializes the animation
  38013. * @param name Name of the animation
  38014. * @param targetProperty Property to animate
  38015. * @param framePerSecond The frames per second of the animation
  38016. * @param dataType The data type of the animation
  38017. * @param loopMode The loop mode of the animation
  38018. * @param enableBlending Specifies if blending should be enabled
  38019. */
  38020. constructor(
  38021. /**Name of the animation */
  38022. name: string,
  38023. /**Property to animate */
  38024. targetProperty: string,
  38025. /**The frames per second of the animation */
  38026. framePerSecond: number,
  38027. /**The data type of the animation */
  38028. dataType: number,
  38029. /**The loop mode of the animation */
  38030. loopMode?: number | undefined,
  38031. /**Specifies if blending should be enabled */
  38032. enableBlending?: boolean | undefined);
  38033. /**
  38034. * Converts the animation to a string
  38035. * @param fullDetails support for multiple levels of logging within scene loading
  38036. * @returns String form of the animation
  38037. */
  38038. toString(fullDetails?: boolean): string;
  38039. /**
  38040. * Add an event to this animation
  38041. * @param event Event to add
  38042. */
  38043. addEvent(event: AnimationEvent): void;
  38044. /**
  38045. * Remove all events found at the given frame
  38046. * @param frame The frame to remove events from
  38047. */
  38048. removeEvents(frame: number): void;
  38049. /**
  38050. * Retrieves all the events from the animation
  38051. * @returns Events from the animation
  38052. */
  38053. getEvents(): AnimationEvent[];
  38054. /**
  38055. * Creates an animation range
  38056. * @param name Name of the animation range
  38057. * @param from Starting frame of the animation range
  38058. * @param to Ending frame of the animation
  38059. */
  38060. createRange(name: string, from: number, to: number): void;
  38061. /**
  38062. * Deletes an animation range by name
  38063. * @param name Name of the animation range to delete
  38064. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38065. */
  38066. deleteRange(name: string, deleteFrames?: boolean): void;
  38067. /**
  38068. * Gets the animation range by name, or null if not defined
  38069. * @param name Name of the animation range
  38070. * @returns Nullable animation range
  38071. */
  38072. getRange(name: string): Nullable<AnimationRange>;
  38073. /**
  38074. * Gets the key frames from the animation
  38075. * @returns The key frames of the animation
  38076. */
  38077. getKeys(): Array<IAnimationKey>;
  38078. /**
  38079. * Gets the highest frame rate of the animation
  38080. * @returns Highest frame rate of the animation
  38081. */
  38082. getHighestFrame(): number;
  38083. /**
  38084. * Gets the easing function of the animation
  38085. * @returns Easing function of the animation
  38086. */
  38087. getEasingFunction(): IEasingFunction;
  38088. /**
  38089. * Sets the easing function of the animation
  38090. * @param easingFunction A custom mathematical formula for animation
  38091. */
  38092. setEasingFunction(easingFunction: EasingFunction): void;
  38093. /**
  38094. * Interpolates a scalar linearly
  38095. * @param startValue Start value of the animation curve
  38096. * @param endValue End value of the animation curve
  38097. * @param gradient Scalar amount to interpolate
  38098. * @returns Interpolated scalar value
  38099. */
  38100. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38101. /**
  38102. * Interpolates a scalar cubically
  38103. * @param startValue Start value of the animation curve
  38104. * @param outTangent End tangent of the animation
  38105. * @param endValue End value of the animation curve
  38106. * @param inTangent Start tangent of the animation curve
  38107. * @param gradient Scalar amount to interpolate
  38108. * @returns Interpolated scalar value
  38109. */
  38110. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38111. /**
  38112. * Interpolates a quaternion using a spherical linear interpolation
  38113. * @param startValue Start value of the animation curve
  38114. * @param endValue End value of the animation curve
  38115. * @param gradient Scalar amount to interpolate
  38116. * @returns Interpolated quaternion value
  38117. */
  38118. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38119. /**
  38120. * Interpolates a quaternion cubically
  38121. * @param startValue Start value of the animation curve
  38122. * @param outTangent End tangent of the animation curve
  38123. * @param endValue End value of the animation curve
  38124. * @param inTangent Start tangent of the animation curve
  38125. * @param gradient Scalar amount to interpolate
  38126. * @returns Interpolated quaternion value
  38127. */
  38128. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38129. /**
  38130. * Interpolates a Vector3 linearl
  38131. * @param startValue Start value of the animation curve
  38132. * @param endValue End value of the animation curve
  38133. * @param gradient Scalar amount to interpolate
  38134. * @returns Interpolated scalar value
  38135. */
  38136. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38137. /**
  38138. * Interpolates a Vector3 cubically
  38139. * @param startValue Start value of the animation curve
  38140. * @param outTangent End tangent of the animation
  38141. * @param endValue End value of the animation curve
  38142. * @param inTangent Start tangent of the animation curve
  38143. * @param gradient Scalar amount to interpolate
  38144. * @returns InterpolatedVector3 value
  38145. */
  38146. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38147. /**
  38148. * Interpolates a Vector2 linearly
  38149. * @param startValue Start value of the animation curve
  38150. * @param endValue End value of the animation curve
  38151. * @param gradient Scalar amount to interpolate
  38152. * @returns Interpolated Vector2 value
  38153. */
  38154. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38155. /**
  38156. * Interpolates a Vector2 cubically
  38157. * @param startValue Start value of the animation curve
  38158. * @param outTangent End tangent of the animation
  38159. * @param endValue End value of the animation curve
  38160. * @param inTangent Start tangent of the animation curve
  38161. * @param gradient Scalar amount to interpolate
  38162. * @returns Interpolated Vector2 value
  38163. */
  38164. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38165. /**
  38166. * Interpolates a size linearly
  38167. * @param startValue Start value of the animation curve
  38168. * @param endValue End value of the animation curve
  38169. * @param gradient Scalar amount to interpolate
  38170. * @returns Interpolated Size value
  38171. */
  38172. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38173. /**
  38174. * Interpolates a Color3 linearly
  38175. * @param startValue Start value of the animation curve
  38176. * @param endValue End value of the animation curve
  38177. * @param gradient Scalar amount to interpolate
  38178. * @returns Interpolated Color3 value
  38179. */
  38180. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38181. /**
  38182. * Interpolates a Color4 linearly
  38183. * @param startValue Start value of the animation curve
  38184. * @param endValue End value of the animation curve
  38185. * @param gradient Scalar amount to interpolate
  38186. * @returns Interpolated Color3 value
  38187. */
  38188. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38189. /**
  38190. * @hidden Internal use only
  38191. */
  38192. _getKeyValue(value: any): any;
  38193. /**
  38194. * @hidden Internal use only
  38195. */
  38196. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38197. /**
  38198. * Defines the function to use to interpolate matrices
  38199. * @param startValue defines the start matrix
  38200. * @param endValue defines the end matrix
  38201. * @param gradient defines the gradient between both matrices
  38202. * @param result defines an optional target matrix where to store the interpolation
  38203. * @returns the interpolated matrix
  38204. */
  38205. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38206. /**
  38207. * Makes a copy of the animation
  38208. * @returns Cloned animation
  38209. */
  38210. clone(): Animation;
  38211. /**
  38212. * Sets the key frames of the animation
  38213. * @param values The animation key frames to set
  38214. */
  38215. setKeys(values: Array<IAnimationKey>): void;
  38216. /**
  38217. * Serializes the animation to an object
  38218. * @returns Serialized object
  38219. */
  38220. serialize(): any;
  38221. /**
  38222. * Float animation type
  38223. */
  38224. static readonly ANIMATIONTYPE_FLOAT: number;
  38225. /**
  38226. * Vector3 animation type
  38227. */
  38228. static readonly ANIMATIONTYPE_VECTOR3: number;
  38229. /**
  38230. * Quaternion animation type
  38231. */
  38232. static readonly ANIMATIONTYPE_QUATERNION: number;
  38233. /**
  38234. * Matrix animation type
  38235. */
  38236. static readonly ANIMATIONTYPE_MATRIX: number;
  38237. /**
  38238. * Color3 animation type
  38239. */
  38240. static readonly ANIMATIONTYPE_COLOR3: number;
  38241. /**
  38242. * Color3 animation type
  38243. */
  38244. static readonly ANIMATIONTYPE_COLOR4: number;
  38245. /**
  38246. * Vector2 animation type
  38247. */
  38248. static readonly ANIMATIONTYPE_VECTOR2: number;
  38249. /**
  38250. * Size animation type
  38251. */
  38252. static readonly ANIMATIONTYPE_SIZE: number;
  38253. /**
  38254. * Relative Loop Mode
  38255. */
  38256. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38257. /**
  38258. * Cycle Loop Mode
  38259. */
  38260. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38261. /**
  38262. * Constant Loop Mode
  38263. */
  38264. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38265. /** @hidden */
  38266. static _UniversalLerp(left: any, right: any, amount: number): any;
  38267. /**
  38268. * Parses an animation object and creates an animation
  38269. * @param parsedAnimation Parsed animation object
  38270. * @returns Animation object
  38271. */
  38272. static Parse(parsedAnimation: any): Animation;
  38273. /**
  38274. * Appends the serialized animations from the source animations
  38275. * @param source Source containing the animations
  38276. * @param destination Target to store the animations
  38277. */
  38278. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38279. /**
  38280. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38281. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38282. * @param url defines the url to load from
  38283. * @returns a promise that will resolve to the new animation or an array of animations
  38284. */
  38285. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38286. /**
  38287. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38288. * @param snippetId defines the snippet to load
  38289. * @returns a promise that will resolve to the new animation or a new array of animations
  38290. */
  38291. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38292. }
  38293. }
  38294. declare module "babylonjs/Animations/animatable.interface" {
  38295. import { Nullable } from "babylonjs/types";
  38296. import { Animation } from "babylonjs/Animations/animation";
  38297. /**
  38298. * Interface containing an array of animations
  38299. */
  38300. export interface IAnimatable {
  38301. /**
  38302. * Array of animations
  38303. */
  38304. animations: Nullable<Array<Animation>>;
  38305. }
  38306. }
  38307. declare module "babylonjs/Misc/decorators" {
  38308. import { Nullable } from "babylonjs/types";
  38309. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38310. import { Scene } from "babylonjs/scene";
  38311. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38312. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38313. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38315. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38316. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38317. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38318. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38319. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38320. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38321. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38322. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38323. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38324. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38325. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38326. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38327. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38328. /**
  38329. * Decorator used to define property that can be serialized as reference to a camera
  38330. * @param sourceName defines the name of the property to decorate
  38331. */
  38332. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38333. /**
  38334. * Class used to help serialization objects
  38335. */
  38336. export class SerializationHelper {
  38337. /** @hidden */
  38338. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38339. /** @hidden */
  38340. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38341. /** @hidden */
  38342. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38343. /** @hidden */
  38344. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38345. /**
  38346. * Appends the serialized animations from the source animations
  38347. * @param source Source containing the animations
  38348. * @param destination Target to store the animations
  38349. */
  38350. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38351. /**
  38352. * Static function used to serialized a specific entity
  38353. * @param entity defines the entity to serialize
  38354. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38355. * @returns a JSON compatible object representing the serialization of the entity
  38356. */
  38357. static Serialize<T>(entity: T, serializationObject?: any): any;
  38358. /**
  38359. * Creates a new entity from a serialization data object
  38360. * @param creationFunction defines a function used to instanciated the new entity
  38361. * @param source defines the source serialization data
  38362. * @param scene defines the hosting scene
  38363. * @param rootUrl defines the root url for resources
  38364. * @returns a new entity
  38365. */
  38366. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38367. /**
  38368. * Clones an object
  38369. * @param creationFunction defines the function used to instanciate the new object
  38370. * @param source defines the source object
  38371. * @returns the cloned object
  38372. */
  38373. static Clone<T>(creationFunction: () => T, source: T): T;
  38374. /**
  38375. * Instanciates a new object based on a source one (some data will be shared between both object)
  38376. * @param creationFunction defines the function used to instanciate the new object
  38377. * @param source defines the source object
  38378. * @returns the new object
  38379. */
  38380. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38381. }
  38382. }
  38383. declare module "babylonjs/Cameras/camera" {
  38384. import { SmartArray } from "babylonjs/Misc/smartArray";
  38385. import { Observable } from "babylonjs/Misc/observable";
  38386. import { Nullable } from "babylonjs/types";
  38387. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38388. import { Scene } from "babylonjs/scene";
  38389. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38390. import { Node } from "babylonjs/node";
  38391. import { Mesh } from "babylonjs/Meshes/mesh";
  38392. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38393. import { ICullable } from "babylonjs/Culling/boundingInfo";
  38394. import { Viewport } from "babylonjs/Maths/math.viewport";
  38395. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38396. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38397. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38398. import { Ray } from "babylonjs/Culling/ray";
  38399. /**
  38400. * This is the base class of all the camera used in the application.
  38401. * @see https://doc.babylonjs.com/features/cameras
  38402. */
  38403. export class Camera extends Node {
  38404. /** @hidden */
  38405. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  38406. /**
  38407. * This is the default projection mode used by the cameras.
  38408. * It helps recreating a feeling of perspective and better appreciate depth.
  38409. * This is the best way to simulate real life cameras.
  38410. */
  38411. static readonly PERSPECTIVE_CAMERA: number;
  38412. /**
  38413. * This helps creating camera with an orthographic mode.
  38414. * 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.
  38415. */
  38416. static readonly ORTHOGRAPHIC_CAMERA: number;
  38417. /**
  38418. * This is the default FOV mode for perspective cameras.
  38419. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  38420. */
  38421. static readonly FOVMODE_VERTICAL_FIXED: number;
  38422. /**
  38423. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  38424. */
  38425. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  38426. /**
  38427. * This specifies ther is no need for a camera rig.
  38428. * Basically only one eye is rendered corresponding to the camera.
  38429. */
  38430. static readonly RIG_MODE_NONE: number;
  38431. /**
  38432. * Simulates a camera Rig with one blue eye and one red eye.
  38433. * This can be use with 3d blue and red glasses.
  38434. */
  38435. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  38436. /**
  38437. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  38438. */
  38439. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  38440. /**
  38441. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  38442. */
  38443. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  38444. /**
  38445. * Defines that both eyes of the camera will be rendered over under each other.
  38446. */
  38447. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  38448. /**
  38449. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  38450. */
  38451. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  38452. /**
  38453. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  38454. */
  38455. static readonly RIG_MODE_VR: number;
  38456. /**
  38457. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  38458. */
  38459. static readonly RIG_MODE_WEBVR: number;
  38460. /**
  38461. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  38462. */
  38463. static readonly RIG_MODE_CUSTOM: number;
  38464. /**
  38465. * Defines if by default attaching controls should prevent the default javascript event to continue.
  38466. */
  38467. static ForceAttachControlToAlwaysPreventDefault: boolean;
  38468. /**
  38469. * Define the input manager associated with the camera.
  38470. */
  38471. inputs: CameraInputsManager<Camera>;
  38472. /** @hidden */
  38473. _position: Vector3;
  38474. /**
  38475. * Define the current local position of the camera in the scene
  38476. */
  38477. get position(): Vector3;
  38478. set position(newPosition: Vector3);
  38479. protected _upVector: Vector3;
  38480. /**
  38481. * The vector the camera should consider as up.
  38482. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  38483. */
  38484. set upVector(vec: Vector3);
  38485. get upVector(): Vector3;
  38486. /**
  38487. * Define the current limit on the left side for an orthographic camera
  38488. * In scene unit
  38489. */
  38490. orthoLeft: Nullable<number>;
  38491. /**
  38492. * Define the current limit on the right side for an orthographic camera
  38493. * In scene unit
  38494. */
  38495. orthoRight: Nullable<number>;
  38496. /**
  38497. * Define the current limit on the bottom side for an orthographic camera
  38498. * In scene unit
  38499. */
  38500. orthoBottom: Nullable<number>;
  38501. /**
  38502. * Define the current limit on the top side for an orthographic camera
  38503. * In scene unit
  38504. */
  38505. orthoTop: Nullable<number>;
  38506. /**
  38507. * Field Of View is set in Radians. (default is 0.8)
  38508. */
  38509. fov: number;
  38510. /**
  38511. * Define the minimum distance the camera can see from.
  38512. * This is important to note that the depth buffer are not infinite and the closer it starts
  38513. * the more your scene might encounter depth fighting issue.
  38514. */
  38515. minZ: number;
  38516. /**
  38517. * Define the maximum distance the camera can see to.
  38518. * This is important to note that the depth buffer are not infinite and the further it end
  38519. * the more your scene might encounter depth fighting issue.
  38520. */
  38521. maxZ: number;
  38522. /**
  38523. * Define the default inertia of the camera.
  38524. * This helps giving a smooth feeling to the camera movement.
  38525. */
  38526. inertia: number;
  38527. /**
  38528. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  38529. */
  38530. mode: number;
  38531. /**
  38532. * Define whether the camera is intermediate.
  38533. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  38534. */
  38535. isIntermediate: boolean;
  38536. /**
  38537. * Define the viewport of the camera.
  38538. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  38539. */
  38540. viewport: Viewport;
  38541. /**
  38542. * Restricts the camera to viewing objects with the same layerMask.
  38543. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  38544. */
  38545. layerMask: number;
  38546. /**
  38547. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  38548. */
  38549. fovMode: number;
  38550. /**
  38551. * Rig mode of the camera.
  38552. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  38553. * This is normally controlled byt the camera themselves as internal use.
  38554. */
  38555. cameraRigMode: number;
  38556. /**
  38557. * Defines the distance between both "eyes" in case of a RIG
  38558. */
  38559. interaxialDistance: number;
  38560. /**
  38561. * Defines if stereoscopic rendering is done side by side or over under.
  38562. */
  38563. isStereoscopicSideBySide: boolean;
  38564. /**
  38565. * 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
  38566. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  38567. * else in the scene. (Eg. security camera)
  38568. *
  38569. * 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)
  38570. */
  38571. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  38572. /**
  38573. * When set, the camera will render to this render target instead of the default canvas
  38574. *
  38575. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  38576. */
  38577. outputRenderTarget: Nullable<RenderTargetTexture>;
  38578. /**
  38579. * Observable triggered when the camera view matrix has changed.
  38580. */
  38581. onViewMatrixChangedObservable: Observable<Camera>;
  38582. /**
  38583. * Observable triggered when the camera Projection matrix has changed.
  38584. */
  38585. onProjectionMatrixChangedObservable: Observable<Camera>;
  38586. /**
  38587. * Observable triggered when the inputs have been processed.
  38588. */
  38589. onAfterCheckInputsObservable: Observable<Camera>;
  38590. /**
  38591. * Observable triggered when reset has been called and applied to the camera.
  38592. */
  38593. onRestoreStateObservable: Observable<Camera>;
  38594. /**
  38595. * Is this camera a part of a rig system?
  38596. */
  38597. isRigCamera: boolean;
  38598. /**
  38599. * If isRigCamera set to true this will be set with the parent camera.
  38600. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  38601. */
  38602. rigParent?: Camera;
  38603. /** @hidden */
  38604. _cameraRigParams: any;
  38605. /** @hidden */
  38606. _rigCameras: Camera[];
  38607. /** @hidden */
  38608. _rigPostProcess: Nullable<PostProcess>;
  38609. protected _webvrViewMatrix: Matrix;
  38610. /** @hidden */
  38611. _skipRendering: boolean;
  38612. /** @hidden */
  38613. _projectionMatrix: Matrix;
  38614. /** @hidden */
  38615. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  38616. /** @hidden */
  38617. _activeMeshes: SmartArray<AbstractMesh>;
  38618. protected _globalPosition: Vector3;
  38619. /** @hidden */
  38620. _computedViewMatrix: Matrix;
  38621. private _doNotComputeProjectionMatrix;
  38622. private _transformMatrix;
  38623. private _frustumPlanes;
  38624. private _refreshFrustumPlanes;
  38625. private _storedFov;
  38626. private _stateStored;
  38627. /**
  38628. * Instantiates a new camera object.
  38629. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  38630. * @see https://doc.babylonjs.com/features/cameras
  38631. * @param name Defines the name of the camera in the scene
  38632. * @param position Defines the position of the camera
  38633. * @param scene Defines the scene the camera belongs too
  38634. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38635. */
  38636. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38637. /**
  38638. * Store current camera state (fov, position, etc..)
  38639. * @returns the camera
  38640. */
  38641. storeState(): Camera;
  38642. /**
  38643. * Restores the camera state values if it has been stored. You must call storeState() first
  38644. */
  38645. protected _restoreStateValues(): boolean;
  38646. /**
  38647. * Restored camera state. You must call storeState() first.
  38648. * @returns true if restored and false otherwise
  38649. */
  38650. restoreState(): boolean;
  38651. /**
  38652. * Gets the class name of the camera.
  38653. * @returns the class name
  38654. */
  38655. getClassName(): string;
  38656. /** @hidden */
  38657. readonly _isCamera: boolean;
  38658. /**
  38659. * Gets a string representation of the camera useful for debug purpose.
  38660. * @param fullDetails Defines that a more verboe level of logging is required
  38661. * @returns the string representation
  38662. */
  38663. toString(fullDetails?: boolean): string;
  38664. /**
  38665. * Gets the current world space position of the camera.
  38666. */
  38667. get globalPosition(): Vector3;
  38668. /**
  38669. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38670. * @returns the active meshe list
  38671. */
  38672. getActiveMeshes(): SmartArray<AbstractMesh>;
  38673. /**
  38674. * Check whether a mesh is part of the current active mesh list of the camera
  38675. * @param mesh Defines the mesh to check
  38676. * @returns true if active, false otherwise
  38677. */
  38678. isActiveMesh(mesh: Mesh): boolean;
  38679. /**
  38680. * Is this camera ready to be used/rendered
  38681. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38682. * @return true if the camera is ready
  38683. */
  38684. isReady(completeCheck?: boolean): boolean;
  38685. /** @hidden */
  38686. _initCache(): void;
  38687. /** @hidden */
  38688. _updateCache(ignoreParentClass?: boolean): void;
  38689. /** @hidden */
  38690. _isSynchronized(): boolean;
  38691. /** @hidden */
  38692. _isSynchronizedViewMatrix(): boolean;
  38693. /** @hidden */
  38694. _isSynchronizedProjectionMatrix(): boolean;
  38695. /**
  38696. * Attach the input controls to a specific dom element to get the input from.
  38697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38698. */
  38699. attachControl(noPreventDefault?: boolean): void;
  38700. /**
  38701. * Attach the input controls to a specific dom element to get the input from.
  38702. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38704. * BACK COMPAT SIGNATURE ONLY.
  38705. */
  38706. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38707. /**
  38708. * Detach the current controls from the specified dom element.
  38709. */
  38710. detachControl(): void;
  38711. /**
  38712. * Detach the current controls from the specified dom element.
  38713. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  38714. */
  38715. detachControl(ignored: any): void;
  38716. /**
  38717. * Update the camera state according to the different inputs gathered during the frame.
  38718. */
  38719. update(): void;
  38720. /** @hidden */
  38721. _checkInputs(): void;
  38722. /** @hidden */
  38723. get rigCameras(): Camera[];
  38724. /**
  38725. * Gets the post process used by the rig cameras
  38726. */
  38727. get rigPostProcess(): Nullable<PostProcess>;
  38728. /**
  38729. * Internal, gets the first post proces.
  38730. * @returns the first post process to be run on this camera.
  38731. */
  38732. _getFirstPostProcess(): Nullable<PostProcess>;
  38733. private _cascadePostProcessesToRigCams;
  38734. /**
  38735. * Attach a post process to the camera.
  38736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38737. * @param postProcess The post process to attach to the camera
  38738. * @param insertAt The position of the post process in case several of them are in use in the scene
  38739. * @returns the position the post process has been inserted at
  38740. */
  38741. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38742. /**
  38743. * Detach a post process to the camera.
  38744. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38745. * @param postProcess The post process to detach from the camera
  38746. */
  38747. detachPostProcess(postProcess: PostProcess): void;
  38748. /**
  38749. * Gets the current world matrix of the camera
  38750. */
  38751. getWorldMatrix(): Matrix;
  38752. /** @hidden */
  38753. _getViewMatrix(): Matrix;
  38754. /**
  38755. * Gets the current view matrix of the camera.
  38756. * @param force forces the camera to recompute the matrix without looking at the cached state
  38757. * @returns the view matrix
  38758. */
  38759. getViewMatrix(force?: boolean): Matrix;
  38760. /**
  38761. * Freeze the projection matrix.
  38762. * It will prevent the cache check of the camera projection compute and can speed up perf
  38763. * if no parameter of the camera are meant to change
  38764. * @param projection Defines manually a projection if necessary
  38765. */
  38766. freezeProjectionMatrix(projection?: Matrix): void;
  38767. /**
  38768. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38769. */
  38770. unfreezeProjectionMatrix(): void;
  38771. /**
  38772. * Gets the current projection matrix of the camera.
  38773. * @param force forces the camera to recompute the matrix without looking at the cached state
  38774. * @returns the projection matrix
  38775. */
  38776. getProjectionMatrix(force?: boolean): Matrix;
  38777. /**
  38778. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38779. * @returns a Matrix
  38780. */
  38781. getTransformationMatrix(): Matrix;
  38782. private _updateFrustumPlanes;
  38783. /**
  38784. * Checks if a cullable object (mesh...) is in the camera frustum
  38785. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38786. * @param target The object to check
  38787. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38788. * @returns true if the object is in frustum otherwise false
  38789. */
  38790. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38791. /**
  38792. * Checks if a cullable object (mesh...) is in the camera frustum
  38793. * Unlike isInFrustum this cheks the full bounding box
  38794. * @param target The object to check
  38795. * @returns true if the object is in frustum otherwise false
  38796. */
  38797. isCompletelyInFrustum(target: ICullable): boolean;
  38798. /**
  38799. * Gets a ray in the forward direction from the camera.
  38800. * @param length Defines the length of the ray to create
  38801. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38802. * @param origin Defines the start point of the ray which defaults to the camera position
  38803. * @returns the forward ray
  38804. */
  38805. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38806. /**
  38807. * Gets a ray in the forward direction from the camera.
  38808. * @param refRay the ray to (re)use when setting the values
  38809. * @param length Defines the length of the ray to create
  38810. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38811. * @param origin Defines the start point of the ray which defaults to the camera position
  38812. * @returns the forward ray
  38813. */
  38814. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38815. /**
  38816. * Releases resources associated with this node.
  38817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38819. */
  38820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38821. /** @hidden */
  38822. _isLeftCamera: boolean;
  38823. /**
  38824. * Gets the left camera of a rig setup in case of Rigged Camera
  38825. */
  38826. get isLeftCamera(): boolean;
  38827. /** @hidden */
  38828. _isRightCamera: boolean;
  38829. /**
  38830. * Gets the right camera of a rig setup in case of Rigged Camera
  38831. */
  38832. get isRightCamera(): boolean;
  38833. /**
  38834. * Gets the left camera of a rig setup in case of Rigged Camera
  38835. */
  38836. get leftCamera(): Nullable<FreeCamera>;
  38837. /**
  38838. * Gets the right camera of a rig setup in case of Rigged Camera
  38839. */
  38840. get rightCamera(): Nullable<FreeCamera>;
  38841. /**
  38842. * Gets the left camera target of a rig setup in case of Rigged Camera
  38843. * @returns the target position
  38844. */
  38845. getLeftTarget(): Nullable<Vector3>;
  38846. /**
  38847. * Gets the right camera target of a rig setup in case of Rigged Camera
  38848. * @returns the target position
  38849. */
  38850. getRightTarget(): Nullable<Vector3>;
  38851. /**
  38852. * @hidden
  38853. */
  38854. setCameraRigMode(mode: number, rigParams: any): void;
  38855. /** @hidden */
  38856. static _setStereoscopicRigMode(camera: Camera): void;
  38857. /** @hidden */
  38858. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38859. /** @hidden */
  38860. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38861. /** @hidden */
  38862. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38863. /** @hidden */
  38864. _getVRProjectionMatrix(): Matrix;
  38865. protected _updateCameraRotationMatrix(): void;
  38866. protected _updateWebVRCameraRotationMatrix(): void;
  38867. /**
  38868. * This function MUST be overwritten by the different WebVR cameras available.
  38869. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38870. * @hidden
  38871. */
  38872. _getWebVRProjectionMatrix(): Matrix;
  38873. /**
  38874. * This function MUST be overwritten by the different WebVR cameras available.
  38875. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38876. * @hidden
  38877. */
  38878. _getWebVRViewMatrix(): Matrix;
  38879. /** @hidden */
  38880. setCameraRigParameter(name: string, value: any): void;
  38881. /**
  38882. * needs to be overridden by children so sub has required properties to be copied
  38883. * @hidden
  38884. */
  38885. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38886. /**
  38887. * May need to be overridden by children
  38888. * @hidden
  38889. */
  38890. _updateRigCameras(): void;
  38891. /** @hidden */
  38892. _setupInputs(): void;
  38893. /**
  38894. * Serialiaze the camera setup to a json represention
  38895. * @returns the JSON representation
  38896. */
  38897. serialize(): any;
  38898. /**
  38899. * Clones the current camera.
  38900. * @param name The cloned camera name
  38901. * @returns the cloned camera
  38902. */
  38903. clone(name: string): Camera;
  38904. /**
  38905. * Gets the direction of the camera relative to a given local axis.
  38906. * @param localAxis Defines the reference axis to provide a relative direction.
  38907. * @return the direction
  38908. */
  38909. getDirection(localAxis: Vector3): Vector3;
  38910. /**
  38911. * Returns the current camera absolute rotation
  38912. */
  38913. get absoluteRotation(): Quaternion;
  38914. /**
  38915. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38916. * @param localAxis Defines the reference axis to provide a relative direction.
  38917. * @param result Defines the vector to store the result in
  38918. */
  38919. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38920. /**
  38921. * Gets a camera constructor for a given camera type
  38922. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38923. * @param name The name of the camera the result will be able to instantiate
  38924. * @param scene The scene the result will construct the camera in
  38925. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38926. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38927. * @returns a factory method to construc the camera
  38928. */
  38929. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38930. /**
  38931. * Compute the world matrix of the camera.
  38932. * @returns the camera world matrix
  38933. */
  38934. computeWorldMatrix(): Matrix;
  38935. /**
  38936. * Parse a JSON and creates the camera from the parsed information
  38937. * @param parsedCamera The JSON to parse
  38938. * @param scene The scene to instantiate the camera in
  38939. * @returns the newly constructed camera
  38940. */
  38941. static Parse(parsedCamera: any, scene: Scene): Camera;
  38942. }
  38943. }
  38944. declare module "babylonjs/PostProcesses/postProcessManager" {
  38945. import { Nullable } from "babylonjs/types";
  38946. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38947. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38948. import { Scene } from "babylonjs/scene";
  38949. /**
  38950. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38951. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38952. */
  38953. export class PostProcessManager {
  38954. private _scene;
  38955. private _indexBuffer;
  38956. private _vertexBuffers;
  38957. /**
  38958. * Creates a new instance PostProcess
  38959. * @param scene The scene that the post process is associated with.
  38960. */
  38961. constructor(scene: Scene);
  38962. private _prepareBuffers;
  38963. private _buildIndexBuffer;
  38964. /**
  38965. * Rebuilds the vertex buffers of the manager.
  38966. * @hidden
  38967. */
  38968. _rebuild(): void;
  38969. /**
  38970. * Prepares a frame to be run through a post process.
  38971. * @param sourceTexture The input texture to the post procesess. (default: null)
  38972. * @param postProcesses An array of post processes to be run. (default: null)
  38973. * @returns True if the post processes were able to be run.
  38974. * @hidden
  38975. */
  38976. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38977. /**
  38978. * Manually render a set of post processes to a texture.
  38979. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38980. * @param postProcesses An array of post processes to be run.
  38981. * @param targetTexture The target texture to render to.
  38982. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38983. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38984. * @param lodLevel defines which lod of the texture to render to
  38985. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38986. */
  38987. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38988. /**
  38989. * Finalize the result of the output of the postprocesses.
  38990. * @param doNotPresent If true the result will not be displayed to the screen.
  38991. * @param targetTexture The target texture to render to.
  38992. * @param faceIndex The index of the face to bind the target texture to.
  38993. * @param postProcesses The array of post processes to render.
  38994. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38995. * @hidden
  38996. */
  38997. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38998. /**
  38999. * Disposes of the post process manager.
  39000. */
  39001. dispose(): void;
  39002. }
  39003. }
  39004. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  39005. import { Observable } from "babylonjs/Misc/observable";
  39006. import { SmartArray } from "babylonjs/Misc/smartArray";
  39007. import { Nullable, Immutable } from "babylonjs/types";
  39008. import { Camera } from "babylonjs/Cameras/camera";
  39009. import { Scene } from "babylonjs/scene";
  39010. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  39011. import { Color4 } from "babylonjs/Maths/math.color";
  39012. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  39013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39014. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39015. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39016. import { Texture } from "babylonjs/Materials/Textures/texture";
  39017. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39018. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  39019. import "babylonjs/Engines/Extensions/engine.renderTarget";
  39020. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  39021. import { Engine } from "babylonjs/Engines/engine";
  39022. /**
  39023. * This Helps creating a texture that will be created from a camera in your scene.
  39024. * It is basically a dynamic texture that could be used to create special effects for instance.
  39025. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  39026. */
  39027. export class RenderTargetTexture extends Texture {
  39028. /**
  39029. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  39030. */
  39031. static readonly REFRESHRATE_RENDER_ONCE: number;
  39032. /**
  39033. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  39034. */
  39035. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  39036. /**
  39037. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  39038. * the central point of your effect and can save a lot of performances.
  39039. */
  39040. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  39041. /**
  39042. * Use this predicate to dynamically define the list of mesh you want to render.
  39043. * If set, the renderList property will be overwritten.
  39044. */
  39045. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  39046. private _renderList;
  39047. /**
  39048. * Use this list to define the list of mesh you want to render.
  39049. */
  39050. get renderList(): Nullable<Array<AbstractMesh>>;
  39051. set renderList(value: Nullable<Array<AbstractMesh>>);
  39052. /**
  39053. * Use this function to overload the renderList array at rendering time.
  39054. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  39055. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  39056. * the cube (if the RTT is a cube, else layerOrFace=0).
  39057. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  39058. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  39059. * hold dummy elements!
  39060. */
  39061. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  39062. private _hookArray;
  39063. /**
  39064. * Define if particles should be rendered in your texture.
  39065. */
  39066. renderParticles: boolean;
  39067. /**
  39068. * Define if sprites should be rendered in your texture.
  39069. */
  39070. renderSprites: boolean;
  39071. /**
  39072. * Define the camera used to render the texture.
  39073. */
  39074. activeCamera: Nullable<Camera>;
  39075. /**
  39076. * Override the mesh isReady function with your own one.
  39077. */
  39078. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  39079. /**
  39080. * Override the render function of the texture with your own one.
  39081. */
  39082. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  39083. /**
  39084. * Define if camera post processes should be use while rendering the texture.
  39085. */
  39086. useCameraPostProcesses: boolean;
  39087. /**
  39088. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  39089. */
  39090. ignoreCameraViewport: boolean;
  39091. private _postProcessManager;
  39092. private _postProcesses;
  39093. private _resizeObserver;
  39094. /**
  39095. * An event triggered when the texture is unbind.
  39096. */
  39097. onBeforeBindObservable: Observable<RenderTargetTexture>;
  39098. /**
  39099. * An event triggered when the texture is unbind.
  39100. */
  39101. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  39102. private _onAfterUnbindObserver;
  39103. /**
  39104. * Set a after unbind callback in the texture.
  39105. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  39106. */
  39107. set onAfterUnbind(callback: () => void);
  39108. /**
  39109. * An event triggered before rendering the texture
  39110. */
  39111. onBeforeRenderObservable: Observable<number>;
  39112. private _onBeforeRenderObserver;
  39113. /**
  39114. * Set a before render callback in the texture.
  39115. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  39116. */
  39117. set onBeforeRender(callback: (faceIndex: number) => void);
  39118. /**
  39119. * An event triggered after rendering the texture
  39120. */
  39121. onAfterRenderObservable: Observable<number>;
  39122. private _onAfterRenderObserver;
  39123. /**
  39124. * Set a after render callback in the texture.
  39125. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  39126. */
  39127. set onAfterRender(callback: (faceIndex: number) => void);
  39128. /**
  39129. * An event triggered after the texture clear
  39130. */
  39131. onClearObservable: Observable<Engine>;
  39132. private _onClearObserver;
  39133. /**
  39134. * Set a clear callback in the texture.
  39135. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  39136. */
  39137. set onClear(callback: (Engine: Engine) => void);
  39138. /**
  39139. * An event triggered when the texture is resized.
  39140. */
  39141. onResizeObservable: Observable<RenderTargetTexture>;
  39142. /**
  39143. * Define the clear color of the Render Target if it should be different from the scene.
  39144. */
  39145. clearColor: Color4;
  39146. protected _size: number | {
  39147. width: number;
  39148. height: number;
  39149. layers?: number;
  39150. };
  39151. protected _initialSizeParameter: number | {
  39152. width: number;
  39153. height: number;
  39154. } | {
  39155. ratio: number;
  39156. };
  39157. protected _sizeRatio: Nullable<number>;
  39158. /** @hidden */
  39159. _generateMipMaps: boolean;
  39160. protected _renderingManager: RenderingManager;
  39161. /** @hidden */
  39162. _waitingRenderList?: string[];
  39163. protected _doNotChangeAspectRatio: boolean;
  39164. protected _currentRefreshId: number;
  39165. protected _refreshRate: number;
  39166. protected _textureMatrix: Matrix;
  39167. protected _samples: number;
  39168. protected _renderTargetOptions: RenderTargetCreationOptions;
  39169. /**
  39170. * Gets render target creation options that were used.
  39171. */
  39172. get renderTargetOptions(): RenderTargetCreationOptions;
  39173. protected _onRatioRescale(): void;
  39174. /**
  39175. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  39176. * It must define where the camera used to render the texture is set
  39177. */
  39178. boundingBoxPosition: Vector3;
  39179. private _boundingBoxSize;
  39180. /**
  39181. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  39182. * When defined, the cubemap will switch to local mode
  39183. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  39184. * @example https://www.babylonjs-playground.com/#RNASML
  39185. */
  39186. set boundingBoxSize(value: Vector3);
  39187. get boundingBoxSize(): Vector3;
  39188. /**
  39189. * In case the RTT has been created with a depth texture, get the associated
  39190. * depth texture.
  39191. * Otherwise, return null.
  39192. */
  39193. get depthStencilTexture(): Nullable<InternalTexture>;
  39194. /**
  39195. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  39196. * or used a shadow, depth texture...
  39197. * @param name The friendly name of the texture
  39198. * @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)
  39199. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  39200. * @param generateMipMaps True if mip maps need to be generated after render.
  39201. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  39202. * @param type The type of the buffer in the RTT (int, half float, float...)
  39203. * @param isCube True if a cube texture needs to be created
  39204. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  39205. * @param generateDepthBuffer True to generate a depth buffer
  39206. * @param generateStencilBuffer True to generate a stencil buffer
  39207. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  39208. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  39209. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39210. */
  39211. constructor(name: string, size: number | {
  39212. width: number;
  39213. height: number;
  39214. layers?: number;
  39215. } | {
  39216. ratio: number;
  39217. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  39218. /**
  39219. * Creates a depth stencil texture.
  39220. * This is only available in WebGL 2 or with the depth texture extension available.
  39221. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  39222. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  39223. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  39224. */
  39225. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  39226. private _processSizeParameter;
  39227. /**
  39228. * Define the number of samples to use in case of MSAA.
  39229. * It defaults to one meaning no MSAA has been enabled.
  39230. */
  39231. get samples(): number;
  39232. set samples(value: number);
  39233. /**
  39234. * Resets the refresh counter of the texture and start bak from scratch.
  39235. * Could be useful to regenerate the texture if it is setup to render only once.
  39236. */
  39237. resetRefreshCounter(): void;
  39238. /**
  39239. * Define the refresh rate of the texture or the rendering frequency.
  39240. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  39241. */
  39242. get refreshRate(): number;
  39243. set refreshRate(value: number);
  39244. /**
  39245. * Adds a post process to the render target rendering passes.
  39246. * @param postProcess define the post process to add
  39247. */
  39248. addPostProcess(postProcess: PostProcess): void;
  39249. /**
  39250. * Clear all the post processes attached to the render target
  39251. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  39252. */
  39253. clearPostProcesses(dispose?: boolean): void;
  39254. /**
  39255. * Remove one of the post process from the list of attached post processes to the texture
  39256. * @param postProcess define the post process to remove from the list
  39257. */
  39258. removePostProcess(postProcess: PostProcess): void;
  39259. /** @hidden */
  39260. _shouldRender(): boolean;
  39261. /**
  39262. * Gets the actual render size of the texture.
  39263. * @returns the width of the render size
  39264. */
  39265. getRenderSize(): number;
  39266. /**
  39267. * Gets the actual render width of the texture.
  39268. * @returns the width of the render size
  39269. */
  39270. getRenderWidth(): number;
  39271. /**
  39272. * Gets the actual render height of the texture.
  39273. * @returns the height of the render size
  39274. */
  39275. getRenderHeight(): number;
  39276. /**
  39277. * Gets the actual number of layers of the texture.
  39278. * @returns the number of layers
  39279. */
  39280. getRenderLayers(): number;
  39281. /**
  39282. * Get if the texture can be rescaled or not.
  39283. */
  39284. get canRescale(): boolean;
  39285. /**
  39286. * Resize the texture using a ratio.
  39287. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  39288. */
  39289. scale(ratio: number): void;
  39290. /**
  39291. * Get the texture reflection matrix used to rotate/transform the reflection.
  39292. * @returns the reflection matrix
  39293. */
  39294. getReflectionTextureMatrix(): Matrix;
  39295. /**
  39296. * Resize the texture to a new desired size.
  39297. * Be carrefull as it will recreate all the data in the new texture.
  39298. * @param size Define the new size. It can be:
  39299. * - a number for squared texture,
  39300. * - an object containing { width: number, height: number }
  39301. * - or an object containing a ratio { ratio: number }
  39302. */
  39303. resize(size: number | {
  39304. width: number;
  39305. height: number;
  39306. } | {
  39307. ratio: number;
  39308. }): void;
  39309. private _defaultRenderListPrepared;
  39310. /**
  39311. * Renders all the objects from the render list into the texture.
  39312. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  39313. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  39314. */
  39315. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  39316. private _bestReflectionRenderTargetDimension;
  39317. private _prepareRenderingManager;
  39318. /**
  39319. * @hidden
  39320. * @param faceIndex face index to bind to if this is a cubetexture
  39321. * @param layer defines the index of the texture to bind in the array
  39322. */
  39323. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  39324. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  39325. private renderToTarget;
  39326. /**
  39327. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  39328. * This allowed control for front to back rendering or reversly depending of the special needs.
  39329. *
  39330. * @param renderingGroupId The rendering group id corresponding to its index
  39331. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  39332. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  39333. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  39334. */
  39335. 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;
  39336. /**
  39337. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  39338. *
  39339. * @param renderingGroupId The rendering group id corresponding to its index
  39340. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  39341. */
  39342. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  39343. /**
  39344. * Clones the texture.
  39345. * @returns the cloned texture
  39346. */
  39347. clone(): RenderTargetTexture;
  39348. /**
  39349. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  39350. * @returns The JSON representation of the texture
  39351. */
  39352. serialize(): any;
  39353. /**
  39354. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  39355. */
  39356. disposeFramebufferObjects(): void;
  39357. /**
  39358. * Dispose the texture and release its associated resources.
  39359. */
  39360. dispose(): void;
  39361. /** @hidden */
  39362. _rebuild(): void;
  39363. /**
  39364. * Clear the info related to rendering groups preventing retention point in material dispose.
  39365. */
  39366. freeRenderingGroups(): void;
  39367. /**
  39368. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  39369. * @returns the view count
  39370. */
  39371. getViewCount(): number;
  39372. }
  39373. }
  39374. declare module "babylonjs/Materials/effect" {
  39375. import { Observable } from "babylonjs/Misc/observable";
  39376. import { Nullable } from "babylonjs/types";
  39377. import { IDisposable } from "babylonjs/scene";
  39378. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39379. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39380. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39381. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39382. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39383. import { Engine } from "babylonjs/Engines/engine";
  39384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39385. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  39386. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39387. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39388. /**
  39389. * Options to be used when creating an effect.
  39390. */
  39391. export interface IEffectCreationOptions {
  39392. /**
  39393. * Atrributes that will be used in the shader.
  39394. */
  39395. attributes: string[];
  39396. /**
  39397. * Uniform varible names that will be set in the shader.
  39398. */
  39399. uniformsNames: string[];
  39400. /**
  39401. * Uniform buffer variable names that will be set in the shader.
  39402. */
  39403. uniformBuffersNames: string[];
  39404. /**
  39405. * Sampler texture variable names that will be set in the shader.
  39406. */
  39407. samplers: string[];
  39408. /**
  39409. * Define statements that will be set in the shader.
  39410. */
  39411. defines: any;
  39412. /**
  39413. * Possible fallbacks for this effect to improve performance when needed.
  39414. */
  39415. fallbacks: Nullable<IEffectFallbacks>;
  39416. /**
  39417. * Callback that will be called when the shader is compiled.
  39418. */
  39419. onCompiled: Nullable<(effect: Effect) => void>;
  39420. /**
  39421. * Callback that will be called if an error occurs during shader compilation.
  39422. */
  39423. onError: Nullable<(effect: Effect, errors: string) => void>;
  39424. /**
  39425. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39426. */
  39427. indexParameters?: any;
  39428. /**
  39429. * Max number of lights that can be used in the shader.
  39430. */
  39431. maxSimultaneousLights?: number;
  39432. /**
  39433. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39434. */
  39435. transformFeedbackVaryings?: Nullable<string[]>;
  39436. /**
  39437. * 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
  39438. */
  39439. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39440. /**
  39441. * Is this effect rendering to several color attachments ?
  39442. */
  39443. multiTarget?: boolean;
  39444. }
  39445. /**
  39446. * Effect containing vertex and fragment shader that can be executed on an object.
  39447. */
  39448. export class Effect implements IDisposable {
  39449. /**
  39450. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39451. */
  39452. static ShadersRepository: string;
  39453. /**
  39454. * Enable logging of the shader code when a compilation error occurs
  39455. */
  39456. static LogShaderCodeOnCompilationError: boolean;
  39457. /**
  39458. * Name of the effect.
  39459. */
  39460. name: any;
  39461. /**
  39462. * String container all the define statements that should be set on the shader.
  39463. */
  39464. defines: string;
  39465. /**
  39466. * Callback that will be called when the shader is compiled.
  39467. */
  39468. onCompiled: Nullable<(effect: Effect) => void>;
  39469. /**
  39470. * Callback that will be called if an error occurs during shader compilation.
  39471. */
  39472. onError: Nullable<(effect: Effect, errors: string) => void>;
  39473. /**
  39474. * Callback that will be called when effect is bound.
  39475. */
  39476. onBind: Nullable<(effect: Effect) => void>;
  39477. /**
  39478. * Unique ID of the effect.
  39479. */
  39480. uniqueId: number;
  39481. /**
  39482. * Observable that will be called when the shader is compiled.
  39483. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39484. */
  39485. onCompileObservable: Observable<Effect>;
  39486. /**
  39487. * Observable that will be called if an error occurs during shader compilation.
  39488. */
  39489. onErrorObservable: Observable<Effect>;
  39490. /** @hidden */
  39491. _onBindObservable: Nullable<Observable<Effect>>;
  39492. /**
  39493. * @hidden
  39494. * Specifies if the effect was previously ready
  39495. */
  39496. _wasPreviouslyReady: boolean;
  39497. /**
  39498. * Observable that will be called when effect is bound.
  39499. */
  39500. get onBindObservable(): Observable<Effect>;
  39501. /** @hidden */
  39502. _bonesComputationForcedToCPU: boolean;
  39503. /** @hidden */
  39504. _multiTarget: boolean;
  39505. private static _uniqueIdSeed;
  39506. private _engine;
  39507. private _uniformBuffersNames;
  39508. private _uniformBuffersNamesList;
  39509. private _uniformsNames;
  39510. private _samplerList;
  39511. private _samplers;
  39512. private _isReady;
  39513. private _compilationError;
  39514. private _allFallbacksProcessed;
  39515. private _attributesNames;
  39516. private _attributes;
  39517. private _attributeLocationByName;
  39518. private _uniforms;
  39519. /**
  39520. * Key for the effect.
  39521. * @hidden
  39522. */
  39523. _key: string;
  39524. private _indexParameters;
  39525. private _fallbacks;
  39526. private _vertexSourceCode;
  39527. private _fragmentSourceCode;
  39528. private _vertexSourceCodeOverride;
  39529. private _fragmentSourceCodeOverride;
  39530. private _transformFeedbackVaryings;
  39531. private _rawVertexSourceCode;
  39532. private _rawFragmentSourceCode;
  39533. /**
  39534. * Compiled shader to webGL program.
  39535. * @hidden
  39536. */
  39537. _pipelineContext: Nullable<IPipelineContext>;
  39538. private _valueCache;
  39539. private static _baseCache;
  39540. /**
  39541. * Instantiates an effect.
  39542. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39543. * @param baseName Name of the effect.
  39544. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39545. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39546. * @param samplers List of sampler variables that will be passed to the shader.
  39547. * @param engine Engine to be used to render the effect
  39548. * @param defines Define statements to be added to the shader.
  39549. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39550. * @param onCompiled Callback that will be called when the shader is compiled.
  39551. * @param onError Callback that will be called if an error occurs during shader compilation.
  39552. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39553. */
  39554. 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);
  39555. private _useFinalCode;
  39556. /**
  39557. * Unique key for this effect
  39558. */
  39559. get key(): string;
  39560. /**
  39561. * If the effect has been compiled and prepared.
  39562. * @returns if the effect is compiled and prepared.
  39563. */
  39564. isReady(): boolean;
  39565. private _isReadyInternal;
  39566. /**
  39567. * The engine the effect was initialized with.
  39568. * @returns the engine.
  39569. */
  39570. getEngine(): Engine;
  39571. /**
  39572. * The pipeline context for this effect
  39573. * @returns the associated pipeline context
  39574. */
  39575. getPipelineContext(): Nullable<IPipelineContext>;
  39576. /**
  39577. * The set of names of attribute variables for the shader.
  39578. * @returns An array of attribute names.
  39579. */
  39580. getAttributesNames(): string[];
  39581. /**
  39582. * Returns the attribute at the given index.
  39583. * @param index The index of the attribute.
  39584. * @returns The location of the attribute.
  39585. */
  39586. getAttributeLocation(index: number): number;
  39587. /**
  39588. * Returns the attribute based on the name of the variable.
  39589. * @param name of the attribute to look up.
  39590. * @returns the attribute location.
  39591. */
  39592. getAttributeLocationByName(name: string): number;
  39593. /**
  39594. * The number of attributes.
  39595. * @returns the numnber of attributes.
  39596. */
  39597. getAttributesCount(): number;
  39598. /**
  39599. * Gets the index of a uniform variable.
  39600. * @param uniformName of the uniform to look up.
  39601. * @returns the index.
  39602. */
  39603. getUniformIndex(uniformName: string): number;
  39604. /**
  39605. * Returns the attribute based on the name of the variable.
  39606. * @param uniformName of the uniform to look up.
  39607. * @returns the location of the uniform.
  39608. */
  39609. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39610. /**
  39611. * Returns an array of sampler variable names
  39612. * @returns The array of sampler variable names.
  39613. */
  39614. getSamplers(): string[];
  39615. /**
  39616. * Returns an array of uniform variable names
  39617. * @returns The array of uniform variable names.
  39618. */
  39619. getUniformNames(): string[];
  39620. /**
  39621. * Returns an array of uniform buffer variable names
  39622. * @returns The array of uniform buffer variable names.
  39623. */
  39624. getUniformBuffersNames(): string[];
  39625. /**
  39626. * Returns the index parameters used to create the effect
  39627. * @returns The index parameters object
  39628. */
  39629. getIndexParameters(): any;
  39630. /**
  39631. * The error from the last compilation.
  39632. * @returns the error string.
  39633. */
  39634. getCompilationError(): string;
  39635. /**
  39636. * Gets a boolean indicating that all fallbacks were used during compilation
  39637. * @returns true if all fallbacks were used
  39638. */
  39639. allFallbacksProcessed(): boolean;
  39640. /**
  39641. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39642. * @param func The callback to be used.
  39643. */
  39644. executeWhenCompiled(func: (effect: Effect) => void): void;
  39645. private _checkIsReady;
  39646. private _loadShader;
  39647. /**
  39648. * Gets the vertex shader source code of this effect
  39649. */
  39650. get vertexSourceCode(): string;
  39651. /**
  39652. * Gets the fragment shader source code of this effect
  39653. */
  39654. get fragmentSourceCode(): string;
  39655. /**
  39656. * Gets the vertex shader source code before it has been processed by the preprocessor
  39657. */
  39658. get rawVertexSourceCode(): string;
  39659. /**
  39660. * Gets the fragment shader source code before it has been processed by the preprocessor
  39661. */
  39662. get rawFragmentSourceCode(): string;
  39663. /**
  39664. * Recompiles the webGL program
  39665. * @param vertexSourceCode The source code for the vertex shader.
  39666. * @param fragmentSourceCode The source code for the fragment shader.
  39667. * @param onCompiled Callback called when completed.
  39668. * @param onError Callback called on error.
  39669. * @hidden
  39670. */
  39671. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39672. /**
  39673. * Prepares the effect
  39674. * @hidden
  39675. */
  39676. _prepareEffect(): void;
  39677. private _getShaderCodeAndErrorLine;
  39678. private _processCompilationErrors;
  39679. /**
  39680. * Checks if the effect is supported. (Must be called after compilation)
  39681. */
  39682. get isSupported(): boolean;
  39683. /**
  39684. * Binds a texture to the engine to be used as output of the shader.
  39685. * @param channel Name of the output variable.
  39686. * @param texture Texture to bind.
  39687. * @hidden
  39688. */
  39689. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39690. /**
  39691. * Sets a texture on the engine to be used in the shader.
  39692. * @param channel Name of the sampler variable.
  39693. * @param texture Texture to set.
  39694. */
  39695. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39696. /**
  39697. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39698. * @param channel Name of the sampler variable.
  39699. * @param texture Texture to set.
  39700. */
  39701. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39702. /**
  39703. * Sets an array of textures on the engine to be used in the shader.
  39704. * @param channel Name of the variable.
  39705. * @param textures Textures to set.
  39706. */
  39707. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39708. /**
  39709. * 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)
  39710. * @param channel Name of the sampler variable.
  39711. * @param postProcess Post process to get the input texture from.
  39712. */
  39713. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39714. /**
  39715. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39716. * 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)
  39717. * @param channel Name of the sampler variable.
  39718. * @param postProcess Post process to get the output texture from.
  39719. */
  39720. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39721. /** @hidden */
  39722. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39723. /** @hidden */
  39724. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39725. /** @hidden */
  39726. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39727. /** @hidden */
  39728. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39729. /**
  39730. * Binds a buffer to a uniform.
  39731. * @param buffer Buffer to bind.
  39732. * @param name Name of the uniform variable to bind to.
  39733. */
  39734. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39735. /**
  39736. * Binds block to a uniform.
  39737. * @param blockName Name of the block to bind.
  39738. * @param index Index to bind.
  39739. */
  39740. bindUniformBlock(blockName: string, index: number): void;
  39741. /**
  39742. * Sets an interger value on a uniform variable.
  39743. * @param uniformName Name of the variable.
  39744. * @param value Value to be set.
  39745. * @returns this effect.
  39746. */
  39747. setInt(uniformName: string, value: number): Effect;
  39748. /**
  39749. * Sets an int array on a uniform variable.
  39750. * @param uniformName Name of the variable.
  39751. * @param array array to be set.
  39752. * @returns this effect.
  39753. */
  39754. setIntArray(uniformName: string, array: Int32Array): Effect;
  39755. /**
  39756. * 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)
  39757. * @param uniformName Name of the variable.
  39758. * @param array array to be set.
  39759. * @returns this effect.
  39760. */
  39761. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39762. /**
  39763. * 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)
  39764. * @param uniformName Name of the variable.
  39765. * @param array array to be set.
  39766. * @returns this effect.
  39767. */
  39768. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39769. /**
  39770. * 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)
  39771. * @param uniformName Name of the variable.
  39772. * @param array array to be set.
  39773. * @returns this effect.
  39774. */
  39775. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39776. /**
  39777. * Sets an float array on a uniform variable.
  39778. * @param uniformName Name of the variable.
  39779. * @param array array to be set.
  39780. * @returns this effect.
  39781. */
  39782. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39783. /**
  39784. * 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)
  39785. * @param uniformName Name of the variable.
  39786. * @param array array to be set.
  39787. * @returns this effect.
  39788. */
  39789. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39790. /**
  39791. * 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)
  39792. * @param uniformName Name of the variable.
  39793. * @param array array to be set.
  39794. * @returns this effect.
  39795. */
  39796. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39797. /**
  39798. * 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)
  39799. * @param uniformName Name of the variable.
  39800. * @param array array to be set.
  39801. * @returns this effect.
  39802. */
  39803. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39804. /**
  39805. * Sets an array on a uniform variable.
  39806. * @param uniformName Name of the variable.
  39807. * @param array array to be set.
  39808. * @returns this effect.
  39809. */
  39810. setArray(uniformName: string, array: number[]): Effect;
  39811. /**
  39812. * 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)
  39813. * @param uniformName Name of the variable.
  39814. * @param array array to be set.
  39815. * @returns this effect.
  39816. */
  39817. setArray2(uniformName: string, array: number[]): Effect;
  39818. /**
  39819. * 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)
  39820. * @param uniformName Name of the variable.
  39821. * @param array array to be set.
  39822. * @returns this effect.
  39823. */
  39824. setArray3(uniformName: string, array: number[]): Effect;
  39825. /**
  39826. * 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)
  39827. * @param uniformName Name of the variable.
  39828. * @param array array to be set.
  39829. * @returns this effect.
  39830. */
  39831. setArray4(uniformName: string, array: number[]): Effect;
  39832. /**
  39833. * Sets matrices on a uniform variable.
  39834. * @param uniformName Name of the variable.
  39835. * @param matrices matrices to be set.
  39836. * @returns this effect.
  39837. */
  39838. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39839. /**
  39840. * Sets matrix on a uniform variable.
  39841. * @param uniformName Name of the variable.
  39842. * @param matrix matrix to be set.
  39843. * @returns this effect.
  39844. */
  39845. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39846. /**
  39847. * 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)
  39848. * @param uniformName Name of the variable.
  39849. * @param matrix matrix to be set.
  39850. * @returns this effect.
  39851. */
  39852. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39853. /**
  39854. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39855. * @param uniformName Name of the variable.
  39856. * @param matrix matrix to be set.
  39857. * @returns this effect.
  39858. */
  39859. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39860. /**
  39861. * Sets a float on a uniform variable.
  39862. * @param uniformName Name of the variable.
  39863. * @param value value to be set.
  39864. * @returns this effect.
  39865. */
  39866. setFloat(uniformName: string, value: number): Effect;
  39867. /**
  39868. * Sets a boolean on a uniform variable.
  39869. * @param uniformName Name of the variable.
  39870. * @param bool value to be set.
  39871. * @returns this effect.
  39872. */
  39873. setBool(uniformName: string, bool: boolean): Effect;
  39874. /**
  39875. * Sets a Vector2 on a uniform variable.
  39876. * @param uniformName Name of the variable.
  39877. * @param vector2 vector2 to be set.
  39878. * @returns this effect.
  39879. */
  39880. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39881. /**
  39882. * Sets a float2 on a uniform variable.
  39883. * @param uniformName Name of the variable.
  39884. * @param x First float in float2.
  39885. * @param y Second float in float2.
  39886. * @returns this effect.
  39887. */
  39888. setFloat2(uniformName: string, x: number, y: number): Effect;
  39889. /**
  39890. * Sets a Vector3 on a uniform variable.
  39891. * @param uniformName Name of the variable.
  39892. * @param vector3 Value to be set.
  39893. * @returns this effect.
  39894. */
  39895. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39896. /**
  39897. * Sets a float3 on a uniform variable.
  39898. * @param uniformName Name of the variable.
  39899. * @param x First float in float3.
  39900. * @param y Second float in float3.
  39901. * @param z Third float in float3.
  39902. * @returns this effect.
  39903. */
  39904. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39905. /**
  39906. * Sets a Vector4 on a uniform variable.
  39907. * @param uniformName Name of the variable.
  39908. * @param vector4 Value to be set.
  39909. * @returns this effect.
  39910. */
  39911. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39912. /**
  39913. * Sets a float4 on a uniform variable.
  39914. * @param uniformName Name of the variable.
  39915. * @param x First float in float4.
  39916. * @param y Second float in float4.
  39917. * @param z Third float in float4.
  39918. * @param w Fourth float in float4.
  39919. * @returns this effect.
  39920. */
  39921. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39922. /**
  39923. * Sets a Color3 on a uniform variable.
  39924. * @param uniformName Name of the variable.
  39925. * @param color3 Value to be set.
  39926. * @returns this effect.
  39927. */
  39928. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39929. /**
  39930. * Sets a Color4 on a uniform variable.
  39931. * @param uniformName Name of the variable.
  39932. * @param color3 Value to be set.
  39933. * @param alpha Alpha value to be set.
  39934. * @returns this effect.
  39935. */
  39936. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39937. /**
  39938. * Sets a Color4 on a uniform variable
  39939. * @param uniformName defines the name of the variable
  39940. * @param color4 defines the value to be set
  39941. * @returns this effect.
  39942. */
  39943. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39944. /** Release all associated resources */
  39945. dispose(): void;
  39946. /**
  39947. * This function will add a new shader to the shader store
  39948. * @param name the name of the shader
  39949. * @param pixelShader optional pixel shader content
  39950. * @param vertexShader optional vertex shader content
  39951. */
  39952. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39953. /**
  39954. * Store of each shader (The can be looked up using effect.key)
  39955. */
  39956. static ShadersStore: {
  39957. [key: string]: string;
  39958. };
  39959. /**
  39960. * Store of each included file for a shader (The can be looked up using effect.key)
  39961. */
  39962. static IncludesShadersStore: {
  39963. [key: string]: string;
  39964. };
  39965. /**
  39966. * Resets the cache of effects.
  39967. */
  39968. static ResetCache(): void;
  39969. }
  39970. }
  39971. declare module "babylonjs/Engines/engineCapabilities" {
  39972. /**
  39973. * Interface used to describe the capabilities of the engine relatively to the current browser
  39974. */
  39975. export interface EngineCapabilities {
  39976. /** Maximum textures units per fragment shader */
  39977. maxTexturesImageUnits: number;
  39978. /** Maximum texture units per vertex shader */
  39979. maxVertexTextureImageUnits: number;
  39980. /** Maximum textures units in the entire pipeline */
  39981. maxCombinedTexturesImageUnits: number;
  39982. /** Maximum texture size */
  39983. maxTextureSize: number;
  39984. /** Maximum texture samples */
  39985. maxSamples?: number;
  39986. /** Maximum cube texture size */
  39987. maxCubemapTextureSize: number;
  39988. /** Maximum render texture size */
  39989. maxRenderTextureSize: number;
  39990. /** Maximum number of vertex attributes */
  39991. maxVertexAttribs: number;
  39992. /** Maximum number of varyings */
  39993. maxVaryingVectors: number;
  39994. /** Maximum number of uniforms per vertex shader */
  39995. maxVertexUniformVectors: number;
  39996. /** Maximum number of uniforms per fragment shader */
  39997. maxFragmentUniformVectors: number;
  39998. /** Defines if standard derivates (dx/dy) are supported */
  39999. standardDerivatives: boolean;
  40000. /** Defines if s3tc texture compression is supported */
  40001. s3tc?: WEBGL_compressed_texture_s3tc;
  40002. /** Defines if pvrtc texture compression is supported */
  40003. pvrtc: any;
  40004. /** Defines if etc1 texture compression is supported */
  40005. etc1: any;
  40006. /** Defines if etc2 texture compression is supported */
  40007. etc2: any;
  40008. /** Defines if astc texture compression is supported */
  40009. astc: any;
  40010. /** Defines if bptc texture compression is supported */
  40011. bptc: any;
  40012. /** Defines if float textures are supported */
  40013. textureFloat: boolean;
  40014. /** Defines if vertex array objects are supported */
  40015. vertexArrayObject: boolean;
  40016. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  40017. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  40018. /** Gets the maximum level of anisotropy supported */
  40019. maxAnisotropy: number;
  40020. /** Defines if instancing is supported */
  40021. instancedArrays: boolean;
  40022. /** Defines if 32 bits indices are supported */
  40023. uintIndices: boolean;
  40024. /** Defines if high precision shaders are supported */
  40025. highPrecisionShaderSupported: boolean;
  40026. /** Defines if depth reading in the fragment shader is supported */
  40027. fragmentDepthSupported: boolean;
  40028. /** Defines if float texture linear filtering is supported*/
  40029. textureFloatLinearFiltering: boolean;
  40030. /** Defines if rendering to float textures is supported */
  40031. textureFloatRender: boolean;
  40032. /** Defines if half float textures are supported*/
  40033. textureHalfFloat: boolean;
  40034. /** Defines if half float texture linear filtering is supported*/
  40035. textureHalfFloatLinearFiltering: boolean;
  40036. /** Defines if rendering to half float textures is supported */
  40037. textureHalfFloatRender: boolean;
  40038. /** Defines if textureLOD shader command is supported */
  40039. textureLOD: boolean;
  40040. /** Defines if draw buffers extension is supported */
  40041. drawBuffersExtension: boolean;
  40042. /** Defines if depth textures are supported */
  40043. depthTextureExtension: boolean;
  40044. /** Defines if float color buffer are supported */
  40045. colorBufferFloat: boolean;
  40046. /** Gets disjoint timer query extension (null if not supported) */
  40047. timerQuery?: EXT_disjoint_timer_query;
  40048. /** Defines if timestamp can be used with timer query */
  40049. canUseTimestampForTimerQuery: boolean;
  40050. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  40051. multiview?: any;
  40052. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  40053. oculusMultiview?: any;
  40054. /** Function used to let the system compiles shaders in background */
  40055. parallelShaderCompile?: {
  40056. COMPLETION_STATUS_KHR: number;
  40057. };
  40058. /** Max number of texture samples for MSAA */
  40059. maxMSAASamples: number;
  40060. /** Defines if the blend min max extension is supported */
  40061. blendMinMax: boolean;
  40062. }
  40063. }
  40064. declare module "babylonjs/States/depthCullingState" {
  40065. import { Nullable } from "babylonjs/types";
  40066. /**
  40067. * @hidden
  40068. **/
  40069. export class DepthCullingState {
  40070. private _isDepthTestDirty;
  40071. private _isDepthMaskDirty;
  40072. private _isDepthFuncDirty;
  40073. private _isCullFaceDirty;
  40074. private _isCullDirty;
  40075. private _isZOffsetDirty;
  40076. private _isFrontFaceDirty;
  40077. private _depthTest;
  40078. private _depthMask;
  40079. private _depthFunc;
  40080. private _cull;
  40081. private _cullFace;
  40082. private _zOffset;
  40083. private _frontFace;
  40084. /**
  40085. * Initializes the state.
  40086. */
  40087. constructor();
  40088. get isDirty(): boolean;
  40089. get zOffset(): number;
  40090. set zOffset(value: number);
  40091. get cullFace(): Nullable<number>;
  40092. set cullFace(value: Nullable<number>);
  40093. get cull(): Nullable<boolean>;
  40094. set cull(value: Nullable<boolean>);
  40095. get depthFunc(): Nullable<number>;
  40096. set depthFunc(value: Nullable<number>);
  40097. get depthMask(): boolean;
  40098. set depthMask(value: boolean);
  40099. get depthTest(): boolean;
  40100. set depthTest(value: boolean);
  40101. get frontFace(): Nullable<number>;
  40102. set frontFace(value: Nullable<number>);
  40103. reset(): void;
  40104. apply(gl: WebGLRenderingContext): void;
  40105. }
  40106. }
  40107. declare module "babylonjs/States/stencilState" {
  40108. /**
  40109. * @hidden
  40110. **/
  40111. export class StencilState {
  40112. /** 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 */
  40113. static readonly ALWAYS: number;
  40114. /** Passed to stencilOperation to specify that stencil value must be kept */
  40115. static readonly KEEP: number;
  40116. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40117. static readonly REPLACE: number;
  40118. private _isStencilTestDirty;
  40119. private _isStencilMaskDirty;
  40120. private _isStencilFuncDirty;
  40121. private _isStencilOpDirty;
  40122. private _stencilTest;
  40123. private _stencilMask;
  40124. private _stencilFunc;
  40125. private _stencilFuncRef;
  40126. private _stencilFuncMask;
  40127. private _stencilOpStencilFail;
  40128. private _stencilOpDepthFail;
  40129. private _stencilOpStencilDepthPass;
  40130. get isDirty(): boolean;
  40131. get stencilFunc(): number;
  40132. set stencilFunc(value: number);
  40133. get stencilFuncRef(): number;
  40134. set stencilFuncRef(value: number);
  40135. get stencilFuncMask(): number;
  40136. set stencilFuncMask(value: number);
  40137. get stencilOpStencilFail(): number;
  40138. set stencilOpStencilFail(value: number);
  40139. get stencilOpDepthFail(): number;
  40140. set stencilOpDepthFail(value: number);
  40141. get stencilOpStencilDepthPass(): number;
  40142. set stencilOpStencilDepthPass(value: number);
  40143. get stencilMask(): number;
  40144. set stencilMask(value: number);
  40145. get stencilTest(): boolean;
  40146. set stencilTest(value: boolean);
  40147. constructor();
  40148. reset(): void;
  40149. apply(gl: WebGLRenderingContext): void;
  40150. }
  40151. }
  40152. declare module "babylonjs/States/alphaCullingState" {
  40153. /**
  40154. * @hidden
  40155. **/
  40156. export class AlphaState {
  40157. private _isAlphaBlendDirty;
  40158. private _isBlendFunctionParametersDirty;
  40159. private _isBlendEquationParametersDirty;
  40160. private _isBlendConstantsDirty;
  40161. private _alphaBlend;
  40162. private _blendFunctionParameters;
  40163. private _blendEquationParameters;
  40164. private _blendConstants;
  40165. /**
  40166. * Initializes the state.
  40167. */
  40168. constructor();
  40169. get isDirty(): boolean;
  40170. get alphaBlend(): boolean;
  40171. set alphaBlend(value: boolean);
  40172. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  40173. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  40174. setAlphaEquationParameters(rgb: number, alpha: number): void;
  40175. reset(): void;
  40176. apply(gl: WebGLRenderingContext): void;
  40177. }
  40178. }
  40179. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  40180. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40181. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  40182. /** @hidden */
  40183. export class WebGLShaderProcessor implements IShaderProcessor {
  40184. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  40185. }
  40186. }
  40187. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  40188. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40189. /** @hidden */
  40190. export class WebGL2ShaderProcessor implements IShaderProcessor {
  40191. attributeProcessor(attribute: string): string;
  40192. varyingProcessor(varying: string, isFragment: boolean): string;
  40193. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  40194. }
  40195. }
  40196. declare module "babylonjs/Engines/instancingAttributeInfo" {
  40197. /**
  40198. * Interface for attribute information associated with buffer instanciation
  40199. */
  40200. export interface InstancingAttributeInfo {
  40201. /**
  40202. * Name of the GLSL attribute
  40203. * if attribute index is not specified, this is used to retrieve the index from the effect
  40204. */
  40205. attributeName: string;
  40206. /**
  40207. * Index/offset of the attribute in the vertex shader
  40208. * if not specified, this will be computes from the name.
  40209. */
  40210. index?: number;
  40211. /**
  40212. * size of the attribute, 1, 2, 3 or 4
  40213. */
  40214. attributeSize: number;
  40215. /**
  40216. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  40217. */
  40218. offset: number;
  40219. /**
  40220. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  40221. * default to 1
  40222. */
  40223. divisor?: number;
  40224. /**
  40225. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  40226. * default is FLOAT
  40227. */
  40228. attributeType?: number;
  40229. /**
  40230. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  40231. */
  40232. normalized?: boolean;
  40233. }
  40234. }
  40235. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  40236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40237. import { Nullable } from "babylonjs/types";
  40238. module "babylonjs/Engines/thinEngine" {
  40239. interface ThinEngine {
  40240. /**
  40241. * Update a video texture
  40242. * @param texture defines the texture to update
  40243. * @param video defines the video element to use
  40244. * @param invertY defines if data must be stored with Y axis inverted
  40245. */
  40246. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  40247. }
  40248. }
  40249. }
  40250. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  40251. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40252. import { Nullable } from "babylonjs/types";
  40253. module "babylonjs/Engines/thinEngine" {
  40254. interface ThinEngine {
  40255. /**
  40256. * Creates a dynamic texture
  40257. * @param width defines the width of the texture
  40258. * @param height defines the height of the texture
  40259. * @param generateMipMaps defines if the engine should generate the mip levels
  40260. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  40261. * @returns the dynamic texture inside an InternalTexture
  40262. */
  40263. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  40264. /**
  40265. * Update the content of a dynamic texture
  40266. * @param texture defines the texture to update
  40267. * @param source defines the source containing the data
  40268. * @param invertY defines if data must be stored with Y axis inverted
  40269. * @param premulAlpha defines if alpha is stored as premultiplied
  40270. * @param format defines the format of the data
  40271. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  40272. */
  40273. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  40274. }
  40275. }
  40276. }
  40277. declare module "babylonjs/Materials/Textures/videoTexture" {
  40278. import { Observable } from "babylonjs/Misc/observable";
  40279. import { Nullable } from "babylonjs/types";
  40280. import { Scene } from "babylonjs/scene";
  40281. import { Texture } from "babylonjs/Materials/Textures/texture";
  40282. import "babylonjs/Engines/Extensions/engine.videoTexture";
  40283. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  40284. /**
  40285. * Settings for finer control over video usage
  40286. */
  40287. export interface VideoTextureSettings {
  40288. /**
  40289. * Applies `autoplay` to video, if specified
  40290. */
  40291. autoPlay?: boolean;
  40292. /**
  40293. * Applies `muted` to video, if specified
  40294. */
  40295. muted?: boolean;
  40296. /**
  40297. * Applies `loop` to video, if specified
  40298. */
  40299. loop?: boolean;
  40300. /**
  40301. * Automatically updates internal texture from video at every frame in the render loop
  40302. */
  40303. autoUpdateTexture: boolean;
  40304. /**
  40305. * Image src displayed during the video loading or until the user interacts with the video.
  40306. */
  40307. poster?: string;
  40308. }
  40309. /**
  40310. * If you want to display a video in your scene, this is the special texture for that.
  40311. * This special texture works similar to other textures, with the exception of a few parameters.
  40312. * @see https://doc.babylonjs.com/how_to/video_texture
  40313. */
  40314. export class VideoTexture extends Texture {
  40315. /**
  40316. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40317. */
  40318. readonly autoUpdateTexture: boolean;
  40319. /**
  40320. * The video instance used by the texture internally
  40321. */
  40322. readonly video: HTMLVideoElement;
  40323. private _onUserActionRequestedObservable;
  40324. /**
  40325. * Event triggerd when a dom action is required by the user to play the video.
  40326. * This happens due to recent changes in browser policies preventing video to auto start.
  40327. */
  40328. get onUserActionRequestedObservable(): Observable<Texture>;
  40329. private _generateMipMaps;
  40330. private _stillImageCaptured;
  40331. private _displayingPosterTexture;
  40332. private _settings;
  40333. private _createInternalTextureOnEvent;
  40334. private _frameId;
  40335. private _currentSrc;
  40336. /**
  40337. * Creates a video texture.
  40338. * If you want to display a video in your scene, this is the special texture for that.
  40339. * This special texture works similar to other textures, with the exception of a few parameters.
  40340. * @see https://doc.babylonjs.com/how_to/video_texture
  40341. * @param name optional name, will detect from video source, if not defined
  40342. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40343. * @param scene is obviously the current scene.
  40344. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40345. * @param invertY is false by default but can be used to invert video on Y axis
  40346. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40347. * @param settings allows finer control over video usage
  40348. */
  40349. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40350. private _getName;
  40351. private _getVideo;
  40352. private _createInternalTexture;
  40353. private reset;
  40354. /**
  40355. * @hidden Internal method to initiate `update`.
  40356. */
  40357. _rebuild(): void;
  40358. /**
  40359. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40360. */
  40361. update(): void;
  40362. /**
  40363. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40364. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40365. */
  40366. updateTexture(isVisible: boolean): void;
  40367. protected _updateInternalTexture: () => void;
  40368. /**
  40369. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40370. * @param url New url.
  40371. */
  40372. updateURL(url: string): void;
  40373. /**
  40374. * Clones the texture.
  40375. * @returns the cloned texture
  40376. */
  40377. clone(): VideoTexture;
  40378. /**
  40379. * Dispose the texture and release its associated resources.
  40380. */
  40381. dispose(): void;
  40382. /**
  40383. * Creates a video texture straight from a stream.
  40384. * @param scene Define the scene the texture should be created in
  40385. * @param stream Define the stream the texture should be created from
  40386. * @returns The created video texture as a promise
  40387. */
  40388. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40389. /**
  40390. * Creates a video texture straight from your WebCam video feed.
  40391. * @param scene Define the scene the texture should be created in
  40392. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40393. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40394. * @returns The created video texture as a promise
  40395. */
  40396. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40397. minWidth: number;
  40398. maxWidth: number;
  40399. minHeight: number;
  40400. maxHeight: number;
  40401. deviceId: string;
  40402. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40403. /**
  40404. * Creates a video texture straight from your WebCam video feed.
  40405. * @param scene Define the scene the texture should be created in
  40406. * @param onReady Define a callback to triggered once the texture will be ready
  40407. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40408. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40409. */
  40410. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40411. minWidth: number;
  40412. maxWidth: number;
  40413. minHeight: number;
  40414. maxHeight: number;
  40415. deviceId: string;
  40416. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40417. }
  40418. }
  40419. declare module "babylonjs/Engines/thinEngine" {
  40420. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40421. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40422. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40423. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40424. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40425. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40426. import { Observable } from "babylonjs/Misc/observable";
  40427. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40428. import { StencilState } from "babylonjs/States/stencilState";
  40429. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40430. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40431. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40432. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40433. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40435. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40436. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40437. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40438. import { ThinTexture } from "babylonjs/Materials/Textures/thinTexture";
  40439. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40440. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40441. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40442. import { WebRequest } from "babylonjs/Misc/webRequest";
  40443. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40444. /**
  40445. * Defines the interface used by objects working like Scene
  40446. * @hidden
  40447. */
  40448. export interface ISceneLike {
  40449. _addPendingData(data: any): void;
  40450. _removePendingData(data: any): void;
  40451. offlineProvider: IOfflineProvider;
  40452. }
  40453. /**
  40454. * Information about the current host
  40455. */
  40456. export interface HostInformation {
  40457. /**
  40458. * Defines if the current host is a mobile
  40459. */
  40460. isMobile: boolean;
  40461. }
  40462. /** Interface defining initialization parameters for Engine class */
  40463. export interface EngineOptions extends WebGLContextAttributes {
  40464. /**
  40465. * Defines if the engine should no exceed a specified device ratio
  40466. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40467. */
  40468. limitDeviceRatio?: number;
  40469. /**
  40470. * Defines if webvr should be enabled automatically
  40471. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40472. */
  40473. autoEnableWebVR?: boolean;
  40474. /**
  40475. * Defines if webgl2 should be turned off even if supported
  40476. * @see https://doc.babylonjs.com/features/webgl2
  40477. */
  40478. disableWebGL2Support?: boolean;
  40479. /**
  40480. * Defines if webaudio should be initialized as well
  40481. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40482. */
  40483. audioEngine?: boolean;
  40484. /**
  40485. * Defines if animations should run using a deterministic lock step
  40486. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40487. */
  40488. deterministicLockstep?: boolean;
  40489. /** Defines the maximum steps to use with deterministic lock step mode */
  40490. lockstepMaxSteps?: number;
  40491. /** Defines the seconds between each deterministic lock step */
  40492. timeStep?: number;
  40493. /**
  40494. * Defines that engine should ignore context lost events
  40495. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40496. */
  40497. doNotHandleContextLost?: boolean;
  40498. /**
  40499. * Defines that engine should ignore modifying touch action attribute and style
  40500. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40501. */
  40502. doNotHandleTouchAction?: boolean;
  40503. /**
  40504. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40505. */
  40506. useHighPrecisionFloats?: boolean;
  40507. /**
  40508. * Make the canvas XR Compatible for XR sessions
  40509. */
  40510. xrCompatible?: boolean;
  40511. /**
  40512. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40513. */
  40514. useHighPrecisionMatrix?: boolean;
  40515. /**
  40516. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40517. */
  40518. failIfMajorPerformanceCaveat?: boolean;
  40519. }
  40520. /**
  40521. * The base engine class (root of all engines)
  40522. */
  40523. export class ThinEngine {
  40524. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40525. static ExceptionList: ({
  40526. key: string;
  40527. capture: string;
  40528. captureConstraint: number;
  40529. targets: string[];
  40530. } | {
  40531. key: string;
  40532. capture: null;
  40533. captureConstraint: null;
  40534. targets: string[];
  40535. })[];
  40536. /** @hidden */
  40537. static _TextureLoaders: IInternalTextureLoader[];
  40538. /**
  40539. * Returns the current npm package of the sdk
  40540. */
  40541. static get NpmPackage(): string;
  40542. /**
  40543. * Returns the current version of the framework
  40544. */
  40545. static get Version(): string;
  40546. /**
  40547. * Returns a string describing the current engine
  40548. */
  40549. get description(): string;
  40550. /**
  40551. * Gets or sets the epsilon value used by collision engine
  40552. */
  40553. static CollisionsEpsilon: number;
  40554. /**
  40555. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40556. */
  40557. static get ShadersRepository(): string;
  40558. static set ShadersRepository(value: string);
  40559. /** @hidden */
  40560. _shaderProcessor: IShaderProcessor;
  40561. /**
  40562. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40563. */
  40564. forcePOTTextures: boolean;
  40565. /**
  40566. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40567. */
  40568. isFullscreen: boolean;
  40569. /**
  40570. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40571. */
  40572. cullBackFaces: boolean;
  40573. /**
  40574. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40575. */
  40576. renderEvenInBackground: boolean;
  40577. /**
  40578. * Gets or sets a boolean indicating that cache can be kept between frames
  40579. */
  40580. preventCacheWipeBetweenFrames: boolean;
  40581. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40582. validateShaderPrograms: boolean;
  40583. /**
  40584. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40585. * This can provide greater z depth for distant objects.
  40586. */
  40587. useReverseDepthBuffer: boolean;
  40588. /**
  40589. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40590. */
  40591. disableUniformBuffers: boolean;
  40592. /** @hidden */
  40593. _uniformBuffers: UniformBuffer[];
  40594. /**
  40595. * Gets a boolean indicating that the engine supports uniform buffers
  40596. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40597. */
  40598. get supportsUniformBuffers(): boolean;
  40599. /** @hidden */
  40600. _gl: WebGLRenderingContext;
  40601. /** @hidden */
  40602. _webGLVersion: number;
  40603. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40604. protected _windowIsBackground: boolean;
  40605. protected _creationOptions: EngineOptions;
  40606. protected _highPrecisionShadersAllowed: boolean;
  40607. /** @hidden */
  40608. get _shouldUseHighPrecisionShader(): boolean;
  40609. /**
  40610. * Gets a boolean indicating that only power of 2 textures are supported
  40611. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40612. */
  40613. get needPOTTextures(): boolean;
  40614. /** @hidden */
  40615. _badOS: boolean;
  40616. /** @hidden */
  40617. _badDesktopOS: boolean;
  40618. private _hardwareScalingLevel;
  40619. /** @hidden */
  40620. _caps: EngineCapabilities;
  40621. private _isStencilEnable;
  40622. private _glVersion;
  40623. private _glRenderer;
  40624. private _glVendor;
  40625. /** @hidden */
  40626. _videoTextureSupported: boolean;
  40627. protected _renderingQueueLaunched: boolean;
  40628. protected _activeRenderLoops: (() => void)[];
  40629. /**
  40630. * Observable signaled when a context lost event is raised
  40631. */
  40632. onContextLostObservable: Observable<ThinEngine>;
  40633. /**
  40634. * Observable signaled when a context restored event is raised
  40635. */
  40636. onContextRestoredObservable: Observable<ThinEngine>;
  40637. private _onContextLost;
  40638. private _onContextRestored;
  40639. protected _contextWasLost: boolean;
  40640. /** @hidden */
  40641. _doNotHandleContextLost: boolean;
  40642. /**
  40643. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40644. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40645. */
  40646. get doNotHandleContextLost(): boolean;
  40647. set doNotHandleContextLost(value: boolean);
  40648. /**
  40649. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40650. */
  40651. disableVertexArrayObjects: boolean;
  40652. /** @hidden */
  40653. protected _colorWrite: boolean;
  40654. /** @hidden */
  40655. protected _colorWriteChanged: boolean;
  40656. /** @hidden */
  40657. protected _depthCullingState: DepthCullingState;
  40658. /** @hidden */
  40659. protected _stencilState: StencilState;
  40660. /** @hidden */
  40661. _alphaState: AlphaState;
  40662. /** @hidden */
  40663. _alphaMode: number;
  40664. /** @hidden */
  40665. _alphaEquation: number;
  40666. /** @hidden */
  40667. _internalTexturesCache: InternalTexture[];
  40668. /** @hidden */
  40669. protected _activeChannel: number;
  40670. private _currentTextureChannel;
  40671. /** @hidden */
  40672. protected _boundTexturesCache: {
  40673. [key: string]: Nullable<InternalTexture>;
  40674. };
  40675. /** @hidden */
  40676. protected _currentEffect: Nullable<Effect>;
  40677. /** @hidden */
  40678. protected _currentProgram: Nullable<WebGLProgram>;
  40679. private _compiledEffects;
  40680. private _vertexAttribArraysEnabled;
  40681. /** @hidden */
  40682. protected _cachedViewport: Nullable<IViewportLike>;
  40683. private _cachedVertexArrayObject;
  40684. /** @hidden */
  40685. protected _cachedVertexBuffers: any;
  40686. /** @hidden */
  40687. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40688. /** @hidden */
  40689. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40690. /** @hidden */
  40691. _currentRenderTarget: Nullable<InternalTexture>;
  40692. private _uintIndicesCurrentlySet;
  40693. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40694. /** @hidden */
  40695. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40696. /** @hidden */
  40697. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40698. private _currentBufferPointers;
  40699. private _currentInstanceLocations;
  40700. private _currentInstanceBuffers;
  40701. private _textureUnits;
  40702. /** @hidden */
  40703. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40704. /** @hidden */
  40705. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40706. /** @hidden */
  40707. _boundRenderFunction: any;
  40708. private _vaoRecordInProgress;
  40709. private _mustWipeVertexAttributes;
  40710. private _emptyTexture;
  40711. private _emptyCubeTexture;
  40712. private _emptyTexture3D;
  40713. private _emptyTexture2DArray;
  40714. /** @hidden */
  40715. _frameHandler: number;
  40716. private _nextFreeTextureSlots;
  40717. private _maxSimultaneousTextures;
  40718. private _activeRequests;
  40719. /** @hidden */
  40720. _transformTextureUrl: Nullable<(url: string) => string>;
  40721. /**
  40722. * Gets information about the current host
  40723. */
  40724. hostInformation: HostInformation;
  40725. protected get _supportsHardwareTextureRescaling(): boolean;
  40726. private _framebufferDimensionsObject;
  40727. /**
  40728. * sets the object from which width and height will be taken from when getting render width and height
  40729. * Will fallback to the gl object
  40730. * @param dimensions the framebuffer width and height that will be used.
  40731. */
  40732. set framebufferDimensionsObject(dimensions: Nullable<{
  40733. framebufferWidth: number;
  40734. framebufferHeight: number;
  40735. }>);
  40736. /**
  40737. * Gets the current viewport
  40738. */
  40739. get currentViewport(): Nullable<IViewportLike>;
  40740. /**
  40741. * Gets the default empty texture
  40742. */
  40743. get emptyTexture(): InternalTexture;
  40744. /**
  40745. * Gets the default empty 3D texture
  40746. */
  40747. get emptyTexture3D(): InternalTexture;
  40748. /**
  40749. * Gets the default empty 2D array texture
  40750. */
  40751. get emptyTexture2DArray(): InternalTexture;
  40752. /**
  40753. * Gets the default empty cube texture
  40754. */
  40755. get emptyCubeTexture(): InternalTexture;
  40756. /**
  40757. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40758. */
  40759. readonly premultipliedAlpha: boolean;
  40760. /**
  40761. * Observable event triggered before each texture is initialized
  40762. */
  40763. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40764. /**
  40765. * Creates a new engine
  40766. * @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
  40767. * @param antialias defines enable antialiasing (default: false)
  40768. * @param options defines further options to be sent to the getContext() function
  40769. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40770. */
  40771. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40772. private _rebuildInternalTextures;
  40773. private _rebuildEffects;
  40774. /**
  40775. * Gets a boolean indicating if all created effects are ready
  40776. * @returns true if all effects are ready
  40777. */
  40778. areAllEffectsReady(): boolean;
  40779. protected _rebuildBuffers(): void;
  40780. protected _initGLContext(): void;
  40781. /**
  40782. * Gets version of the current webGL context
  40783. */
  40784. get webGLVersion(): number;
  40785. /**
  40786. * Gets a string identifying the name of the class
  40787. * @returns "Engine" string
  40788. */
  40789. getClassName(): string;
  40790. /**
  40791. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40792. */
  40793. get isStencilEnable(): boolean;
  40794. /** @hidden */
  40795. _prepareWorkingCanvas(): void;
  40796. /**
  40797. * Reset the texture cache to empty state
  40798. */
  40799. resetTextureCache(): void;
  40800. /**
  40801. * Gets an object containing information about the current webGL context
  40802. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40803. */
  40804. getGlInfo(): {
  40805. vendor: string;
  40806. renderer: string;
  40807. version: string;
  40808. };
  40809. /**
  40810. * Defines the hardware scaling level.
  40811. * By default the hardware scaling level is computed from the window device ratio.
  40812. * 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.
  40813. * @param level defines the level to use
  40814. */
  40815. setHardwareScalingLevel(level: number): void;
  40816. /**
  40817. * Gets the current hardware scaling level.
  40818. * By default the hardware scaling level is computed from the window device ratio.
  40819. * 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.
  40820. * @returns a number indicating the current hardware scaling level
  40821. */
  40822. getHardwareScalingLevel(): number;
  40823. /**
  40824. * Gets the list of loaded textures
  40825. * @returns an array containing all loaded textures
  40826. */
  40827. getLoadedTexturesCache(): InternalTexture[];
  40828. /**
  40829. * Gets the object containing all engine capabilities
  40830. * @returns the EngineCapabilities object
  40831. */
  40832. getCaps(): EngineCapabilities;
  40833. /**
  40834. * stop executing a render loop function and remove it from the execution array
  40835. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40836. */
  40837. stopRenderLoop(renderFunction?: () => void): void;
  40838. /** @hidden */
  40839. _renderLoop(): void;
  40840. /**
  40841. * Gets the HTML canvas attached with the current webGL context
  40842. * @returns a HTML canvas
  40843. */
  40844. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40845. /**
  40846. * Gets host window
  40847. * @returns the host window object
  40848. */
  40849. getHostWindow(): Nullable<Window>;
  40850. /**
  40851. * Gets the current render width
  40852. * @param useScreen defines if screen size must be used (or the current render target if any)
  40853. * @returns a number defining the current render width
  40854. */
  40855. getRenderWidth(useScreen?: boolean): number;
  40856. /**
  40857. * Gets the current render height
  40858. * @param useScreen defines if screen size must be used (or the current render target if any)
  40859. * @returns a number defining the current render height
  40860. */
  40861. getRenderHeight(useScreen?: boolean): number;
  40862. /**
  40863. * Can be used to override the current requestAnimationFrame requester.
  40864. * @hidden
  40865. */
  40866. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40867. /**
  40868. * Register and execute a render loop. The engine can have more than one render function
  40869. * @param renderFunction defines the function to continuously execute
  40870. */
  40871. runRenderLoop(renderFunction: () => void): void;
  40872. /**
  40873. * Clear the current render buffer or the current render target (if any is set up)
  40874. * @param color defines the color to use
  40875. * @param backBuffer defines if the back buffer must be cleared
  40876. * @param depth defines if the depth buffer must be cleared
  40877. * @param stencil defines if the stencil buffer must be cleared
  40878. */
  40879. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40880. private _viewportCached;
  40881. /** @hidden */
  40882. _viewport(x: number, y: number, width: number, height: number): void;
  40883. /**
  40884. * Set the WebGL's viewport
  40885. * @param viewport defines the viewport element to be used
  40886. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40887. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40888. */
  40889. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40890. /**
  40891. * Begin a new frame
  40892. */
  40893. beginFrame(): void;
  40894. /**
  40895. * Enf the current frame
  40896. */
  40897. endFrame(): void;
  40898. /**
  40899. * Resize the view according to the canvas' size
  40900. */
  40901. resize(): void;
  40902. /**
  40903. * Force a specific size of the canvas
  40904. * @param width defines the new canvas' width
  40905. * @param height defines the new canvas' height
  40906. * @returns true if the size was changed
  40907. */
  40908. setSize(width: number, height: number): boolean;
  40909. /**
  40910. * Binds the frame buffer to the specified texture.
  40911. * @param texture The texture to render to or null for the default canvas
  40912. * @param faceIndex The face of the texture to render to in case of cube texture
  40913. * @param requiredWidth The width of the target to render to
  40914. * @param requiredHeight The height of the target to render to
  40915. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40916. * @param lodLevel defines the lod level to bind to the frame buffer
  40917. * @param layer defines the 2d array index to bind to frame buffer to
  40918. */
  40919. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40920. /** @hidden */
  40921. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40922. /**
  40923. * Unbind the current render target texture from the webGL context
  40924. * @param texture defines the render target texture to unbind
  40925. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40926. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40927. */
  40928. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40929. /**
  40930. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40931. */
  40932. flushFramebuffer(): void;
  40933. /**
  40934. * Unbind the current render target and bind the default framebuffer
  40935. */
  40936. restoreDefaultFramebuffer(): void;
  40937. /** @hidden */
  40938. protected _resetVertexBufferBinding(): void;
  40939. /**
  40940. * Creates a vertex buffer
  40941. * @param data the data for the vertex buffer
  40942. * @returns the new WebGL static buffer
  40943. */
  40944. createVertexBuffer(data: DataArray): DataBuffer;
  40945. private _createVertexBuffer;
  40946. /**
  40947. * Creates a dynamic vertex buffer
  40948. * @param data the data for the dynamic vertex buffer
  40949. * @returns the new WebGL dynamic buffer
  40950. */
  40951. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40952. protected _resetIndexBufferBinding(): void;
  40953. /**
  40954. * Creates a new index buffer
  40955. * @param indices defines the content of the index buffer
  40956. * @param updatable defines if the index buffer must be updatable
  40957. * @returns a new webGL buffer
  40958. */
  40959. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40960. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40961. /**
  40962. * Bind a webGL buffer to the webGL context
  40963. * @param buffer defines the buffer to bind
  40964. */
  40965. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40966. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40967. private bindBuffer;
  40968. /**
  40969. * update the bound buffer with the given data
  40970. * @param data defines the data to update
  40971. */
  40972. updateArrayBuffer(data: Float32Array): void;
  40973. private _vertexAttribPointer;
  40974. /** @hidden */
  40975. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40976. private _bindVertexBuffersAttributes;
  40977. /**
  40978. * Records a vertex array object
  40979. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40980. * @param vertexBuffers defines the list of vertex buffers to store
  40981. * @param indexBuffer defines the index buffer to store
  40982. * @param effect defines the effect to store
  40983. * @returns the new vertex array object
  40984. */
  40985. recordVertexArrayObject(vertexBuffers: {
  40986. [key: string]: VertexBuffer;
  40987. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40988. /**
  40989. * Bind a specific vertex array object
  40990. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40991. * @param vertexArrayObject defines the vertex array object to bind
  40992. * @param indexBuffer defines the index buffer to bind
  40993. */
  40994. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40995. /**
  40996. * Bind webGl buffers directly to the webGL context
  40997. * @param vertexBuffer defines the vertex buffer to bind
  40998. * @param indexBuffer defines the index buffer to bind
  40999. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  41000. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  41001. * @param effect defines the effect associated with the vertex buffer
  41002. */
  41003. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  41004. private _unbindVertexArrayObject;
  41005. /**
  41006. * Bind a list of vertex buffers to the webGL context
  41007. * @param vertexBuffers defines the list of vertex buffers to bind
  41008. * @param indexBuffer defines the index buffer to bind
  41009. * @param effect defines the effect associated with the vertex buffers
  41010. */
  41011. bindBuffers(vertexBuffers: {
  41012. [key: string]: Nullable<VertexBuffer>;
  41013. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  41014. /**
  41015. * Unbind all instance attributes
  41016. */
  41017. unbindInstanceAttributes(): void;
  41018. /**
  41019. * Release and free the memory of a vertex array object
  41020. * @param vao defines the vertex array object to delete
  41021. */
  41022. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  41023. /** @hidden */
  41024. _releaseBuffer(buffer: DataBuffer): boolean;
  41025. protected _deleteBuffer(buffer: DataBuffer): void;
  41026. /**
  41027. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  41028. * @param instancesBuffer defines the webGL buffer to update and bind
  41029. * @param data defines the data to store in the buffer
  41030. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  41031. */
  41032. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  41033. /**
  41034. * Bind the content of a webGL buffer used with instantiation
  41035. * @param instancesBuffer defines the webGL buffer to bind
  41036. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  41037. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  41038. */
  41039. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  41040. /**
  41041. * Disable the instance attribute corresponding to the name in parameter
  41042. * @param name defines the name of the attribute to disable
  41043. */
  41044. disableInstanceAttributeByName(name: string): void;
  41045. /**
  41046. * Disable the instance attribute corresponding to the location in parameter
  41047. * @param attributeLocation defines the attribute location of the attribute to disable
  41048. */
  41049. disableInstanceAttribute(attributeLocation: number): void;
  41050. /**
  41051. * Disable the attribute corresponding to the location in parameter
  41052. * @param attributeLocation defines the attribute location of the attribute to disable
  41053. */
  41054. disableAttributeByIndex(attributeLocation: number): void;
  41055. /**
  41056. * Send a draw order
  41057. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41058. * @param indexStart defines the starting index
  41059. * @param indexCount defines the number of index to draw
  41060. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41061. */
  41062. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41063. /**
  41064. * Draw a list of points
  41065. * @param verticesStart defines the index of first vertex to draw
  41066. * @param verticesCount defines the count of vertices to draw
  41067. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41068. */
  41069. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41070. /**
  41071. * Draw a list of unindexed primitives
  41072. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  41073. * @param verticesStart defines the index of first vertex to draw
  41074. * @param verticesCount defines the count of vertices to draw
  41075. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41076. */
  41077. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41078. /**
  41079. * Draw a list of indexed primitives
  41080. * @param fillMode defines the primitive to use
  41081. * @param indexStart defines the starting index
  41082. * @param indexCount defines the number of index to draw
  41083. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41084. */
  41085. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41086. /**
  41087. * Draw a list of unindexed primitives
  41088. * @param fillMode defines the primitive to use
  41089. * @param verticesStart defines the index of first vertex to draw
  41090. * @param verticesCount defines the count of vertices to draw
  41091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  41092. */
  41093. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41094. private _drawMode;
  41095. /** @hidden */
  41096. protected _reportDrawCall(): void;
  41097. /** @hidden */
  41098. _releaseEffect(effect: Effect): void;
  41099. /** @hidden */
  41100. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41101. /**
  41102. * Create a new effect (used to store vertex/fragment shaders)
  41103. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  41104. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  41105. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  41106. * @param samplers defines an array of string used to represent textures
  41107. * @param defines defines the string containing the defines to use to compile the shaders
  41108. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  41109. * @param onCompiled defines a function to call when the effect creation is successful
  41110. * @param onError defines a function to call when the effect creation has failed
  41111. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  41112. * @returns the new Effect
  41113. */
  41114. 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;
  41115. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  41116. private _compileShader;
  41117. private _compileRawShader;
  41118. /** @hidden */
  41119. _getShaderSource(shader: WebGLShader): Nullable<string>;
  41120. /**
  41121. * Directly creates a webGL program
  41122. * @param pipelineContext defines the pipeline context to attach to
  41123. * @param vertexCode defines the vertex shader code to use
  41124. * @param fragmentCode defines the fragment shader code to use
  41125. * @param context defines the webGL context to use (if not set, the current one will be used)
  41126. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41127. * @returns the new webGL program
  41128. */
  41129. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41130. /**
  41131. * Creates a webGL program
  41132. * @param pipelineContext defines the pipeline context to attach to
  41133. * @param vertexCode defines the vertex shader code to use
  41134. * @param fragmentCode defines the fragment shader code to use
  41135. * @param defines defines the string containing the defines to use to compile the shaders
  41136. * @param context defines the webGL context to use (if not set, the current one will be used)
  41137. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  41138. * @returns the new webGL program
  41139. */
  41140. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41141. /**
  41142. * Creates a new pipeline context
  41143. * @returns the new pipeline
  41144. */
  41145. createPipelineContext(): IPipelineContext;
  41146. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41147. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  41148. /** @hidden */
  41149. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  41150. /** @hidden */
  41151. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  41152. /** @hidden */
  41153. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  41154. /**
  41155. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  41156. * @param pipelineContext defines the pipeline context to use
  41157. * @param uniformsNames defines the list of uniform names
  41158. * @returns an array of webGL uniform locations
  41159. */
  41160. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41161. /**
  41162. * Gets the lsit of active attributes for a given webGL program
  41163. * @param pipelineContext defines the pipeline context to use
  41164. * @param attributesNames defines the list of attribute names to get
  41165. * @returns an array of indices indicating the offset of each attribute
  41166. */
  41167. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41168. /**
  41169. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  41170. * @param effect defines the effect to activate
  41171. */
  41172. enableEffect(effect: Nullable<Effect>): void;
  41173. /**
  41174. * Set the value of an uniform to a number (int)
  41175. * @param uniform defines the webGL uniform location where to store the value
  41176. * @param value defines the int number to store
  41177. * @returns true if the value was set
  41178. */
  41179. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41180. /**
  41181. * Set the value of an uniform to an array of int32
  41182. * @param uniform defines the webGL uniform location where to store the value
  41183. * @param array defines the array of int32 to store
  41184. * @returns true if the value was set
  41185. */
  41186. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41187. /**
  41188. * Set the value of an uniform to an array of int32 (stored as vec2)
  41189. * @param uniform defines the webGL uniform location where to store the value
  41190. * @param array defines the array of int32 to store
  41191. * @returns true if the value was set
  41192. */
  41193. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41194. /**
  41195. * Set the value of an uniform to an array of int32 (stored as vec3)
  41196. * @param uniform defines the webGL uniform location where to store the value
  41197. * @param array defines the array of int32 to store
  41198. * @returns true if the value was set
  41199. */
  41200. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41201. /**
  41202. * Set the value of an uniform to an array of int32 (stored as vec4)
  41203. * @param uniform defines the webGL uniform location where to store the value
  41204. * @param array defines the array of int32 to store
  41205. * @returns true if the value was set
  41206. */
  41207. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  41208. /**
  41209. * Set the value of an uniform to an array of number
  41210. * @param uniform defines the webGL uniform location where to store the value
  41211. * @param array defines the array of number to store
  41212. * @returns true if the value was set
  41213. */
  41214. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41215. /**
  41216. * Set the value of an uniform to an array of number (stored as vec2)
  41217. * @param uniform defines the webGL uniform location where to store the value
  41218. * @param array defines the array of number to store
  41219. * @returns true if the value was set
  41220. */
  41221. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41222. /**
  41223. * Set the value of an uniform to an array of number (stored as vec3)
  41224. * @param uniform defines the webGL uniform location where to store the value
  41225. * @param array defines the array of number to store
  41226. * @returns true if the value was set
  41227. */
  41228. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41229. /**
  41230. * Set the value of an uniform to an array of number (stored as vec4)
  41231. * @param uniform defines the webGL uniform location where to store the value
  41232. * @param array defines the array of number to store
  41233. * @returns true if the value was set
  41234. */
  41235. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  41236. /**
  41237. * Set the value of an uniform to an array of float32 (stored as matrices)
  41238. * @param uniform defines the webGL uniform location where to store the value
  41239. * @param matrices defines the array of float32 to store
  41240. * @returns true if the value was set
  41241. */
  41242. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  41243. /**
  41244. * Set the value of an uniform to a matrix (3x3)
  41245. * @param uniform defines the webGL uniform location where to store the value
  41246. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  41247. * @returns true if the value was set
  41248. */
  41249. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41250. /**
  41251. * Set the value of an uniform to a matrix (2x2)
  41252. * @param uniform defines the webGL uniform location where to store the value
  41253. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  41254. * @returns true if the value was set
  41255. */
  41256. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  41257. /**
  41258. * Set the value of an uniform to a number (float)
  41259. * @param uniform defines the webGL uniform location where to store the value
  41260. * @param value defines the float number to store
  41261. * @returns true if the value was transfered
  41262. */
  41263. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  41264. /**
  41265. * Set the value of an uniform to a vec2
  41266. * @param uniform defines the webGL uniform location where to store the value
  41267. * @param x defines the 1st component of the value
  41268. * @param y defines the 2nd component of the value
  41269. * @returns true if the value was set
  41270. */
  41271. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  41272. /**
  41273. * Set the value of an uniform to a vec3
  41274. * @param uniform defines the webGL uniform location where to store the value
  41275. * @param x defines the 1st component of the value
  41276. * @param y defines the 2nd component of the value
  41277. * @param z defines the 3rd component of the value
  41278. * @returns true if the value was set
  41279. */
  41280. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  41281. /**
  41282. * Set the value of an uniform to a vec4
  41283. * @param uniform defines the webGL uniform location where to store the value
  41284. * @param x defines the 1st component of the value
  41285. * @param y defines the 2nd component of the value
  41286. * @param z defines the 3rd component of the value
  41287. * @param w defines the 4th component of the value
  41288. * @returns true if the value was set
  41289. */
  41290. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  41291. /**
  41292. * Apply all cached states (depth, culling, stencil and alpha)
  41293. */
  41294. applyStates(): void;
  41295. /**
  41296. * Enable or disable color writing
  41297. * @param enable defines the state to set
  41298. */
  41299. setColorWrite(enable: boolean): void;
  41300. /**
  41301. * Gets a boolean indicating if color writing is enabled
  41302. * @returns the current color writing state
  41303. */
  41304. getColorWrite(): boolean;
  41305. /**
  41306. * Gets the depth culling state manager
  41307. */
  41308. get depthCullingState(): DepthCullingState;
  41309. /**
  41310. * Gets the alpha state manager
  41311. */
  41312. get alphaState(): AlphaState;
  41313. /**
  41314. * Gets the stencil state manager
  41315. */
  41316. get stencilState(): StencilState;
  41317. /**
  41318. * Clears the list of texture accessible through engine.
  41319. * This can help preventing texture load conflict due to name collision.
  41320. */
  41321. clearInternalTexturesCache(): void;
  41322. /**
  41323. * Force the entire cache to be cleared
  41324. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41325. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41326. */
  41327. wipeCaches(bruteForce?: boolean): void;
  41328. /** @hidden */
  41329. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41330. min: number;
  41331. mag: number;
  41332. };
  41333. /** @hidden */
  41334. _createTexture(): WebGLTexture;
  41335. /**
  41336. * Usually called from Texture.ts.
  41337. * Passed information to create a WebGLTexture
  41338. * @param url defines a value which contains one of the following:
  41339. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41340. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41341. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41342. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41343. * @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)
  41344. * @param scene needed for loading to the correct scene
  41345. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41346. * @param onLoad optional callback to be called upon successful completion
  41347. * @param onError optional callback to be called upon failure
  41348. * @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
  41349. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41350. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41351. * @param forcedExtension defines the extension to use to pick the right loader
  41352. * @param mimeType defines an optional mime type
  41353. * @param loaderOptions options to be passed to the loader
  41354. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41355. */
  41356. 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, loaderOptions?: any): InternalTexture;
  41357. /**
  41358. * Loads an image as an HTMLImageElement.
  41359. * @param input url string, ArrayBuffer, or Blob to load
  41360. * @param onLoad callback called when the image successfully loads
  41361. * @param onError callback called when the image fails to load
  41362. * @param offlineProvider offline provider for caching
  41363. * @param mimeType optional mime type
  41364. * @returns the HTMLImageElement of the loaded image
  41365. * @hidden
  41366. */
  41367. 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>;
  41368. /**
  41369. * @hidden
  41370. */
  41371. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41372. private _unpackFlipYCached;
  41373. /**
  41374. * In case you are sharing the context with other applications, it might
  41375. * be interested to not cache the unpack flip y state to ensure a consistent
  41376. * value would be set.
  41377. */
  41378. enableUnpackFlipYCached: boolean;
  41379. /** @hidden */
  41380. _unpackFlipY(value: boolean): void;
  41381. /** @hidden */
  41382. _getUnpackAlignement(): number;
  41383. private _getTextureTarget;
  41384. /**
  41385. * Update the sampling mode of a given texture
  41386. * @param samplingMode defines the required sampling mode
  41387. * @param texture defines the texture to update
  41388. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41389. */
  41390. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41391. /**
  41392. * Update the sampling mode of a given texture
  41393. * @param texture defines the texture to update
  41394. * @param wrapU defines the texture wrap mode of the u coordinates
  41395. * @param wrapV defines the texture wrap mode of the v coordinates
  41396. * @param wrapR defines the texture wrap mode of the r coordinates
  41397. */
  41398. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41399. /** @hidden */
  41400. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41401. width: number;
  41402. height: number;
  41403. layers?: number;
  41404. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41405. /** @hidden */
  41406. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41407. /** @hidden */
  41408. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41409. /**
  41410. * Update a portion of an internal texture
  41411. * @param texture defines the texture to update
  41412. * @param imageData defines the data to store into the texture
  41413. * @param xOffset defines the x coordinates of the update rectangle
  41414. * @param yOffset defines the y coordinates of the update rectangle
  41415. * @param width defines the width of the update rectangle
  41416. * @param height defines the height of the update rectangle
  41417. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41418. * @param lod defines the lod level to update (0 by default)
  41419. */
  41420. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41421. /** @hidden */
  41422. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41423. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41424. private _prepareWebGLTexture;
  41425. /** @hidden */
  41426. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41427. private _getDepthStencilBuffer;
  41428. /** @hidden */
  41429. _releaseFramebufferObjects(texture: InternalTexture): void;
  41430. /** @hidden */
  41431. _releaseTexture(texture: InternalTexture): void;
  41432. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41433. protected _setProgram(program: WebGLProgram): void;
  41434. protected _boundUniforms: {
  41435. [key: number]: WebGLUniformLocation;
  41436. };
  41437. /**
  41438. * Binds an effect to the webGL context
  41439. * @param effect defines the effect to bind
  41440. */
  41441. bindSamplers(effect: Effect): void;
  41442. private _activateCurrentTexture;
  41443. /** @hidden */
  41444. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41445. /** @hidden */
  41446. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41447. /**
  41448. * Unbind all textures from the webGL context
  41449. */
  41450. unbindAllTextures(): void;
  41451. /**
  41452. * Sets a texture to the according uniform.
  41453. * @param channel The texture channel
  41454. * @param uniform The uniform to set
  41455. * @param texture The texture to apply
  41456. */
  41457. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  41458. private _bindSamplerUniformToChannel;
  41459. private _getTextureWrapMode;
  41460. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41461. /**
  41462. * Sets an array of texture to the webGL context
  41463. * @param channel defines the channel where the texture array must be set
  41464. * @param uniform defines the associated uniform location
  41465. * @param textures defines the array of textures to bind
  41466. */
  41467. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  41468. /** @hidden */
  41469. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41470. private _setTextureParameterFloat;
  41471. private _setTextureParameterInteger;
  41472. /**
  41473. * Unbind all vertex attributes from the webGL context
  41474. */
  41475. unbindAllAttributes(): void;
  41476. /**
  41477. * 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
  41478. */
  41479. releaseEffects(): void;
  41480. /**
  41481. * Dispose and release all associated resources
  41482. */
  41483. dispose(): void;
  41484. /**
  41485. * Attach a new callback raised when context lost event is fired
  41486. * @param callback defines the callback to call
  41487. */
  41488. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41489. /**
  41490. * Attach a new callback raised when context restored event is fired
  41491. * @param callback defines the callback to call
  41492. */
  41493. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41494. /**
  41495. * Get the current error code of the webGL context
  41496. * @returns the error code
  41497. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41498. */
  41499. getError(): number;
  41500. private _canRenderToFloatFramebuffer;
  41501. private _canRenderToHalfFloatFramebuffer;
  41502. private _canRenderToFramebuffer;
  41503. /** @hidden */
  41504. _getWebGLTextureType(type: number): number;
  41505. /** @hidden */
  41506. _getInternalFormat(format: number): number;
  41507. /** @hidden */
  41508. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41509. /** @hidden */
  41510. _getRGBAMultiSampleBufferFormat(type: number): number;
  41511. /** @hidden */
  41512. _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;
  41513. /**
  41514. * Loads a file from a url
  41515. * @param url url to load
  41516. * @param onSuccess callback called when the file successfully loads
  41517. * @param onProgress callback called while file is loading (if the server supports this mode)
  41518. * @param offlineProvider defines the offline provider for caching
  41519. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41520. * @param onError callback called when the file fails to load
  41521. * @returns a file request object
  41522. * @hidden
  41523. */
  41524. 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;
  41525. /**
  41526. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41527. * @param x defines the x coordinate of the rectangle where pixels must be read
  41528. * @param y defines the y coordinate of the rectangle where pixels must be read
  41529. * @param width defines the width of the rectangle where pixels must be read
  41530. * @param height defines the height of the rectangle where pixels must be read
  41531. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41532. * @returns a Uint8Array containing RGBA colors
  41533. */
  41534. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41535. private static _IsSupported;
  41536. private static _HasMajorPerformanceCaveat;
  41537. /**
  41538. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41539. */
  41540. static get IsSupported(): boolean;
  41541. /**
  41542. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41543. * @returns true if the engine can be created
  41544. * @ignorenaming
  41545. */
  41546. static isSupported(): boolean;
  41547. /**
  41548. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  41549. */
  41550. static get HasMajorPerformanceCaveat(): boolean;
  41551. /**
  41552. * Find the next highest power of two.
  41553. * @param x Number to start search from.
  41554. * @return Next highest power of two.
  41555. */
  41556. static CeilingPOT(x: number): number;
  41557. /**
  41558. * Find the next lowest power of two.
  41559. * @param x Number to start search from.
  41560. * @return Next lowest power of two.
  41561. */
  41562. static FloorPOT(x: number): number;
  41563. /**
  41564. * Find the nearest power of two.
  41565. * @param x Number to start search from.
  41566. * @return Next nearest power of two.
  41567. */
  41568. static NearestPOT(x: number): number;
  41569. /**
  41570. * Get the closest exponent of two
  41571. * @param value defines the value to approximate
  41572. * @param max defines the maximum value to return
  41573. * @param mode defines how to define the closest value
  41574. * @returns closest exponent of two of the given value
  41575. */
  41576. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41577. /**
  41578. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41579. * @param func - the function to be called
  41580. * @param requester - the object that will request the next frame. Falls back to window.
  41581. * @returns frame number
  41582. */
  41583. static QueueNewFrame(func: () => void, requester?: any): number;
  41584. /**
  41585. * Gets host document
  41586. * @returns the host document object
  41587. */
  41588. getHostDocument(): Nullable<Document>;
  41589. }
  41590. }
  41591. declare module "babylonjs/Materials/Textures/internalTexture" {
  41592. import { Observable } from "babylonjs/Misc/observable";
  41593. import { Nullable, int } from "babylonjs/types";
  41594. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41596. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41597. /**
  41598. * Defines the source of the internal texture
  41599. */
  41600. export enum InternalTextureSource {
  41601. /**
  41602. * The source of the texture data is unknown
  41603. */
  41604. Unknown = 0,
  41605. /**
  41606. * Texture data comes from an URL
  41607. */
  41608. Url = 1,
  41609. /**
  41610. * Texture data is only used for temporary storage
  41611. */
  41612. Temp = 2,
  41613. /**
  41614. * Texture data comes from raw data (ArrayBuffer)
  41615. */
  41616. Raw = 3,
  41617. /**
  41618. * Texture content is dynamic (video or dynamic texture)
  41619. */
  41620. Dynamic = 4,
  41621. /**
  41622. * Texture content is generated by rendering to it
  41623. */
  41624. RenderTarget = 5,
  41625. /**
  41626. * Texture content is part of a multi render target process
  41627. */
  41628. MultiRenderTarget = 6,
  41629. /**
  41630. * Texture data comes from a cube data file
  41631. */
  41632. Cube = 7,
  41633. /**
  41634. * Texture data comes from a raw cube data
  41635. */
  41636. CubeRaw = 8,
  41637. /**
  41638. * Texture data come from a prefiltered cube data file
  41639. */
  41640. CubePrefiltered = 9,
  41641. /**
  41642. * Texture content is raw 3D data
  41643. */
  41644. Raw3D = 10,
  41645. /**
  41646. * Texture content is raw 2D array data
  41647. */
  41648. Raw2DArray = 11,
  41649. /**
  41650. * Texture content is a depth texture
  41651. */
  41652. Depth = 12,
  41653. /**
  41654. * Texture data comes from a raw cube data encoded with RGBD
  41655. */
  41656. CubeRawRGBD = 13
  41657. }
  41658. /**
  41659. * Class used to store data associated with WebGL texture data for the engine
  41660. * This class should not be used directly
  41661. */
  41662. export class InternalTexture {
  41663. /** @hidden */
  41664. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41665. /**
  41666. * Defines if the texture is ready
  41667. */
  41668. isReady: boolean;
  41669. /**
  41670. * Defines if the texture is a cube texture
  41671. */
  41672. isCube: boolean;
  41673. /**
  41674. * Defines if the texture contains 3D data
  41675. */
  41676. is3D: boolean;
  41677. /**
  41678. * Defines if the texture contains 2D array data
  41679. */
  41680. is2DArray: boolean;
  41681. /**
  41682. * Defines if the texture contains multiview data
  41683. */
  41684. isMultiview: boolean;
  41685. /**
  41686. * Gets the URL used to load this texture
  41687. */
  41688. url: string;
  41689. /** @hidden */
  41690. _originalUrl: string;
  41691. /**
  41692. * Gets the sampling mode of the texture
  41693. */
  41694. samplingMode: number;
  41695. /**
  41696. * Gets a boolean indicating if the texture needs mipmaps generation
  41697. */
  41698. generateMipMaps: boolean;
  41699. /**
  41700. * Gets the number of samples used by the texture (WebGL2+ only)
  41701. */
  41702. samples: number;
  41703. /**
  41704. * Gets the type of the texture (int, float...)
  41705. */
  41706. type: number;
  41707. /**
  41708. * Gets the format of the texture (RGB, RGBA...)
  41709. */
  41710. format: number;
  41711. /**
  41712. * Observable called when the texture is loaded
  41713. */
  41714. onLoadedObservable: Observable<InternalTexture>;
  41715. /**
  41716. * Gets the width of the texture
  41717. */
  41718. width: number;
  41719. /**
  41720. * Gets the height of the texture
  41721. */
  41722. height: number;
  41723. /**
  41724. * Gets the depth of the texture
  41725. */
  41726. depth: number;
  41727. /**
  41728. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41729. */
  41730. baseWidth: number;
  41731. /**
  41732. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41733. */
  41734. baseHeight: number;
  41735. /**
  41736. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41737. */
  41738. baseDepth: number;
  41739. /**
  41740. * Gets a boolean indicating if the texture is inverted on Y axis
  41741. */
  41742. invertY: boolean;
  41743. /** @hidden */
  41744. _invertVScale: boolean;
  41745. /** @hidden */
  41746. _associatedChannel: number;
  41747. /** @hidden */
  41748. _source: InternalTextureSource;
  41749. /** @hidden */
  41750. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41751. /** @hidden */
  41752. _bufferView: Nullable<ArrayBufferView>;
  41753. /** @hidden */
  41754. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41755. /** @hidden */
  41756. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41757. /** @hidden */
  41758. _size: number;
  41759. /** @hidden */
  41760. _extension: string;
  41761. /** @hidden */
  41762. _files: Nullable<string[]>;
  41763. /** @hidden */
  41764. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41765. /** @hidden */
  41766. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41767. /** @hidden */
  41768. _framebuffer: Nullable<WebGLFramebuffer>;
  41769. /** @hidden */
  41770. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41771. /** @hidden */
  41772. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41773. /** @hidden */
  41774. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41775. /** @hidden */
  41776. _attachments: Nullable<number[]>;
  41777. /** @hidden */
  41778. _textureArray: Nullable<InternalTexture[]>;
  41779. /** @hidden */
  41780. _cachedCoordinatesMode: Nullable<number>;
  41781. /** @hidden */
  41782. _cachedWrapU: Nullable<number>;
  41783. /** @hidden */
  41784. _cachedWrapV: Nullable<number>;
  41785. /** @hidden */
  41786. _cachedWrapR: Nullable<number>;
  41787. /** @hidden */
  41788. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41789. /** @hidden */
  41790. _isDisabled: boolean;
  41791. /** @hidden */
  41792. _compression: Nullable<string>;
  41793. /** @hidden */
  41794. _generateStencilBuffer: boolean;
  41795. /** @hidden */
  41796. _generateDepthBuffer: boolean;
  41797. /** @hidden */
  41798. _comparisonFunction: number;
  41799. /** @hidden */
  41800. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41801. /** @hidden */
  41802. _lodGenerationScale: number;
  41803. /** @hidden */
  41804. _lodGenerationOffset: number;
  41805. /** @hidden */
  41806. _depthStencilTexture: Nullable<InternalTexture>;
  41807. /** @hidden */
  41808. _colorTextureArray: Nullable<WebGLTexture>;
  41809. /** @hidden */
  41810. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41811. /** @hidden */
  41812. _lodTextureHigh: Nullable<BaseTexture>;
  41813. /** @hidden */
  41814. _lodTextureMid: Nullable<BaseTexture>;
  41815. /** @hidden */
  41816. _lodTextureLow: Nullable<BaseTexture>;
  41817. /** @hidden */
  41818. _isRGBD: boolean;
  41819. /** @hidden */
  41820. _linearSpecularLOD: boolean;
  41821. /** @hidden */
  41822. _irradianceTexture: Nullable<BaseTexture>;
  41823. /** @hidden */
  41824. _webGLTexture: Nullable<WebGLTexture>;
  41825. /** @hidden */
  41826. _references: number;
  41827. /** @hidden */
  41828. _gammaSpace: Nullable<boolean>;
  41829. private _engine;
  41830. /**
  41831. * Gets the Engine the texture belongs to.
  41832. * @returns The babylon engine
  41833. */
  41834. getEngine(): ThinEngine;
  41835. /**
  41836. * Gets the data source type of the texture
  41837. */
  41838. get source(): InternalTextureSource;
  41839. /**
  41840. * Creates a new InternalTexture
  41841. * @param engine defines the engine to use
  41842. * @param source defines the type of data that will be used
  41843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41844. */
  41845. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41846. /**
  41847. * Increments the number of references (ie. the number of Texture that point to it)
  41848. */
  41849. incrementReferences(): void;
  41850. /**
  41851. * Change the size of the texture (not the size of the content)
  41852. * @param width defines the new width
  41853. * @param height defines the new height
  41854. * @param depth defines the new depth (1 by default)
  41855. */
  41856. updateSize(width: int, height: int, depth?: int): void;
  41857. /** @hidden */
  41858. _rebuild(): void;
  41859. /** @hidden */
  41860. _swapAndDie(target: InternalTexture): void;
  41861. /**
  41862. * Dispose the current allocated resources
  41863. */
  41864. dispose(): void;
  41865. }
  41866. }
  41867. declare module "babylonjs/Loading/loadingScreen" {
  41868. /**
  41869. * Interface used to present a loading screen while loading a scene
  41870. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41871. */
  41872. export interface ILoadingScreen {
  41873. /**
  41874. * Function called to display the loading screen
  41875. */
  41876. displayLoadingUI: () => void;
  41877. /**
  41878. * Function called to hide the loading screen
  41879. */
  41880. hideLoadingUI: () => void;
  41881. /**
  41882. * Gets or sets the color to use for the background
  41883. */
  41884. loadingUIBackgroundColor: string;
  41885. /**
  41886. * Gets or sets the text to display while loading
  41887. */
  41888. loadingUIText: string;
  41889. }
  41890. /**
  41891. * Class used for the default loading screen
  41892. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41893. */
  41894. export class DefaultLoadingScreen implements ILoadingScreen {
  41895. private _renderingCanvas;
  41896. private _loadingText;
  41897. private _loadingDivBackgroundColor;
  41898. private _loadingDiv;
  41899. private _loadingTextDiv;
  41900. /** Gets or sets the logo url to use for the default loading screen */
  41901. static DefaultLogoUrl: string;
  41902. /** Gets or sets the spinner url to use for the default loading screen */
  41903. static DefaultSpinnerUrl: string;
  41904. /**
  41905. * Creates a new default loading screen
  41906. * @param _renderingCanvas defines the canvas used to render the scene
  41907. * @param _loadingText defines the default text to display
  41908. * @param _loadingDivBackgroundColor defines the default background color
  41909. */
  41910. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41911. /**
  41912. * Function called to display the loading screen
  41913. */
  41914. displayLoadingUI(): void;
  41915. /**
  41916. * Function called to hide the loading screen
  41917. */
  41918. hideLoadingUI(): void;
  41919. /**
  41920. * Gets or sets the text to display while loading
  41921. */
  41922. set loadingUIText(text: string);
  41923. get loadingUIText(): string;
  41924. /**
  41925. * Gets or sets the color to use for the background
  41926. */
  41927. get loadingUIBackgroundColor(): string;
  41928. set loadingUIBackgroundColor(color: string);
  41929. private _resizeLoadingUI;
  41930. }
  41931. }
  41932. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41933. /**
  41934. * Interface for any object that can request an animation frame
  41935. */
  41936. export interface ICustomAnimationFrameRequester {
  41937. /**
  41938. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41939. */
  41940. renderFunction?: Function;
  41941. /**
  41942. * Called to request the next frame to render to
  41943. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41944. */
  41945. requestAnimationFrame: Function;
  41946. /**
  41947. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41948. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41949. */
  41950. requestID?: number;
  41951. }
  41952. }
  41953. declare module "babylonjs/Misc/performanceMonitor" {
  41954. /**
  41955. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41956. */
  41957. export class PerformanceMonitor {
  41958. private _enabled;
  41959. private _rollingFrameTime;
  41960. private _lastFrameTimeMs;
  41961. /**
  41962. * constructor
  41963. * @param frameSampleSize The number of samples required to saturate the sliding window
  41964. */
  41965. constructor(frameSampleSize?: number);
  41966. /**
  41967. * Samples current frame
  41968. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41969. */
  41970. sampleFrame(timeMs?: number): void;
  41971. /**
  41972. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41973. */
  41974. get averageFrameTime(): number;
  41975. /**
  41976. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41977. */
  41978. get averageFrameTimeVariance(): number;
  41979. /**
  41980. * Returns the frame time of the most recent frame
  41981. */
  41982. get instantaneousFrameTime(): number;
  41983. /**
  41984. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41985. */
  41986. get averageFPS(): number;
  41987. /**
  41988. * Returns the average framerate in frames per second using the most recent frame time
  41989. */
  41990. get instantaneousFPS(): number;
  41991. /**
  41992. * Returns true if enough samples have been taken to completely fill the sliding window
  41993. */
  41994. get isSaturated(): boolean;
  41995. /**
  41996. * Enables contributions to the sliding window sample set
  41997. */
  41998. enable(): void;
  41999. /**
  42000. * Disables contributions to the sliding window sample set
  42001. * Samples will not be interpolated over the disabled period
  42002. */
  42003. disable(): void;
  42004. /**
  42005. * Returns true if sampling is enabled
  42006. */
  42007. get isEnabled(): boolean;
  42008. /**
  42009. * Resets performance monitor
  42010. */
  42011. reset(): void;
  42012. }
  42013. /**
  42014. * RollingAverage
  42015. *
  42016. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  42017. */
  42018. export class RollingAverage {
  42019. /**
  42020. * Current average
  42021. */
  42022. average: number;
  42023. /**
  42024. * Current variance
  42025. */
  42026. variance: number;
  42027. protected _samples: Array<number>;
  42028. protected _sampleCount: number;
  42029. protected _pos: number;
  42030. protected _m2: number;
  42031. /**
  42032. * constructor
  42033. * @param length The number of samples required to saturate the sliding window
  42034. */
  42035. constructor(length: number);
  42036. /**
  42037. * Adds a sample to the sample set
  42038. * @param v The sample value
  42039. */
  42040. add(v: number): void;
  42041. /**
  42042. * Returns previously added values or null if outside of history or outside the sliding window domain
  42043. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42044. * @return Value previously recorded with add() or null if outside of range
  42045. */
  42046. history(i: number): number;
  42047. /**
  42048. * Returns true if enough samples have been taken to completely fill the sliding window
  42049. * @return true if sample-set saturated
  42050. */
  42051. isSaturated(): boolean;
  42052. /**
  42053. * Resets the rolling average (equivalent to 0 samples taken so far)
  42054. */
  42055. reset(): void;
  42056. /**
  42057. * Wraps a value around the sample range boundaries
  42058. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42059. * @return Wrapped position in sample range
  42060. */
  42061. protected _wrapPosition(i: number): number;
  42062. }
  42063. }
  42064. declare module "babylonjs/Misc/perfCounter" {
  42065. /**
  42066. * This class is used to track a performance counter which is number based.
  42067. * The user has access to many properties which give statistics of different nature.
  42068. *
  42069. * The implementer can track two kinds of Performance Counter: time and count.
  42070. * 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.
  42071. * 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.
  42072. */
  42073. export class PerfCounter {
  42074. /**
  42075. * Gets or sets a global boolean to turn on and off all the counters
  42076. */
  42077. static Enabled: boolean;
  42078. /**
  42079. * Returns the smallest value ever
  42080. */
  42081. get min(): number;
  42082. /**
  42083. * Returns the biggest value ever
  42084. */
  42085. get max(): number;
  42086. /**
  42087. * Returns the average value since the performance counter is running
  42088. */
  42089. get average(): number;
  42090. /**
  42091. * Returns the average value of the last second the counter was monitored
  42092. */
  42093. get lastSecAverage(): number;
  42094. /**
  42095. * Returns the current value
  42096. */
  42097. get current(): number;
  42098. /**
  42099. * Gets the accumulated total
  42100. */
  42101. get total(): number;
  42102. /**
  42103. * Gets the total value count
  42104. */
  42105. get count(): number;
  42106. /**
  42107. * Creates a new counter
  42108. */
  42109. constructor();
  42110. /**
  42111. * Call this method to start monitoring a new frame.
  42112. * 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.
  42113. */
  42114. fetchNewFrame(): void;
  42115. /**
  42116. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42117. * @param newCount the count value to add to the monitored count
  42118. * @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.
  42119. */
  42120. addCount(newCount: number, fetchResult: boolean): void;
  42121. /**
  42122. * Start monitoring this performance counter
  42123. */
  42124. beginMonitoring(): void;
  42125. /**
  42126. * Compute the time lapsed since the previous beginMonitoring() call.
  42127. * @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
  42128. */
  42129. endMonitoring(newFrame?: boolean): void;
  42130. private _fetchResult;
  42131. private _startMonitoringTime;
  42132. private _min;
  42133. private _max;
  42134. private _average;
  42135. private _current;
  42136. private _totalValueCount;
  42137. private _totalAccumulated;
  42138. private _lastSecAverage;
  42139. private _lastSecAccumulated;
  42140. private _lastSecTime;
  42141. private _lastSecValueCount;
  42142. }
  42143. }
  42144. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  42145. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42146. import { Nullable } from "babylonjs/types";
  42147. module "babylonjs/Engines/thinEngine" {
  42148. interface ThinEngine {
  42149. /** @hidden */
  42150. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  42151. }
  42152. }
  42153. }
  42154. declare module "babylonjs/Audio/analyser" {
  42155. import { Scene } from "babylonjs/scene";
  42156. /**
  42157. * Class used to work with sound analyzer using fast fourier transform (FFT)
  42158. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42159. */
  42160. export class Analyser {
  42161. /**
  42162. * Gets or sets the smoothing
  42163. * @ignorenaming
  42164. */
  42165. SMOOTHING: number;
  42166. /**
  42167. * Gets or sets the FFT table size
  42168. * @ignorenaming
  42169. */
  42170. FFT_SIZE: number;
  42171. /**
  42172. * Gets or sets the bar graph amplitude
  42173. * @ignorenaming
  42174. */
  42175. BARGRAPHAMPLITUDE: number;
  42176. /**
  42177. * Gets or sets the position of the debug canvas
  42178. * @ignorenaming
  42179. */
  42180. DEBUGCANVASPOS: {
  42181. x: number;
  42182. y: number;
  42183. };
  42184. /**
  42185. * Gets or sets the debug canvas size
  42186. * @ignorenaming
  42187. */
  42188. DEBUGCANVASSIZE: {
  42189. width: number;
  42190. height: number;
  42191. };
  42192. private _byteFreqs;
  42193. private _byteTime;
  42194. private _floatFreqs;
  42195. private _webAudioAnalyser;
  42196. private _debugCanvas;
  42197. private _debugCanvasContext;
  42198. private _scene;
  42199. private _registerFunc;
  42200. private _audioEngine;
  42201. /**
  42202. * Creates a new analyser
  42203. * @param scene defines hosting scene
  42204. */
  42205. constructor(scene: Scene);
  42206. /**
  42207. * Get the number of data values you will have to play with for the visualization
  42208. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  42209. * @returns a number
  42210. */
  42211. getFrequencyBinCount(): number;
  42212. /**
  42213. * Gets the current frequency data as a byte array
  42214. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42215. * @returns a Uint8Array
  42216. */
  42217. getByteFrequencyData(): Uint8Array;
  42218. /**
  42219. * Gets the current waveform as a byte array
  42220. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  42221. * @returns a Uint8Array
  42222. */
  42223. getByteTimeDomainData(): Uint8Array;
  42224. /**
  42225. * Gets the current frequency data as a float array
  42226. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  42227. * @returns a Float32Array
  42228. */
  42229. getFloatFrequencyData(): Float32Array;
  42230. /**
  42231. * Renders the debug canvas
  42232. */
  42233. drawDebugCanvas(): void;
  42234. /**
  42235. * Stops rendering the debug canvas and removes it
  42236. */
  42237. stopDebugCanvas(): void;
  42238. /**
  42239. * Connects two audio nodes
  42240. * @param inputAudioNode defines first node to connect
  42241. * @param outputAudioNode defines second node to connect
  42242. */
  42243. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  42244. /**
  42245. * Releases all associated resources
  42246. */
  42247. dispose(): void;
  42248. }
  42249. }
  42250. declare module "babylonjs/Audio/Interfaces/IAudioEngine" {
  42251. import { Observable } from "babylonjs/Misc/observable";
  42252. import { IDisposable } from "babylonjs/scene";
  42253. import { Nullable } from "babylonjs/types";
  42254. import { Analyser } from "babylonjs/Audio/analyser";
  42255. /**
  42256. * This represents an audio engine and it is responsible
  42257. * to play, synchronize and analyse sounds throughout the application.
  42258. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42259. */
  42260. export interface IAudioEngine extends IDisposable {
  42261. /**
  42262. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  42263. */
  42264. readonly canUseWebAudio: boolean;
  42265. /**
  42266. * Gets the current AudioContext if available.
  42267. */
  42268. readonly audioContext: Nullable<AudioContext>;
  42269. /**
  42270. * The master gain node defines the global audio volume of your audio engine.
  42271. */
  42272. readonly masterGain: GainNode;
  42273. /**
  42274. * Gets whether or not mp3 are supported by your browser.
  42275. */
  42276. readonly isMP3supported: boolean;
  42277. /**
  42278. * Gets whether or not ogg are supported by your browser.
  42279. */
  42280. readonly isOGGsupported: boolean;
  42281. /**
  42282. * Defines if Babylon should emit a warning if WebAudio is not supported.
  42283. * @ignoreNaming
  42284. */
  42285. WarnedWebAudioUnsupported: boolean;
  42286. /**
  42287. * Defines if the audio engine relies on a custom unlocked button.
  42288. * In this case, the embedded button will not be displayed.
  42289. */
  42290. useCustomUnlockedButton: boolean;
  42291. /**
  42292. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  42293. */
  42294. readonly unlocked: boolean;
  42295. /**
  42296. * Event raised when audio has been unlocked on the browser.
  42297. */
  42298. onAudioUnlockedObservable: Observable<IAudioEngine>;
  42299. /**
  42300. * Event raised when audio has been locked on the browser.
  42301. */
  42302. onAudioLockedObservable: Observable<IAudioEngine>;
  42303. /**
  42304. * Flags the audio engine in Locked state.
  42305. * This happens due to new browser policies preventing audio to autoplay.
  42306. */
  42307. lock(): void;
  42308. /**
  42309. * Unlocks the audio engine once a user action has been done on the dom.
  42310. * This is helpful to resume play once browser policies have been satisfied.
  42311. */
  42312. unlock(): void;
  42313. /**
  42314. * Gets the global volume sets on the master gain.
  42315. * @returns the global volume if set or -1 otherwise
  42316. */
  42317. getGlobalVolume(): number;
  42318. /**
  42319. * Sets the global volume of your experience (sets on the master gain).
  42320. * @param newVolume Defines the new global volume of the application
  42321. */
  42322. setGlobalVolume(newVolume: number): void;
  42323. /**
  42324. * Connect the audio engine to an audio analyser allowing some amazing
  42325. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42326. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42327. * @param analyser The analyser to connect to the engine
  42328. */
  42329. connectToAnalyser(analyser: Analyser): void;
  42330. }
  42331. }
  42332. declare module "babylonjs/Engines/engine" {
  42333. import { Observable } from "babylonjs/Misc/observable";
  42334. import { Nullable } from "babylonjs/types";
  42335. import { Scene } from "babylonjs/scene";
  42336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42337. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42338. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42339. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42340. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42341. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42342. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42343. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42344. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42345. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42346. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42347. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42348. import "babylonjs/Engines/Extensions/engine.alpha";
  42349. import "babylonjs/Engines/Extensions/engine.readTexture";
  42350. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42351. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  42352. import { Material } from "babylonjs/Materials/material";
  42353. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42354. /**
  42355. * Defines the interface used by display changed events
  42356. */
  42357. export interface IDisplayChangedEventArgs {
  42358. /** Gets the vrDisplay object (if any) */
  42359. vrDisplay: Nullable<any>;
  42360. /** Gets a boolean indicating if webVR is supported */
  42361. vrSupported: boolean;
  42362. }
  42363. /**
  42364. * Defines the interface used by objects containing a viewport (like a camera)
  42365. */
  42366. interface IViewportOwnerLike {
  42367. /**
  42368. * Gets or sets the viewport
  42369. */
  42370. viewport: IViewportLike;
  42371. }
  42372. /**
  42373. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42374. */
  42375. export class Engine extends ThinEngine {
  42376. /** Defines that alpha blending is disabled */
  42377. static readonly ALPHA_DISABLE: number;
  42378. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42379. static readonly ALPHA_ADD: number;
  42380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42381. static readonly ALPHA_COMBINE: number;
  42382. /** Defines that alpha blending to DEST - SRC * DEST */
  42383. static readonly ALPHA_SUBTRACT: number;
  42384. /** Defines that alpha blending to SRC * DEST */
  42385. static readonly ALPHA_MULTIPLY: number;
  42386. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42387. static readonly ALPHA_MAXIMIZED: number;
  42388. /** Defines that alpha blending to SRC + DEST */
  42389. static readonly ALPHA_ONEONE: number;
  42390. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42391. static readonly ALPHA_PREMULTIPLIED: number;
  42392. /**
  42393. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42394. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42395. */
  42396. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42397. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42398. static readonly ALPHA_INTERPOLATE: number;
  42399. /**
  42400. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42401. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42402. */
  42403. static readonly ALPHA_SCREENMODE: number;
  42404. /** Defines that the ressource is not delayed*/
  42405. static readonly DELAYLOADSTATE_NONE: number;
  42406. /** Defines that the ressource was successfully delay loaded */
  42407. static readonly DELAYLOADSTATE_LOADED: number;
  42408. /** Defines that the ressource is currently delay loading */
  42409. static readonly DELAYLOADSTATE_LOADING: number;
  42410. /** Defines that the ressource is delayed and has not started loading */
  42411. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42413. static readonly NEVER: number;
  42414. /** 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 */
  42415. static readonly ALWAYS: number;
  42416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42417. static readonly LESS: number;
  42418. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42419. static readonly EQUAL: number;
  42420. /** 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 */
  42421. static readonly LEQUAL: number;
  42422. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42423. static readonly GREATER: number;
  42424. /** 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 */
  42425. static readonly GEQUAL: number;
  42426. /** 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 */
  42427. static readonly NOTEQUAL: number;
  42428. /** Passed to stencilOperation to specify that stencil value must be kept */
  42429. static readonly KEEP: number;
  42430. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42431. static readonly REPLACE: number;
  42432. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42433. static readonly INCR: number;
  42434. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42435. static readonly DECR: number;
  42436. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42437. static readonly INVERT: number;
  42438. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42439. static readonly INCR_WRAP: number;
  42440. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42441. static readonly DECR_WRAP: number;
  42442. /** Texture is not repeating outside of 0..1 UVs */
  42443. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42444. /** Texture is repeating outside of 0..1 UVs */
  42445. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42446. /** Texture is repeating and mirrored */
  42447. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42448. /** ALPHA */
  42449. static readonly TEXTUREFORMAT_ALPHA: number;
  42450. /** LUMINANCE */
  42451. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42452. /** LUMINANCE_ALPHA */
  42453. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42454. /** RGB */
  42455. static readonly TEXTUREFORMAT_RGB: number;
  42456. /** RGBA */
  42457. static readonly TEXTUREFORMAT_RGBA: number;
  42458. /** RED */
  42459. static readonly TEXTUREFORMAT_RED: number;
  42460. /** RED (2nd reference) */
  42461. static readonly TEXTUREFORMAT_R: number;
  42462. /** RG */
  42463. static readonly TEXTUREFORMAT_RG: number;
  42464. /** RED_INTEGER */
  42465. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42466. /** RED_INTEGER (2nd reference) */
  42467. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42468. /** RG_INTEGER */
  42469. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42470. /** RGB_INTEGER */
  42471. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42472. /** RGBA_INTEGER */
  42473. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42474. /** UNSIGNED_BYTE */
  42475. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42476. /** UNSIGNED_BYTE (2nd reference) */
  42477. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42478. /** FLOAT */
  42479. static readonly TEXTURETYPE_FLOAT: number;
  42480. /** HALF_FLOAT */
  42481. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42482. /** BYTE */
  42483. static readonly TEXTURETYPE_BYTE: number;
  42484. /** SHORT */
  42485. static readonly TEXTURETYPE_SHORT: number;
  42486. /** UNSIGNED_SHORT */
  42487. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42488. /** INT */
  42489. static readonly TEXTURETYPE_INT: number;
  42490. /** UNSIGNED_INT */
  42491. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42492. /** UNSIGNED_SHORT_4_4_4_4 */
  42493. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42494. /** UNSIGNED_SHORT_5_5_5_1 */
  42495. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42496. /** UNSIGNED_SHORT_5_6_5 */
  42497. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42498. /** UNSIGNED_INT_2_10_10_10_REV */
  42499. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42500. /** UNSIGNED_INT_24_8 */
  42501. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42502. /** UNSIGNED_INT_10F_11F_11F_REV */
  42503. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42504. /** UNSIGNED_INT_5_9_9_9_REV */
  42505. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42506. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42507. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42508. /** nearest is mag = nearest and min = nearest and mip = linear */
  42509. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42511. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42512. /** Trilinear is mag = linear and min = linear and mip = linear */
  42513. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42514. /** nearest is mag = nearest and min = nearest and mip = linear */
  42515. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42516. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42517. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42518. /** Trilinear is mag = linear and min = linear and mip = linear */
  42519. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42520. /** mag = nearest and min = nearest and mip = nearest */
  42521. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42522. /** mag = nearest and min = linear and mip = nearest */
  42523. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42524. /** mag = nearest and min = linear and mip = linear */
  42525. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42526. /** mag = nearest and min = linear and mip = none */
  42527. static readonly TEXTURE_NEAREST_LINEAR: number;
  42528. /** mag = nearest and min = nearest and mip = none */
  42529. static readonly TEXTURE_NEAREST_NEAREST: number;
  42530. /** mag = linear and min = nearest and mip = nearest */
  42531. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42532. /** mag = linear and min = nearest and mip = linear */
  42533. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42534. /** mag = linear and min = linear and mip = none */
  42535. static readonly TEXTURE_LINEAR_LINEAR: number;
  42536. /** mag = linear and min = nearest and mip = none */
  42537. static readonly TEXTURE_LINEAR_NEAREST: number;
  42538. /** Explicit coordinates mode */
  42539. static readonly TEXTURE_EXPLICIT_MODE: number;
  42540. /** Spherical coordinates mode */
  42541. static readonly TEXTURE_SPHERICAL_MODE: number;
  42542. /** Planar coordinates mode */
  42543. static readonly TEXTURE_PLANAR_MODE: number;
  42544. /** Cubic coordinates mode */
  42545. static readonly TEXTURE_CUBIC_MODE: number;
  42546. /** Projection coordinates mode */
  42547. static readonly TEXTURE_PROJECTION_MODE: number;
  42548. /** Skybox coordinates mode */
  42549. static readonly TEXTURE_SKYBOX_MODE: number;
  42550. /** Inverse Cubic coordinates mode */
  42551. static readonly TEXTURE_INVCUBIC_MODE: number;
  42552. /** Equirectangular coordinates mode */
  42553. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42554. /** Equirectangular Fixed coordinates mode */
  42555. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42556. /** Equirectangular Fixed Mirrored coordinates mode */
  42557. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42558. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42559. static readonly SCALEMODE_FLOOR: number;
  42560. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42561. static readonly SCALEMODE_NEAREST: number;
  42562. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42563. static readonly SCALEMODE_CEILING: number;
  42564. /**
  42565. * Returns the current npm package of the sdk
  42566. */
  42567. static get NpmPackage(): string;
  42568. /**
  42569. * Returns the current version of the framework
  42570. */
  42571. static get Version(): string;
  42572. /** Gets the list of created engines */
  42573. static get Instances(): Engine[];
  42574. /**
  42575. * Gets the latest created engine
  42576. */
  42577. static get LastCreatedEngine(): Nullable<Engine>;
  42578. /**
  42579. * Gets the latest created scene
  42580. */
  42581. static get LastCreatedScene(): Nullable<Scene>;
  42582. /**
  42583. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42584. * @param flag defines which part of the materials must be marked as dirty
  42585. * @param predicate defines a predicate used to filter which materials should be affected
  42586. */
  42587. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42588. /**
  42589. * Method called to create the default loading screen.
  42590. * This can be overriden in your own app.
  42591. * @param canvas The rendering canvas element
  42592. * @returns The loading screen
  42593. */
  42594. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42595. /**
  42596. * Method called to create the default rescale post process on each engine.
  42597. */
  42598. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42599. /**
  42600. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42601. **/
  42602. enableOfflineSupport: boolean;
  42603. /**
  42604. * 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)
  42605. **/
  42606. disableManifestCheck: boolean;
  42607. /**
  42608. * Gets the list of created scenes
  42609. */
  42610. scenes: Scene[];
  42611. /**
  42612. * Event raised when a new scene is created
  42613. */
  42614. onNewSceneAddedObservable: Observable<Scene>;
  42615. /**
  42616. * Gets the list of created postprocesses
  42617. */
  42618. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42619. /**
  42620. * Gets a boolean indicating if the pointer is currently locked
  42621. */
  42622. isPointerLock: boolean;
  42623. /**
  42624. * Observable event triggered each time the rendering canvas is resized
  42625. */
  42626. onResizeObservable: Observable<Engine>;
  42627. /**
  42628. * Observable event triggered each time the canvas loses focus
  42629. */
  42630. onCanvasBlurObservable: Observable<Engine>;
  42631. /**
  42632. * Observable event triggered each time the canvas gains focus
  42633. */
  42634. onCanvasFocusObservable: Observable<Engine>;
  42635. /**
  42636. * Observable event triggered each time the canvas receives pointerout event
  42637. */
  42638. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42639. /**
  42640. * Observable raised when the engine begins a new frame
  42641. */
  42642. onBeginFrameObservable: Observable<Engine>;
  42643. /**
  42644. * If set, will be used to request the next animation frame for the render loop
  42645. */
  42646. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42647. /**
  42648. * Observable raised when the engine ends the current frame
  42649. */
  42650. onEndFrameObservable: Observable<Engine>;
  42651. /**
  42652. * Observable raised when the engine is about to compile a shader
  42653. */
  42654. onBeforeShaderCompilationObservable: Observable<Engine>;
  42655. /**
  42656. * Observable raised when the engine has jsut compiled a shader
  42657. */
  42658. onAfterShaderCompilationObservable: Observable<Engine>;
  42659. /**
  42660. * Gets the audio engine
  42661. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42662. * @ignorenaming
  42663. */
  42664. static audioEngine: IAudioEngine;
  42665. /**
  42666. * Default AudioEngine factory responsible of creating the Audio Engine.
  42667. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42668. */
  42669. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42670. /**
  42671. * Default offline support factory responsible of creating a tool used to store data locally.
  42672. * By default, this will create a Database object if the workload has been embedded.
  42673. */
  42674. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42675. private _loadingScreen;
  42676. private _pointerLockRequested;
  42677. private _rescalePostProcess;
  42678. private _deterministicLockstep;
  42679. private _lockstepMaxSteps;
  42680. private _timeStep;
  42681. protected get _supportsHardwareTextureRescaling(): boolean;
  42682. private _fps;
  42683. private _deltaTime;
  42684. /** @hidden */
  42685. _drawCalls: PerfCounter;
  42686. /** 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 */
  42687. canvasTabIndex: number;
  42688. /**
  42689. * Turn this value on if you want to pause FPS computation when in background
  42690. */
  42691. disablePerformanceMonitorInBackground: boolean;
  42692. private _performanceMonitor;
  42693. /**
  42694. * Gets the performance monitor attached to this engine
  42695. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42696. */
  42697. get performanceMonitor(): PerformanceMonitor;
  42698. private _onFocus;
  42699. private _onBlur;
  42700. private _onCanvasPointerOut;
  42701. private _onCanvasBlur;
  42702. private _onCanvasFocus;
  42703. private _onFullscreenChange;
  42704. private _onPointerLockChange;
  42705. /**
  42706. * Gets the HTML element used to attach event listeners
  42707. * @returns a HTML element
  42708. */
  42709. getInputElement(): Nullable<HTMLElement>;
  42710. /**
  42711. * Creates a new engine
  42712. * @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
  42713. * @param antialias defines enable antialiasing (default: false)
  42714. * @param options defines further options to be sent to the getContext() function
  42715. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42716. */
  42717. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42718. /**
  42719. * Gets current aspect ratio
  42720. * @param viewportOwner defines the camera to use to get the aspect ratio
  42721. * @param useScreen defines if screen size must be used (or the current render target if any)
  42722. * @returns a number defining the aspect ratio
  42723. */
  42724. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42725. /**
  42726. * Gets current screen aspect ratio
  42727. * @returns a number defining the aspect ratio
  42728. */
  42729. getScreenAspectRatio(): number;
  42730. /**
  42731. * Gets the client rect of the HTML canvas attached with the current webGL context
  42732. * @returns a client rectanglee
  42733. */
  42734. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42735. /**
  42736. * Gets the client rect of the HTML element used for events
  42737. * @returns a client rectanglee
  42738. */
  42739. getInputElementClientRect(): Nullable<ClientRect>;
  42740. /**
  42741. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42742. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42743. * @returns true if engine is in deterministic lock step mode
  42744. */
  42745. isDeterministicLockStep(): boolean;
  42746. /**
  42747. * Gets the max steps when engine is running in deterministic lock step
  42748. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42749. * @returns the max steps
  42750. */
  42751. getLockstepMaxSteps(): number;
  42752. /**
  42753. * Returns the time in ms between steps when using deterministic lock step.
  42754. * @returns time step in (ms)
  42755. */
  42756. getTimeStep(): number;
  42757. /**
  42758. * Force the mipmap generation for the given render target texture
  42759. * @param texture defines the render target texture to use
  42760. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42761. */
  42762. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42763. /** States */
  42764. /**
  42765. * Set various states to the webGL context
  42766. * @param culling defines backface culling state
  42767. * @param zOffset defines the value to apply to zOffset (0 by default)
  42768. * @param force defines if states must be applied even if cache is up to date
  42769. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42770. */
  42771. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42772. /**
  42773. * Set the z offset to apply to current rendering
  42774. * @param value defines the offset to apply
  42775. */
  42776. setZOffset(value: number): void;
  42777. /**
  42778. * Gets the current value of the zOffset
  42779. * @returns the current zOffset state
  42780. */
  42781. getZOffset(): number;
  42782. /**
  42783. * Enable or disable depth buffering
  42784. * @param enable defines the state to set
  42785. */
  42786. setDepthBuffer(enable: boolean): void;
  42787. /**
  42788. * Gets a boolean indicating if depth writing is enabled
  42789. * @returns the current depth writing state
  42790. */
  42791. getDepthWrite(): boolean;
  42792. /**
  42793. * Enable or disable depth writing
  42794. * @param enable defines the state to set
  42795. */
  42796. setDepthWrite(enable: boolean): void;
  42797. /**
  42798. * Gets a boolean indicating if stencil buffer is enabled
  42799. * @returns the current stencil buffer state
  42800. */
  42801. getStencilBuffer(): boolean;
  42802. /**
  42803. * Enable or disable the stencil buffer
  42804. * @param enable defines if the stencil buffer must be enabled or disabled
  42805. */
  42806. setStencilBuffer(enable: boolean): void;
  42807. /**
  42808. * Gets the current stencil mask
  42809. * @returns a number defining the new stencil mask to use
  42810. */
  42811. getStencilMask(): number;
  42812. /**
  42813. * Sets the current stencil mask
  42814. * @param mask defines the new stencil mask to use
  42815. */
  42816. setStencilMask(mask: number): void;
  42817. /**
  42818. * Gets the current stencil function
  42819. * @returns a number defining the stencil function to use
  42820. */
  42821. getStencilFunction(): number;
  42822. /**
  42823. * Gets the current stencil reference value
  42824. * @returns a number defining the stencil reference value to use
  42825. */
  42826. getStencilFunctionReference(): number;
  42827. /**
  42828. * Gets the current stencil mask
  42829. * @returns a number defining the stencil mask to use
  42830. */
  42831. getStencilFunctionMask(): number;
  42832. /**
  42833. * Sets the current stencil function
  42834. * @param stencilFunc defines the new stencil function to use
  42835. */
  42836. setStencilFunction(stencilFunc: number): void;
  42837. /**
  42838. * Sets the current stencil reference
  42839. * @param reference defines the new stencil reference to use
  42840. */
  42841. setStencilFunctionReference(reference: number): void;
  42842. /**
  42843. * Sets the current stencil mask
  42844. * @param mask defines the new stencil mask to use
  42845. */
  42846. setStencilFunctionMask(mask: number): void;
  42847. /**
  42848. * Gets the current stencil operation when stencil fails
  42849. * @returns a number defining stencil operation to use when stencil fails
  42850. */
  42851. getStencilOperationFail(): number;
  42852. /**
  42853. * Gets the current stencil operation when depth fails
  42854. * @returns a number defining stencil operation to use when depth fails
  42855. */
  42856. getStencilOperationDepthFail(): number;
  42857. /**
  42858. * Gets the current stencil operation when stencil passes
  42859. * @returns a number defining stencil operation to use when stencil passes
  42860. */
  42861. getStencilOperationPass(): number;
  42862. /**
  42863. * Sets the stencil operation to use when stencil fails
  42864. * @param operation defines the stencil operation to use when stencil fails
  42865. */
  42866. setStencilOperationFail(operation: number): void;
  42867. /**
  42868. * Sets the stencil operation to use when depth fails
  42869. * @param operation defines the stencil operation to use when depth fails
  42870. */
  42871. setStencilOperationDepthFail(operation: number): void;
  42872. /**
  42873. * Sets the stencil operation to use when stencil passes
  42874. * @param operation defines the stencil operation to use when stencil passes
  42875. */
  42876. setStencilOperationPass(operation: number): void;
  42877. /**
  42878. * Sets a boolean indicating if the dithering state is enabled or disabled
  42879. * @param value defines the dithering state
  42880. */
  42881. setDitheringState(value: boolean): void;
  42882. /**
  42883. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42884. * @param value defines the rasterizer state
  42885. */
  42886. setRasterizerState(value: boolean): void;
  42887. /**
  42888. * Gets the current depth function
  42889. * @returns a number defining the depth function
  42890. */
  42891. getDepthFunction(): Nullable<number>;
  42892. /**
  42893. * Sets the current depth function
  42894. * @param depthFunc defines the function to use
  42895. */
  42896. setDepthFunction(depthFunc: number): void;
  42897. /**
  42898. * Sets the current depth function to GREATER
  42899. */
  42900. setDepthFunctionToGreater(): void;
  42901. /**
  42902. * Sets the current depth function to GEQUAL
  42903. */
  42904. setDepthFunctionToGreaterOrEqual(): void;
  42905. /**
  42906. * Sets the current depth function to LESS
  42907. */
  42908. setDepthFunctionToLess(): void;
  42909. /**
  42910. * Sets the current depth function to LEQUAL
  42911. */
  42912. setDepthFunctionToLessOrEqual(): void;
  42913. private _cachedStencilBuffer;
  42914. private _cachedStencilFunction;
  42915. private _cachedStencilMask;
  42916. private _cachedStencilOperationPass;
  42917. private _cachedStencilOperationFail;
  42918. private _cachedStencilOperationDepthFail;
  42919. private _cachedStencilReference;
  42920. /**
  42921. * Caches the the state of the stencil buffer
  42922. */
  42923. cacheStencilState(): void;
  42924. /**
  42925. * Restores the state of the stencil buffer
  42926. */
  42927. restoreStencilState(): void;
  42928. /**
  42929. * Directly set the WebGL Viewport
  42930. * @param x defines the x coordinate of the viewport (in screen space)
  42931. * @param y defines the y coordinate of the viewport (in screen space)
  42932. * @param width defines the width of the viewport (in screen space)
  42933. * @param height defines the height of the viewport (in screen space)
  42934. * @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
  42935. */
  42936. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42937. /**
  42938. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42939. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42940. * @param y defines the y-coordinate of the corner of the clear rectangle
  42941. * @param width defines the width of the clear rectangle
  42942. * @param height defines the height of the clear rectangle
  42943. * @param clearColor defines the clear color
  42944. */
  42945. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42946. /**
  42947. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42948. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42949. * @param y defines the y-coordinate of the corner of the clear rectangle
  42950. * @param width defines the width of the clear rectangle
  42951. * @param height defines the height of the clear rectangle
  42952. */
  42953. enableScissor(x: number, y: number, width: number, height: number): void;
  42954. /**
  42955. * Disable previously set scissor test rectangle
  42956. */
  42957. disableScissor(): void;
  42958. protected _reportDrawCall(): void;
  42959. /**
  42960. * Initializes a webVR display and starts listening to display change events
  42961. * The onVRDisplayChangedObservable will be notified upon these changes
  42962. * @returns The onVRDisplayChangedObservable
  42963. */
  42964. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42965. /** @hidden */
  42966. _prepareVRComponent(): void;
  42967. /** @hidden */
  42968. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42969. /** @hidden */
  42970. _submitVRFrame(): void;
  42971. /**
  42972. * Call this function to leave webVR mode
  42973. * Will do nothing if webVR is not supported or if there is no webVR device
  42974. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42975. */
  42976. disableVR(): void;
  42977. /**
  42978. * Gets a boolean indicating that the system is in VR mode and is presenting
  42979. * @returns true if VR mode is engaged
  42980. */
  42981. isVRPresenting(): boolean;
  42982. /** @hidden */
  42983. _requestVRFrame(): void;
  42984. /** @hidden */
  42985. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42986. /**
  42987. * Gets the source code of the vertex shader associated with a specific webGL program
  42988. * @param program defines the program to use
  42989. * @returns a string containing the source code of the vertex shader associated with the program
  42990. */
  42991. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42992. /**
  42993. * Gets the source code of the fragment shader associated with a specific webGL program
  42994. * @param program defines the program to use
  42995. * @returns a string containing the source code of the fragment shader associated with the program
  42996. */
  42997. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42998. /**
  42999. * Sets a depth stencil texture from a render target to the according uniform.
  43000. * @param channel The texture channel
  43001. * @param uniform The uniform to set
  43002. * @param texture The render target texture containing the depth stencil texture to apply
  43003. */
  43004. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  43005. /**
  43006. * Sets a texture to the webGL context from a postprocess
  43007. * @param channel defines the channel to use
  43008. * @param postProcess defines the source postprocess
  43009. */
  43010. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  43011. /**
  43012. * Binds the output of the passed in post process to the texture channel specified
  43013. * @param channel The channel the texture should be bound to
  43014. * @param postProcess The post process which's output should be bound
  43015. */
  43016. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  43017. protected _rebuildBuffers(): void;
  43018. /** @hidden */
  43019. _renderFrame(): void;
  43020. _renderLoop(): void;
  43021. /** @hidden */
  43022. _renderViews(): boolean;
  43023. /**
  43024. * Toggle full screen mode
  43025. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43026. */
  43027. switchFullscreen(requestPointerLock: boolean): void;
  43028. /**
  43029. * Enters full screen mode
  43030. * @param requestPointerLock defines if a pointer lock should be requested from the user
  43031. */
  43032. enterFullscreen(requestPointerLock: boolean): void;
  43033. /**
  43034. * Exits full screen mode
  43035. */
  43036. exitFullscreen(): void;
  43037. /**
  43038. * Enters Pointerlock mode
  43039. */
  43040. enterPointerlock(): void;
  43041. /**
  43042. * Exits Pointerlock mode
  43043. */
  43044. exitPointerlock(): void;
  43045. /**
  43046. * Begin a new frame
  43047. */
  43048. beginFrame(): void;
  43049. /**
  43050. * Enf the current frame
  43051. */
  43052. endFrame(): void;
  43053. resize(): void;
  43054. /**
  43055. * Force a specific size of the canvas
  43056. * @param width defines the new canvas' width
  43057. * @param height defines the new canvas' height
  43058. * @returns true if the size was changed
  43059. */
  43060. setSize(width: number, height: number): boolean;
  43061. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  43062. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43063. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  43064. _releaseTexture(texture: InternalTexture): void;
  43065. /**
  43066. * @hidden
  43067. * Rescales a texture
  43068. * @param source input texutre
  43069. * @param destination destination texture
  43070. * @param scene scene to use to render the resize
  43071. * @param internalFormat format to use when resizing
  43072. * @param onComplete callback to be called when resize has completed
  43073. */
  43074. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  43075. /**
  43076. * Gets the current framerate
  43077. * @returns a number representing the framerate
  43078. */
  43079. getFps(): number;
  43080. /**
  43081. * Gets the time spent between current and previous frame
  43082. * @returns a number representing the delta time in ms
  43083. */
  43084. getDeltaTime(): number;
  43085. private _measureFps;
  43086. /** @hidden */
  43087. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  43088. /**
  43089. * Updates the sample count of a render target texture
  43090. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43091. * @param texture defines the texture to update
  43092. * @param samples defines the sample count to set
  43093. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43094. */
  43095. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  43096. /**
  43097. * Updates a depth texture Comparison Mode and Function.
  43098. * If the comparison Function is equal to 0, the mode will be set to none.
  43099. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  43100. * @param texture The texture to set the comparison function for
  43101. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  43102. */
  43103. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  43104. /**
  43105. * Creates a webGL buffer to use with instanciation
  43106. * @param capacity defines the size of the buffer
  43107. * @returns the webGL buffer
  43108. */
  43109. createInstancesBuffer(capacity: number): DataBuffer;
  43110. /**
  43111. * Delete a webGL buffer used with instanciation
  43112. * @param buffer defines the webGL buffer to delete
  43113. */
  43114. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  43115. private _clientWaitAsync;
  43116. /** @hidden */
  43117. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  43118. dispose(): void;
  43119. private _disableTouchAction;
  43120. /**
  43121. * Display the loading screen
  43122. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43123. */
  43124. displayLoadingUI(): void;
  43125. /**
  43126. * Hide the loading screen
  43127. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43128. */
  43129. hideLoadingUI(): void;
  43130. /**
  43131. * Gets the current loading screen object
  43132. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43133. */
  43134. get loadingScreen(): ILoadingScreen;
  43135. /**
  43136. * Sets the current loading screen object
  43137. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43138. */
  43139. set loadingScreen(loadingScreen: ILoadingScreen);
  43140. /**
  43141. * Sets the current loading screen text
  43142. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43143. */
  43144. set loadingUIText(text: string);
  43145. /**
  43146. * Sets the current loading screen background color
  43147. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  43148. */
  43149. set loadingUIBackgroundColor(color: string);
  43150. /** Pointerlock and fullscreen */
  43151. /**
  43152. * Ask the browser to promote the current element to pointerlock mode
  43153. * @param element defines the DOM element to promote
  43154. */
  43155. static _RequestPointerlock(element: HTMLElement): void;
  43156. /**
  43157. * Asks the browser to exit pointerlock mode
  43158. */
  43159. static _ExitPointerlock(): void;
  43160. /**
  43161. * Ask the browser to promote the current element to fullscreen rendering mode
  43162. * @param element defines the DOM element to promote
  43163. */
  43164. static _RequestFullscreen(element: HTMLElement): void;
  43165. /**
  43166. * Asks the browser to exit fullscreen mode
  43167. */
  43168. static _ExitFullscreen(): void;
  43169. }
  43170. }
  43171. declare module "babylonjs/Engines/engineStore" {
  43172. import { Nullable } from "babylonjs/types";
  43173. import { Engine } from "babylonjs/Engines/engine";
  43174. import { Scene } from "babylonjs/scene";
  43175. /**
  43176. * The engine store class is responsible to hold all the instances of Engine and Scene created
  43177. * during the life time of the application.
  43178. */
  43179. export class EngineStore {
  43180. /** Gets the list of created engines */
  43181. static Instances: import("babylonjs/Engines/engine").Engine[];
  43182. /** @hidden */
  43183. static _LastCreatedScene: Nullable<Scene>;
  43184. /**
  43185. * Gets the latest created engine
  43186. */
  43187. static get LastCreatedEngine(): Nullable<Engine>;
  43188. /**
  43189. * Gets the latest created scene
  43190. */
  43191. static get LastCreatedScene(): Nullable<Scene>;
  43192. /**
  43193. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43194. * @ignorenaming
  43195. */
  43196. static UseFallbackTexture: boolean;
  43197. /**
  43198. * Texture content used if a texture cannot loaded
  43199. * @ignorenaming
  43200. */
  43201. static FallbackTexture: string;
  43202. }
  43203. }
  43204. declare module "babylonjs/Misc/promise" {
  43205. /**
  43206. * Helper class that provides a small promise polyfill
  43207. */
  43208. export class PromisePolyfill {
  43209. /**
  43210. * Static function used to check if the polyfill is required
  43211. * If this is the case then the function will inject the polyfill to window.Promise
  43212. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43213. */
  43214. static Apply(force?: boolean): void;
  43215. }
  43216. }
  43217. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  43218. /**
  43219. * Interface for screenshot methods with describe argument called `size` as object with options
  43220. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43221. */
  43222. export interface IScreenshotSize {
  43223. /**
  43224. * number in pixels for canvas height
  43225. */
  43226. height?: number;
  43227. /**
  43228. * multiplier allowing render at a higher or lower resolution
  43229. * If value is defined then height and width will be ignored and taken from camera
  43230. */
  43231. precision?: number;
  43232. /**
  43233. * number in pixels for canvas width
  43234. */
  43235. width?: number;
  43236. }
  43237. }
  43238. declare module "babylonjs/Misc/tools" {
  43239. import { Nullable, float } from "babylonjs/types";
  43240. import { DomManagement } from "babylonjs/Misc/domManagement";
  43241. import { WebRequest } from "babylonjs/Misc/webRequest";
  43242. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43243. import { ReadFileError } from "babylonjs/Misc/fileTools";
  43244. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43245. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  43246. import { Camera } from "babylonjs/Cameras/camera";
  43247. import { Engine } from "babylonjs/Engines/engine";
  43248. interface IColor4Like {
  43249. r: float;
  43250. g: float;
  43251. b: float;
  43252. a: float;
  43253. }
  43254. /**
  43255. * Class containing a set of static utilities functions
  43256. */
  43257. export class Tools {
  43258. /**
  43259. * Gets or sets the base URL to use to load assets
  43260. */
  43261. static get BaseUrl(): string;
  43262. static set BaseUrl(value: string);
  43263. /**
  43264. * Enable/Disable Custom HTTP Request Headers globally.
  43265. * default = false
  43266. * @see CustomRequestHeaders
  43267. */
  43268. static UseCustomRequestHeaders: boolean;
  43269. /**
  43270. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43271. * i.e. when loading files, where the server/service expects an Authorization header
  43272. */
  43273. static CustomRequestHeaders: {
  43274. [key: string]: string;
  43275. };
  43276. /**
  43277. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43278. */
  43279. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43280. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43281. /**
  43282. * Default behaviour for cors in the application.
  43283. * It can be a string if the expected behavior is identical in the entire app.
  43284. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43285. */
  43286. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43287. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43288. /**
  43289. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43290. * @ignorenaming
  43291. */
  43292. static get UseFallbackTexture(): boolean;
  43293. static set UseFallbackTexture(value: boolean);
  43294. /**
  43295. * Use this object to register external classes like custom textures or material
  43296. * to allow the laoders to instantiate them
  43297. */
  43298. static get RegisteredExternalClasses(): {
  43299. [key: string]: Object;
  43300. };
  43301. static set RegisteredExternalClasses(classes: {
  43302. [key: string]: Object;
  43303. });
  43304. /**
  43305. * Texture content used if a texture cannot loaded
  43306. * @ignorenaming
  43307. */
  43308. static get fallbackTexture(): string;
  43309. static set fallbackTexture(value: string);
  43310. /**
  43311. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43312. * @param u defines the coordinate on X axis
  43313. * @param v defines the coordinate on Y axis
  43314. * @param width defines the width of the source data
  43315. * @param height defines the height of the source data
  43316. * @param pixels defines the source byte array
  43317. * @param color defines the output color
  43318. */
  43319. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43320. /**
  43321. * Interpolates between a and b via alpha
  43322. * @param a The lower value (returned when alpha = 0)
  43323. * @param b The upper value (returned when alpha = 1)
  43324. * @param alpha The interpolation-factor
  43325. * @return The mixed value
  43326. */
  43327. static Mix(a: number, b: number, alpha: number): number;
  43328. /**
  43329. * Tries to instantiate a new object from a given class name
  43330. * @param className defines the class name to instantiate
  43331. * @returns the new object or null if the system was not able to do the instantiation
  43332. */
  43333. static Instantiate(className: string): any;
  43334. /**
  43335. * Provides a slice function that will work even on IE
  43336. * @param data defines the array to slice
  43337. * @param start defines the start of the data (optional)
  43338. * @param end defines the end of the data (optional)
  43339. * @returns the new sliced array
  43340. */
  43341. static Slice<T>(data: T, start?: number, end?: number): T;
  43342. /**
  43343. * Provides a slice function that will work even on IE
  43344. * The difference between this and Slice is that this will force-convert to array
  43345. * @param data defines the array to slice
  43346. * @param start defines the start of the data (optional)
  43347. * @param end defines the end of the data (optional)
  43348. * @returns the new sliced array
  43349. */
  43350. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43351. /**
  43352. * Polyfill for setImmediate
  43353. * @param action defines the action to execute after the current execution block
  43354. */
  43355. static SetImmediate(action: () => void): void;
  43356. /**
  43357. * Function indicating if a number is an exponent of 2
  43358. * @param value defines the value to test
  43359. * @returns true if the value is an exponent of 2
  43360. */
  43361. static IsExponentOfTwo(value: number): boolean;
  43362. private static _tmpFloatArray;
  43363. /**
  43364. * Returns the nearest 32-bit single precision float representation of a Number
  43365. * @param value A Number. If the parameter is of a different type, it will get converted
  43366. * to a number or to NaN if it cannot be converted
  43367. * @returns number
  43368. */
  43369. static FloatRound(value: number): number;
  43370. /**
  43371. * Extracts the filename from a path
  43372. * @param path defines the path to use
  43373. * @returns the filename
  43374. */
  43375. static GetFilename(path: string): string;
  43376. /**
  43377. * Extracts the "folder" part of a path (everything before the filename).
  43378. * @param uri The URI to extract the info from
  43379. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43380. * @returns The "folder" part of the path
  43381. */
  43382. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43383. /**
  43384. * Extracts text content from a DOM element hierarchy
  43385. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43386. */
  43387. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43388. /**
  43389. * Convert an angle in radians to degrees
  43390. * @param angle defines the angle to convert
  43391. * @returns the angle in degrees
  43392. */
  43393. static ToDegrees(angle: number): number;
  43394. /**
  43395. * Convert an angle in degrees to radians
  43396. * @param angle defines the angle to convert
  43397. * @returns the angle in radians
  43398. */
  43399. static ToRadians(angle: number): number;
  43400. /**
  43401. * Returns an array if obj is not an array
  43402. * @param obj defines the object to evaluate as an array
  43403. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43404. * @returns either obj directly if obj is an array or a new array containing obj
  43405. */
  43406. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43407. /**
  43408. * Gets the pointer prefix to use
  43409. * @param engine defines the engine we are finding the prefix for
  43410. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43411. */
  43412. static GetPointerPrefix(engine: Engine): string;
  43413. /**
  43414. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43415. * @param url define the url we are trying
  43416. * @param element define the dom element where to configure the cors policy
  43417. */
  43418. static SetCorsBehavior(url: string | string[], element: {
  43419. crossOrigin: string | null;
  43420. }): void;
  43421. /**
  43422. * Removes unwanted characters from an url
  43423. * @param url defines the url to clean
  43424. * @returns the cleaned url
  43425. */
  43426. static CleanUrl(url: string): string;
  43427. /**
  43428. * Gets or sets a function used to pre-process url before using them to load assets
  43429. */
  43430. static get PreprocessUrl(): (url: string) => string;
  43431. static set PreprocessUrl(processor: (url: string) => string);
  43432. /**
  43433. * Loads an image as an HTMLImageElement.
  43434. * @param input url string, ArrayBuffer, or Blob to load
  43435. * @param onLoad callback called when the image successfully loads
  43436. * @param onError callback called when the image fails to load
  43437. * @param offlineProvider offline provider for caching
  43438. * @param mimeType optional mime type
  43439. * @returns the HTMLImageElement of the loaded image
  43440. */
  43441. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43442. /**
  43443. * Loads a file from a url
  43444. * @param url url string, ArrayBuffer, or Blob to load
  43445. * @param onSuccess callback called when the file successfully loads
  43446. * @param onProgress callback called while file is loading (if the server supports this mode)
  43447. * @param offlineProvider defines the offline provider for caching
  43448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43449. * @param onError callback called when the file fails to load
  43450. * @returns a file request object
  43451. */
  43452. 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;
  43453. /**
  43454. * Loads a file from a url
  43455. * @param url the file url to load
  43456. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43457. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43458. */
  43459. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43460. /**
  43461. * Load a script (identified by an url). When the url returns, the
  43462. * content of this file is added into a new script element, attached to the DOM (body element)
  43463. * @param scriptUrl defines the url of the script to laod
  43464. * @param onSuccess defines the callback called when the script is loaded
  43465. * @param onError defines the callback to call if an error occurs
  43466. * @param scriptId defines the id of the script element
  43467. */
  43468. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43469. /**
  43470. * Load an asynchronous script (identified by an url). When the url returns, the
  43471. * content of this file is added into a new script element, attached to the DOM (body element)
  43472. * @param scriptUrl defines the url of the script to laod
  43473. * @param scriptId defines the id of the script element
  43474. * @returns a promise request object
  43475. */
  43476. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43477. /**
  43478. * Loads a file from a blob
  43479. * @param fileToLoad defines the blob to use
  43480. * @param callback defines the callback to call when data is loaded
  43481. * @param progressCallback defines the callback to call during loading process
  43482. * @returns a file request object
  43483. */
  43484. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43485. /**
  43486. * Reads a file from a File object
  43487. * @param file defines the file to load
  43488. * @param onSuccess defines the callback to call when data is loaded
  43489. * @param onProgress defines the callback to call during loading process
  43490. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43491. * @param onError defines the callback to call when an error occurs
  43492. * @returns a file request object
  43493. */
  43494. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43495. /**
  43496. * Creates a data url from a given string content
  43497. * @param content defines the content to convert
  43498. * @returns the new data url link
  43499. */
  43500. static FileAsURL(content: string): string;
  43501. /**
  43502. * Format the given number to a specific decimal format
  43503. * @param value defines the number to format
  43504. * @param decimals defines the number of decimals to use
  43505. * @returns the formatted string
  43506. */
  43507. static Format(value: number, decimals?: number): string;
  43508. /**
  43509. * Tries to copy an object by duplicating every property
  43510. * @param source defines the source object
  43511. * @param destination defines the target object
  43512. * @param doNotCopyList defines a list of properties to avoid
  43513. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43514. */
  43515. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43516. /**
  43517. * Gets a boolean indicating if the given object has no own property
  43518. * @param obj defines the object to test
  43519. * @returns true if object has no own property
  43520. */
  43521. static IsEmpty(obj: any): boolean;
  43522. /**
  43523. * Function used to register events at window level
  43524. * @param windowElement defines the Window object to use
  43525. * @param events defines the events to register
  43526. */
  43527. static RegisterTopRootEvents(windowElement: Window, events: {
  43528. name: string;
  43529. handler: Nullable<(e: FocusEvent) => any>;
  43530. }[]): void;
  43531. /**
  43532. * Function used to unregister events from window level
  43533. * @param windowElement defines the Window object to use
  43534. * @param events defines the events to unregister
  43535. */
  43536. static UnregisterTopRootEvents(windowElement: Window, events: {
  43537. name: string;
  43538. handler: Nullable<(e: FocusEvent) => any>;
  43539. }[]): void;
  43540. /**
  43541. * @ignore
  43542. */
  43543. static _ScreenshotCanvas: HTMLCanvasElement;
  43544. /**
  43545. * Dumps the current bound framebuffer
  43546. * @param width defines the rendering width
  43547. * @param height defines the rendering height
  43548. * @param engine defines the hosting engine
  43549. * @param successCallback defines the callback triggered once the data are available
  43550. * @param mimeType defines the mime type of the result
  43551. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43552. */
  43553. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43554. /**
  43555. * Converts the canvas data to blob.
  43556. * This acts as a polyfill for browsers not supporting the to blob function.
  43557. * @param canvas Defines the canvas to extract the data from
  43558. * @param successCallback Defines the callback triggered once the data are available
  43559. * @param mimeType Defines the mime type of the result
  43560. */
  43561. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43562. /**
  43563. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43564. * @param successCallback defines the callback triggered once the data are available
  43565. * @param mimeType defines the mime type of the result
  43566. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43567. */
  43568. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43569. /**
  43570. * Downloads a blob in the browser
  43571. * @param blob defines the blob to download
  43572. * @param fileName defines the name of the downloaded file
  43573. */
  43574. static Download(blob: Blob, fileName: string): void;
  43575. /**
  43576. * Will return the right value of the noPreventDefault variable
  43577. * Needed to keep backwards compatibility to the old API.
  43578. *
  43579. * @param args arguments passed to the attachControl function
  43580. * @returns the correct value for noPreventDefault
  43581. */
  43582. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43583. /**
  43584. * Captures a screenshot of the current rendering
  43585. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43586. * @param engine defines the rendering engine
  43587. * @param camera defines the source camera
  43588. * @param size This parameter can be set to a single number or to an object with the
  43589. * following (optional) properties: precision, width, height. If a single number is passed,
  43590. * it will be used for both width and height. If an object is passed, the screenshot size
  43591. * will be derived from the parameters. The precision property is a multiplier allowing
  43592. * rendering at a higher or lower resolution
  43593. * @param successCallback defines the callback receives a single parameter which contains the
  43594. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43595. * src parameter of an <img> to display it
  43596. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43597. * Check your browser for supported MIME types
  43598. */
  43599. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43600. /**
  43601. * Captures a screenshot of the current rendering
  43602. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43603. * @param engine defines the rendering engine
  43604. * @param camera defines the source camera
  43605. * @param size This parameter can be set to a single number or to an object with the
  43606. * following (optional) properties: precision, width, height. If a single number is passed,
  43607. * it will be used for both width and height. If an object is passed, the screenshot size
  43608. * will be derived from the parameters. The precision property is a multiplier allowing
  43609. * rendering at a higher or lower resolution
  43610. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43611. * Check your browser for supported MIME types
  43612. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43613. * to the src parameter of an <img> to display it
  43614. */
  43615. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43616. /**
  43617. * Generates an image screenshot from the specified camera.
  43618. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43619. * @param engine The engine to use for rendering
  43620. * @param camera The camera to use for rendering
  43621. * @param size This parameter can be set to a single number or to an object with the
  43622. * following (optional) properties: precision, width, height. If a single number is passed,
  43623. * it will be used for both width and height. If an object is passed, the screenshot size
  43624. * will be derived from the parameters. The precision property is a multiplier allowing
  43625. * rendering at a higher or lower resolution
  43626. * @param successCallback The callback receives a single parameter which contains the
  43627. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43628. * src parameter of an <img> to display it
  43629. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43630. * Check your browser for supported MIME types
  43631. * @param samples Texture samples (default: 1)
  43632. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43633. * @param fileName A name for for the downloaded file.
  43634. */
  43635. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43636. /**
  43637. * Generates an image screenshot from the specified camera.
  43638. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43639. * @param engine The engine to use for rendering
  43640. * @param camera The camera to use for rendering
  43641. * @param size This parameter can be set to a single number or to an object with the
  43642. * following (optional) properties: precision, width, height. If a single number is passed,
  43643. * it will be used for both width and height. If an object is passed, the screenshot size
  43644. * will be derived from the parameters. The precision property is a multiplier allowing
  43645. * rendering at a higher or lower resolution
  43646. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43647. * Check your browser for supported MIME types
  43648. * @param samples Texture samples (default: 1)
  43649. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43650. * @param fileName A name for for the downloaded file.
  43651. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43652. * to the src parameter of an <img> to display it
  43653. */
  43654. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43655. /**
  43656. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43657. * Be aware Math.random() could cause collisions, but:
  43658. * "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"
  43659. * @returns a pseudo random id
  43660. */
  43661. static RandomId(): string;
  43662. /**
  43663. * Test if the given uri is a base64 string
  43664. * @param uri The uri to test
  43665. * @return True if the uri is a base64 string or false otherwise
  43666. */
  43667. static IsBase64(uri: string): boolean;
  43668. /**
  43669. * Decode the given base64 uri.
  43670. * @param uri The uri to decode
  43671. * @return The decoded base64 data.
  43672. */
  43673. static DecodeBase64(uri: string): ArrayBuffer;
  43674. /**
  43675. * Gets the absolute url.
  43676. * @param url the input url
  43677. * @return the absolute url
  43678. */
  43679. static GetAbsoluteUrl(url: string): string;
  43680. /**
  43681. * No log
  43682. */
  43683. static readonly NoneLogLevel: number;
  43684. /**
  43685. * Only message logs
  43686. */
  43687. static readonly MessageLogLevel: number;
  43688. /**
  43689. * Only warning logs
  43690. */
  43691. static readonly WarningLogLevel: number;
  43692. /**
  43693. * Only error logs
  43694. */
  43695. static readonly ErrorLogLevel: number;
  43696. /**
  43697. * All logs
  43698. */
  43699. static readonly AllLogLevel: number;
  43700. /**
  43701. * Gets a value indicating the number of loading errors
  43702. * @ignorenaming
  43703. */
  43704. static get errorsCount(): number;
  43705. /**
  43706. * Callback called when a new log is added
  43707. */
  43708. static OnNewCacheEntry: (entry: string) => void;
  43709. /**
  43710. * Log a message to the console
  43711. * @param message defines the message to log
  43712. */
  43713. static Log(message: string): void;
  43714. /**
  43715. * Write a warning message to the console
  43716. * @param message defines the message to log
  43717. */
  43718. static Warn(message: string): void;
  43719. /**
  43720. * Write an error message to the console
  43721. * @param message defines the message to log
  43722. */
  43723. static Error(message: string): void;
  43724. /**
  43725. * Gets current log cache (list of logs)
  43726. */
  43727. static get LogCache(): string;
  43728. /**
  43729. * Clears the log cache
  43730. */
  43731. static ClearLogCache(): void;
  43732. /**
  43733. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43734. */
  43735. static set LogLevels(level: number);
  43736. /**
  43737. * Checks if the window object exists
  43738. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43739. */
  43740. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43741. /**
  43742. * No performance log
  43743. */
  43744. static readonly PerformanceNoneLogLevel: number;
  43745. /**
  43746. * Use user marks to log performance
  43747. */
  43748. static readonly PerformanceUserMarkLogLevel: number;
  43749. /**
  43750. * Log performance to the console
  43751. */
  43752. static readonly PerformanceConsoleLogLevel: number;
  43753. private static _performance;
  43754. /**
  43755. * Sets the current performance log level
  43756. */
  43757. static set PerformanceLogLevel(level: number);
  43758. private static _StartPerformanceCounterDisabled;
  43759. private static _EndPerformanceCounterDisabled;
  43760. private static _StartUserMark;
  43761. private static _EndUserMark;
  43762. private static _StartPerformanceConsole;
  43763. private static _EndPerformanceConsole;
  43764. /**
  43765. * Starts a performance counter
  43766. */
  43767. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43768. /**
  43769. * Ends a specific performance coutner
  43770. */
  43771. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43772. /**
  43773. * Gets either window.performance.now() if supported or Date.now() else
  43774. */
  43775. static get Now(): number;
  43776. /**
  43777. * This method will return the name of the class used to create the instance of the given object.
  43778. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43779. * @param object the object to get the class name from
  43780. * @param isType defines if the object is actually a type
  43781. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43782. */
  43783. static GetClassName(object: any, isType?: boolean): string;
  43784. /**
  43785. * Gets the first element of an array satisfying a given predicate
  43786. * @param array defines the array to browse
  43787. * @param predicate defines the predicate to use
  43788. * @returns null if not found or the element
  43789. */
  43790. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43791. /**
  43792. * This method will return the name of the full name of the class, including its owning module (if any).
  43793. * 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).
  43794. * @param object the object to get the class name from
  43795. * @param isType defines if the object is actually a type
  43796. * @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.
  43797. * @ignorenaming
  43798. */
  43799. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43800. /**
  43801. * Returns a promise that resolves after the given amount of time.
  43802. * @param delay Number of milliseconds to delay
  43803. * @returns Promise that resolves after the given amount of time
  43804. */
  43805. static DelayAsync(delay: number): Promise<void>;
  43806. /**
  43807. * Utility function to detect if the current user agent is Safari
  43808. * @returns whether or not the current user agent is safari
  43809. */
  43810. static IsSafari(): boolean;
  43811. }
  43812. /**
  43813. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43814. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43815. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43816. * @param name The name of the class, case should be preserved
  43817. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43818. */
  43819. export function className(name: string, module?: string): (target: Object) => void;
  43820. /**
  43821. * An implementation of a loop for asynchronous functions.
  43822. */
  43823. export class AsyncLoop {
  43824. /**
  43825. * Defines the number of iterations for the loop
  43826. */
  43827. iterations: number;
  43828. /**
  43829. * Defines the current index of the loop.
  43830. */
  43831. index: number;
  43832. private _done;
  43833. private _fn;
  43834. private _successCallback;
  43835. /**
  43836. * Constructor.
  43837. * @param iterations the number of iterations.
  43838. * @param func the function to run each iteration
  43839. * @param successCallback the callback that will be called upon succesful execution
  43840. * @param offset starting offset.
  43841. */
  43842. constructor(
  43843. /**
  43844. * Defines the number of iterations for the loop
  43845. */
  43846. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43847. /**
  43848. * Execute the next iteration. Must be called after the last iteration was finished.
  43849. */
  43850. executeNext(): void;
  43851. /**
  43852. * Break the loop and run the success callback.
  43853. */
  43854. breakLoop(): void;
  43855. /**
  43856. * Create and run an async loop.
  43857. * @param iterations the number of iterations.
  43858. * @param fn the function to run each iteration
  43859. * @param successCallback the callback that will be called upon succesful execution
  43860. * @param offset starting offset.
  43861. * @returns the created async loop object
  43862. */
  43863. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43864. /**
  43865. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43866. * @param iterations total number of iterations
  43867. * @param syncedIterations number of synchronous iterations in each async iteration.
  43868. * @param fn the function to call each iteration.
  43869. * @param callback a success call back that will be called when iterating stops.
  43870. * @param breakFunction a break condition (optional)
  43871. * @param timeout timeout settings for the setTimeout function. default - 0.
  43872. * @returns the created async loop object
  43873. */
  43874. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43875. }
  43876. }
  43877. declare module "babylonjs/Misc/stringDictionary" {
  43878. import { Nullable } from "babylonjs/types";
  43879. /**
  43880. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43881. * The underlying implementation relies on an associative array to ensure the best performances.
  43882. * The value can be anything including 'null' but except 'undefined'
  43883. */
  43884. export class StringDictionary<T> {
  43885. /**
  43886. * This will clear this dictionary and copy the content from the 'source' one.
  43887. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43888. * @param source the dictionary to take the content from and copy to this dictionary
  43889. */
  43890. copyFrom(source: StringDictionary<T>): void;
  43891. /**
  43892. * Get a value based from its key
  43893. * @param key the given key to get the matching value from
  43894. * @return the value if found, otherwise undefined is returned
  43895. */
  43896. get(key: string): T | undefined;
  43897. /**
  43898. * Get a value from its key or add it if it doesn't exist.
  43899. * This method will ensure you that a given key/data will be present in the dictionary.
  43900. * @param key the given key to get the matching value from
  43901. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43902. * The factory will only be invoked if there's no data for the given key.
  43903. * @return the value corresponding to the key.
  43904. */
  43905. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43906. /**
  43907. * Get a value from its key if present in the dictionary otherwise add it
  43908. * @param key the key to get the value from
  43909. * @param val if there's no such key/value pair in the dictionary add it with this value
  43910. * @return the value corresponding to the key
  43911. */
  43912. getOrAdd(key: string, val: T): T;
  43913. /**
  43914. * Check if there's a given key in the dictionary
  43915. * @param key the key to check for
  43916. * @return true if the key is present, false otherwise
  43917. */
  43918. contains(key: string): boolean;
  43919. /**
  43920. * Add a new key and its corresponding value
  43921. * @param key the key to add
  43922. * @param value the value corresponding to the key
  43923. * @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
  43924. */
  43925. add(key: string, value: T): boolean;
  43926. /**
  43927. * Update a specific value associated to a key
  43928. * @param key defines the key to use
  43929. * @param value defines the value to store
  43930. * @returns true if the value was updated (or false if the key was not found)
  43931. */
  43932. set(key: string, value: T): boolean;
  43933. /**
  43934. * Get the element of the given key and remove it from the dictionary
  43935. * @param key defines the key to search
  43936. * @returns the value associated with the key or null if not found
  43937. */
  43938. getAndRemove(key: string): Nullable<T>;
  43939. /**
  43940. * Remove a key/value from the dictionary.
  43941. * @param key the key to remove
  43942. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43943. */
  43944. remove(key: string): boolean;
  43945. /**
  43946. * Clear the whole content of the dictionary
  43947. */
  43948. clear(): void;
  43949. /**
  43950. * Gets the current count
  43951. */
  43952. get count(): number;
  43953. /**
  43954. * Execute a callback on each key/val of the dictionary.
  43955. * Note that you can remove any element in this dictionary in the callback implementation
  43956. * @param callback the callback to execute on a given key/value pair
  43957. */
  43958. forEach(callback: (key: string, val: T) => void): void;
  43959. /**
  43960. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43961. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43962. * Note that you can remove any element in this dictionary in the callback implementation
  43963. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43964. * @returns the first item
  43965. */
  43966. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43967. private _count;
  43968. private _data;
  43969. }
  43970. }
  43971. declare module "babylonjs/Collisions/collisionCoordinator" {
  43972. import { Nullable } from "babylonjs/types";
  43973. import { Scene } from "babylonjs/scene";
  43974. import { Vector3 } from "babylonjs/Maths/math.vector";
  43975. import { Collider } from "babylonjs/Collisions/collider";
  43976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43977. /** @hidden */
  43978. export interface ICollisionCoordinator {
  43979. createCollider(): Collider;
  43980. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43981. init(scene: Scene): void;
  43982. }
  43983. /** @hidden */
  43984. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43985. private _scene;
  43986. private _scaledPosition;
  43987. private _scaledVelocity;
  43988. private _finalPosition;
  43989. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43990. createCollider(): Collider;
  43991. init(scene: Scene): void;
  43992. private _collideWithWorld;
  43993. }
  43994. }
  43995. declare module "babylonjs/Inputs/scene.inputManager" {
  43996. import { Nullable } from "babylonjs/types";
  43997. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43998. import { Vector2 } from "babylonjs/Maths/math.vector";
  43999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44000. import { Scene } from "babylonjs/scene";
  44001. /**
  44002. * Class used to manage all inputs for the scene.
  44003. */
  44004. export class InputManager {
  44005. /** The distance in pixel that you have to move to prevent some events */
  44006. static DragMovementThreshold: number;
  44007. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  44008. static LongPressDelay: number;
  44009. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  44010. static DoubleClickDelay: number;
  44011. /** If you need to check double click without raising a single click at first click, enable this flag */
  44012. static ExclusiveDoubleClickMode: boolean;
  44013. /** 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. */
  44014. private _alreadyAttached;
  44015. private _alreadyAttachedTo;
  44016. private _wheelEventName;
  44017. private _onPointerMove;
  44018. private _onPointerDown;
  44019. private _onPointerUp;
  44020. private _initClickEvent;
  44021. private _initActionManager;
  44022. private _delayedSimpleClick;
  44023. private _delayedSimpleClickTimeout;
  44024. private _previousDelayedSimpleClickTimeout;
  44025. private _meshPickProceed;
  44026. private _previousButtonPressed;
  44027. private _currentPickResult;
  44028. private _previousPickResult;
  44029. private _totalPointersPressed;
  44030. private _doubleClickOccured;
  44031. private _pointerOverMesh;
  44032. private _pickedDownMesh;
  44033. private _pickedUpMesh;
  44034. private _pointerX;
  44035. private _pointerY;
  44036. private _unTranslatedPointerX;
  44037. private _unTranslatedPointerY;
  44038. private _startingPointerPosition;
  44039. private _previousStartingPointerPosition;
  44040. private _startingPointerTime;
  44041. private _previousStartingPointerTime;
  44042. private _pointerCaptures;
  44043. private _meshUnderPointerId;
  44044. private _onKeyDown;
  44045. private _onKeyUp;
  44046. private _keyboardIsAttached;
  44047. private _onCanvasFocusObserver;
  44048. private _onCanvasBlurObserver;
  44049. private _scene;
  44050. /**
  44051. * Creates a new InputManager
  44052. * @param scene defines the hosting scene
  44053. */
  44054. constructor(scene: Scene);
  44055. /**
  44056. * Gets the mesh that is currently under the pointer
  44057. */
  44058. get meshUnderPointer(): Nullable<AbstractMesh>;
  44059. /**
  44060. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  44061. * @param pointerId the pointer id to use
  44062. * @returns The mesh under this pointer id or null if not found
  44063. */
  44064. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  44065. /**
  44066. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  44067. */
  44068. get unTranslatedPointer(): Vector2;
  44069. /**
  44070. * Gets or sets the current on-screen X position of the pointer
  44071. */
  44072. get pointerX(): number;
  44073. set pointerX(value: number);
  44074. /**
  44075. * Gets or sets the current on-screen Y position of the pointer
  44076. */
  44077. get pointerY(): number;
  44078. set pointerY(value: number);
  44079. private _updatePointerPosition;
  44080. private _processPointerMove;
  44081. private _setRayOnPointerInfo;
  44082. private _checkPrePointerObservable;
  44083. /**
  44084. * Use this method to simulate a pointer move on a mesh
  44085. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44086. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44087. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44088. */
  44089. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44090. /**
  44091. * Use this method to simulate a pointer down on a mesh
  44092. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44093. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44094. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44095. */
  44096. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  44097. private _processPointerDown;
  44098. /** @hidden */
  44099. _isPointerSwiping(): boolean;
  44100. /**
  44101. * Use this method to simulate a pointer up on a mesh
  44102. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  44103. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  44104. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  44105. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  44106. */
  44107. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  44108. private _processPointerUp;
  44109. /**
  44110. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  44111. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  44112. * @returns true if the pointer was captured
  44113. */
  44114. isPointerCaptured(pointerId?: number): boolean;
  44115. /**
  44116. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  44117. * @param attachUp defines if you want to attach events to pointerup
  44118. * @param attachDown defines if you want to attach events to pointerdown
  44119. * @param attachMove defines if you want to attach events to pointermove
  44120. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  44121. */
  44122. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  44123. /**
  44124. * Detaches all event handlers
  44125. */
  44126. detachControl(): void;
  44127. /**
  44128. * Force the value of meshUnderPointer
  44129. * @param mesh defines the mesh to use
  44130. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  44131. */
  44132. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44133. /**
  44134. * Gets the mesh under the pointer
  44135. * @returns a Mesh or null if no mesh is under the pointer
  44136. */
  44137. getPointerOverMesh(): Nullable<AbstractMesh>;
  44138. }
  44139. }
  44140. declare module "babylonjs/Animations/animationGroup" {
  44141. import { Animatable } from "babylonjs/Animations/animatable";
  44142. import { Animation } from "babylonjs/Animations/animation";
  44143. import { Scene, IDisposable } from "babylonjs/scene";
  44144. import { Observable } from "babylonjs/Misc/observable";
  44145. import { Nullable } from "babylonjs/types";
  44146. import "babylonjs/Animations/animatable";
  44147. /**
  44148. * This class defines the direct association between an animation and a target
  44149. */
  44150. export class TargetedAnimation {
  44151. /**
  44152. * Animation to perform
  44153. */
  44154. animation: Animation;
  44155. /**
  44156. * Target to animate
  44157. */
  44158. target: any;
  44159. /**
  44160. * Returns the string "TargetedAnimation"
  44161. * @returns "TargetedAnimation"
  44162. */
  44163. getClassName(): string;
  44164. /**
  44165. * Serialize the object
  44166. * @returns the JSON object representing the current entity
  44167. */
  44168. serialize(): any;
  44169. }
  44170. /**
  44171. * Use this class to create coordinated animations on multiple targets
  44172. */
  44173. export class AnimationGroup implements IDisposable {
  44174. /** The name of the animation group */
  44175. name: string;
  44176. private _scene;
  44177. private _targetedAnimations;
  44178. private _animatables;
  44179. private _from;
  44180. private _to;
  44181. private _isStarted;
  44182. private _isPaused;
  44183. private _speedRatio;
  44184. private _loopAnimation;
  44185. private _isAdditive;
  44186. /**
  44187. * Gets or sets the unique id of the node
  44188. */
  44189. uniqueId: number;
  44190. /**
  44191. * This observable will notify when one animation have ended
  44192. */
  44193. onAnimationEndObservable: Observable<TargetedAnimation>;
  44194. /**
  44195. * Observer raised when one animation loops
  44196. */
  44197. onAnimationLoopObservable: Observable<TargetedAnimation>;
  44198. /**
  44199. * Observer raised when all animations have looped
  44200. */
  44201. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  44202. /**
  44203. * This observable will notify when all animations have ended.
  44204. */
  44205. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  44206. /**
  44207. * This observable will notify when all animations have paused.
  44208. */
  44209. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  44210. /**
  44211. * This observable will notify when all animations are playing.
  44212. */
  44213. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44214. /**
  44215. * Gets the first frame
  44216. */
  44217. get from(): number;
  44218. /**
  44219. * Gets the last frame
  44220. */
  44221. get to(): number;
  44222. /**
  44223. * Define if the animations are started
  44224. */
  44225. get isStarted(): boolean;
  44226. /**
  44227. * Gets a value indicating that the current group is playing
  44228. */
  44229. get isPlaying(): boolean;
  44230. /**
  44231. * Gets or sets the speed ratio to use for all animations
  44232. */
  44233. get speedRatio(): number;
  44234. /**
  44235. * Gets or sets the speed ratio to use for all animations
  44236. */
  44237. set speedRatio(value: number);
  44238. /**
  44239. * Gets or sets if all animations should loop or not
  44240. */
  44241. get loopAnimation(): boolean;
  44242. set loopAnimation(value: boolean);
  44243. /**
  44244. * Gets or sets if all animations should be evaluated additively
  44245. */
  44246. get isAdditive(): boolean;
  44247. set isAdditive(value: boolean);
  44248. /**
  44249. * Gets the targeted animations for this animation group
  44250. */
  44251. get targetedAnimations(): Array<TargetedAnimation>;
  44252. /**
  44253. * returning the list of animatables controlled by this animation group.
  44254. */
  44255. get animatables(): Array<Animatable>;
  44256. /**
  44257. * Gets the list of target animations
  44258. */
  44259. get children(): TargetedAnimation[];
  44260. /**
  44261. * Instantiates a new Animation Group.
  44262. * This helps managing several animations at once.
  44263. * @see https://doc.babylonjs.com/how_to/group
  44264. * @param name Defines the name of the group
  44265. * @param scene Defines the scene the group belongs to
  44266. */
  44267. constructor(
  44268. /** The name of the animation group */
  44269. name: string, scene?: Nullable<Scene>);
  44270. /**
  44271. * Add an animation (with its target) in the group
  44272. * @param animation defines the animation we want to add
  44273. * @param target defines the target of the animation
  44274. * @returns the TargetedAnimation object
  44275. */
  44276. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44277. /**
  44278. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44279. * It can add constant keys at begin or end
  44280. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44281. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44282. * @returns the animation group
  44283. */
  44284. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44285. private _animationLoopCount;
  44286. private _animationLoopFlags;
  44287. private _processLoop;
  44288. /**
  44289. * Start all animations on given targets
  44290. * @param loop defines if animations must loop
  44291. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44292. * @param from defines the from key (optional)
  44293. * @param to defines the to key (optional)
  44294. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44295. * @returns the current animation group
  44296. */
  44297. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44298. /**
  44299. * Pause all animations
  44300. * @returns the animation group
  44301. */
  44302. pause(): AnimationGroup;
  44303. /**
  44304. * Play all animations to initial state
  44305. * This function will start() the animations if they were not started or will restart() them if they were paused
  44306. * @param loop defines if animations must loop
  44307. * @returns the animation group
  44308. */
  44309. play(loop?: boolean): AnimationGroup;
  44310. /**
  44311. * Reset all animations to initial state
  44312. * @returns the animation group
  44313. */
  44314. reset(): AnimationGroup;
  44315. /**
  44316. * Restart animations from key 0
  44317. * @returns the animation group
  44318. */
  44319. restart(): AnimationGroup;
  44320. /**
  44321. * Stop all animations
  44322. * @returns the animation group
  44323. */
  44324. stop(): AnimationGroup;
  44325. /**
  44326. * Set animation weight for all animatables
  44327. * @param weight defines the weight to use
  44328. * @return the animationGroup
  44329. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44330. */
  44331. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44332. /**
  44333. * Synchronize and normalize all animatables with a source animatable
  44334. * @param root defines the root animatable to synchronize with
  44335. * @return the animationGroup
  44336. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44337. */
  44338. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44339. /**
  44340. * Goes to a specific frame in this animation group
  44341. * @param frame the frame number to go to
  44342. * @return the animationGroup
  44343. */
  44344. goToFrame(frame: number): AnimationGroup;
  44345. /**
  44346. * Dispose all associated resources
  44347. */
  44348. dispose(): void;
  44349. private _checkAnimationGroupEnded;
  44350. /**
  44351. * Clone the current animation group and returns a copy
  44352. * @param newName defines the name of the new group
  44353. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44354. * @returns the new aniamtion group
  44355. */
  44356. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44357. /**
  44358. * Serializes the animationGroup to an object
  44359. * @returns Serialized object
  44360. */
  44361. serialize(): any;
  44362. /**
  44363. * Returns a new AnimationGroup object parsed from the source provided.
  44364. * @param parsedAnimationGroup defines the source
  44365. * @param scene defines the scene that will receive the animationGroup
  44366. * @returns a new AnimationGroup
  44367. */
  44368. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44369. /**
  44370. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44371. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44372. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44373. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44374. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44375. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44376. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44377. */
  44378. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44379. /**
  44380. * Returns the string "AnimationGroup"
  44381. * @returns "AnimationGroup"
  44382. */
  44383. getClassName(): string;
  44384. /**
  44385. * Creates a detailled string about the object
  44386. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44387. * @returns a string representing the object
  44388. */
  44389. toString(fullDetails?: boolean): string;
  44390. }
  44391. }
  44392. declare module "babylonjs/scene" {
  44393. import { Nullable } from "babylonjs/types";
  44394. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44395. import { Observable } from "babylonjs/Misc/observable";
  44396. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44397. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44398. import { Geometry } from "babylonjs/Meshes/geometry";
  44399. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44400. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44402. import { Mesh } from "babylonjs/Meshes/mesh";
  44403. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44404. import { Bone } from "babylonjs/Bones/bone";
  44405. import { Skeleton } from "babylonjs/Bones/skeleton";
  44406. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44407. import { Camera } from "babylonjs/Cameras/camera";
  44408. import { AbstractScene } from "babylonjs/abstractScene";
  44409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44411. import { Material } from "babylonjs/Materials/material";
  44412. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44413. import { Effect } from "babylonjs/Materials/effect";
  44414. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44415. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44416. import { Light } from "babylonjs/Lights/light";
  44417. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44418. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44419. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44420. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44421. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44422. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44423. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44424. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44425. import { Engine } from "babylonjs/Engines/engine";
  44426. import { Node } from "babylonjs/node";
  44427. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44428. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44429. import { WebRequest } from "babylonjs/Misc/webRequest";
  44430. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44431. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44432. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44433. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44434. import { Plane } from "babylonjs/Maths/math.plane";
  44435. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44436. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44437. import { Ray } from "babylonjs/Culling/ray";
  44438. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44439. import { Animation } from "babylonjs/Animations/animation";
  44440. import { Animatable } from "babylonjs/Animations/animatable";
  44441. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44442. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44443. import { Collider } from "babylonjs/Collisions/collider";
  44444. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44445. /**
  44446. * Define an interface for all classes that will hold resources
  44447. */
  44448. export interface IDisposable {
  44449. /**
  44450. * Releases all held resources
  44451. */
  44452. dispose(): void;
  44453. }
  44454. /** Interface defining initialization parameters for Scene class */
  44455. export interface SceneOptions {
  44456. /**
  44457. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44458. * It will improve performance when the number of geometries becomes important.
  44459. */
  44460. useGeometryUniqueIdsMap?: boolean;
  44461. /**
  44462. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44463. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44464. */
  44465. useMaterialMeshMap?: boolean;
  44466. /**
  44467. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44468. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44469. */
  44470. useClonedMeshMap?: boolean;
  44471. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44472. virtual?: boolean;
  44473. }
  44474. /**
  44475. * Represents a scene to be rendered by the engine.
  44476. * @see https://doc.babylonjs.com/features/scene
  44477. */
  44478. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44479. /** The fog is deactivated */
  44480. static readonly FOGMODE_NONE: number;
  44481. /** The fog density is following an exponential function */
  44482. static readonly FOGMODE_EXP: number;
  44483. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44484. static readonly FOGMODE_EXP2: number;
  44485. /** The fog density is following a linear function. */
  44486. static readonly FOGMODE_LINEAR: number;
  44487. /**
  44488. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44489. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44490. */
  44491. static MinDeltaTime: number;
  44492. /**
  44493. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44494. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44495. */
  44496. static MaxDeltaTime: number;
  44497. /**
  44498. * Factory used to create the default material.
  44499. * @param name The name of the material to create
  44500. * @param scene The scene to create the material for
  44501. * @returns The default material
  44502. */
  44503. static DefaultMaterialFactory(scene: Scene): Material;
  44504. /**
  44505. * Factory used to create the a collision coordinator.
  44506. * @returns The collision coordinator
  44507. */
  44508. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44509. /** @hidden */
  44510. _inputManager: InputManager;
  44511. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44512. cameraToUseForPointers: Nullable<Camera>;
  44513. /** @hidden */
  44514. readonly _isScene: boolean;
  44515. /** @hidden */
  44516. _blockEntityCollection: boolean;
  44517. /**
  44518. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44519. */
  44520. autoClear: boolean;
  44521. /**
  44522. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44523. */
  44524. autoClearDepthAndStencil: boolean;
  44525. /**
  44526. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44527. */
  44528. clearColor: Color4;
  44529. /**
  44530. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44531. */
  44532. ambientColor: Color3;
  44533. /**
  44534. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44535. * It should only be one of the following (if not the default embedded one):
  44536. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44537. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44538. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44539. * The material properties need to be setup according to the type of texture in use.
  44540. */
  44541. environmentBRDFTexture: BaseTexture;
  44542. /**
  44543. * Texture used in all pbr material as the reflection texture.
  44544. * As in the majority of the scene they are the same (exception for multi room and so on),
  44545. * this is easier to reference from here than from all the materials.
  44546. */
  44547. get environmentTexture(): Nullable<BaseTexture>;
  44548. /**
  44549. * Texture used in all pbr material as the reflection texture.
  44550. * As in the majority of the scene they are the same (exception for multi room and so on),
  44551. * this is easier to set here than in all the materials.
  44552. */
  44553. set environmentTexture(value: Nullable<BaseTexture>);
  44554. /** @hidden */
  44555. protected _environmentIntensity: number;
  44556. /**
  44557. * Intensity of the environment in all pbr material.
  44558. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44559. * As in the majority of the scene they are the same (exception for multi room and so on),
  44560. * this is easier to reference from here than from all the materials.
  44561. */
  44562. get environmentIntensity(): number;
  44563. /**
  44564. * Intensity of the environment in all pbr material.
  44565. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44566. * As in the majority of the scene they are the same (exception for multi room and so on),
  44567. * this is easier to set here than in all the materials.
  44568. */
  44569. set environmentIntensity(value: number);
  44570. /** @hidden */
  44571. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44572. /**
  44573. * Default image processing configuration used either in the rendering
  44574. * Forward main pass or through the imageProcessingPostProcess if present.
  44575. * As in the majority of the scene they are the same (exception for multi camera),
  44576. * this is easier to reference from here than from all the materials and post process.
  44577. *
  44578. * No setter as we it is a shared configuration, you can set the values instead.
  44579. */
  44580. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44581. private _forceWireframe;
  44582. /**
  44583. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44584. */
  44585. set forceWireframe(value: boolean);
  44586. get forceWireframe(): boolean;
  44587. private _skipFrustumClipping;
  44588. /**
  44589. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44590. */
  44591. set skipFrustumClipping(value: boolean);
  44592. get skipFrustumClipping(): boolean;
  44593. private _forcePointsCloud;
  44594. /**
  44595. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44596. */
  44597. set forcePointsCloud(value: boolean);
  44598. get forcePointsCloud(): boolean;
  44599. /**
  44600. * Gets or sets the active clipplane 1
  44601. */
  44602. clipPlane: Nullable<Plane>;
  44603. /**
  44604. * Gets or sets the active clipplane 2
  44605. */
  44606. clipPlane2: Nullable<Plane>;
  44607. /**
  44608. * Gets or sets the active clipplane 3
  44609. */
  44610. clipPlane3: Nullable<Plane>;
  44611. /**
  44612. * Gets or sets the active clipplane 4
  44613. */
  44614. clipPlane4: Nullable<Plane>;
  44615. /**
  44616. * Gets or sets the active clipplane 5
  44617. */
  44618. clipPlane5: Nullable<Plane>;
  44619. /**
  44620. * Gets or sets the active clipplane 6
  44621. */
  44622. clipPlane6: Nullable<Plane>;
  44623. /**
  44624. * Gets or sets a boolean indicating if animations are enabled
  44625. */
  44626. animationsEnabled: boolean;
  44627. private _animationPropertiesOverride;
  44628. /**
  44629. * Gets or sets the animation properties override
  44630. */
  44631. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44632. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44633. /**
  44634. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44635. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44636. */
  44637. useConstantAnimationDeltaTime: boolean;
  44638. /**
  44639. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44640. * Please note that it requires to run a ray cast through the scene on every frame
  44641. */
  44642. constantlyUpdateMeshUnderPointer: boolean;
  44643. /**
  44644. * Defines the HTML cursor to use when hovering over interactive elements
  44645. */
  44646. hoverCursor: string;
  44647. /**
  44648. * Defines the HTML default cursor to use (empty by default)
  44649. */
  44650. defaultCursor: string;
  44651. /**
  44652. * Defines whether cursors are handled by the scene.
  44653. */
  44654. doNotHandleCursors: boolean;
  44655. /**
  44656. * This is used to call preventDefault() on pointer down
  44657. * in order to block unwanted artifacts like system double clicks
  44658. */
  44659. preventDefaultOnPointerDown: boolean;
  44660. /**
  44661. * This is used to call preventDefault() on pointer up
  44662. * in order to block unwanted artifacts like system double clicks
  44663. */
  44664. preventDefaultOnPointerUp: boolean;
  44665. /**
  44666. * Gets or sets user defined metadata
  44667. */
  44668. metadata: any;
  44669. /**
  44670. * For internal use only. Please do not use.
  44671. */
  44672. reservedDataStore: any;
  44673. /**
  44674. * Gets the name of the plugin used to load this scene (null by default)
  44675. */
  44676. loadingPluginName: string;
  44677. /**
  44678. * Use this array to add regular expressions used to disable offline support for specific urls
  44679. */
  44680. disableOfflineSupportExceptionRules: RegExp[];
  44681. /**
  44682. * An event triggered when the scene is disposed.
  44683. */
  44684. onDisposeObservable: Observable<Scene>;
  44685. private _onDisposeObserver;
  44686. /** Sets a function to be executed when this scene is disposed. */
  44687. set onDispose(callback: () => void);
  44688. /**
  44689. * An event triggered before rendering the scene (right after animations and physics)
  44690. */
  44691. onBeforeRenderObservable: Observable<Scene>;
  44692. private _onBeforeRenderObserver;
  44693. /** Sets a function to be executed before rendering this scene */
  44694. set beforeRender(callback: Nullable<() => void>);
  44695. /**
  44696. * An event triggered after rendering the scene
  44697. */
  44698. onAfterRenderObservable: Observable<Scene>;
  44699. /**
  44700. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44701. */
  44702. onAfterRenderCameraObservable: Observable<Camera>;
  44703. private _onAfterRenderObserver;
  44704. /** Sets a function to be executed after rendering this scene */
  44705. set afterRender(callback: Nullable<() => void>);
  44706. /**
  44707. * An event triggered before animating the scene
  44708. */
  44709. onBeforeAnimationsObservable: Observable<Scene>;
  44710. /**
  44711. * An event triggered after animations processing
  44712. */
  44713. onAfterAnimationsObservable: Observable<Scene>;
  44714. /**
  44715. * An event triggered before draw calls are ready to be sent
  44716. */
  44717. onBeforeDrawPhaseObservable: Observable<Scene>;
  44718. /**
  44719. * An event triggered after draw calls have been sent
  44720. */
  44721. onAfterDrawPhaseObservable: Observable<Scene>;
  44722. /**
  44723. * An event triggered when the scene is ready
  44724. */
  44725. onReadyObservable: Observable<Scene>;
  44726. /**
  44727. * An event triggered before rendering a camera
  44728. */
  44729. onBeforeCameraRenderObservable: Observable<Camera>;
  44730. private _onBeforeCameraRenderObserver;
  44731. /** Sets a function to be executed before rendering a camera*/
  44732. set beforeCameraRender(callback: () => void);
  44733. /**
  44734. * An event triggered after rendering a camera
  44735. */
  44736. onAfterCameraRenderObservable: Observable<Camera>;
  44737. private _onAfterCameraRenderObserver;
  44738. /** Sets a function to be executed after rendering a camera*/
  44739. set afterCameraRender(callback: () => void);
  44740. /**
  44741. * An event triggered when active meshes evaluation is about to start
  44742. */
  44743. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44744. /**
  44745. * An event triggered when active meshes evaluation is done
  44746. */
  44747. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44748. /**
  44749. * An event triggered when particles rendering is about to start
  44750. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44751. */
  44752. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44753. /**
  44754. * An event triggered when particles rendering is done
  44755. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44756. */
  44757. onAfterParticlesRenderingObservable: Observable<Scene>;
  44758. /**
  44759. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44760. */
  44761. onDataLoadedObservable: Observable<Scene>;
  44762. /**
  44763. * An event triggered when a camera is created
  44764. */
  44765. onNewCameraAddedObservable: Observable<Camera>;
  44766. /**
  44767. * An event triggered when a camera is removed
  44768. */
  44769. onCameraRemovedObservable: Observable<Camera>;
  44770. /**
  44771. * An event triggered when a light is created
  44772. */
  44773. onNewLightAddedObservable: Observable<Light>;
  44774. /**
  44775. * An event triggered when a light is removed
  44776. */
  44777. onLightRemovedObservable: Observable<Light>;
  44778. /**
  44779. * An event triggered when a geometry is created
  44780. */
  44781. onNewGeometryAddedObservable: Observable<Geometry>;
  44782. /**
  44783. * An event triggered when a geometry is removed
  44784. */
  44785. onGeometryRemovedObservable: Observable<Geometry>;
  44786. /**
  44787. * An event triggered when a transform node is created
  44788. */
  44789. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44790. /**
  44791. * An event triggered when a transform node is removed
  44792. */
  44793. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44794. /**
  44795. * An event triggered when a mesh is created
  44796. */
  44797. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44798. /**
  44799. * An event triggered when a mesh is removed
  44800. */
  44801. onMeshRemovedObservable: Observable<AbstractMesh>;
  44802. /**
  44803. * An event triggered when a skeleton is created
  44804. */
  44805. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44806. /**
  44807. * An event triggered when a skeleton is removed
  44808. */
  44809. onSkeletonRemovedObservable: Observable<Skeleton>;
  44810. /**
  44811. * An event triggered when a material is created
  44812. */
  44813. onNewMaterialAddedObservable: Observable<Material>;
  44814. /**
  44815. * An event triggered when a multi material is created
  44816. */
  44817. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  44818. /**
  44819. * An event triggered when a material is removed
  44820. */
  44821. onMaterialRemovedObservable: Observable<Material>;
  44822. /**
  44823. * An event triggered when a multi material is removed
  44824. */
  44825. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  44826. /**
  44827. * An event triggered when a texture is created
  44828. */
  44829. onNewTextureAddedObservable: Observable<BaseTexture>;
  44830. /**
  44831. * An event triggered when a texture is removed
  44832. */
  44833. onTextureRemovedObservable: Observable<BaseTexture>;
  44834. /**
  44835. * An event triggered when render targets are about to be rendered
  44836. * Can happen multiple times per frame.
  44837. */
  44838. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44839. /**
  44840. * An event triggered when render targets were rendered.
  44841. * Can happen multiple times per frame.
  44842. */
  44843. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44844. /**
  44845. * An event triggered before calculating deterministic simulation step
  44846. */
  44847. onBeforeStepObservable: Observable<Scene>;
  44848. /**
  44849. * An event triggered after calculating deterministic simulation step
  44850. */
  44851. onAfterStepObservable: Observable<Scene>;
  44852. /**
  44853. * An event triggered when the activeCamera property is updated
  44854. */
  44855. onActiveCameraChanged: Observable<Scene>;
  44856. /**
  44857. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44858. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44859. * 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)
  44860. */
  44861. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44862. /**
  44863. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44864. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44865. * 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)
  44866. */
  44867. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44868. /**
  44869. * This Observable will when a mesh has been imported into the scene.
  44870. */
  44871. onMeshImportedObservable: Observable<AbstractMesh>;
  44872. /**
  44873. * This Observable will when an animation file has been imported into the scene.
  44874. */
  44875. onAnimationFileImportedObservable: Observable<Scene>;
  44876. /**
  44877. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44878. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44879. */
  44880. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44881. /** @hidden */
  44882. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44883. /**
  44884. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44885. */
  44886. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44887. /**
  44888. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44889. */
  44890. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44891. /**
  44892. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44893. */
  44894. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44895. /** Callback called when a pointer move is detected */
  44896. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44897. /** Callback called when a pointer down is detected */
  44898. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44899. /** Callback called when a pointer up is detected */
  44900. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44901. /** Callback called when a pointer pick is detected */
  44902. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44903. /**
  44904. * 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).
  44905. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44906. */
  44907. onPrePointerObservable: Observable<PointerInfoPre>;
  44908. /**
  44909. * Observable event triggered each time an input event is received from the rendering canvas
  44910. */
  44911. onPointerObservable: Observable<PointerInfo>;
  44912. /**
  44913. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44914. */
  44915. get unTranslatedPointer(): Vector2;
  44916. /**
  44917. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44918. */
  44919. static get DragMovementThreshold(): number;
  44920. static set DragMovementThreshold(value: number);
  44921. /**
  44922. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44923. */
  44924. static get LongPressDelay(): number;
  44925. static set LongPressDelay(value: number);
  44926. /**
  44927. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44928. */
  44929. static get DoubleClickDelay(): number;
  44930. static set DoubleClickDelay(value: number);
  44931. /** If you need to check double click without raising a single click at first click, enable this flag */
  44932. static get ExclusiveDoubleClickMode(): boolean;
  44933. static set ExclusiveDoubleClickMode(value: boolean);
  44934. /** @hidden */
  44935. _mirroredCameraPosition: Nullable<Vector3>;
  44936. /**
  44937. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44938. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44939. */
  44940. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44941. /**
  44942. * Observable event triggered each time an keyboard event is received from the hosting window
  44943. */
  44944. onKeyboardObservable: Observable<KeyboardInfo>;
  44945. private _useRightHandedSystem;
  44946. /**
  44947. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44948. */
  44949. set useRightHandedSystem(value: boolean);
  44950. get useRightHandedSystem(): boolean;
  44951. private _timeAccumulator;
  44952. private _currentStepId;
  44953. private _currentInternalStep;
  44954. /**
  44955. * Sets the step Id used by deterministic lock step
  44956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44957. * @param newStepId defines the step Id
  44958. */
  44959. setStepId(newStepId: number): void;
  44960. /**
  44961. * Gets the step Id used by deterministic lock step
  44962. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44963. * @returns the step Id
  44964. */
  44965. getStepId(): number;
  44966. /**
  44967. * Gets the internal step used by deterministic lock step
  44968. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44969. * @returns the internal step
  44970. */
  44971. getInternalStep(): number;
  44972. private _fogEnabled;
  44973. /**
  44974. * Gets or sets a boolean indicating if fog is enabled on this scene
  44975. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44976. * (Default is true)
  44977. */
  44978. set fogEnabled(value: boolean);
  44979. get fogEnabled(): boolean;
  44980. private _fogMode;
  44981. /**
  44982. * Gets or sets the fog mode to use
  44983. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44984. * | mode | value |
  44985. * | --- | --- |
  44986. * | FOGMODE_NONE | 0 |
  44987. * | FOGMODE_EXP | 1 |
  44988. * | FOGMODE_EXP2 | 2 |
  44989. * | FOGMODE_LINEAR | 3 |
  44990. */
  44991. set fogMode(value: number);
  44992. get fogMode(): number;
  44993. /**
  44994. * Gets or sets the fog color to use
  44995. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44996. * (Default is Color3(0.2, 0.2, 0.3))
  44997. */
  44998. fogColor: Color3;
  44999. /**
  45000. * Gets or sets the fog density to use
  45001. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45002. * (Default is 0.1)
  45003. */
  45004. fogDensity: number;
  45005. /**
  45006. * Gets or sets the fog start distance to use
  45007. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45008. * (Default is 0)
  45009. */
  45010. fogStart: number;
  45011. /**
  45012. * Gets or sets the fog end distance to use
  45013. * @see https://doc.babylonjs.com/babylon101/environment#fog
  45014. * (Default is 1000)
  45015. */
  45016. fogEnd: number;
  45017. /**
  45018. * Flag indicating that the frame buffer binding is handled by another component
  45019. */
  45020. prePass: boolean;
  45021. private _shadowsEnabled;
  45022. /**
  45023. * Gets or sets a boolean indicating if shadows are enabled on this scene
  45024. */
  45025. set shadowsEnabled(value: boolean);
  45026. get shadowsEnabled(): boolean;
  45027. private _lightsEnabled;
  45028. /**
  45029. * Gets or sets a boolean indicating if lights are enabled on this scene
  45030. */
  45031. set lightsEnabled(value: boolean);
  45032. get lightsEnabled(): boolean;
  45033. /** All of the active cameras added to this scene. */
  45034. activeCameras: Nullable<Camera[]>;
  45035. /** @hidden */
  45036. _activeCamera: Nullable<Camera>;
  45037. /** Gets or sets the current active camera */
  45038. get activeCamera(): Nullable<Camera>;
  45039. set activeCamera(value: Nullable<Camera>);
  45040. private _defaultMaterial;
  45041. /** The default material used on meshes when no material is affected */
  45042. get defaultMaterial(): Material;
  45043. /** The default material used on meshes when no material is affected */
  45044. set defaultMaterial(value: Material);
  45045. private _texturesEnabled;
  45046. /**
  45047. * Gets or sets a boolean indicating if textures are enabled on this scene
  45048. */
  45049. set texturesEnabled(value: boolean);
  45050. get texturesEnabled(): boolean;
  45051. /**
  45052. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  45053. */
  45054. physicsEnabled: boolean;
  45055. /**
  45056. * Gets or sets a boolean indicating if particles are enabled on this scene
  45057. */
  45058. particlesEnabled: boolean;
  45059. /**
  45060. * Gets or sets a boolean indicating if sprites are enabled on this scene
  45061. */
  45062. spritesEnabled: boolean;
  45063. private _skeletonsEnabled;
  45064. /**
  45065. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  45066. */
  45067. set skeletonsEnabled(value: boolean);
  45068. get skeletonsEnabled(): boolean;
  45069. /**
  45070. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  45071. */
  45072. lensFlaresEnabled: boolean;
  45073. /**
  45074. * Gets or sets a boolean indicating if collisions are enabled on this scene
  45075. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45076. */
  45077. collisionsEnabled: boolean;
  45078. private _collisionCoordinator;
  45079. /** @hidden */
  45080. get collisionCoordinator(): ICollisionCoordinator;
  45081. /**
  45082. * Defines the gravity applied to this scene (used only for collisions)
  45083. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  45084. */
  45085. gravity: Vector3;
  45086. /**
  45087. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  45088. */
  45089. postProcessesEnabled: boolean;
  45090. /**
  45091. * Gets the current postprocess manager
  45092. */
  45093. postProcessManager: PostProcessManager;
  45094. /**
  45095. * Gets or sets a boolean indicating if render targets are enabled on this scene
  45096. */
  45097. renderTargetsEnabled: boolean;
  45098. /**
  45099. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  45100. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  45101. */
  45102. dumpNextRenderTargets: boolean;
  45103. /**
  45104. * The list of user defined render targets added to the scene
  45105. */
  45106. customRenderTargets: RenderTargetTexture[];
  45107. /**
  45108. * Defines if texture loading must be delayed
  45109. * If true, textures will only be loaded when they need to be rendered
  45110. */
  45111. useDelayedTextureLoading: boolean;
  45112. /**
  45113. * Gets the list of meshes imported to the scene through SceneLoader
  45114. */
  45115. importedMeshesFiles: String[];
  45116. /**
  45117. * Gets or sets a boolean indicating if probes are enabled on this scene
  45118. */
  45119. probesEnabled: boolean;
  45120. /**
  45121. * Gets or sets the current offline provider to use to store scene data
  45122. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  45123. */
  45124. offlineProvider: IOfflineProvider;
  45125. /**
  45126. * Gets or sets the action manager associated with the scene
  45127. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45128. */
  45129. actionManager: AbstractActionManager;
  45130. private _meshesForIntersections;
  45131. /**
  45132. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  45133. */
  45134. proceduralTexturesEnabled: boolean;
  45135. private _engine;
  45136. private _totalVertices;
  45137. /** @hidden */
  45138. _activeIndices: PerfCounter;
  45139. /** @hidden */
  45140. _activeParticles: PerfCounter;
  45141. /** @hidden */
  45142. _activeBones: PerfCounter;
  45143. private _animationRatio;
  45144. /** @hidden */
  45145. _animationTimeLast: number;
  45146. /** @hidden */
  45147. _animationTime: number;
  45148. /**
  45149. * Gets or sets a general scale for animation speed
  45150. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  45151. */
  45152. animationTimeScale: number;
  45153. /** @hidden */
  45154. _cachedMaterial: Nullable<Material>;
  45155. /** @hidden */
  45156. _cachedEffect: Nullable<Effect>;
  45157. /** @hidden */
  45158. _cachedVisibility: Nullable<number>;
  45159. private _renderId;
  45160. private _frameId;
  45161. private _executeWhenReadyTimeoutId;
  45162. private _intermediateRendering;
  45163. private _viewUpdateFlag;
  45164. private _projectionUpdateFlag;
  45165. /** @hidden */
  45166. _toBeDisposed: Nullable<IDisposable>[];
  45167. private _activeRequests;
  45168. /** @hidden */
  45169. _pendingData: any[];
  45170. private _isDisposed;
  45171. /**
  45172. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  45173. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  45174. */
  45175. dispatchAllSubMeshesOfActiveMeshes: boolean;
  45176. private _activeMeshes;
  45177. private _processedMaterials;
  45178. private _renderTargets;
  45179. /** @hidden */
  45180. _activeParticleSystems: SmartArray<IParticleSystem>;
  45181. private _activeSkeletons;
  45182. private _softwareSkinnedMeshes;
  45183. private _renderingManager;
  45184. /** @hidden */
  45185. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  45186. private _transformMatrix;
  45187. private _sceneUbo;
  45188. /** @hidden */
  45189. _viewMatrix: Matrix;
  45190. private _projectionMatrix;
  45191. /** @hidden */
  45192. _forcedViewPosition: Nullable<Vector3>;
  45193. /** @hidden */
  45194. _frustumPlanes: Plane[];
  45195. /**
  45196. * Gets the list of frustum planes (built from the active camera)
  45197. */
  45198. get frustumPlanes(): Plane[];
  45199. /**
  45200. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  45201. * This is useful if there are more lights that the maximum simulteanous authorized
  45202. */
  45203. requireLightSorting: boolean;
  45204. /** @hidden */
  45205. readonly useMaterialMeshMap: boolean;
  45206. /** @hidden */
  45207. readonly useClonedMeshMap: boolean;
  45208. private _externalData;
  45209. private _uid;
  45210. /**
  45211. * @hidden
  45212. * Backing store of defined scene components.
  45213. */
  45214. _components: ISceneComponent[];
  45215. /**
  45216. * @hidden
  45217. * Backing store of defined scene components.
  45218. */
  45219. _serializableComponents: ISceneSerializableComponent[];
  45220. /**
  45221. * List of components to register on the next registration step.
  45222. */
  45223. private _transientComponents;
  45224. /**
  45225. * Registers the transient components if needed.
  45226. */
  45227. private _registerTransientComponents;
  45228. /**
  45229. * @hidden
  45230. * Add a component to the scene.
  45231. * Note that the ccomponent could be registered on th next frame if this is called after
  45232. * the register component stage.
  45233. * @param component Defines the component to add to the scene
  45234. */
  45235. _addComponent(component: ISceneComponent): void;
  45236. /**
  45237. * @hidden
  45238. * Gets a component from the scene.
  45239. * @param name defines the name of the component to retrieve
  45240. * @returns the component or null if not present
  45241. */
  45242. _getComponent(name: string): Nullable<ISceneComponent>;
  45243. /**
  45244. * @hidden
  45245. * Defines the actions happening before camera updates.
  45246. */
  45247. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  45248. /**
  45249. * @hidden
  45250. * Defines the actions happening before clear the canvas.
  45251. */
  45252. _beforeClearStage: Stage<SimpleStageAction>;
  45253. /**
  45254. * @hidden
  45255. * Defines the actions when collecting render targets for the frame.
  45256. */
  45257. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45258. /**
  45259. * @hidden
  45260. * Defines the actions happening for one camera in the frame.
  45261. */
  45262. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45263. /**
  45264. * @hidden
  45265. * Defines the actions happening during the per mesh ready checks.
  45266. */
  45267. _isReadyForMeshStage: Stage<MeshStageAction>;
  45268. /**
  45269. * @hidden
  45270. * Defines the actions happening before evaluate active mesh checks.
  45271. */
  45272. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  45273. /**
  45274. * @hidden
  45275. * Defines the actions happening during the evaluate sub mesh checks.
  45276. */
  45277. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  45278. /**
  45279. * @hidden
  45280. * Defines the actions happening during the active mesh stage.
  45281. */
  45282. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  45283. /**
  45284. * @hidden
  45285. * Defines the actions happening during the per camera render target step.
  45286. */
  45287. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  45288. /**
  45289. * @hidden
  45290. * Defines the actions happening just before the active camera is drawing.
  45291. */
  45292. _beforeCameraDrawStage: Stage<CameraStageAction>;
  45293. /**
  45294. * @hidden
  45295. * Defines the actions happening just before a render target is drawing.
  45296. */
  45297. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45298. /**
  45299. * @hidden
  45300. * Defines the actions happening just before a rendering group is drawing.
  45301. */
  45302. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45303. /**
  45304. * @hidden
  45305. * Defines the actions happening just before a mesh is drawing.
  45306. */
  45307. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45308. /**
  45309. * @hidden
  45310. * Defines the actions happening just after a mesh has been drawn.
  45311. */
  45312. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45313. /**
  45314. * @hidden
  45315. * Defines the actions happening just after a rendering group has been drawn.
  45316. */
  45317. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45318. /**
  45319. * @hidden
  45320. * Defines the actions happening just after the active camera has been drawn.
  45321. */
  45322. _afterCameraDrawStage: Stage<CameraStageAction>;
  45323. /**
  45324. * @hidden
  45325. * Defines the actions happening just after a render target has been drawn.
  45326. */
  45327. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45328. /**
  45329. * @hidden
  45330. * Defines the actions happening just after rendering all cameras and computing intersections.
  45331. */
  45332. _afterRenderStage: Stage<SimpleStageAction>;
  45333. /**
  45334. * @hidden
  45335. * Defines the actions happening when a pointer move event happens.
  45336. */
  45337. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45338. /**
  45339. * @hidden
  45340. * Defines the actions happening when a pointer down event happens.
  45341. */
  45342. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45343. /**
  45344. * @hidden
  45345. * Defines the actions happening when a pointer up event happens.
  45346. */
  45347. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45348. /**
  45349. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45350. */
  45351. private geometriesByUniqueId;
  45352. /**
  45353. * Creates a new Scene
  45354. * @param engine defines the engine to use to render this scene
  45355. * @param options defines the scene options
  45356. */
  45357. constructor(engine: Engine, options?: SceneOptions);
  45358. /**
  45359. * Gets a string identifying the name of the class
  45360. * @returns "Scene" string
  45361. */
  45362. getClassName(): string;
  45363. private _defaultMeshCandidates;
  45364. /**
  45365. * @hidden
  45366. */
  45367. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45368. private _defaultSubMeshCandidates;
  45369. /**
  45370. * @hidden
  45371. */
  45372. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45373. /**
  45374. * Sets the default candidate providers for the scene.
  45375. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45376. * and getCollidingSubMeshCandidates to their default function
  45377. */
  45378. setDefaultCandidateProviders(): void;
  45379. /**
  45380. * Gets the mesh that is currently under the pointer
  45381. */
  45382. get meshUnderPointer(): Nullable<AbstractMesh>;
  45383. /**
  45384. * Gets or sets the current on-screen X position of the pointer
  45385. */
  45386. get pointerX(): number;
  45387. set pointerX(value: number);
  45388. /**
  45389. * Gets or sets the current on-screen Y position of the pointer
  45390. */
  45391. get pointerY(): number;
  45392. set pointerY(value: number);
  45393. /**
  45394. * Gets the cached material (ie. the latest rendered one)
  45395. * @returns the cached material
  45396. */
  45397. getCachedMaterial(): Nullable<Material>;
  45398. /**
  45399. * Gets the cached effect (ie. the latest rendered one)
  45400. * @returns the cached effect
  45401. */
  45402. getCachedEffect(): Nullable<Effect>;
  45403. /**
  45404. * Gets the cached visibility state (ie. the latest rendered one)
  45405. * @returns the cached visibility state
  45406. */
  45407. getCachedVisibility(): Nullable<number>;
  45408. /**
  45409. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45410. * @param material defines the current material
  45411. * @param effect defines the current effect
  45412. * @param visibility defines the current visibility state
  45413. * @returns true if one parameter is not cached
  45414. */
  45415. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45416. /**
  45417. * Gets the engine associated with the scene
  45418. * @returns an Engine
  45419. */
  45420. getEngine(): Engine;
  45421. /**
  45422. * Gets the total number of vertices rendered per frame
  45423. * @returns the total number of vertices rendered per frame
  45424. */
  45425. getTotalVertices(): number;
  45426. /**
  45427. * Gets the performance counter for total vertices
  45428. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45429. */
  45430. get totalVerticesPerfCounter(): PerfCounter;
  45431. /**
  45432. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45433. * @returns the total number of active indices rendered per frame
  45434. */
  45435. getActiveIndices(): number;
  45436. /**
  45437. * Gets the performance counter for active indices
  45438. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45439. */
  45440. get totalActiveIndicesPerfCounter(): PerfCounter;
  45441. /**
  45442. * Gets the total number of active particles rendered per frame
  45443. * @returns the total number of active particles rendered per frame
  45444. */
  45445. getActiveParticles(): number;
  45446. /**
  45447. * Gets the performance counter for active particles
  45448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45449. */
  45450. get activeParticlesPerfCounter(): PerfCounter;
  45451. /**
  45452. * Gets the total number of active bones rendered per frame
  45453. * @returns the total number of active bones rendered per frame
  45454. */
  45455. getActiveBones(): number;
  45456. /**
  45457. * Gets the performance counter for active bones
  45458. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45459. */
  45460. get activeBonesPerfCounter(): PerfCounter;
  45461. /**
  45462. * Gets the array of active meshes
  45463. * @returns an array of AbstractMesh
  45464. */
  45465. getActiveMeshes(): SmartArray<AbstractMesh>;
  45466. /**
  45467. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45468. * @returns a number
  45469. */
  45470. getAnimationRatio(): number;
  45471. /**
  45472. * Gets an unique Id for the current render phase
  45473. * @returns a number
  45474. */
  45475. getRenderId(): number;
  45476. /**
  45477. * Gets an unique Id for the current frame
  45478. * @returns a number
  45479. */
  45480. getFrameId(): number;
  45481. /** Call this function if you want to manually increment the render Id*/
  45482. incrementRenderId(): void;
  45483. private _createUbo;
  45484. /**
  45485. * Use this method to simulate a pointer move on a mesh
  45486. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45487. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45488. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45489. * @returns the current scene
  45490. */
  45491. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45492. /**
  45493. * Use this method to simulate a pointer down on a mesh
  45494. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45495. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45496. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45497. * @returns the current scene
  45498. */
  45499. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45500. /**
  45501. * Use this method to simulate a pointer up on a mesh
  45502. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45503. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45504. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45505. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45506. * @returns the current scene
  45507. */
  45508. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45509. /**
  45510. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45511. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45512. * @returns true if the pointer was captured
  45513. */
  45514. isPointerCaptured(pointerId?: number): boolean;
  45515. /**
  45516. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45517. * @param attachUp defines if you want to attach events to pointerup
  45518. * @param attachDown defines if you want to attach events to pointerdown
  45519. * @param attachMove defines if you want to attach events to pointermove
  45520. */
  45521. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45522. /** Detaches all event handlers*/
  45523. detachControl(): void;
  45524. /**
  45525. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45526. * Delay loaded resources are not taking in account
  45527. * @return true if all required resources are ready
  45528. */
  45529. isReady(): boolean;
  45530. /** Resets all cached information relative to material (including effect and visibility) */
  45531. resetCachedMaterial(): void;
  45532. /**
  45533. * Registers a function to be called before every frame render
  45534. * @param func defines the function to register
  45535. */
  45536. registerBeforeRender(func: () => void): void;
  45537. /**
  45538. * Unregisters a function called before every frame render
  45539. * @param func defines the function to unregister
  45540. */
  45541. unregisterBeforeRender(func: () => void): void;
  45542. /**
  45543. * Registers a function to be called after every frame render
  45544. * @param func defines the function to register
  45545. */
  45546. registerAfterRender(func: () => void): void;
  45547. /**
  45548. * Unregisters a function called after every frame render
  45549. * @param func defines the function to unregister
  45550. */
  45551. unregisterAfterRender(func: () => void): void;
  45552. private _executeOnceBeforeRender;
  45553. /**
  45554. * The provided function will run before render once and will be disposed afterwards.
  45555. * A timeout delay can be provided so that the function will be executed in N ms.
  45556. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45557. * @param func The function to be executed.
  45558. * @param timeout optional delay in ms
  45559. */
  45560. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45561. /** @hidden */
  45562. _addPendingData(data: any): void;
  45563. /** @hidden */
  45564. _removePendingData(data: any): void;
  45565. /**
  45566. * Returns the number of items waiting to be loaded
  45567. * @returns the number of items waiting to be loaded
  45568. */
  45569. getWaitingItemsCount(): number;
  45570. /**
  45571. * Returns a boolean indicating if the scene is still loading data
  45572. */
  45573. get isLoading(): boolean;
  45574. /**
  45575. * Registers a function to be executed when the scene is ready
  45576. * @param {Function} func - the function to be executed
  45577. */
  45578. executeWhenReady(func: () => void): void;
  45579. /**
  45580. * Returns a promise that resolves when the scene is ready
  45581. * @returns A promise that resolves when the scene is ready
  45582. */
  45583. whenReadyAsync(): Promise<void>;
  45584. /** @hidden */
  45585. _checkIsReady(): void;
  45586. /**
  45587. * Gets all animatable attached to the scene
  45588. */
  45589. get animatables(): Animatable[];
  45590. /**
  45591. * Resets the last animation time frame.
  45592. * Useful to override when animations start running when loading a scene for the first time.
  45593. */
  45594. resetLastAnimationTimeFrame(): void;
  45595. /**
  45596. * Gets the current view matrix
  45597. * @returns a Matrix
  45598. */
  45599. getViewMatrix(): Matrix;
  45600. /**
  45601. * Gets the current projection matrix
  45602. * @returns a Matrix
  45603. */
  45604. getProjectionMatrix(): Matrix;
  45605. /**
  45606. * Gets the current transform matrix
  45607. * @returns a Matrix made of View * Projection
  45608. */
  45609. getTransformMatrix(): Matrix;
  45610. /**
  45611. * Sets the current transform matrix
  45612. * @param viewL defines the View matrix to use
  45613. * @param projectionL defines the Projection matrix to use
  45614. * @param viewR defines the right View matrix to use (if provided)
  45615. * @param projectionR defines the right Projection matrix to use (if provided)
  45616. */
  45617. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45618. /**
  45619. * Gets the uniform buffer used to store scene data
  45620. * @returns a UniformBuffer
  45621. */
  45622. getSceneUniformBuffer(): UniformBuffer;
  45623. /**
  45624. * Gets an unique (relatively to the current scene) Id
  45625. * @returns an unique number for the scene
  45626. */
  45627. getUniqueId(): number;
  45628. /**
  45629. * Add a mesh to the list of scene's meshes
  45630. * @param newMesh defines the mesh to add
  45631. * @param recursive if all child meshes should also be added to the scene
  45632. */
  45633. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45634. /**
  45635. * Remove a mesh for the list of scene's meshes
  45636. * @param toRemove defines the mesh to remove
  45637. * @param recursive if all child meshes should also be removed from the scene
  45638. * @returns the index where the mesh was in the mesh list
  45639. */
  45640. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45641. /**
  45642. * Add a transform node to the list of scene's transform nodes
  45643. * @param newTransformNode defines the transform node to add
  45644. */
  45645. addTransformNode(newTransformNode: TransformNode): void;
  45646. /**
  45647. * Remove a transform node for the list of scene's transform nodes
  45648. * @param toRemove defines the transform node to remove
  45649. * @returns the index where the transform node was in the transform node list
  45650. */
  45651. removeTransformNode(toRemove: TransformNode): number;
  45652. /**
  45653. * Remove a skeleton for the list of scene's skeletons
  45654. * @param toRemove defines the skeleton to remove
  45655. * @returns the index where the skeleton was in the skeleton list
  45656. */
  45657. removeSkeleton(toRemove: Skeleton): number;
  45658. /**
  45659. * Remove a morph target for the list of scene's morph targets
  45660. * @param toRemove defines the morph target to remove
  45661. * @returns the index where the morph target was in the morph target list
  45662. */
  45663. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45664. /**
  45665. * Remove a light for the list of scene's lights
  45666. * @param toRemove defines the light to remove
  45667. * @returns the index where the light was in the light list
  45668. */
  45669. removeLight(toRemove: Light): number;
  45670. /**
  45671. * Remove a camera for the list of scene's cameras
  45672. * @param toRemove defines the camera to remove
  45673. * @returns the index where the camera was in the camera list
  45674. */
  45675. removeCamera(toRemove: Camera): number;
  45676. /**
  45677. * Remove a particle system for the list of scene's particle systems
  45678. * @param toRemove defines the particle system to remove
  45679. * @returns the index where the particle system was in the particle system list
  45680. */
  45681. removeParticleSystem(toRemove: IParticleSystem): number;
  45682. /**
  45683. * Remove a animation for the list of scene's animations
  45684. * @param toRemove defines the animation to remove
  45685. * @returns the index where the animation was in the animation list
  45686. */
  45687. removeAnimation(toRemove: Animation): number;
  45688. /**
  45689. * Will stop the animation of the given target
  45690. * @param target - the target
  45691. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45692. * @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)
  45693. */
  45694. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45695. /**
  45696. * Removes the given animation group from this scene.
  45697. * @param toRemove The animation group to remove
  45698. * @returns The index of the removed animation group
  45699. */
  45700. removeAnimationGroup(toRemove: AnimationGroup): number;
  45701. /**
  45702. * Removes the given multi-material from this scene.
  45703. * @param toRemove The multi-material to remove
  45704. * @returns The index of the removed multi-material
  45705. */
  45706. removeMultiMaterial(toRemove: MultiMaterial): number;
  45707. /**
  45708. * Removes the given material from this scene.
  45709. * @param toRemove The material to remove
  45710. * @returns The index of the removed material
  45711. */
  45712. removeMaterial(toRemove: Material): number;
  45713. /**
  45714. * Removes the given action manager from this scene.
  45715. * @param toRemove The action manager to remove
  45716. * @returns The index of the removed action manager
  45717. */
  45718. removeActionManager(toRemove: AbstractActionManager): number;
  45719. /**
  45720. * Removes the given texture from this scene.
  45721. * @param toRemove The texture to remove
  45722. * @returns The index of the removed texture
  45723. */
  45724. removeTexture(toRemove: BaseTexture): number;
  45725. /**
  45726. * Adds the given light to this scene
  45727. * @param newLight The light to add
  45728. */
  45729. addLight(newLight: Light): void;
  45730. /**
  45731. * Sorts the list list based on light priorities
  45732. */
  45733. sortLightsByPriority(): void;
  45734. /**
  45735. * Adds the given camera to this scene
  45736. * @param newCamera The camera to add
  45737. */
  45738. addCamera(newCamera: Camera): void;
  45739. /**
  45740. * Adds the given skeleton to this scene
  45741. * @param newSkeleton The skeleton to add
  45742. */
  45743. addSkeleton(newSkeleton: Skeleton): void;
  45744. /**
  45745. * Adds the given particle system to this scene
  45746. * @param newParticleSystem The particle system to add
  45747. */
  45748. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45749. /**
  45750. * Adds the given animation to this scene
  45751. * @param newAnimation The animation to add
  45752. */
  45753. addAnimation(newAnimation: Animation): void;
  45754. /**
  45755. * Adds the given animation group to this scene.
  45756. * @param newAnimationGroup The animation group to add
  45757. */
  45758. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45759. /**
  45760. * Adds the given multi-material to this scene
  45761. * @param newMultiMaterial The multi-material to add
  45762. */
  45763. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45764. /**
  45765. * Adds the given material to this scene
  45766. * @param newMaterial The material to add
  45767. */
  45768. addMaterial(newMaterial: Material): void;
  45769. /**
  45770. * Adds the given morph target to this scene
  45771. * @param newMorphTargetManager The morph target to add
  45772. */
  45773. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45774. /**
  45775. * Adds the given geometry to this scene
  45776. * @param newGeometry The geometry to add
  45777. */
  45778. addGeometry(newGeometry: Geometry): void;
  45779. /**
  45780. * Adds the given action manager to this scene
  45781. * @param newActionManager The action manager to add
  45782. */
  45783. addActionManager(newActionManager: AbstractActionManager): void;
  45784. /**
  45785. * Adds the given texture to this scene.
  45786. * @param newTexture The texture to add
  45787. */
  45788. addTexture(newTexture: BaseTexture): void;
  45789. /**
  45790. * Switch active camera
  45791. * @param newCamera defines the new active camera
  45792. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45793. */
  45794. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45795. /**
  45796. * sets the active camera of the scene using its ID
  45797. * @param id defines the camera's ID
  45798. * @return the new active camera or null if none found.
  45799. */
  45800. setActiveCameraByID(id: string): Nullable<Camera>;
  45801. /**
  45802. * sets the active camera of the scene using its name
  45803. * @param name defines the camera's name
  45804. * @returns the new active camera or null if none found.
  45805. */
  45806. setActiveCameraByName(name: string): Nullable<Camera>;
  45807. /**
  45808. * get an animation group using its name
  45809. * @param name defines the material's name
  45810. * @return the animation group or null if none found.
  45811. */
  45812. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45813. /**
  45814. * Get a material using its unique id
  45815. * @param uniqueId defines the material's unique id
  45816. * @return the material or null if none found.
  45817. */
  45818. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45819. /**
  45820. * get a material using its id
  45821. * @param id defines the material's ID
  45822. * @return the material or null if none found.
  45823. */
  45824. getMaterialByID(id: string): Nullable<Material>;
  45825. /**
  45826. * Gets a the last added material using a given id
  45827. * @param id defines the material's ID
  45828. * @return the last material with the given id or null if none found.
  45829. */
  45830. getLastMaterialByID(id: string): Nullable<Material>;
  45831. /**
  45832. * Gets a material using its name
  45833. * @param name defines the material's name
  45834. * @return the material or null if none found.
  45835. */
  45836. getMaterialByName(name: string): Nullable<Material>;
  45837. /**
  45838. * Get a texture using its unique id
  45839. * @param uniqueId defines the texture's unique id
  45840. * @return the texture or null if none found.
  45841. */
  45842. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45843. /**
  45844. * Gets a camera using its id
  45845. * @param id defines the id to look for
  45846. * @returns the camera or null if not found
  45847. */
  45848. getCameraByID(id: string): Nullable<Camera>;
  45849. /**
  45850. * Gets a camera using its unique id
  45851. * @param uniqueId defines the unique id to look for
  45852. * @returns the camera or null if not found
  45853. */
  45854. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45855. /**
  45856. * Gets a camera using its name
  45857. * @param name defines the camera's name
  45858. * @return the camera or null if none found.
  45859. */
  45860. getCameraByName(name: string): Nullable<Camera>;
  45861. /**
  45862. * Gets a bone using its id
  45863. * @param id defines the bone's id
  45864. * @return the bone or null if not found
  45865. */
  45866. getBoneByID(id: string): Nullable<Bone>;
  45867. /**
  45868. * Gets a bone using its id
  45869. * @param name defines the bone's name
  45870. * @return the bone or null if not found
  45871. */
  45872. getBoneByName(name: string): Nullable<Bone>;
  45873. /**
  45874. * Gets a light node using its name
  45875. * @param name defines the the light's name
  45876. * @return the light or null if none found.
  45877. */
  45878. getLightByName(name: string): Nullable<Light>;
  45879. /**
  45880. * Gets a light node using its id
  45881. * @param id defines the light's id
  45882. * @return the light or null if none found.
  45883. */
  45884. getLightByID(id: string): Nullable<Light>;
  45885. /**
  45886. * Gets a light node using its scene-generated unique ID
  45887. * @param uniqueId defines the light's unique id
  45888. * @return the light or null if none found.
  45889. */
  45890. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45891. /**
  45892. * Gets a particle system by id
  45893. * @param id defines the particle system id
  45894. * @return the corresponding system or null if none found
  45895. */
  45896. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45897. /**
  45898. * Gets a geometry using its ID
  45899. * @param id defines the geometry's id
  45900. * @return the geometry or null if none found.
  45901. */
  45902. getGeometryByID(id: string): Nullable<Geometry>;
  45903. private _getGeometryByUniqueID;
  45904. /**
  45905. * Add a new geometry to this scene
  45906. * @param geometry defines the geometry to be added to the scene.
  45907. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45908. * @return a boolean defining if the geometry was added or not
  45909. */
  45910. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45911. /**
  45912. * Removes an existing geometry
  45913. * @param geometry defines the geometry to be removed from the scene
  45914. * @return a boolean defining if the geometry was removed or not
  45915. */
  45916. removeGeometry(geometry: Geometry): boolean;
  45917. /**
  45918. * Gets the list of geometries attached to the scene
  45919. * @returns an array of Geometry
  45920. */
  45921. getGeometries(): Geometry[];
  45922. /**
  45923. * Gets the first added mesh found of a given ID
  45924. * @param id defines the id to search for
  45925. * @return the mesh found or null if not found at all
  45926. */
  45927. getMeshByID(id: string): Nullable<AbstractMesh>;
  45928. /**
  45929. * Gets a list of meshes using their id
  45930. * @param id defines the id to search for
  45931. * @returns a list of meshes
  45932. */
  45933. getMeshesByID(id: string): Array<AbstractMesh>;
  45934. /**
  45935. * Gets the first added transform node found of a given ID
  45936. * @param id defines the id to search for
  45937. * @return the found transform node or null if not found at all.
  45938. */
  45939. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45940. /**
  45941. * Gets a transform node with its auto-generated unique id
  45942. * @param uniqueId efines the unique id to search for
  45943. * @return the found transform node or null if not found at all.
  45944. */
  45945. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45946. /**
  45947. * Gets a list of transform nodes using their id
  45948. * @param id defines the id to search for
  45949. * @returns a list of transform nodes
  45950. */
  45951. getTransformNodesByID(id: string): Array<TransformNode>;
  45952. /**
  45953. * Gets a mesh with its auto-generated unique id
  45954. * @param uniqueId defines the unique id to search for
  45955. * @return the found mesh or null if not found at all.
  45956. */
  45957. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45958. /**
  45959. * Gets a the last added mesh using a given id
  45960. * @param id defines the id to search for
  45961. * @return the found mesh or null if not found at all.
  45962. */
  45963. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45964. /**
  45965. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45966. * @param id defines the id to search for
  45967. * @return the found node or null if not found at all
  45968. */
  45969. getLastEntryByID(id: string): Nullable<Node>;
  45970. /**
  45971. * Gets a node (Mesh, Camera, Light) using a given id
  45972. * @param id defines the id to search for
  45973. * @return the found node or null if not found at all
  45974. */
  45975. getNodeByID(id: string): Nullable<Node>;
  45976. /**
  45977. * Gets a node (Mesh, Camera, Light) using a given name
  45978. * @param name defines the name to search for
  45979. * @return the found node or null if not found at all.
  45980. */
  45981. getNodeByName(name: string): Nullable<Node>;
  45982. /**
  45983. * Gets a mesh using a given name
  45984. * @param name defines the name to search for
  45985. * @return the found mesh or null if not found at all.
  45986. */
  45987. getMeshByName(name: string): Nullable<AbstractMesh>;
  45988. /**
  45989. * Gets a transform node using a given name
  45990. * @param name defines the name to search for
  45991. * @return the found transform node or null if not found at all.
  45992. */
  45993. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45994. /**
  45995. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45996. * @param id defines the id to search for
  45997. * @return the found skeleton or null if not found at all.
  45998. */
  45999. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  46000. /**
  46001. * Gets a skeleton using a given auto generated unique id
  46002. * @param uniqueId defines the unique id to search for
  46003. * @return the found skeleton or null if not found at all.
  46004. */
  46005. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  46006. /**
  46007. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  46008. * @param id defines the id to search for
  46009. * @return the found skeleton or null if not found at all.
  46010. */
  46011. getSkeletonById(id: string): Nullable<Skeleton>;
  46012. /**
  46013. * Gets a skeleton using a given name
  46014. * @param name defines the name to search for
  46015. * @return the found skeleton or null if not found at all.
  46016. */
  46017. getSkeletonByName(name: string): Nullable<Skeleton>;
  46018. /**
  46019. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  46020. * @param id defines the id to search for
  46021. * @return the found morph target manager or null if not found at all.
  46022. */
  46023. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  46024. /**
  46025. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  46026. * @param id defines the id to search for
  46027. * @return the found morph target or null if not found at all.
  46028. */
  46029. getMorphTargetById(id: string): Nullable<MorphTarget>;
  46030. /**
  46031. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  46032. * @param name defines the name to search for
  46033. * @return the found morph target or null if not found at all.
  46034. */
  46035. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  46036. /**
  46037. * Gets a post process using a given name (if many are found, this function will pick the first one)
  46038. * @param name defines the name to search for
  46039. * @return the found post process or null if not found at all.
  46040. */
  46041. getPostProcessByName(name: string): Nullable<PostProcess>;
  46042. /**
  46043. * Gets a boolean indicating if the given mesh is active
  46044. * @param mesh defines the mesh to look for
  46045. * @returns true if the mesh is in the active list
  46046. */
  46047. isActiveMesh(mesh: AbstractMesh): boolean;
  46048. /**
  46049. * Return a unique id as a string which can serve as an identifier for the scene
  46050. */
  46051. get uid(): string;
  46052. /**
  46053. * Add an externaly attached data from its key.
  46054. * This method call will fail and return false, if such key already exists.
  46055. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  46056. * @param key the unique key that identifies the data
  46057. * @param data the data object to associate to the key for this Engine instance
  46058. * @return true if no such key were already present and the data was added successfully, false otherwise
  46059. */
  46060. addExternalData<T>(key: string, data: T): boolean;
  46061. /**
  46062. * Get an externaly attached data from its key
  46063. * @param key the unique key that identifies the data
  46064. * @return the associated data, if present (can be null), or undefined if not present
  46065. */
  46066. getExternalData<T>(key: string): Nullable<T>;
  46067. /**
  46068. * Get an externaly attached data from its key, create it using a factory if it's not already present
  46069. * @param key the unique key that identifies the data
  46070. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  46071. * @return the associated data, can be null if the factory returned null.
  46072. */
  46073. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  46074. /**
  46075. * Remove an externaly attached data from the Engine instance
  46076. * @param key the unique key that identifies the data
  46077. * @return true if the data was successfully removed, false if it doesn't exist
  46078. */
  46079. removeExternalData(key: string): boolean;
  46080. private _evaluateSubMesh;
  46081. /**
  46082. * Clear the processed materials smart array preventing retention point in material dispose.
  46083. */
  46084. freeProcessedMaterials(): void;
  46085. private _preventFreeActiveMeshesAndRenderingGroups;
  46086. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  46087. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  46088. * when disposing several meshes in a row or a hierarchy of meshes.
  46089. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  46090. */
  46091. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  46092. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  46093. /**
  46094. * Clear the active meshes smart array preventing retention point in mesh dispose.
  46095. */
  46096. freeActiveMeshes(): void;
  46097. /**
  46098. * Clear the info related to rendering groups preventing retention points during dispose.
  46099. */
  46100. freeRenderingGroups(): void;
  46101. /** @hidden */
  46102. _isInIntermediateRendering(): boolean;
  46103. /**
  46104. * Lambda returning the list of potentially active meshes.
  46105. */
  46106. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  46107. /**
  46108. * Lambda returning the list of potentially active sub meshes.
  46109. */
  46110. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  46111. /**
  46112. * Lambda returning the list of potentially intersecting sub meshes.
  46113. */
  46114. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  46115. /**
  46116. * Lambda returning the list of potentially colliding sub meshes.
  46117. */
  46118. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  46119. /** @hidden */
  46120. _activeMeshesFrozen: boolean;
  46121. private _skipEvaluateActiveMeshesCompletely;
  46122. /**
  46123. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  46124. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  46125. * @param onSuccess optional success callback
  46126. * @param onError optional error callback
  46127. * @returns the current scene
  46128. */
  46129. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  46130. /**
  46131. * Use this function to restart evaluating active meshes on every frame
  46132. * @returns the current scene
  46133. */
  46134. unfreezeActiveMeshes(): Scene;
  46135. private _evaluateActiveMeshes;
  46136. private _activeMesh;
  46137. /**
  46138. * Update the transform matrix to update from the current active camera
  46139. * @param force defines a boolean used to force the update even if cache is up to date
  46140. */
  46141. updateTransformMatrix(force?: boolean): void;
  46142. private _bindFrameBuffer;
  46143. /** @hidden */
  46144. _allowPostProcessClearColor: boolean;
  46145. /** @hidden */
  46146. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  46147. private _processSubCameras;
  46148. private _checkIntersections;
  46149. /** @hidden */
  46150. _advancePhysicsEngineStep(step: number): void;
  46151. /**
  46152. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  46153. */
  46154. getDeterministicFrameTime: () => number;
  46155. /** @hidden */
  46156. _animate(): void;
  46157. /** Execute all animations (for a frame) */
  46158. animate(): void;
  46159. /**
  46160. * Render the scene
  46161. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  46162. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  46163. */
  46164. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  46165. /**
  46166. * Freeze all materials
  46167. * A frozen material will not be updatable but should be faster to render
  46168. */
  46169. freezeMaterials(): void;
  46170. /**
  46171. * Unfreeze all materials
  46172. * A frozen material will not be updatable but should be faster to render
  46173. */
  46174. unfreezeMaterials(): void;
  46175. /**
  46176. * Releases all held ressources
  46177. */
  46178. dispose(): void;
  46179. /**
  46180. * Gets if the scene is already disposed
  46181. */
  46182. get isDisposed(): boolean;
  46183. /**
  46184. * Call this function to reduce memory footprint of the scene.
  46185. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  46186. */
  46187. clearCachedVertexData(): void;
  46188. /**
  46189. * This function will remove the local cached buffer data from texture.
  46190. * It will save memory but will prevent the texture from being rebuilt
  46191. */
  46192. cleanCachedTextureBuffer(): void;
  46193. /**
  46194. * Get the world extend vectors with an optional filter
  46195. *
  46196. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  46197. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  46198. */
  46199. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  46200. min: Vector3;
  46201. max: Vector3;
  46202. };
  46203. /**
  46204. * Creates a ray that can be used to pick in the scene
  46205. * @param x defines the x coordinate of the origin (on-screen)
  46206. * @param y defines the y coordinate of the origin (on-screen)
  46207. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46208. * @param camera defines the camera to use for the picking
  46209. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46210. * @returns a Ray
  46211. */
  46212. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  46213. /**
  46214. * Creates a ray that can be used to pick in the scene
  46215. * @param x defines the x coordinate of the origin (on-screen)
  46216. * @param y defines the y coordinate of the origin (on-screen)
  46217. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  46218. * @param result defines the ray where to store the picking ray
  46219. * @param camera defines the camera to use for the picking
  46220. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  46221. * @returns the current scene
  46222. */
  46223. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  46224. /**
  46225. * Creates a ray that can be used to pick in the scene
  46226. * @param x defines the x coordinate of the origin (on-screen)
  46227. * @param y defines the y coordinate of the origin (on-screen)
  46228. * @param camera defines the camera to use for the picking
  46229. * @returns a Ray
  46230. */
  46231. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  46232. /**
  46233. * Creates a ray that can be used to pick in the scene
  46234. * @param x defines the x coordinate of the origin (on-screen)
  46235. * @param y defines the y coordinate of the origin (on-screen)
  46236. * @param result defines the ray where to store the picking ray
  46237. * @param camera defines the camera to use for the picking
  46238. * @returns the current scene
  46239. */
  46240. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  46241. /** Launch a ray to try to pick a mesh in the scene
  46242. * @param x position on screen
  46243. * @param y position on screen
  46244. * @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
  46245. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46246. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46247. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46248. * @returns a PickingInfo
  46249. */
  46250. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46251. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  46252. * @param x position on screen
  46253. * @param y position on screen
  46254. * @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
  46255. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46256. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46257. * @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)
  46258. */
  46259. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  46260. /** Use the given ray to pick a mesh in the scene
  46261. * @param ray The ray to use to pick meshes
  46262. * @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
  46263. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46264. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46265. * @returns a PickingInfo
  46266. */
  46267. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46268. /**
  46269. * Launch a ray to try to pick a mesh in the scene
  46270. * @param x X position on screen
  46271. * @param y Y position on screen
  46272. * @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
  46273. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46274. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46275. * @returns an array of PickingInfo
  46276. */
  46277. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46278. /**
  46279. * Launch a ray to try to pick a mesh in the scene
  46280. * @param ray Ray to use
  46281. * @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
  46282. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46283. * @returns an array of PickingInfo
  46284. */
  46285. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46286. /**
  46287. * Force the value of meshUnderPointer
  46288. * @param mesh defines the mesh to use
  46289. * @param pointerId optional pointer id when using more than one pointer
  46290. */
  46291. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  46292. /**
  46293. * Gets the mesh under the pointer
  46294. * @returns a Mesh or null if no mesh is under the pointer
  46295. */
  46296. getPointerOverMesh(): Nullable<AbstractMesh>;
  46297. /** @hidden */
  46298. _rebuildGeometries(): void;
  46299. /** @hidden */
  46300. _rebuildTextures(): void;
  46301. private _getByTags;
  46302. /**
  46303. * Get a list of meshes by tags
  46304. * @param tagsQuery defines the tags query to use
  46305. * @param forEach defines a predicate used to filter results
  46306. * @returns an array of Mesh
  46307. */
  46308. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46309. /**
  46310. * Get a list of cameras by tags
  46311. * @param tagsQuery defines the tags query to use
  46312. * @param forEach defines a predicate used to filter results
  46313. * @returns an array of Camera
  46314. */
  46315. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46316. /**
  46317. * Get a list of lights by tags
  46318. * @param tagsQuery defines the tags query to use
  46319. * @param forEach defines a predicate used to filter results
  46320. * @returns an array of Light
  46321. */
  46322. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46323. /**
  46324. * Get a list of materials by tags
  46325. * @param tagsQuery defines the tags query to use
  46326. * @param forEach defines a predicate used to filter results
  46327. * @returns an array of Material
  46328. */
  46329. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46330. /**
  46331. * Get a list of transform nodes by tags
  46332. * @param tagsQuery defines the tags query to use
  46333. * @param forEach defines a predicate used to filter results
  46334. * @returns an array of TransformNode
  46335. */
  46336. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46337. /**
  46338. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46339. * This allowed control for front to back rendering or reversly depending of the special needs.
  46340. *
  46341. * @param renderingGroupId The rendering group id corresponding to its index
  46342. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46343. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46344. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46345. */
  46346. 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;
  46347. /**
  46348. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46349. *
  46350. * @param renderingGroupId The rendering group id corresponding to its index
  46351. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46352. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46353. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46354. */
  46355. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46356. /**
  46357. * Gets the current auto clear configuration for one rendering group of the rendering
  46358. * manager.
  46359. * @param index the rendering group index to get the information for
  46360. * @returns The auto clear setup for the requested rendering group
  46361. */
  46362. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46363. private _blockMaterialDirtyMechanism;
  46364. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46365. get blockMaterialDirtyMechanism(): boolean;
  46366. set blockMaterialDirtyMechanism(value: boolean);
  46367. /**
  46368. * Will flag all materials as dirty to trigger new shader compilation
  46369. * @param flag defines the flag used to specify which material part must be marked as dirty
  46370. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46371. */
  46372. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46373. /** @hidden */
  46374. _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;
  46375. /** @hidden */
  46376. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46377. /** @hidden */
  46378. _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;
  46379. /** @hidden */
  46380. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46381. /** @hidden */
  46382. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46383. /** @hidden */
  46384. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46385. }
  46386. }
  46387. declare module "babylonjs/assetContainer" {
  46388. import { AbstractScene } from "babylonjs/abstractScene";
  46389. import { Scene } from "babylonjs/scene";
  46390. import { Mesh } from "babylonjs/Meshes/mesh";
  46391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46392. import { Skeleton } from "babylonjs/Bones/skeleton";
  46393. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46394. import { Animatable } from "babylonjs/Animations/animatable";
  46395. import { Nullable } from "babylonjs/types";
  46396. import { Node } from "babylonjs/node";
  46397. /**
  46398. * Set of assets to keep when moving a scene into an asset container.
  46399. */
  46400. export class KeepAssets extends AbstractScene {
  46401. }
  46402. /**
  46403. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46404. */
  46405. export class InstantiatedEntries {
  46406. /**
  46407. * List of new root nodes (eg. nodes with no parent)
  46408. */
  46409. rootNodes: TransformNode[];
  46410. /**
  46411. * List of new skeletons
  46412. */
  46413. skeletons: Skeleton[];
  46414. /**
  46415. * List of new animation groups
  46416. */
  46417. animationGroups: AnimationGroup[];
  46418. }
  46419. /**
  46420. * Container with a set of assets that can be added or removed from a scene.
  46421. */
  46422. export class AssetContainer extends AbstractScene {
  46423. private _wasAddedToScene;
  46424. /**
  46425. * The scene the AssetContainer belongs to.
  46426. */
  46427. scene: Scene;
  46428. /**
  46429. * Instantiates an AssetContainer.
  46430. * @param scene The scene the AssetContainer belongs to.
  46431. */
  46432. constructor(scene: Scene);
  46433. /**
  46434. * Instantiate or clone all meshes and add the new ones to the scene.
  46435. * Skeletons and animation groups will all be cloned
  46436. * @param nameFunction defines an optional function used to get new names for clones
  46437. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46438. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46439. */
  46440. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46441. /**
  46442. * Adds all the assets from the container to the scene.
  46443. */
  46444. addAllToScene(): void;
  46445. /**
  46446. * Removes all the assets in the container from the scene
  46447. */
  46448. removeAllFromScene(): void;
  46449. /**
  46450. * Disposes all the assets in the container
  46451. */
  46452. dispose(): void;
  46453. private _moveAssets;
  46454. /**
  46455. * Removes all the assets contained in the scene and adds them to the container.
  46456. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46457. */
  46458. moveAllFromScene(keepAssets?: KeepAssets): void;
  46459. /**
  46460. * 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.
  46461. * @returns the root mesh
  46462. */
  46463. createRootMesh(): Mesh;
  46464. /**
  46465. * Merge animations (direct and animation groups) from this asset container into a scene
  46466. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46467. * @param animatables set of animatables to retarget to a node from the scene
  46468. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46469. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46470. */
  46471. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46472. }
  46473. }
  46474. declare module "babylonjs/abstractScene" {
  46475. import { Scene } from "babylonjs/scene";
  46476. import { Nullable } from "babylonjs/types";
  46477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46478. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46479. import { Geometry } from "babylonjs/Meshes/geometry";
  46480. import { Skeleton } from "babylonjs/Bones/skeleton";
  46481. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46482. import { AssetContainer } from "babylonjs/assetContainer";
  46483. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46484. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46486. import { Material } from "babylonjs/Materials/material";
  46487. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46488. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46489. import { Camera } from "babylonjs/Cameras/camera";
  46490. import { Light } from "babylonjs/Lights/light";
  46491. import { Node } from "babylonjs/node";
  46492. import { Animation } from "babylonjs/Animations/animation";
  46493. /**
  46494. * Defines how the parser contract is defined.
  46495. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46496. */
  46497. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46498. /**
  46499. * Defines how the individual parser contract is defined.
  46500. * These parser can parse an individual asset
  46501. */
  46502. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46503. /**
  46504. * Base class of the scene acting as a container for the different elements composing a scene.
  46505. * This class is dynamically extended by the different components of the scene increasing
  46506. * flexibility and reducing coupling
  46507. */
  46508. export abstract class AbstractScene {
  46509. /**
  46510. * Stores the list of available parsers in the application.
  46511. */
  46512. private static _BabylonFileParsers;
  46513. /**
  46514. * Stores the list of available individual parsers in the application.
  46515. */
  46516. private static _IndividualBabylonFileParsers;
  46517. /**
  46518. * Adds a parser in the list of available ones
  46519. * @param name Defines the name of the parser
  46520. * @param parser Defines the parser to add
  46521. */
  46522. static AddParser(name: string, parser: BabylonFileParser): void;
  46523. /**
  46524. * Gets a general parser from the list of avaialble ones
  46525. * @param name Defines the name of the parser
  46526. * @returns the requested parser or null
  46527. */
  46528. static GetParser(name: string): Nullable<BabylonFileParser>;
  46529. /**
  46530. * Adds n individual parser in the list of available ones
  46531. * @param name Defines the name of the parser
  46532. * @param parser Defines the parser to add
  46533. */
  46534. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46535. /**
  46536. * Gets an individual parser from the list of avaialble ones
  46537. * @param name Defines the name of the parser
  46538. * @returns the requested parser or null
  46539. */
  46540. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46541. /**
  46542. * Parser json data and populate both a scene and its associated container object
  46543. * @param jsonData Defines the data to parse
  46544. * @param scene Defines the scene to parse the data for
  46545. * @param container Defines the container attached to the parsing sequence
  46546. * @param rootUrl Defines the root url of the data
  46547. */
  46548. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46549. /**
  46550. * Gets the list of root nodes (ie. nodes with no parent)
  46551. */
  46552. rootNodes: Node[];
  46553. /** All of the cameras added to this scene
  46554. * @see https://doc.babylonjs.com/babylon101/cameras
  46555. */
  46556. cameras: Camera[];
  46557. /**
  46558. * All of the lights added to this scene
  46559. * @see https://doc.babylonjs.com/babylon101/lights
  46560. */
  46561. lights: Light[];
  46562. /**
  46563. * All of the (abstract) meshes added to this scene
  46564. */
  46565. meshes: AbstractMesh[];
  46566. /**
  46567. * The list of skeletons added to the scene
  46568. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46569. */
  46570. skeletons: Skeleton[];
  46571. /**
  46572. * All of the particle systems added to this scene
  46573. * @see https://doc.babylonjs.com/babylon101/particles
  46574. */
  46575. particleSystems: IParticleSystem[];
  46576. /**
  46577. * Gets a list of Animations associated with the scene
  46578. */
  46579. animations: Animation[];
  46580. /**
  46581. * All of the animation groups added to this scene
  46582. * @see https://doc.babylonjs.com/how_to/group
  46583. */
  46584. animationGroups: AnimationGroup[];
  46585. /**
  46586. * All of the multi-materials added to this scene
  46587. * @see https://doc.babylonjs.com/how_to/multi_materials
  46588. */
  46589. multiMaterials: MultiMaterial[];
  46590. /**
  46591. * All of the materials added to this scene
  46592. * In the context of a Scene, it is not supposed to be modified manually.
  46593. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46594. * Note also that the order of the Material within the array is not significant and might change.
  46595. * @see https://doc.babylonjs.com/babylon101/materials
  46596. */
  46597. materials: Material[];
  46598. /**
  46599. * The list of morph target managers added to the scene
  46600. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46601. */
  46602. morphTargetManagers: MorphTargetManager[];
  46603. /**
  46604. * The list of geometries used in the scene.
  46605. */
  46606. geometries: Geometry[];
  46607. /**
  46608. * All of the tranform nodes added to this scene
  46609. * In the context of a Scene, it is not supposed to be modified manually.
  46610. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46611. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46612. * @see https://doc.babylonjs.com/how_to/transformnode
  46613. */
  46614. transformNodes: TransformNode[];
  46615. /**
  46616. * ActionManagers available on the scene.
  46617. */
  46618. actionManagers: AbstractActionManager[];
  46619. /**
  46620. * Textures to keep.
  46621. */
  46622. textures: BaseTexture[];
  46623. /** @hidden */
  46624. protected _environmentTexture: Nullable<BaseTexture>;
  46625. /**
  46626. * Texture used in all pbr material as the reflection texture.
  46627. * As in the majority of the scene they are the same (exception for multi room and so on),
  46628. * this is easier to reference from here than from all the materials.
  46629. */
  46630. get environmentTexture(): Nullable<BaseTexture>;
  46631. set environmentTexture(value: Nullable<BaseTexture>);
  46632. /**
  46633. * The list of postprocesses added to the scene
  46634. */
  46635. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46636. /**
  46637. * @returns all meshes, lights, cameras, transformNodes and bones
  46638. */
  46639. getNodes(): Array<Node>;
  46640. }
  46641. }
  46642. declare module "babylonjs/Audio/Interfaces/ISoundOptions" {
  46643. /**
  46644. * Interface used to define options for Sound class
  46645. */
  46646. export interface ISoundOptions {
  46647. /**
  46648. * Does the sound autoplay once loaded.
  46649. */
  46650. autoplay?: boolean;
  46651. /**
  46652. * Does the sound loop after it finishes playing once.
  46653. */
  46654. loop?: boolean;
  46655. /**
  46656. * Sound's volume
  46657. */
  46658. volume?: number;
  46659. /**
  46660. * Is it a spatial sound?
  46661. */
  46662. spatialSound?: boolean;
  46663. /**
  46664. * Maximum distance to hear that sound
  46665. */
  46666. maxDistance?: number;
  46667. /**
  46668. * Uses user defined attenuation function
  46669. */
  46670. useCustomAttenuation?: boolean;
  46671. /**
  46672. * Define the roll off factor of spatial sounds.
  46673. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46674. */
  46675. rolloffFactor?: number;
  46676. /**
  46677. * Define the reference distance the sound should be heard perfectly.
  46678. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46679. */
  46680. refDistance?: number;
  46681. /**
  46682. * Define the distance attenuation model the sound will follow.
  46683. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46684. */
  46685. distanceModel?: string;
  46686. /**
  46687. * Defines the playback speed (1 by default)
  46688. */
  46689. playbackRate?: number;
  46690. /**
  46691. * Defines if the sound is from a streaming source
  46692. */
  46693. streaming?: boolean;
  46694. /**
  46695. * Defines an optional length (in seconds) inside the sound file
  46696. */
  46697. length?: number;
  46698. /**
  46699. * Defines an optional offset (in seconds) inside the sound file
  46700. */
  46701. offset?: number;
  46702. /**
  46703. * If true, URLs will not be required to state the audio file codec to use.
  46704. */
  46705. skipCodecCheck?: boolean;
  46706. }
  46707. }
  46708. declare module "babylonjs/Audio/sound" {
  46709. import { Observable } from "babylonjs/Misc/observable";
  46710. import { Vector3 } from "babylonjs/Maths/math.vector";
  46711. import { Nullable } from "babylonjs/types";
  46712. import { Scene } from "babylonjs/scene";
  46713. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46714. import { ISoundOptions } from "babylonjs/Audio/Interfaces/ISoundOptions";
  46715. /**
  46716. * Defines a sound that can be played in the application.
  46717. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46718. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46719. */
  46720. export class Sound {
  46721. /**
  46722. * The name of the sound in the scene.
  46723. */
  46724. name: string;
  46725. /**
  46726. * Does the sound autoplay once loaded.
  46727. */
  46728. autoplay: boolean;
  46729. /**
  46730. * Does the sound loop after it finishes playing once.
  46731. */
  46732. loop: boolean;
  46733. /**
  46734. * Does the sound use a custom attenuation curve to simulate the falloff
  46735. * happening when the source gets further away from the camera.
  46736. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46737. */
  46738. useCustomAttenuation: boolean;
  46739. /**
  46740. * The sound track id this sound belongs to.
  46741. */
  46742. soundTrackId: number;
  46743. /**
  46744. * Is this sound currently played.
  46745. */
  46746. isPlaying: boolean;
  46747. /**
  46748. * Is this sound currently paused.
  46749. */
  46750. isPaused: boolean;
  46751. /**
  46752. * Does this sound enables spatial sound.
  46753. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46754. */
  46755. spatialSound: boolean;
  46756. /**
  46757. * Define the reference distance the sound should be heard perfectly.
  46758. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46759. */
  46760. refDistance: number;
  46761. /**
  46762. * Define the roll off factor of spatial sounds.
  46763. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46764. */
  46765. rolloffFactor: number;
  46766. /**
  46767. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46769. */
  46770. maxDistance: number;
  46771. /**
  46772. * Define the distance attenuation model the sound will follow.
  46773. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46774. */
  46775. distanceModel: string;
  46776. /**
  46777. * @hidden
  46778. * Back Compat
  46779. **/
  46780. onended: () => any;
  46781. /**
  46782. * Gets or sets an object used to store user defined information for the sound.
  46783. */
  46784. metadata: any;
  46785. /**
  46786. * Observable event when the current playing sound finishes.
  46787. */
  46788. onEndedObservable: Observable<Sound>;
  46789. /**
  46790. * Gets the current time for the sound.
  46791. */
  46792. get currentTime(): number;
  46793. private _panningModel;
  46794. private _playbackRate;
  46795. private _streaming;
  46796. private _startTime;
  46797. private _startOffset;
  46798. private _position;
  46799. /** @hidden */
  46800. _positionInEmitterSpace: boolean;
  46801. private _localDirection;
  46802. private _volume;
  46803. private _isReadyToPlay;
  46804. private _isDirectional;
  46805. private _readyToPlayCallback;
  46806. private _audioBuffer;
  46807. private _soundSource;
  46808. private _streamingSource;
  46809. private _soundPanner;
  46810. private _soundGain;
  46811. private _inputAudioNode;
  46812. private _outputAudioNode;
  46813. private _coneInnerAngle;
  46814. private _coneOuterAngle;
  46815. private _coneOuterGain;
  46816. private _scene;
  46817. private _connectedTransformNode;
  46818. private _customAttenuationFunction;
  46819. private _registerFunc;
  46820. private _isOutputConnected;
  46821. private _htmlAudioElement;
  46822. private _urlType;
  46823. private _length?;
  46824. private _offset?;
  46825. /** @hidden */
  46826. static _SceneComponentInitialization: (scene: Scene) => void;
  46827. /**
  46828. * Create a sound and attach it to a scene
  46829. * @param name Name of your sound
  46830. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46831. * @param scene defines the scene the sound belongs to
  46832. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46833. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46834. */
  46835. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46836. /**
  46837. * Release the sound and its associated resources
  46838. */
  46839. dispose(): void;
  46840. /**
  46841. * Gets if the sounds is ready to be played or not.
  46842. * @returns true if ready, otherwise false
  46843. */
  46844. isReady(): boolean;
  46845. private _soundLoaded;
  46846. /**
  46847. * Sets the data of the sound from an audiobuffer
  46848. * @param audioBuffer The audioBuffer containing the data
  46849. */
  46850. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46851. /**
  46852. * Updates the current sounds options such as maxdistance, loop...
  46853. * @param options A JSON object containing values named as the object properties
  46854. */
  46855. updateOptions(options: ISoundOptions): void;
  46856. private _createSpatialParameters;
  46857. private _updateSpatialParameters;
  46858. /**
  46859. * Switch the panning model to HRTF:
  46860. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46861. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46862. */
  46863. switchPanningModelToHRTF(): void;
  46864. /**
  46865. * Switch the panning model to Equal Power:
  46866. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46867. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46868. */
  46869. switchPanningModelToEqualPower(): void;
  46870. private _switchPanningModel;
  46871. /**
  46872. * Connect this sound to a sound track audio node like gain...
  46873. * @param soundTrackAudioNode the sound track audio node to connect to
  46874. */
  46875. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46876. /**
  46877. * Transform this sound into a directional source
  46878. * @param coneInnerAngle Size of the inner cone in degree
  46879. * @param coneOuterAngle Size of the outer cone in degree
  46880. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46881. */
  46882. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46883. /**
  46884. * Gets or sets the inner angle for the directional cone.
  46885. */
  46886. get directionalConeInnerAngle(): number;
  46887. /**
  46888. * Gets or sets the inner angle for the directional cone.
  46889. */
  46890. set directionalConeInnerAngle(value: number);
  46891. /**
  46892. * Gets or sets the outer angle for the directional cone.
  46893. */
  46894. get directionalConeOuterAngle(): number;
  46895. /**
  46896. * Gets or sets the outer angle for the directional cone.
  46897. */
  46898. set directionalConeOuterAngle(value: number);
  46899. /**
  46900. * Sets the position of the emitter if spatial sound is enabled
  46901. * @param newPosition Defines the new posisiton
  46902. */
  46903. setPosition(newPosition: Vector3): void;
  46904. /**
  46905. * Sets the local direction of the emitter if spatial sound is enabled
  46906. * @param newLocalDirection Defines the new local direction
  46907. */
  46908. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46909. private _updateDirection;
  46910. /** @hidden */
  46911. updateDistanceFromListener(): void;
  46912. /**
  46913. * Sets a new custom attenuation function for the sound.
  46914. * @param callback Defines the function used for the attenuation
  46915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46916. */
  46917. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46918. /**
  46919. * Play the sound
  46920. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46921. * @param offset (optional) Start the sound at a specific time in seconds
  46922. * @param length (optional) Sound duration (in seconds)
  46923. */
  46924. play(time?: number, offset?: number, length?: number): void;
  46925. private _onended;
  46926. /**
  46927. * Stop the sound
  46928. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46929. */
  46930. stop(time?: number): void;
  46931. /**
  46932. * Put the sound in pause
  46933. */
  46934. pause(): void;
  46935. /**
  46936. * Sets a dedicated volume for this sounds
  46937. * @param newVolume Define the new volume of the sound
  46938. * @param time Define time for gradual change to new volume
  46939. */
  46940. setVolume(newVolume: number, time?: number): void;
  46941. /**
  46942. * Set the sound play back rate
  46943. * @param newPlaybackRate Define the playback rate the sound should be played at
  46944. */
  46945. setPlaybackRate(newPlaybackRate: number): void;
  46946. /**
  46947. * Gets the volume of the sound.
  46948. * @returns the volume of the sound
  46949. */
  46950. getVolume(): number;
  46951. /**
  46952. * Attach the sound to a dedicated mesh
  46953. * @param transformNode The transform node to connect the sound with
  46954. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46955. */
  46956. attachToMesh(transformNode: TransformNode): void;
  46957. /**
  46958. * Detach the sound from the previously attached mesh
  46959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46960. */
  46961. detachFromMesh(): void;
  46962. private _onRegisterAfterWorldMatrixUpdate;
  46963. /**
  46964. * Clone the current sound in the scene.
  46965. * @returns the new sound clone
  46966. */
  46967. clone(): Nullable<Sound>;
  46968. /**
  46969. * Gets the current underlying audio buffer containing the data
  46970. * @returns the audio buffer
  46971. */
  46972. getAudioBuffer(): Nullable<AudioBuffer>;
  46973. /**
  46974. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46975. * @returns the source node
  46976. */
  46977. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46978. /**
  46979. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46980. * @returns the gain node
  46981. */
  46982. getSoundGain(): Nullable<GainNode>;
  46983. /**
  46984. * Serializes the Sound in a JSON representation
  46985. * @returns the JSON representation of the sound
  46986. */
  46987. serialize(): any;
  46988. /**
  46989. * Parse a JSON representation of a sound to innstantiate in a given scene
  46990. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46991. * @param scene Define the scene the new parsed sound should be created in
  46992. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46993. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46994. * @returns the newly parsed sound
  46995. */
  46996. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46997. }
  46998. }
  46999. declare module "babylonjs/Actions/directAudioActions" {
  47000. import { Action } from "babylonjs/Actions/action";
  47001. import { Condition } from "babylonjs/Actions/condition";
  47002. import { Sound } from "babylonjs/Audio/sound";
  47003. /**
  47004. * This defines an action helpful to play a defined sound on a triggered action.
  47005. */
  47006. export class PlaySoundAction extends Action {
  47007. private _sound;
  47008. /**
  47009. * Instantiate the action
  47010. * @param triggerOptions defines the trigger options
  47011. * @param sound defines the sound to play
  47012. * @param condition defines the trigger related conditions
  47013. */
  47014. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47015. /** @hidden */
  47016. _prepare(): void;
  47017. /**
  47018. * Execute the action and play the sound.
  47019. */
  47020. execute(): void;
  47021. /**
  47022. * Serializes the actions and its related information.
  47023. * @param parent defines the object to serialize in
  47024. * @returns the serialized object
  47025. */
  47026. serialize(parent: any): any;
  47027. }
  47028. /**
  47029. * This defines an action helpful to stop a defined sound on a triggered action.
  47030. */
  47031. export class StopSoundAction extends Action {
  47032. private _sound;
  47033. /**
  47034. * Instantiate the action
  47035. * @param triggerOptions defines the trigger options
  47036. * @param sound defines the sound to stop
  47037. * @param condition defines the trigger related conditions
  47038. */
  47039. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  47040. /** @hidden */
  47041. _prepare(): void;
  47042. /**
  47043. * Execute the action and stop the sound.
  47044. */
  47045. execute(): void;
  47046. /**
  47047. * Serializes the actions and its related information.
  47048. * @param parent defines the object to serialize in
  47049. * @returns the serialized object
  47050. */
  47051. serialize(parent: any): any;
  47052. }
  47053. }
  47054. declare module "babylonjs/Actions/interpolateValueAction" {
  47055. import { Action } from "babylonjs/Actions/action";
  47056. import { Condition } from "babylonjs/Actions/condition";
  47057. import { Observable } from "babylonjs/Misc/observable";
  47058. /**
  47059. * This defines an action responsible to change the value of a property
  47060. * by interpolating between its current value and the newly set one once triggered.
  47061. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  47062. */
  47063. export class InterpolateValueAction extends Action {
  47064. /**
  47065. * Defines the path of the property where the value should be interpolated
  47066. */
  47067. propertyPath: string;
  47068. /**
  47069. * Defines the target value at the end of the interpolation.
  47070. */
  47071. value: any;
  47072. /**
  47073. * Defines the time it will take for the property to interpolate to the value.
  47074. */
  47075. duration: number;
  47076. /**
  47077. * Defines if the other scene animations should be stopped when the action has been triggered
  47078. */
  47079. stopOtherAnimations?: boolean;
  47080. /**
  47081. * Defines a callback raised once the interpolation animation has been done.
  47082. */
  47083. onInterpolationDone?: () => void;
  47084. /**
  47085. * Observable triggered once the interpolation animation has been done.
  47086. */
  47087. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  47088. private _target;
  47089. private _effectiveTarget;
  47090. private _property;
  47091. /**
  47092. * Instantiate the action
  47093. * @param triggerOptions defines the trigger options
  47094. * @param target defines the object containing the value to interpolate
  47095. * @param propertyPath defines the path to the property in the target object
  47096. * @param value defines the target value at the end of the interpolation
  47097. * @param duration deines the time it will take for the property to interpolate to the value.
  47098. * @param condition defines the trigger related conditions
  47099. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  47100. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  47101. */
  47102. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  47103. /** @hidden */
  47104. _prepare(): void;
  47105. /**
  47106. * Execute the action starts the value interpolation.
  47107. */
  47108. execute(): void;
  47109. /**
  47110. * Serializes the actions and its related information.
  47111. * @param parent defines the object to serialize in
  47112. * @returns the serialized object
  47113. */
  47114. serialize(parent: any): any;
  47115. }
  47116. }
  47117. declare module "babylonjs/Actions/index" {
  47118. export * from "babylonjs/Actions/abstractActionManager";
  47119. export * from "babylonjs/Actions/action";
  47120. export * from "babylonjs/Actions/actionEvent";
  47121. export * from "babylonjs/Actions/actionManager";
  47122. export * from "babylonjs/Actions/condition";
  47123. export * from "babylonjs/Actions/directActions";
  47124. export * from "babylonjs/Actions/directAudioActions";
  47125. export * from "babylonjs/Actions/interpolateValueAction";
  47126. }
  47127. declare module "babylonjs/Animations/index" {
  47128. export * from "babylonjs/Animations/animatable";
  47129. export * from "babylonjs/Animations/animation";
  47130. export * from "babylonjs/Animations/animationGroup";
  47131. export * from "babylonjs/Animations/animationPropertiesOverride";
  47132. export * from "babylonjs/Animations/easing";
  47133. export * from "babylonjs/Animations/runtimeAnimation";
  47134. export * from "babylonjs/Animations/animationEvent";
  47135. export * from "babylonjs/Animations/animationGroup";
  47136. export * from "babylonjs/Animations/animationKey";
  47137. export * from "babylonjs/Animations/animationRange";
  47138. export * from "babylonjs/Animations/animatable.interface";
  47139. }
  47140. declare module "babylonjs/Audio/audioEngine" {
  47141. import { Analyser } from "babylonjs/Audio/analyser";
  47142. import { Nullable } from "babylonjs/types";
  47143. import { Observable } from "babylonjs/Misc/observable";
  47144. import { IAudioEngine } from "babylonjs/Audio/Interfaces/IAudioEngine";
  47145. /**
  47146. * This represents the default audio engine used in babylon.
  47147. * It is responsible to play, synchronize and analyse sounds throughout the application.
  47148. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47149. */
  47150. export class AudioEngine implements IAudioEngine {
  47151. private _audioContext;
  47152. private _audioContextInitialized;
  47153. private _muteButton;
  47154. private _hostElement;
  47155. /**
  47156. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  47157. */
  47158. canUseWebAudio: boolean;
  47159. /**
  47160. * The master gain node defines the global audio volume of your audio engine.
  47161. */
  47162. masterGain: GainNode;
  47163. /**
  47164. * Defines if Babylon should emit a warning if WebAudio is not supported.
  47165. * @ignoreNaming
  47166. */
  47167. WarnedWebAudioUnsupported: boolean;
  47168. /**
  47169. * Gets whether or not mp3 are supported by your browser.
  47170. */
  47171. isMP3supported: boolean;
  47172. /**
  47173. * Gets whether or not ogg are supported by your browser.
  47174. */
  47175. isOGGsupported: boolean;
  47176. /**
  47177. * Gets whether audio has been unlocked on the device.
  47178. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  47179. * a user interaction has happened.
  47180. */
  47181. unlocked: boolean;
  47182. /**
  47183. * Defines if the audio engine relies on a custom unlocked button.
  47184. * In this case, the embedded button will not be displayed.
  47185. */
  47186. useCustomUnlockedButton: boolean;
  47187. /**
  47188. * Event raised when audio has been unlocked on the browser.
  47189. */
  47190. onAudioUnlockedObservable: Observable<IAudioEngine>;
  47191. /**
  47192. * Event raised when audio has been locked on the browser.
  47193. */
  47194. onAudioLockedObservable: Observable<IAudioEngine>;
  47195. /**
  47196. * Gets the current AudioContext if available.
  47197. */
  47198. get audioContext(): Nullable<AudioContext>;
  47199. private _connectedAnalyser;
  47200. /**
  47201. * Instantiates a new audio engine.
  47202. *
  47203. * There should be only one per page as some browsers restrict the number
  47204. * of audio contexts you can create.
  47205. * @param hostElement defines the host element where to display the mute icon if necessary
  47206. */
  47207. constructor(hostElement?: Nullable<HTMLElement>);
  47208. /**
  47209. * Flags the audio engine in Locked state.
  47210. * This happens due to new browser policies preventing audio to autoplay.
  47211. */
  47212. lock(): void;
  47213. /**
  47214. * Unlocks the audio engine once a user action has been done on the dom.
  47215. * This is helpful to resume play once browser policies have been satisfied.
  47216. */
  47217. unlock(): void;
  47218. private _resumeAudioContext;
  47219. private _initializeAudioContext;
  47220. private _tryToRun;
  47221. private _triggerRunningState;
  47222. private _triggerSuspendedState;
  47223. private _displayMuteButton;
  47224. private _moveButtonToTopLeft;
  47225. private _onResize;
  47226. private _hideMuteButton;
  47227. /**
  47228. * Destroy and release the resources associated with the audio ccontext.
  47229. */
  47230. dispose(): void;
  47231. /**
  47232. * Gets the global volume sets on the master gain.
  47233. * @returns the global volume if set or -1 otherwise
  47234. */
  47235. getGlobalVolume(): number;
  47236. /**
  47237. * Sets the global volume of your experience (sets on the master gain).
  47238. * @param newVolume Defines the new global volume of the application
  47239. */
  47240. setGlobalVolume(newVolume: number): void;
  47241. /**
  47242. * Connect the audio engine to an audio analyser allowing some amazing
  47243. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47244. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47245. * @param analyser The analyser to connect to the engine
  47246. */
  47247. connectToAnalyser(analyser: Analyser): void;
  47248. }
  47249. }
  47250. declare module "babylonjs/Audio/soundTrack" {
  47251. import { Sound } from "babylonjs/Audio/sound";
  47252. import { Analyser } from "babylonjs/Audio/analyser";
  47253. import { Scene } from "babylonjs/scene";
  47254. /**
  47255. * Options allowed during the creation of a sound track.
  47256. */
  47257. export interface ISoundTrackOptions {
  47258. /**
  47259. * The volume the sound track should take during creation
  47260. */
  47261. volume?: number;
  47262. /**
  47263. * Define if the sound track is the main sound track of the scene
  47264. */
  47265. mainTrack?: boolean;
  47266. }
  47267. /**
  47268. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  47269. * It will be also used in a future release to apply effects on a specific track.
  47270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47271. */
  47272. export class SoundTrack {
  47273. /**
  47274. * The unique identifier of the sound track in the scene.
  47275. */
  47276. id: number;
  47277. /**
  47278. * The list of sounds included in the sound track.
  47279. */
  47280. soundCollection: Array<Sound>;
  47281. private _outputAudioNode;
  47282. private _scene;
  47283. private _connectedAnalyser;
  47284. private _options;
  47285. private _isInitialized;
  47286. /**
  47287. * Creates a new sound track.
  47288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  47289. * @param scene Define the scene the sound track belongs to
  47290. * @param options
  47291. */
  47292. constructor(scene: Scene, options?: ISoundTrackOptions);
  47293. private _initializeSoundTrackAudioGraph;
  47294. /**
  47295. * Release the sound track and its associated resources
  47296. */
  47297. dispose(): void;
  47298. /**
  47299. * Adds a sound to this sound track
  47300. * @param sound define the cound to add
  47301. * @ignoreNaming
  47302. */
  47303. addSound(sound: Sound): void;
  47304. /**
  47305. * Removes a sound to this sound track
  47306. * @param sound define the cound to remove
  47307. * @ignoreNaming
  47308. */
  47309. removeSound(sound: Sound): void;
  47310. /**
  47311. * Set a global volume for the full sound track.
  47312. * @param newVolume Define the new volume of the sound track
  47313. */
  47314. setVolume(newVolume: number): void;
  47315. /**
  47316. * Switch the panning model to HRTF:
  47317. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47318. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47319. */
  47320. switchPanningModelToHRTF(): void;
  47321. /**
  47322. * Switch the panning model to Equal Power:
  47323. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47324. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47325. */
  47326. switchPanningModelToEqualPower(): void;
  47327. /**
  47328. * Connect the sound track to an audio analyser allowing some amazing
  47329. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  47330. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  47331. * @param analyser The analyser to connect to the engine
  47332. */
  47333. connectToAnalyser(analyser: Analyser): void;
  47334. }
  47335. }
  47336. declare module "babylonjs/Audio/audioSceneComponent" {
  47337. import { Sound } from "babylonjs/Audio/sound";
  47338. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47339. import { Nullable } from "babylonjs/types";
  47340. import { Vector3 } from "babylonjs/Maths/math.vector";
  47341. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47342. import { Scene } from "babylonjs/scene";
  47343. import { AbstractScene } from "babylonjs/abstractScene";
  47344. import "babylonjs/Audio/audioEngine";
  47345. module "babylonjs/abstractScene" {
  47346. interface AbstractScene {
  47347. /**
  47348. * The list of sounds used in the scene.
  47349. */
  47350. sounds: Nullable<Array<Sound>>;
  47351. }
  47352. }
  47353. module "babylonjs/scene" {
  47354. interface Scene {
  47355. /**
  47356. * @hidden
  47357. * Backing field
  47358. */
  47359. _mainSoundTrack: SoundTrack;
  47360. /**
  47361. * The main sound track played by the scene.
  47362. * It cotains your primary collection of sounds.
  47363. */
  47364. mainSoundTrack: SoundTrack;
  47365. /**
  47366. * The list of sound tracks added to the scene
  47367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47368. */
  47369. soundTracks: Nullable<Array<SoundTrack>>;
  47370. /**
  47371. * Gets a sound using a given name
  47372. * @param name defines the name to search for
  47373. * @return the found sound or null if not found at all.
  47374. */
  47375. getSoundByName(name: string): Nullable<Sound>;
  47376. /**
  47377. * Gets or sets if audio support is enabled
  47378. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47379. */
  47380. audioEnabled: boolean;
  47381. /**
  47382. * Gets or sets if audio will be output to headphones
  47383. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47384. */
  47385. headphone: boolean;
  47386. /**
  47387. * Gets or sets custom audio listener position provider
  47388. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47389. */
  47390. audioListenerPositionProvider: Nullable<() => Vector3>;
  47391. /**
  47392. * Gets or sets a refresh rate when using 3D audio positioning
  47393. */
  47394. audioPositioningRefreshRate: number;
  47395. }
  47396. }
  47397. /**
  47398. * Defines the sound scene component responsible to manage any sounds
  47399. * in a given scene.
  47400. */
  47401. export class AudioSceneComponent implements ISceneSerializableComponent {
  47402. private static _CameraDirectionLH;
  47403. private static _CameraDirectionRH;
  47404. /**
  47405. * The component name helpfull to identify the component in the list of scene components.
  47406. */
  47407. readonly name: string;
  47408. /**
  47409. * The scene the component belongs to.
  47410. */
  47411. scene: Scene;
  47412. private _audioEnabled;
  47413. /**
  47414. * Gets whether audio is enabled or not.
  47415. * Please use related enable/disable method to switch state.
  47416. */
  47417. get audioEnabled(): boolean;
  47418. private _headphone;
  47419. /**
  47420. * Gets whether audio is outputing to headphone or not.
  47421. * Please use the according Switch methods to change output.
  47422. */
  47423. get headphone(): boolean;
  47424. /**
  47425. * Gets or sets a refresh rate when using 3D audio positioning
  47426. */
  47427. audioPositioningRefreshRate: number;
  47428. private _audioListenerPositionProvider;
  47429. /**
  47430. * Gets the current audio listener position provider
  47431. */
  47432. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47433. /**
  47434. * Sets a custom listener position for all sounds in the scene
  47435. * By default, this is the position of the first active camera
  47436. */
  47437. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47438. /**
  47439. * Creates a new instance of the component for the given scene
  47440. * @param scene Defines the scene to register the component in
  47441. */
  47442. constructor(scene: Scene);
  47443. /**
  47444. * Registers the component in a given scene
  47445. */
  47446. register(): void;
  47447. /**
  47448. * Rebuilds the elements related to this component in case of
  47449. * context lost for instance.
  47450. */
  47451. rebuild(): void;
  47452. /**
  47453. * Serializes the component data to the specified json object
  47454. * @param serializationObject The object to serialize to
  47455. */
  47456. serialize(serializationObject: any): void;
  47457. /**
  47458. * Adds all the elements from the container to the scene
  47459. * @param container the container holding the elements
  47460. */
  47461. addFromContainer(container: AbstractScene): void;
  47462. /**
  47463. * Removes all the elements in the container from the scene
  47464. * @param container contains the elements to remove
  47465. * @param dispose if the removed element should be disposed (default: false)
  47466. */
  47467. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47468. /**
  47469. * Disposes the component and the associated ressources.
  47470. */
  47471. dispose(): void;
  47472. /**
  47473. * Disables audio in the associated scene.
  47474. */
  47475. disableAudio(): void;
  47476. /**
  47477. * Enables audio in the associated scene.
  47478. */
  47479. enableAudio(): void;
  47480. /**
  47481. * Switch audio to headphone output.
  47482. */
  47483. switchAudioModeForHeadphones(): void;
  47484. /**
  47485. * Switch audio to normal speakers.
  47486. */
  47487. switchAudioModeForNormalSpeakers(): void;
  47488. private _cachedCameraDirection;
  47489. private _cachedCameraPosition;
  47490. private _lastCheck;
  47491. private _afterRender;
  47492. }
  47493. }
  47494. declare module "babylonjs/Audio/weightedsound" {
  47495. import { Sound } from "babylonjs/Audio/sound";
  47496. /**
  47497. * Wraps one or more Sound objects and selects one with random weight for playback.
  47498. */
  47499. export class WeightedSound {
  47500. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47501. loop: boolean;
  47502. private _coneInnerAngle;
  47503. private _coneOuterAngle;
  47504. private _volume;
  47505. /** A Sound is currently playing. */
  47506. isPlaying: boolean;
  47507. /** A Sound is currently paused. */
  47508. isPaused: boolean;
  47509. private _sounds;
  47510. private _weights;
  47511. private _currentIndex?;
  47512. /**
  47513. * Creates a new WeightedSound from the list of sounds given.
  47514. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47515. * @param sounds Array of Sounds that will be selected from.
  47516. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47517. */
  47518. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47519. /**
  47520. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47521. */
  47522. get directionalConeInnerAngle(): number;
  47523. /**
  47524. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47525. */
  47526. set directionalConeInnerAngle(value: number);
  47527. /**
  47528. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47529. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47530. */
  47531. get directionalConeOuterAngle(): number;
  47532. /**
  47533. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47534. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47535. */
  47536. set directionalConeOuterAngle(value: number);
  47537. /**
  47538. * Playback volume.
  47539. */
  47540. get volume(): number;
  47541. /**
  47542. * Playback volume.
  47543. */
  47544. set volume(value: number);
  47545. private _onended;
  47546. /**
  47547. * Suspend playback
  47548. */
  47549. pause(): void;
  47550. /**
  47551. * Stop playback
  47552. */
  47553. stop(): void;
  47554. /**
  47555. * Start playback.
  47556. * @param startOffset Position the clip head at a specific time in seconds.
  47557. */
  47558. play(startOffset?: number): void;
  47559. }
  47560. }
  47561. declare module "babylonjs/Audio/index" {
  47562. export * from "babylonjs/Audio/Interfaces/IAudioEngine";
  47563. export * from "babylonjs/Audio/Interfaces/ISoundOptions";
  47564. export * from "babylonjs/Audio/analyser";
  47565. export * from "babylonjs/Audio/audioEngine";
  47566. export * from "babylonjs/Audio/audioSceneComponent";
  47567. export * from "babylonjs/Audio/sound";
  47568. export * from "babylonjs/Audio/soundTrack";
  47569. export * from "babylonjs/Audio/weightedsound";
  47570. }
  47571. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47572. import { Behavior } from "babylonjs/Behaviors/behavior";
  47573. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47574. import { BackEase } from "babylonjs/Animations/easing";
  47575. /**
  47576. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47577. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47578. */
  47579. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47580. /**
  47581. * Gets the name of the behavior.
  47582. */
  47583. get name(): string;
  47584. /**
  47585. * The easing function used by animations
  47586. */
  47587. static EasingFunction: BackEase;
  47588. /**
  47589. * The easing mode used by animations
  47590. */
  47591. static EasingMode: number;
  47592. /**
  47593. * The duration of the animation, in milliseconds
  47594. */
  47595. transitionDuration: number;
  47596. /**
  47597. * Length of the distance animated by the transition when lower radius is reached
  47598. */
  47599. lowerRadiusTransitionRange: number;
  47600. /**
  47601. * Length of the distance animated by the transition when upper radius is reached
  47602. */
  47603. upperRadiusTransitionRange: number;
  47604. private _autoTransitionRange;
  47605. /**
  47606. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47607. */
  47608. get autoTransitionRange(): boolean;
  47609. /**
  47610. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47611. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47612. */
  47613. set autoTransitionRange(value: boolean);
  47614. private _attachedCamera;
  47615. private _onAfterCheckInputsObserver;
  47616. private _onMeshTargetChangedObserver;
  47617. /**
  47618. * Initializes the behavior.
  47619. */
  47620. init(): void;
  47621. /**
  47622. * Attaches the behavior to its arc rotate camera.
  47623. * @param camera Defines the camera to attach the behavior to
  47624. */
  47625. attach(camera: ArcRotateCamera): void;
  47626. /**
  47627. * Detaches the behavior from its current arc rotate camera.
  47628. */
  47629. detach(): void;
  47630. private _radiusIsAnimating;
  47631. private _radiusBounceTransition;
  47632. private _animatables;
  47633. private _cachedWheelPrecision;
  47634. /**
  47635. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47636. * @param radiusLimit The limit to check against.
  47637. * @return Bool to indicate if at limit.
  47638. */
  47639. private _isRadiusAtLimit;
  47640. /**
  47641. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47642. * @param radiusDelta The delta by which to animate to. Can be negative.
  47643. */
  47644. private _applyBoundRadiusAnimation;
  47645. /**
  47646. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47647. */
  47648. protected _clearAnimationLocks(): void;
  47649. /**
  47650. * Stops and removes all animations that have been applied to the camera
  47651. */
  47652. stopAllAnimations(): void;
  47653. }
  47654. }
  47655. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47656. import { Behavior } from "babylonjs/Behaviors/behavior";
  47657. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47658. import { ExponentialEase } from "babylonjs/Animations/easing";
  47659. import { Nullable } from "babylonjs/types";
  47660. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47661. import { Vector3 } from "babylonjs/Maths/math.vector";
  47662. /**
  47663. * 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.
  47664. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47665. */
  47666. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47667. /**
  47668. * Gets the name of the behavior.
  47669. */
  47670. get name(): string;
  47671. private _mode;
  47672. private _radiusScale;
  47673. private _positionScale;
  47674. private _defaultElevation;
  47675. private _elevationReturnTime;
  47676. private _elevationReturnWaitTime;
  47677. private _zoomStopsAnimation;
  47678. private _framingTime;
  47679. /**
  47680. * The easing function used by animations
  47681. */
  47682. static EasingFunction: ExponentialEase;
  47683. /**
  47684. * The easing mode used by animations
  47685. */
  47686. static EasingMode: number;
  47687. /**
  47688. * Sets the current mode used by the behavior
  47689. */
  47690. set mode(mode: number);
  47691. /**
  47692. * Gets current mode used by the behavior.
  47693. */
  47694. get mode(): number;
  47695. /**
  47696. * Sets the scale applied to the radius (1 by default)
  47697. */
  47698. set radiusScale(radius: number);
  47699. /**
  47700. * Gets the scale applied to the radius
  47701. */
  47702. get radiusScale(): number;
  47703. /**
  47704. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47705. */
  47706. set positionScale(scale: number);
  47707. /**
  47708. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47709. */
  47710. get positionScale(): number;
  47711. /**
  47712. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47713. * behaviour is triggered, in radians.
  47714. */
  47715. set defaultElevation(elevation: number);
  47716. /**
  47717. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47718. * behaviour is triggered, in radians.
  47719. */
  47720. get defaultElevation(): number;
  47721. /**
  47722. * Sets the time (in milliseconds) taken to return to the default beta position.
  47723. * Negative value indicates camera should not return to default.
  47724. */
  47725. set elevationReturnTime(speed: number);
  47726. /**
  47727. * Gets the time (in milliseconds) taken to return to the default beta position.
  47728. * Negative value indicates camera should not return to default.
  47729. */
  47730. get elevationReturnTime(): number;
  47731. /**
  47732. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47733. */
  47734. set elevationReturnWaitTime(time: number);
  47735. /**
  47736. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47737. */
  47738. get elevationReturnWaitTime(): number;
  47739. /**
  47740. * Sets the flag that indicates if user zooming should stop animation.
  47741. */
  47742. set zoomStopsAnimation(flag: boolean);
  47743. /**
  47744. * Gets the flag that indicates if user zooming should stop animation.
  47745. */
  47746. get zoomStopsAnimation(): boolean;
  47747. /**
  47748. * Sets the transition time when framing the mesh, in milliseconds
  47749. */
  47750. set framingTime(time: number);
  47751. /**
  47752. * Gets the transition time when framing the mesh, in milliseconds
  47753. */
  47754. get framingTime(): number;
  47755. /**
  47756. * Define if the behavior should automatically change the configured
  47757. * camera limits and sensibilities.
  47758. */
  47759. autoCorrectCameraLimitsAndSensibility: boolean;
  47760. private _onPrePointerObservableObserver;
  47761. private _onAfterCheckInputsObserver;
  47762. private _onMeshTargetChangedObserver;
  47763. private _attachedCamera;
  47764. private _isPointerDown;
  47765. private _lastInteractionTime;
  47766. /**
  47767. * Initializes the behavior.
  47768. */
  47769. init(): void;
  47770. /**
  47771. * Attaches the behavior to its arc rotate camera.
  47772. * @param camera Defines the camera to attach the behavior to
  47773. */
  47774. attach(camera: ArcRotateCamera): void;
  47775. /**
  47776. * Detaches the behavior from its current arc rotate camera.
  47777. */
  47778. detach(): void;
  47779. private _animatables;
  47780. private _betaIsAnimating;
  47781. private _betaTransition;
  47782. private _radiusTransition;
  47783. private _vectorTransition;
  47784. /**
  47785. * Targets the given mesh and updates zoom level accordingly.
  47786. * @param mesh The mesh to target.
  47787. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47788. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47789. */
  47790. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47791. /**
  47792. * Targets the given mesh with its children and updates zoom level accordingly.
  47793. * @param mesh The mesh to target.
  47794. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47795. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47796. */
  47797. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47798. /**
  47799. * Targets the given meshes with their children and updates zoom level accordingly.
  47800. * @param meshes The mesh to target.
  47801. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47802. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47803. */
  47804. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47805. /**
  47806. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47807. * @param minimumWorld Determines the smaller position of the bounding box extend
  47808. * @param maximumWorld Determines the bigger position of the bounding box extend
  47809. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47810. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47811. */
  47812. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47813. /**
  47814. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47815. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47816. * frustum width.
  47817. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47818. * to fully enclose the mesh in the viewing frustum.
  47819. */
  47820. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47821. /**
  47822. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47823. * is automatically returned to its default position (expected to be above ground plane).
  47824. */
  47825. private _maintainCameraAboveGround;
  47826. /**
  47827. * Returns the frustum slope based on the canvas ratio and camera FOV
  47828. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47829. */
  47830. private _getFrustumSlope;
  47831. /**
  47832. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47833. */
  47834. private _clearAnimationLocks;
  47835. /**
  47836. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47837. */
  47838. private _applyUserInteraction;
  47839. /**
  47840. * Stops and removes all animations that have been applied to the camera
  47841. */
  47842. stopAllAnimations(): void;
  47843. /**
  47844. * Gets a value indicating if the user is moving the camera
  47845. */
  47846. get isUserIsMoving(): boolean;
  47847. /**
  47848. * The camera can move all the way towards the mesh.
  47849. */
  47850. static IgnoreBoundsSizeMode: number;
  47851. /**
  47852. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47853. */
  47854. static FitFrustumSidesMode: number;
  47855. }
  47856. }
  47857. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47858. import { Nullable } from "babylonjs/types";
  47859. import { Camera } from "babylonjs/Cameras/camera";
  47860. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47861. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47862. /**
  47863. * Base class for Camera Pointer Inputs.
  47864. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47865. * for example usage.
  47866. */
  47867. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47868. /**
  47869. * Defines the camera the input is attached to.
  47870. */
  47871. abstract camera: Camera;
  47872. /**
  47873. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47874. */
  47875. protected _altKey: boolean;
  47876. protected _ctrlKey: boolean;
  47877. protected _metaKey: boolean;
  47878. protected _shiftKey: boolean;
  47879. /**
  47880. * Which mouse buttons were pressed at time of last mouse event.
  47881. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47882. */
  47883. protected _buttonsPressed: number;
  47884. /**
  47885. * Defines the buttons associated with the input to handle camera move.
  47886. */
  47887. buttons: number[];
  47888. /**
  47889. * Attach the input controls to a specific dom element to get the input from.
  47890. * @param element Defines the element the controls should be listened from
  47891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47892. */
  47893. attachControl(noPreventDefault?: boolean): void;
  47894. /**
  47895. * Detach the current controls from the specified dom element.
  47896. */
  47897. detachControl(): void;
  47898. /**
  47899. * Gets the class name of the current input.
  47900. * @returns the class name
  47901. */
  47902. getClassName(): string;
  47903. /**
  47904. * Get the friendly name associated with the input class.
  47905. * @returns the input friendly name
  47906. */
  47907. getSimpleName(): string;
  47908. /**
  47909. * Called on pointer POINTERDOUBLETAP event.
  47910. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47911. */
  47912. protected onDoubleTap(type: string): void;
  47913. /**
  47914. * Called on pointer POINTERMOVE event if only a single touch is active.
  47915. * Override this method to provide functionality.
  47916. */
  47917. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47918. /**
  47919. * Called on pointer POINTERMOVE event if multiple touches are active.
  47920. * Override this method to provide functionality.
  47921. */
  47922. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47923. /**
  47924. * Called on JS contextmenu event.
  47925. * Override this method to provide functionality.
  47926. */
  47927. protected onContextMenu(evt: PointerEvent): void;
  47928. /**
  47929. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47930. * press.
  47931. * Override this method to provide functionality.
  47932. */
  47933. protected onButtonDown(evt: PointerEvent): void;
  47934. /**
  47935. * Called each time a new POINTERUP event occurs. Ie, for each button
  47936. * release.
  47937. * Override this method to provide functionality.
  47938. */
  47939. protected onButtonUp(evt: PointerEvent): void;
  47940. /**
  47941. * Called when window becomes inactive.
  47942. * Override this method to provide functionality.
  47943. */
  47944. protected onLostFocus(): void;
  47945. private _pointerInput;
  47946. private _observer;
  47947. private _onLostFocus;
  47948. private pointA;
  47949. private pointB;
  47950. }
  47951. }
  47952. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47953. import { Nullable } from "babylonjs/types";
  47954. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47955. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47956. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47957. /**
  47958. * Manage the pointers inputs to control an arc rotate camera.
  47959. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47960. */
  47961. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47962. /**
  47963. * Defines the camera the input is attached to.
  47964. */
  47965. camera: ArcRotateCamera;
  47966. /**
  47967. * Gets the class name of the current input.
  47968. * @returns the class name
  47969. */
  47970. getClassName(): string;
  47971. /**
  47972. * Defines the buttons associated with the input to handle camera move.
  47973. */
  47974. buttons: number[];
  47975. /**
  47976. * Defines the pointer angular sensibility along the X axis or how fast is
  47977. * the camera rotating.
  47978. */
  47979. angularSensibilityX: number;
  47980. /**
  47981. * Defines the pointer angular sensibility along the Y axis or how fast is
  47982. * the camera rotating.
  47983. */
  47984. angularSensibilityY: number;
  47985. /**
  47986. * Defines the pointer pinch precision or how fast is the camera zooming.
  47987. */
  47988. pinchPrecision: number;
  47989. /**
  47990. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47991. * from 0.
  47992. * It defines the percentage of current camera.radius to use as delta when
  47993. * pinch zoom is used.
  47994. */
  47995. pinchDeltaPercentage: number;
  47996. /**
  47997. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47998. * that any object in the plane at the camera's target point will scale
  47999. * perfectly with finger motion.
  48000. * Overrides pinchDeltaPercentage and pinchPrecision.
  48001. */
  48002. useNaturalPinchZoom: boolean;
  48003. /**
  48004. * Defines the pointer panning sensibility or how fast is the camera moving.
  48005. */
  48006. panningSensibility: number;
  48007. /**
  48008. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  48009. */
  48010. multiTouchPanning: boolean;
  48011. /**
  48012. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  48013. * zoom (pinch) through multitouch.
  48014. */
  48015. multiTouchPanAndZoom: boolean;
  48016. /**
  48017. * Revers pinch action direction.
  48018. */
  48019. pinchInwards: boolean;
  48020. private _isPanClick;
  48021. private _twoFingerActivityCount;
  48022. private _isPinching;
  48023. /**
  48024. * Called on pointer POINTERMOVE event if only a single touch is active.
  48025. */
  48026. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48027. /**
  48028. * Called on pointer POINTERDOUBLETAP event.
  48029. */
  48030. protected onDoubleTap(type: string): void;
  48031. /**
  48032. * Called on pointer POINTERMOVE event if multiple touches are active.
  48033. */
  48034. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48035. /**
  48036. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48037. * press.
  48038. */
  48039. protected onButtonDown(evt: PointerEvent): void;
  48040. /**
  48041. * Called each time a new POINTERUP event occurs. Ie, for each button
  48042. * release.
  48043. */
  48044. protected onButtonUp(evt: PointerEvent): void;
  48045. /**
  48046. * Called when window becomes inactive.
  48047. */
  48048. protected onLostFocus(): void;
  48049. }
  48050. }
  48051. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  48052. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48053. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48054. /**
  48055. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  48056. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48057. */
  48058. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  48059. /**
  48060. * Defines the camera the input is attached to.
  48061. */
  48062. camera: ArcRotateCamera;
  48063. /**
  48064. * Defines the list of key codes associated with the up action (increase alpha)
  48065. */
  48066. keysUp: number[];
  48067. /**
  48068. * Defines the list of key codes associated with the down action (decrease alpha)
  48069. */
  48070. keysDown: number[];
  48071. /**
  48072. * Defines the list of key codes associated with the left action (increase beta)
  48073. */
  48074. keysLeft: number[];
  48075. /**
  48076. * Defines the list of key codes associated with the right action (decrease beta)
  48077. */
  48078. keysRight: number[];
  48079. /**
  48080. * Defines the list of key codes associated with the reset action.
  48081. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  48082. */
  48083. keysReset: number[];
  48084. /**
  48085. * Defines the panning sensibility of the inputs.
  48086. * (How fast is the camera panning)
  48087. */
  48088. panningSensibility: number;
  48089. /**
  48090. * Defines the zooming sensibility of the inputs.
  48091. * (How fast is the camera zooming)
  48092. */
  48093. zoomingSensibility: number;
  48094. /**
  48095. * Defines whether maintaining the alt key down switch the movement mode from
  48096. * orientation to zoom.
  48097. */
  48098. useAltToZoom: boolean;
  48099. /**
  48100. * Rotation speed of the camera
  48101. */
  48102. angularSpeed: number;
  48103. private _keys;
  48104. private _ctrlPressed;
  48105. private _altPressed;
  48106. private _onCanvasBlurObserver;
  48107. private _onKeyboardObserver;
  48108. private _engine;
  48109. private _scene;
  48110. /**
  48111. * Attach the input controls to a specific dom element to get the input from.
  48112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48113. */
  48114. attachControl(noPreventDefault?: boolean): void;
  48115. /**
  48116. * Detach the current controls from the specified dom element.
  48117. */
  48118. detachControl(): void;
  48119. /**
  48120. * Update the current camera state depending on the inputs that have been used this frame.
  48121. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48122. */
  48123. checkInputs(): void;
  48124. /**
  48125. * Gets the class name of the current intput.
  48126. * @returns the class name
  48127. */
  48128. getClassName(): string;
  48129. /**
  48130. * Get the friendly name associated with the input class.
  48131. * @returns the input friendly name
  48132. */
  48133. getSimpleName(): string;
  48134. }
  48135. }
  48136. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  48137. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48138. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  48139. /**
  48140. * Manage the mouse wheel inputs to control an arc rotate camera.
  48141. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48142. */
  48143. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  48144. /**
  48145. * Defines the camera the input is attached to.
  48146. */
  48147. camera: ArcRotateCamera;
  48148. /**
  48149. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48150. */
  48151. wheelPrecision: number;
  48152. /**
  48153. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48154. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48155. */
  48156. wheelDeltaPercentage: number;
  48157. private _wheel;
  48158. private _observer;
  48159. private computeDeltaFromMouseWheelLegacyEvent;
  48160. /**
  48161. * Attach the input controls to a specific dom element to get the input from.
  48162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48163. */
  48164. attachControl(noPreventDefault?: boolean): void;
  48165. /**
  48166. * Detach the current controls from the specified dom element.
  48167. */
  48168. detachControl(): void;
  48169. /**
  48170. * Gets the class name of the current intput.
  48171. * @returns the class name
  48172. */
  48173. getClassName(): string;
  48174. /**
  48175. * Get the friendly name associated with the input class.
  48176. * @returns the input friendly name
  48177. */
  48178. getSimpleName(): string;
  48179. }
  48180. }
  48181. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  48182. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48183. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  48184. /**
  48185. * Default Inputs manager for the ArcRotateCamera.
  48186. * It groups all the default supported inputs for ease of use.
  48187. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48188. */
  48189. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  48190. /**
  48191. * Instantiates a new ArcRotateCameraInputsManager.
  48192. * @param camera Defines the camera the inputs belong to
  48193. */
  48194. constructor(camera: ArcRotateCamera);
  48195. /**
  48196. * Add mouse wheel input support to the input manager.
  48197. * @returns the current input manager
  48198. */
  48199. addMouseWheel(): ArcRotateCameraInputsManager;
  48200. /**
  48201. * Add pointers input support to the input manager.
  48202. * @returns the current input manager
  48203. */
  48204. addPointers(): ArcRotateCameraInputsManager;
  48205. /**
  48206. * Add keyboard input support to the input manager.
  48207. * @returns the current input manager
  48208. */
  48209. addKeyboard(): ArcRotateCameraInputsManager;
  48210. }
  48211. }
  48212. declare module "babylonjs/Cameras/arcRotateCamera" {
  48213. import { Observable } from "babylonjs/Misc/observable";
  48214. import { Nullable } from "babylonjs/types";
  48215. import { Scene } from "babylonjs/scene";
  48216. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  48217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48218. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48219. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48220. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  48221. import { Camera } from "babylonjs/Cameras/camera";
  48222. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  48223. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  48224. import { Collider } from "babylonjs/Collisions/collider";
  48225. /**
  48226. * This represents an orbital type of camera.
  48227. *
  48228. * 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.
  48229. * 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.
  48230. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  48231. */
  48232. export class ArcRotateCamera extends TargetCamera {
  48233. /**
  48234. * Defines the rotation angle of the camera along the longitudinal axis.
  48235. */
  48236. alpha: number;
  48237. /**
  48238. * Defines the rotation angle of the camera along the latitudinal axis.
  48239. */
  48240. beta: number;
  48241. /**
  48242. * Defines the radius of the camera from it s target point.
  48243. */
  48244. radius: number;
  48245. protected _target: Vector3;
  48246. protected _targetHost: Nullable<AbstractMesh>;
  48247. /**
  48248. * Defines the target point of the camera.
  48249. * The camera looks towards it form the radius distance.
  48250. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  48251. */
  48252. get target(): Vector3;
  48253. set target(value: Vector3);
  48254. /**
  48255. * Define the current local position of the camera in the scene
  48256. */
  48257. get position(): Vector3;
  48258. set position(newPosition: Vector3);
  48259. protected _upToYMatrix: Matrix;
  48260. protected _YToUpMatrix: Matrix;
  48261. /**
  48262. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  48263. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  48264. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  48265. */
  48266. set upVector(vec: Vector3);
  48267. get upVector(): Vector3;
  48268. /**
  48269. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  48270. */
  48271. setMatUp(): void;
  48272. /**
  48273. * Current inertia value on the longitudinal axis.
  48274. * The bigger this number the longer it will take for the camera to stop.
  48275. */
  48276. inertialAlphaOffset: number;
  48277. /**
  48278. * Current inertia value on the latitudinal axis.
  48279. * The bigger this number the longer it will take for the camera to stop.
  48280. */
  48281. inertialBetaOffset: number;
  48282. /**
  48283. * Current inertia value on the radius axis.
  48284. * The bigger this number the longer it will take for the camera to stop.
  48285. */
  48286. inertialRadiusOffset: number;
  48287. /**
  48288. * Minimum allowed angle on the longitudinal axis.
  48289. * This can help limiting how the Camera is able to move in the scene.
  48290. */
  48291. lowerAlphaLimit: Nullable<number>;
  48292. /**
  48293. * Maximum allowed angle on the longitudinal axis.
  48294. * This can help limiting how the Camera is able to move in the scene.
  48295. */
  48296. upperAlphaLimit: Nullable<number>;
  48297. /**
  48298. * Minimum allowed angle on the latitudinal axis.
  48299. * This can help limiting how the Camera is able to move in the scene.
  48300. */
  48301. lowerBetaLimit: number;
  48302. /**
  48303. * Maximum allowed angle on the latitudinal axis.
  48304. * This can help limiting how the Camera is able to move in the scene.
  48305. */
  48306. upperBetaLimit: number;
  48307. /**
  48308. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  48309. * This can help limiting how the Camera is able to move in the scene.
  48310. */
  48311. lowerRadiusLimit: Nullable<number>;
  48312. /**
  48313. * Maximum allowed distance of the camera to the target (The camera can not get further).
  48314. * This can help limiting how the Camera is able to move in the scene.
  48315. */
  48316. upperRadiusLimit: Nullable<number>;
  48317. /**
  48318. * Defines the current inertia value used during panning of the camera along the X axis.
  48319. */
  48320. inertialPanningX: number;
  48321. /**
  48322. * Defines the current inertia value used during panning of the camera along the Y axis.
  48323. */
  48324. inertialPanningY: number;
  48325. /**
  48326. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  48327. * Basically if your fingers moves away from more than this distance you will be considered
  48328. * in pinch mode.
  48329. */
  48330. pinchToPanMaxDistance: number;
  48331. /**
  48332. * Defines the maximum distance the camera can pan.
  48333. * This could help keeping the cammera always in your scene.
  48334. */
  48335. panningDistanceLimit: Nullable<number>;
  48336. /**
  48337. * Defines the target of the camera before paning.
  48338. */
  48339. panningOriginTarget: Vector3;
  48340. /**
  48341. * Defines the value of the inertia used during panning.
  48342. * 0 would mean stop inertia and one would mean no decelleration at all.
  48343. */
  48344. panningInertia: number;
  48345. /**
  48346. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48347. */
  48348. get angularSensibilityX(): number;
  48349. set angularSensibilityX(value: number);
  48350. /**
  48351. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48352. */
  48353. get angularSensibilityY(): number;
  48354. set angularSensibilityY(value: number);
  48355. /**
  48356. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48357. */
  48358. get pinchPrecision(): number;
  48359. set pinchPrecision(value: number);
  48360. /**
  48361. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48362. * It will be used instead of pinchDeltaPrecision if different from 0.
  48363. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48364. */
  48365. get pinchDeltaPercentage(): number;
  48366. set pinchDeltaPercentage(value: number);
  48367. /**
  48368. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48369. * and pinch delta percentage.
  48370. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48371. * that any object in the plane at the camera's target point will scale
  48372. * perfectly with finger motion.
  48373. */
  48374. get useNaturalPinchZoom(): boolean;
  48375. set useNaturalPinchZoom(value: boolean);
  48376. /**
  48377. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48378. */
  48379. get panningSensibility(): number;
  48380. set panningSensibility(value: number);
  48381. /**
  48382. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48383. */
  48384. get keysUp(): number[];
  48385. set keysUp(value: number[]);
  48386. /**
  48387. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48388. */
  48389. get keysDown(): number[];
  48390. set keysDown(value: number[]);
  48391. /**
  48392. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48393. */
  48394. get keysLeft(): number[];
  48395. set keysLeft(value: number[]);
  48396. /**
  48397. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48398. */
  48399. get keysRight(): number[];
  48400. set keysRight(value: number[]);
  48401. /**
  48402. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48403. */
  48404. get wheelPrecision(): number;
  48405. set wheelPrecision(value: number);
  48406. /**
  48407. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48408. * It will be used instead of pinchDeltaPrecision if different from 0.
  48409. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48410. */
  48411. get wheelDeltaPercentage(): number;
  48412. set wheelDeltaPercentage(value: number);
  48413. /**
  48414. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48415. */
  48416. zoomOnFactor: number;
  48417. /**
  48418. * Defines a screen offset for the camera position.
  48419. */
  48420. targetScreenOffset: Vector2;
  48421. /**
  48422. * Allows the camera to be completely reversed.
  48423. * If false the camera can not arrive upside down.
  48424. */
  48425. allowUpsideDown: boolean;
  48426. /**
  48427. * Define if double tap/click is used to restore the previously saved state of the camera.
  48428. */
  48429. useInputToRestoreState: boolean;
  48430. /** @hidden */
  48431. _viewMatrix: Matrix;
  48432. /** @hidden */
  48433. _useCtrlForPanning: boolean;
  48434. /** @hidden */
  48435. _panningMouseButton: number;
  48436. /**
  48437. * Defines the input associated to the camera.
  48438. */
  48439. inputs: ArcRotateCameraInputsManager;
  48440. /** @hidden */
  48441. _reset: () => void;
  48442. /**
  48443. * Defines the allowed panning axis.
  48444. */
  48445. panningAxis: Vector3;
  48446. protected _localDirection: Vector3;
  48447. protected _transformedDirection: Vector3;
  48448. private _bouncingBehavior;
  48449. /**
  48450. * Gets the bouncing behavior of the camera if it has been enabled.
  48451. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48452. */
  48453. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48454. /**
  48455. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48456. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48457. */
  48458. get useBouncingBehavior(): boolean;
  48459. set useBouncingBehavior(value: boolean);
  48460. private _framingBehavior;
  48461. /**
  48462. * Gets the framing behavior of the camera if it has been enabled.
  48463. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48464. */
  48465. get framingBehavior(): Nullable<FramingBehavior>;
  48466. /**
  48467. * Defines if the framing behavior of the camera is enabled on the camera.
  48468. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48469. */
  48470. get useFramingBehavior(): boolean;
  48471. set useFramingBehavior(value: boolean);
  48472. private _autoRotationBehavior;
  48473. /**
  48474. * Gets the auto rotation behavior of the camera if it has been enabled.
  48475. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48476. */
  48477. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48478. /**
  48479. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48480. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48481. */
  48482. get useAutoRotationBehavior(): boolean;
  48483. set useAutoRotationBehavior(value: boolean);
  48484. /**
  48485. * Observable triggered when the mesh target has been changed on the camera.
  48486. */
  48487. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48488. /**
  48489. * Event raised when the camera is colliding with a mesh.
  48490. */
  48491. onCollide: (collidedMesh: AbstractMesh) => void;
  48492. /**
  48493. * Defines whether the camera should check collision with the objects oh the scene.
  48494. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48495. */
  48496. checkCollisions: boolean;
  48497. /**
  48498. * Defines the collision radius of the camera.
  48499. * This simulates a sphere around the camera.
  48500. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48501. */
  48502. collisionRadius: Vector3;
  48503. protected _collider: Collider;
  48504. protected _previousPosition: Vector3;
  48505. protected _collisionVelocity: Vector3;
  48506. protected _newPosition: Vector3;
  48507. protected _previousAlpha: number;
  48508. protected _previousBeta: number;
  48509. protected _previousRadius: number;
  48510. protected _collisionTriggered: boolean;
  48511. protected _targetBoundingCenter: Nullable<Vector3>;
  48512. private _computationVector;
  48513. /**
  48514. * Instantiates a new ArcRotateCamera in a given scene
  48515. * @param name Defines the name of the camera
  48516. * @param alpha Defines the camera rotation along the logitudinal axis
  48517. * @param beta Defines the camera rotation along the latitudinal axis
  48518. * @param radius Defines the camera distance from its target
  48519. * @param target Defines the camera target
  48520. * @param scene Defines the scene the camera belongs to
  48521. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48522. */
  48523. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48524. /** @hidden */
  48525. _initCache(): void;
  48526. /** @hidden */
  48527. _updateCache(ignoreParentClass?: boolean): void;
  48528. protected _getTargetPosition(): Vector3;
  48529. private _storedAlpha;
  48530. private _storedBeta;
  48531. private _storedRadius;
  48532. private _storedTarget;
  48533. private _storedTargetScreenOffset;
  48534. /**
  48535. * Stores the current state of the camera (alpha, beta, radius and target)
  48536. * @returns the camera itself
  48537. */
  48538. storeState(): Camera;
  48539. /**
  48540. * @hidden
  48541. * Restored camera state. You must call storeState() first
  48542. */
  48543. _restoreStateValues(): boolean;
  48544. /** @hidden */
  48545. _isSynchronizedViewMatrix(): boolean;
  48546. /**
  48547. * Attach the input controls to a specific dom element to get the input from.
  48548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48549. */
  48550. attachControl(noPreventDefault?: boolean): void;
  48551. /**
  48552. * Attach the input controls to a specific dom element to get the input from.
  48553. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48554. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48555. */
  48556. attachControl(ignored: any, noPreventDefault?: boolean): void;
  48557. /**
  48558. * Attached controls to the current camera.
  48559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48560. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48561. */
  48562. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48563. /**
  48564. * Attached controls to the current camera.
  48565. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48567. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48568. */
  48569. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  48570. /**
  48571. * Attached controls to the current camera.
  48572. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48573. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48574. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48575. */
  48576. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  48577. /**
  48578. * Detach the current controls from the specified dom element.
  48579. */
  48580. detachControl(): void;
  48581. /**
  48582. * Detach the current controls from the specified dom element.
  48583. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  48584. */
  48585. detachControl(ignored: any): void;
  48586. /** @hidden */
  48587. _checkInputs(): void;
  48588. protected _checkLimits(): void;
  48589. /**
  48590. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48591. */
  48592. rebuildAnglesAndRadius(): void;
  48593. /**
  48594. * Use a position to define the current camera related information like alpha, beta and radius
  48595. * @param position Defines the position to set the camera at
  48596. */
  48597. setPosition(position: Vector3): void;
  48598. /**
  48599. * Defines the target the camera should look at.
  48600. * This will automatically adapt alpha beta and radius to fit within the new target.
  48601. * @param target Defines the new target as a Vector or a mesh
  48602. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48603. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48604. */
  48605. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48606. /** @hidden */
  48607. _getViewMatrix(): Matrix;
  48608. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48609. /**
  48610. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48611. * @param meshes Defines the mesh to zoom on
  48612. * @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)
  48613. */
  48614. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48615. /**
  48616. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48617. * The target will be changed but the radius
  48618. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48619. * @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)
  48620. */
  48621. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48622. min: Vector3;
  48623. max: Vector3;
  48624. distance: number;
  48625. }, doNotUpdateMaxZ?: boolean): void;
  48626. /**
  48627. * @override
  48628. * Override Camera.createRigCamera
  48629. */
  48630. createRigCamera(name: string, cameraIndex: number): Camera;
  48631. /**
  48632. * @hidden
  48633. * @override
  48634. * Override Camera._updateRigCameras
  48635. */
  48636. _updateRigCameras(): void;
  48637. /**
  48638. * Destroy the camera and release the current resources hold by it.
  48639. */
  48640. dispose(): void;
  48641. /**
  48642. * Gets the current object class name.
  48643. * @return the class name
  48644. */
  48645. getClassName(): string;
  48646. }
  48647. }
  48648. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48649. import { Behavior } from "babylonjs/Behaviors/behavior";
  48650. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48651. /**
  48652. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48653. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48654. */
  48655. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48656. /**
  48657. * Gets the name of the behavior.
  48658. */
  48659. get name(): string;
  48660. private _zoomStopsAnimation;
  48661. private _idleRotationSpeed;
  48662. private _idleRotationWaitTime;
  48663. private _idleRotationSpinupTime;
  48664. /**
  48665. * Sets the flag that indicates if user zooming should stop animation.
  48666. */
  48667. set zoomStopsAnimation(flag: boolean);
  48668. /**
  48669. * Gets the flag that indicates if user zooming should stop animation.
  48670. */
  48671. get zoomStopsAnimation(): boolean;
  48672. /**
  48673. * Sets the default speed at which the camera rotates around the model.
  48674. */
  48675. set idleRotationSpeed(speed: number);
  48676. /**
  48677. * Gets the default speed at which the camera rotates around the model.
  48678. */
  48679. get idleRotationSpeed(): number;
  48680. /**
  48681. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48682. */
  48683. set idleRotationWaitTime(time: number);
  48684. /**
  48685. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48686. */
  48687. get idleRotationWaitTime(): number;
  48688. /**
  48689. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48690. */
  48691. set idleRotationSpinupTime(time: number);
  48692. /**
  48693. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48694. */
  48695. get idleRotationSpinupTime(): number;
  48696. /**
  48697. * Gets a value indicating if the camera is currently rotating because of this behavior
  48698. */
  48699. get rotationInProgress(): boolean;
  48700. private _onPrePointerObservableObserver;
  48701. private _onAfterCheckInputsObserver;
  48702. private _attachedCamera;
  48703. private _isPointerDown;
  48704. private _lastFrameTime;
  48705. private _lastInteractionTime;
  48706. private _cameraRotationSpeed;
  48707. /**
  48708. * Initializes the behavior.
  48709. */
  48710. init(): void;
  48711. /**
  48712. * Attaches the behavior to its arc rotate camera.
  48713. * @param camera Defines the camera to attach the behavior to
  48714. */
  48715. attach(camera: ArcRotateCamera): void;
  48716. /**
  48717. * Detaches the behavior from its current arc rotate camera.
  48718. */
  48719. detach(): void;
  48720. /**
  48721. * Returns true if user is scrolling.
  48722. * @return true if user is scrolling.
  48723. */
  48724. private _userIsZooming;
  48725. private _lastFrameRadius;
  48726. private _shouldAnimationStopForInteraction;
  48727. /**
  48728. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48729. */
  48730. private _applyUserInteraction;
  48731. private _userIsMoving;
  48732. }
  48733. }
  48734. declare module "babylonjs/Behaviors/Cameras/index" {
  48735. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48736. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48737. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48738. }
  48739. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48740. import { Mesh } from "babylonjs/Meshes/mesh";
  48741. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48742. import { Behavior } from "babylonjs/Behaviors/behavior";
  48743. /**
  48744. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48745. */
  48746. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48747. private ui;
  48748. /**
  48749. * The name of the behavior
  48750. */
  48751. name: string;
  48752. /**
  48753. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48754. */
  48755. distanceAwayFromFace: number;
  48756. /**
  48757. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48758. */
  48759. distanceAwayFromBottomOfFace: number;
  48760. private _faceVectors;
  48761. private _target;
  48762. private _scene;
  48763. private _onRenderObserver;
  48764. private _tmpMatrix;
  48765. private _tmpVector;
  48766. /**
  48767. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48768. * @param ui The transform node that should be attched to the mesh
  48769. */
  48770. constructor(ui: TransformNode);
  48771. /**
  48772. * Initializes the behavior
  48773. */
  48774. init(): void;
  48775. private _closestFace;
  48776. private _zeroVector;
  48777. private _lookAtTmpMatrix;
  48778. private _lookAtToRef;
  48779. /**
  48780. * Attaches the AttachToBoxBehavior to the passed in mesh
  48781. * @param target The mesh that the specified node will be attached to
  48782. */
  48783. attach(target: Mesh): void;
  48784. /**
  48785. * Detaches the behavior from the mesh
  48786. */
  48787. detach(): void;
  48788. }
  48789. }
  48790. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48791. import { Behavior } from "babylonjs/Behaviors/behavior";
  48792. import { Mesh } from "babylonjs/Meshes/mesh";
  48793. /**
  48794. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48795. */
  48796. export class FadeInOutBehavior implements Behavior<Mesh> {
  48797. /**
  48798. * Time in milliseconds to delay before fading in (Default: 0)
  48799. */
  48800. delay: number;
  48801. /**
  48802. * Time in milliseconds for the mesh to fade in (Default: 300)
  48803. */
  48804. fadeInTime: number;
  48805. private _millisecondsPerFrame;
  48806. private _hovered;
  48807. private _hoverValue;
  48808. private _ownerNode;
  48809. /**
  48810. * Instatiates the FadeInOutBehavior
  48811. */
  48812. constructor();
  48813. /**
  48814. * The name of the behavior
  48815. */
  48816. get name(): string;
  48817. /**
  48818. * Initializes the behavior
  48819. */
  48820. init(): void;
  48821. /**
  48822. * Attaches the fade behavior on the passed in mesh
  48823. * @param ownerNode The mesh that will be faded in/out once attached
  48824. */
  48825. attach(ownerNode: Mesh): void;
  48826. /**
  48827. * Detaches the behavior from the mesh
  48828. */
  48829. detach(): void;
  48830. /**
  48831. * Triggers the mesh to begin fading in or out
  48832. * @param value if the object should fade in or out (true to fade in)
  48833. */
  48834. fadeIn(value: boolean): void;
  48835. private _update;
  48836. private _setAllVisibility;
  48837. }
  48838. }
  48839. declare module "babylonjs/Misc/pivotTools" {
  48840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48841. /**
  48842. * Class containing a set of static utilities functions for managing Pivots
  48843. * @hidden
  48844. */
  48845. export class PivotTools {
  48846. private static _PivotCached;
  48847. private static _OldPivotPoint;
  48848. private static _PivotTranslation;
  48849. private static _PivotTmpVector;
  48850. private static _PivotPostMultiplyPivotMatrix;
  48851. /** @hidden */
  48852. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48853. /** @hidden */
  48854. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48855. }
  48856. }
  48857. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48858. import { Scene } from "babylonjs/scene";
  48859. import { Vector4 } from "babylonjs/Maths/math.vector";
  48860. import { Mesh } from "babylonjs/Meshes/mesh";
  48861. import { Nullable } from "babylonjs/types";
  48862. import { Plane } from "babylonjs/Maths/math.plane";
  48863. /**
  48864. * Class containing static functions to help procedurally build meshes
  48865. */
  48866. export class PlaneBuilder {
  48867. /**
  48868. * Creates a plane mesh
  48869. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48870. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48871. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48875. * @param name defines the name of the mesh
  48876. * @param options defines the options used to create the mesh
  48877. * @param scene defines the hosting scene
  48878. * @returns the plane mesh
  48879. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48880. */
  48881. static CreatePlane(name: string, options: {
  48882. size?: number;
  48883. width?: number;
  48884. height?: number;
  48885. sideOrientation?: number;
  48886. frontUVs?: Vector4;
  48887. backUVs?: Vector4;
  48888. updatable?: boolean;
  48889. sourcePlane?: Plane;
  48890. }, scene?: Nullable<Scene>): Mesh;
  48891. }
  48892. }
  48893. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48894. import { Behavior } from "babylonjs/Behaviors/behavior";
  48895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48896. import { Observable } from "babylonjs/Misc/observable";
  48897. import { Vector3 } from "babylonjs/Maths/math.vector";
  48898. import { Ray } from "babylonjs/Culling/ray";
  48899. import "babylonjs/Meshes/Builders/planeBuilder";
  48900. /**
  48901. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48902. */
  48903. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48904. private static _AnyMouseID;
  48905. /**
  48906. * Abstract mesh the behavior is set on
  48907. */
  48908. attachedNode: AbstractMesh;
  48909. private _dragPlane;
  48910. private _scene;
  48911. private _pointerObserver;
  48912. private _beforeRenderObserver;
  48913. private static _planeScene;
  48914. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48915. /**
  48916. * 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)
  48917. */
  48918. maxDragAngle: number;
  48919. /**
  48920. * @hidden
  48921. */
  48922. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48923. /**
  48924. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48925. */
  48926. currentDraggingPointerID: number;
  48927. /**
  48928. * The last position where the pointer hit the drag plane in world space
  48929. */
  48930. lastDragPosition: Vector3;
  48931. /**
  48932. * If the behavior is currently in a dragging state
  48933. */
  48934. dragging: boolean;
  48935. /**
  48936. * 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)
  48937. */
  48938. dragDeltaRatio: number;
  48939. /**
  48940. * If the drag plane orientation should be updated during the dragging (Default: true)
  48941. */
  48942. updateDragPlane: boolean;
  48943. private _debugMode;
  48944. private _moving;
  48945. /**
  48946. * Fires each time the attached mesh is dragged with the pointer
  48947. * * delta between last drag position and current drag position in world space
  48948. * * dragDistance along the drag axis
  48949. * * dragPlaneNormal normal of the current drag plane used during the drag
  48950. * * dragPlanePoint in world space where the drag intersects the drag plane
  48951. */
  48952. onDragObservable: Observable<{
  48953. delta: Vector3;
  48954. dragPlanePoint: Vector3;
  48955. dragPlaneNormal: Vector3;
  48956. dragDistance: number;
  48957. pointerId: number;
  48958. }>;
  48959. /**
  48960. * Fires each time a drag begins (eg. mouse down on mesh)
  48961. */
  48962. onDragStartObservable: Observable<{
  48963. dragPlanePoint: Vector3;
  48964. pointerId: number;
  48965. }>;
  48966. /**
  48967. * Fires each time a drag ends (eg. mouse release after drag)
  48968. */
  48969. onDragEndObservable: Observable<{
  48970. dragPlanePoint: Vector3;
  48971. pointerId: number;
  48972. }>;
  48973. /**
  48974. * If the attached mesh should be moved when dragged
  48975. */
  48976. moveAttached: boolean;
  48977. /**
  48978. * If the drag behavior will react to drag events (Default: true)
  48979. */
  48980. enabled: boolean;
  48981. /**
  48982. * If pointer events should start and release the drag (Default: true)
  48983. */
  48984. startAndReleaseDragOnPointerEvents: boolean;
  48985. /**
  48986. * If camera controls should be detached during the drag
  48987. */
  48988. detachCameraControls: boolean;
  48989. /**
  48990. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48991. */
  48992. useObjectOrientationForDragging: boolean;
  48993. private _options;
  48994. /**
  48995. * Gets the options used by the behavior
  48996. */
  48997. get options(): {
  48998. dragAxis?: Vector3;
  48999. dragPlaneNormal?: Vector3;
  49000. };
  49001. /**
  49002. * Sets the options used by the behavior
  49003. */
  49004. set options(options: {
  49005. dragAxis?: Vector3;
  49006. dragPlaneNormal?: Vector3;
  49007. });
  49008. /**
  49009. * Creates a pointer drag behavior that can be attached to a mesh
  49010. * @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)
  49011. */
  49012. constructor(options?: {
  49013. dragAxis?: Vector3;
  49014. dragPlaneNormal?: Vector3;
  49015. });
  49016. /**
  49017. * Predicate to determine if it is valid to move the object to a new position when it is moved
  49018. */
  49019. validateDrag: (targetPosition: Vector3) => boolean;
  49020. /**
  49021. * The name of the behavior
  49022. */
  49023. get name(): string;
  49024. /**
  49025. * Initializes the behavior
  49026. */
  49027. init(): void;
  49028. private _tmpVector;
  49029. private _alternatePickedPoint;
  49030. private _worldDragAxis;
  49031. private _targetPosition;
  49032. private _attachedToElement;
  49033. /**
  49034. * Attaches the drag behavior the passed in mesh
  49035. * @param ownerNode The mesh that will be dragged around once attached
  49036. * @param predicate Predicate to use for pick filtering
  49037. */
  49038. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  49039. /**
  49040. * Force relase the drag action by code.
  49041. */
  49042. releaseDrag(): void;
  49043. private _startDragRay;
  49044. private _lastPointerRay;
  49045. /**
  49046. * Simulates the start of a pointer drag event on the behavior
  49047. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  49048. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  49049. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  49050. */
  49051. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49052. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  49053. private _dragDelta;
  49054. protected _moveDrag(ray: Ray): void;
  49055. private _pickWithRayOnDragPlane;
  49056. private _pointA;
  49057. private _pointC;
  49058. private _localAxis;
  49059. private _lookAt;
  49060. private _updateDragPlanePosition;
  49061. /**
  49062. * Detaches the behavior from the mesh
  49063. */
  49064. detach(): void;
  49065. }
  49066. }
  49067. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  49068. import { Mesh } from "babylonjs/Meshes/mesh";
  49069. import { Behavior } from "babylonjs/Behaviors/behavior";
  49070. /**
  49071. * A behavior that when attached to a mesh will allow the mesh to be scaled
  49072. */
  49073. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  49074. private _dragBehaviorA;
  49075. private _dragBehaviorB;
  49076. private _startDistance;
  49077. private _initialScale;
  49078. private _targetScale;
  49079. private _ownerNode;
  49080. private _sceneRenderObserver;
  49081. /**
  49082. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  49083. */
  49084. constructor();
  49085. /**
  49086. * The name of the behavior
  49087. */
  49088. get name(): string;
  49089. /**
  49090. * Initializes the behavior
  49091. */
  49092. init(): void;
  49093. private _getCurrentDistance;
  49094. /**
  49095. * Attaches the scale behavior the passed in mesh
  49096. * @param ownerNode The mesh that will be scaled around once attached
  49097. */
  49098. attach(ownerNode: Mesh): void;
  49099. /**
  49100. * Detaches the behavior from the mesh
  49101. */
  49102. detach(): void;
  49103. }
  49104. }
  49105. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  49106. import { Behavior } from "babylonjs/Behaviors/behavior";
  49107. import { Mesh } from "babylonjs/Meshes/mesh";
  49108. import { Observable } from "babylonjs/Misc/observable";
  49109. /**
  49110. * 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
  49111. */
  49112. export class SixDofDragBehavior implements Behavior<Mesh> {
  49113. private static _virtualScene;
  49114. private _ownerNode;
  49115. private _sceneRenderObserver;
  49116. private _scene;
  49117. private _targetPosition;
  49118. private _virtualOriginMesh;
  49119. private _virtualDragMesh;
  49120. private _pointerObserver;
  49121. private _moving;
  49122. private _startingOrientation;
  49123. private _attachedToElement;
  49124. /**
  49125. * 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)
  49126. */
  49127. private zDragFactor;
  49128. /**
  49129. * If the object should rotate to face the drag origin
  49130. */
  49131. rotateDraggedObject: boolean;
  49132. /**
  49133. * If the behavior is currently in a dragging state
  49134. */
  49135. dragging: boolean;
  49136. /**
  49137. * 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)
  49138. */
  49139. dragDeltaRatio: number;
  49140. /**
  49141. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49142. */
  49143. currentDraggingPointerID: number;
  49144. /**
  49145. * If camera controls should be detached during the drag
  49146. */
  49147. detachCameraControls: boolean;
  49148. /**
  49149. * Fires each time a drag starts
  49150. */
  49151. onDragStartObservable: Observable<{}>;
  49152. /**
  49153. * Fires each time a drag happens
  49154. */
  49155. onDragObservable: Observable<void>;
  49156. /**
  49157. * Fires each time a drag ends (eg. mouse release after drag)
  49158. */
  49159. onDragEndObservable: Observable<{}>;
  49160. /**
  49161. * 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
  49162. */
  49163. constructor();
  49164. /**
  49165. * The name of the behavior
  49166. */
  49167. get name(): string;
  49168. /**
  49169. * Initializes the behavior
  49170. */
  49171. init(): void;
  49172. /**
  49173. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  49174. */
  49175. private get _pointerCamera();
  49176. /**
  49177. * Attaches the scale behavior the passed in mesh
  49178. * @param ownerNode The mesh that will be scaled around once attached
  49179. */
  49180. attach(ownerNode: Mesh): void;
  49181. /**
  49182. * Detaches the behavior from the mesh
  49183. */
  49184. detach(): void;
  49185. }
  49186. }
  49187. declare module "babylonjs/Behaviors/Meshes/index" {
  49188. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  49189. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  49190. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  49191. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  49192. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  49193. }
  49194. declare module "babylonjs/Behaviors/index" {
  49195. export * from "babylonjs/Behaviors/behavior";
  49196. export * from "babylonjs/Behaviors/Cameras/index";
  49197. export * from "babylonjs/Behaviors/Meshes/index";
  49198. }
  49199. declare module "babylonjs/Bones/boneIKController" {
  49200. import { Bone } from "babylonjs/Bones/bone";
  49201. import { Vector3 } from "babylonjs/Maths/math.vector";
  49202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49203. import { Nullable } from "babylonjs/types";
  49204. /**
  49205. * Class used to apply inverse kinematics to bones
  49206. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  49207. */
  49208. export class BoneIKController {
  49209. private static _tmpVecs;
  49210. private static _tmpQuat;
  49211. private static _tmpMats;
  49212. /**
  49213. * Gets or sets the target mesh
  49214. */
  49215. targetMesh: AbstractMesh;
  49216. /** Gets or sets the mesh used as pole */
  49217. poleTargetMesh: AbstractMesh;
  49218. /**
  49219. * Gets or sets the bone used as pole
  49220. */
  49221. poleTargetBone: Nullable<Bone>;
  49222. /**
  49223. * Gets or sets the target position
  49224. */
  49225. targetPosition: Vector3;
  49226. /**
  49227. * Gets or sets the pole target position
  49228. */
  49229. poleTargetPosition: Vector3;
  49230. /**
  49231. * Gets or sets the pole target local offset
  49232. */
  49233. poleTargetLocalOffset: Vector3;
  49234. /**
  49235. * Gets or sets the pole angle
  49236. */
  49237. poleAngle: number;
  49238. /**
  49239. * Gets or sets the mesh associated with the controller
  49240. */
  49241. mesh: AbstractMesh;
  49242. /**
  49243. * 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)
  49244. */
  49245. slerpAmount: number;
  49246. private _bone1Quat;
  49247. private _bone1Mat;
  49248. private _bone2Ang;
  49249. private _bone1;
  49250. private _bone2;
  49251. private _bone1Length;
  49252. private _bone2Length;
  49253. private _maxAngle;
  49254. private _maxReach;
  49255. private _rightHandedSystem;
  49256. private _bendAxis;
  49257. private _slerping;
  49258. private _adjustRoll;
  49259. /**
  49260. * Gets or sets maximum allowed angle
  49261. */
  49262. get maxAngle(): number;
  49263. set maxAngle(value: number);
  49264. /**
  49265. * Creates a new BoneIKController
  49266. * @param mesh defines the mesh to control
  49267. * @param bone defines the bone to control
  49268. * @param options defines options to set up the controller
  49269. */
  49270. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  49271. targetMesh?: AbstractMesh;
  49272. poleTargetMesh?: AbstractMesh;
  49273. poleTargetBone?: Bone;
  49274. poleTargetLocalOffset?: Vector3;
  49275. poleAngle?: number;
  49276. bendAxis?: Vector3;
  49277. maxAngle?: number;
  49278. slerpAmount?: number;
  49279. });
  49280. private _setMaxAngle;
  49281. /**
  49282. * Force the controller to update the bones
  49283. */
  49284. update(): void;
  49285. }
  49286. }
  49287. declare module "babylonjs/Bones/boneLookController" {
  49288. import { Vector3 } from "babylonjs/Maths/math.vector";
  49289. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49290. import { Bone } from "babylonjs/Bones/bone";
  49291. import { Space } from "babylonjs/Maths/math.axis";
  49292. /**
  49293. * Class used to make a bone look toward a point in space
  49294. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  49295. */
  49296. export class BoneLookController {
  49297. private static _tmpVecs;
  49298. private static _tmpQuat;
  49299. private static _tmpMats;
  49300. /**
  49301. * The target Vector3 that the bone will look at
  49302. */
  49303. target: Vector3;
  49304. /**
  49305. * The mesh that the bone is attached to
  49306. */
  49307. mesh: AbstractMesh;
  49308. /**
  49309. * The bone that will be looking to the target
  49310. */
  49311. bone: Bone;
  49312. /**
  49313. * The up axis of the coordinate system that is used when the bone is rotated
  49314. */
  49315. upAxis: Vector3;
  49316. /**
  49317. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  49318. */
  49319. upAxisSpace: Space;
  49320. /**
  49321. * Used to make an adjustment to the yaw of the bone
  49322. */
  49323. adjustYaw: number;
  49324. /**
  49325. * Used to make an adjustment to the pitch of the bone
  49326. */
  49327. adjustPitch: number;
  49328. /**
  49329. * Used to make an adjustment to the roll of the bone
  49330. */
  49331. adjustRoll: number;
  49332. /**
  49333. * 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)
  49334. */
  49335. slerpAmount: number;
  49336. private _minYaw;
  49337. private _maxYaw;
  49338. private _minPitch;
  49339. private _maxPitch;
  49340. private _minYawSin;
  49341. private _minYawCos;
  49342. private _maxYawSin;
  49343. private _maxYawCos;
  49344. private _midYawConstraint;
  49345. private _minPitchTan;
  49346. private _maxPitchTan;
  49347. private _boneQuat;
  49348. private _slerping;
  49349. private _transformYawPitch;
  49350. private _transformYawPitchInv;
  49351. private _firstFrameSkipped;
  49352. private _yawRange;
  49353. private _fowardAxis;
  49354. /**
  49355. * Gets or sets the minimum yaw angle that the bone can look to
  49356. */
  49357. get minYaw(): number;
  49358. set minYaw(value: number);
  49359. /**
  49360. * Gets or sets the maximum yaw angle that the bone can look to
  49361. */
  49362. get maxYaw(): number;
  49363. set maxYaw(value: number);
  49364. /**
  49365. * Gets or sets the minimum pitch angle that the bone can look to
  49366. */
  49367. get minPitch(): number;
  49368. set minPitch(value: number);
  49369. /**
  49370. * Gets or sets the maximum pitch angle that the bone can look to
  49371. */
  49372. get maxPitch(): number;
  49373. set maxPitch(value: number);
  49374. /**
  49375. * Create a BoneLookController
  49376. * @param mesh the mesh that the bone belongs to
  49377. * @param bone the bone that will be looking to the target
  49378. * @param target the target Vector3 to look at
  49379. * @param options optional settings:
  49380. * * maxYaw: the maximum angle the bone will yaw to
  49381. * * minYaw: the minimum angle the bone will yaw to
  49382. * * maxPitch: the maximum angle the bone will pitch to
  49383. * * minPitch: the minimum angle the bone will yaw to
  49384. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49385. * * upAxis: the up axis of the coordinate system
  49386. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49387. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49388. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49389. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49390. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49391. * * adjustRoll: used to make an adjustment to the roll of the bone
  49392. **/
  49393. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49394. maxYaw?: number;
  49395. minYaw?: number;
  49396. maxPitch?: number;
  49397. minPitch?: number;
  49398. slerpAmount?: number;
  49399. upAxis?: Vector3;
  49400. upAxisSpace?: Space;
  49401. yawAxis?: Vector3;
  49402. pitchAxis?: Vector3;
  49403. adjustYaw?: number;
  49404. adjustPitch?: number;
  49405. adjustRoll?: number;
  49406. });
  49407. /**
  49408. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49409. */
  49410. update(): void;
  49411. private _getAngleDiff;
  49412. private _getAngleBetween;
  49413. private _isAngleBetween;
  49414. }
  49415. }
  49416. declare module "babylonjs/Bones/index" {
  49417. export * from "babylonjs/Bones/bone";
  49418. export * from "babylonjs/Bones/boneIKController";
  49419. export * from "babylonjs/Bones/boneLookController";
  49420. export * from "babylonjs/Bones/skeleton";
  49421. }
  49422. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49423. import { Nullable } from "babylonjs/types";
  49424. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49425. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49426. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49427. /**
  49428. * Manage the gamepad inputs to control an arc rotate camera.
  49429. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49430. */
  49431. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49432. /**
  49433. * Defines the camera the input is attached to.
  49434. */
  49435. camera: ArcRotateCamera;
  49436. /**
  49437. * Defines the gamepad the input is gathering event from.
  49438. */
  49439. gamepad: Nullable<Gamepad>;
  49440. /**
  49441. * Defines the gamepad rotation sensiblity.
  49442. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49443. */
  49444. gamepadRotationSensibility: number;
  49445. /**
  49446. * Defines the gamepad move sensiblity.
  49447. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49448. */
  49449. gamepadMoveSensibility: number;
  49450. private _yAxisScale;
  49451. /**
  49452. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49453. */
  49454. get invertYAxis(): boolean;
  49455. set invertYAxis(value: boolean);
  49456. private _onGamepadConnectedObserver;
  49457. private _onGamepadDisconnectedObserver;
  49458. /**
  49459. * Attach the input controls to a specific dom element to get the input from.
  49460. */
  49461. attachControl(): void;
  49462. /**
  49463. * Detach the current controls from the specified dom element.
  49464. */
  49465. detachControl(): void;
  49466. /**
  49467. * Update the current camera state depending on the inputs that have been used this frame.
  49468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49469. */
  49470. checkInputs(): void;
  49471. /**
  49472. * Gets the class name of the current intput.
  49473. * @returns the class name
  49474. */
  49475. getClassName(): string;
  49476. /**
  49477. * Get the friendly name associated with the input class.
  49478. * @returns the input friendly name
  49479. */
  49480. getSimpleName(): string;
  49481. }
  49482. }
  49483. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49485. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49486. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49487. interface ArcRotateCameraInputsManager {
  49488. /**
  49489. * Add orientation input support to the input manager.
  49490. * @returns the current input manager
  49491. */
  49492. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49493. }
  49494. }
  49495. /**
  49496. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49498. */
  49499. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49500. /**
  49501. * Defines the camera the input is attached to.
  49502. */
  49503. camera: ArcRotateCamera;
  49504. /**
  49505. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49506. */
  49507. alphaCorrection: number;
  49508. /**
  49509. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49510. */
  49511. gammaCorrection: number;
  49512. private _alpha;
  49513. private _gamma;
  49514. private _dirty;
  49515. private _deviceOrientationHandler;
  49516. /**
  49517. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49518. */
  49519. constructor();
  49520. /**
  49521. * Attach the input controls to a specific dom element to get the input from.
  49522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49523. */
  49524. attachControl(noPreventDefault?: boolean): void;
  49525. /** @hidden */
  49526. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49527. /**
  49528. * Update the current camera state depending on the inputs that have been used this frame.
  49529. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49530. */
  49531. checkInputs(): void;
  49532. /**
  49533. * Detach the current controls from the specified dom element.
  49534. */
  49535. detachControl(): void;
  49536. /**
  49537. * Gets the class name of the current intput.
  49538. * @returns the class name
  49539. */
  49540. getClassName(): string;
  49541. /**
  49542. * Get the friendly name associated with the input class.
  49543. * @returns the input friendly name
  49544. */
  49545. getSimpleName(): string;
  49546. }
  49547. }
  49548. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49549. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49550. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49551. /**
  49552. * Listen to mouse events to control the camera.
  49553. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49554. */
  49555. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49556. /**
  49557. * Defines the camera the input is attached to.
  49558. */
  49559. camera: FlyCamera;
  49560. /**
  49561. * Defines if touch is enabled. (Default is true.)
  49562. */
  49563. touchEnabled: boolean;
  49564. /**
  49565. * Defines the buttons associated with the input to handle camera rotation.
  49566. */
  49567. buttons: number[];
  49568. /**
  49569. * Assign buttons for Yaw control.
  49570. */
  49571. buttonsYaw: number[];
  49572. /**
  49573. * Assign buttons for Pitch control.
  49574. */
  49575. buttonsPitch: number[];
  49576. /**
  49577. * Assign buttons for Roll control.
  49578. */
  49579. buttonsRoll: number[];
  49580. /**
  49581. * Detect if any button is being pressed while mouse is moved.
  49582. * -1 = Mouse locked.
  49583. * 0 = Left button.
  49584. * 1 = Middle Button.
  49585. * 2 = Right Button.
  49586. */
  49587. activeButton: number;
  49588. /**
  49589. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49590. * Higher values reduce its sensitivity.
  49591. */
  49592. angularSensibility: number;
  49593. private _observer;
  49594. private _rollObserver;
  49595. private previousPosition;
  49596. private noPreventDefault;
  49597. private element;
  49598. /**
  49599. * Listen to mouse events to control the camera.
  49600. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49601. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49602. */
  49603. constructor(touchEnabled?: boolean);
  49604. /**
  49605. * Attach the mouse control to the HTML DOM element.
  49606. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49607. */
  49608. attachControl(noPreventDefault?: boolean): void;
  49609. /**
  49610. * Detach the current controls from the specified dom element.
  49611. */
  49612. detachControl(): void;
  49613. /**
  49614. * Gets the class name of the current input.
  49615. * @returns the class name.
  49616. */
  49617. getClassName(): string;
  49618. /**
  49619. * Get the friendly name associated with the input class.
  49620. * @returns the input's friendly name.
  49621. */
  49622. getSimpleName(): string;
  49623. private _pointerInput;
  49624. private _onMouseMove;
  49625. /**
  49626. * Rotate camera by mouse offset.
  49627. */
  49628. private rotateCamera;
  49629. }
  49630. }
  49631. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49632. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49633. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49634. /**
  49635. * Default Inputs manager for the FlyCamera.
  49636. * It groups all the default supported inputs for ease of use.
  49637. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49638. */
  49639. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49640. /**
  49641. * Instantiates a new FlyCameraInputsManager.
  49642. * @param camera Defines the camera the inputs belong to.
  49643. */
  49644. constructor(camera: FlyCamera);
  49645. /**
  49646. * Add keyboard input support to the input manager.
  49647. * @returns the new FlyCameraKeyboardMoveInput().
  49648. */
  49649. addKeyboard(): FlyCameraInputsManager;
  49650. /**
  49651. * Add mouse input support to the input manager.
  49652. * @param touchEnabled Enable touch screen support.
  49653. * @returns the new FlyCameraMouseInput().
  49654. */
  49655. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49656. }
  49657. }
  49658. declare module "babylonjs/Cameras/flyCamera" {
  49659. import { Scene } from "babylonjs/scene";
  49660. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49662. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49663. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49664. /**
  49665. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49666. * such as in a 3D Space Shooter or a Flight Simulator.
  49667. */
  49668. export class FlyCamera extends TargetCamera {
  49669. /**
  49670. * Define the collision ellipsoid of the camera.
  49671. * This is helpful for simulating a camera body, like a player's body.
  49672. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49673. */
  49674. ellipsoid: Vector3;
  49675. /**
  49676. * Define an offset for the position of the ellipsoid around the camera.
  49677. * This can be helpful if the camera is attached away from the player's body center,
  49678. * such as at its head.
  49679. */
  49680. ellipsoidOffset: Vector3;
  49681. /**
  49682. * Enable or disable collisions of the camera with the rest of the scene objects.
  49683. */
  49684. checkCollisions: boolean;
  49685. /**
  49686. * Enable or disable gravity on the camera.
  49687. */
  49688. applyGravity: boolean;
  49689. /**
  49690. * Define the current direction the camera is moving to.
  49691. */
  49692. cameraDirection: Vector3;
  49693. /**
  49694. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49695. * This overrides and empties cameraRotation.
  49696. */
  49697. rotationQuaternion: Quaternion;
  49698. /**
  49699. * Track Roll to maintain the wanted Rolling when looking around.
  49700. */
  49701. _trackRoll: number;
  49702. /**
  49703. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49704. */
  49705. rollCorrect: number;
  49706. /**
  49707. * Mimic a banked turn, Rolling the camera when Yawing.
  49708. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49709. */
  49710. bankedTurn: boolean;
  49711. /**
  49712. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49713. */
  49714. bankedTurnLimit: number;
  49715. /**
  49716. * Value of 0 disables the banked Roll.
  49717. * Value of 1 is equal to the Yaw angle in radians.
  49718. */
  49719. bankedTurnMultiplier: number;
  49720. /**
  49721. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49722. */
  49723. inputs: FlyCameraInputsManager;
  49724. /**
  49725. * Gets the input sensibility for mouse input.
  49726. * Higher values reduce sensitivity.
  49727. */
  49728. get angularSensibility(): number;
  49729. /**
  49730. * Sets the input sensibility for a mouse input.
  49731. * Higher values reduce sensitivity.
  49732. */
  49733. set angularSensibility(value: number);
  49734. /**
  49735. * Get the keys for camera movement forward.
  49736. */
  49737. get keysForward(): number[];
  49738. /**
  49739. * Set the keys for camera movement forward.
  49740. */
  49741. set keysForward(value: number[]);
  49742. /**
  49743. * Get the keys for camera movement backward.
  49744. */
  49745. get keysBackward(): number[];
  49746. set keysBackward(value: number[]);
  49747. /**
  49748. * Get the keys for camera movement up.
  49749. */
  49750. get keysUp(): number[];
  49751. /**
  49752. * Set the keys for camera movement up.
  49753. */
  49754. set keysUp(value: number[]);
  49755. /**
  49756. * Get the keys for camera movement down.
  49757. */
  49758. get keysDown(): number[];
  49759. /**
  49760. * Set the keys for camera movement down.
  49761. */
  49762. set keysDown(value: number[]);
  49763. /**
  49764. * Get the keys for camera movement left.
  49765. */
  49766. get keysLeft(): number[];
  49767. /**
  49768. * Set the keys for camera movement left.
  49769. */
  49770. set keysLeft(value: number[]);
  49771. /**
  49772. * Set the keys for camera movement right.
  49773. */
  49774. get keysRight(): number[];
  49775. /**
  49776. * Set the keys for camera movement right.
  49777. */
  49778. set keysRight(value: number[]);
  49779. /**
  49780. * Event raised when the camera collides with a mesh in the scene.
  49781. */
  49782. onCollide: (collidedMesh: AbstractMesh) => void;
  49783. private _collider;
  49784. private _needMoveForGravity;
  49785. private _oldPosition;
  49786. private _diffPosition;
  49787. private _newPosition;
  49788. /** @hidden */
  49789. _localDirection: Vector3;
  49790. /** @hidden */
  49791. _transformedDirection: Vector3;
  49792. /**
  49793. * Instantiates a FlyCamera.
  49794. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49795. * such as in a 3D Space Shooter or a Flight Simulator.
  49796. * @param name Define the name of the camera in the scene.
  49797. * @param position Define the starting position of the camera in the scene.
  49798. * @param scene Define the scene the camera belongs to.
  49799. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49800. */
  49801. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49802. /**
  49803. * Attach the input controls to a specific dom element to get the input from.
  49804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49805. */
  49806. attachControl(noPreventDefault?: boolean): void;
  49807. /**
  49808. * Detach a control from the HTML DOM element.
  49809. * The camera will stop reacting to that input.
  49810. */
  49811. detachControl(): void;
  49812. private _collisionMask;
  49813. /**
  49814. * Get the mask that the camera ignores in collision events.
  49815. */
  49816. get collisionMask(): number;
  49817. /**
  49818. * Set the mask that the camera ignores in collision events.
  49819. */
  49820. set collisionMask(mask: number);
  49821. /** @hidden */
  49822. _collideWithWorld(displacement: Vector3): void;
  49823. /** @hidden */
  49824. private _onCollisionPositionChange;
  49825. /** @hidden */
  49826. _checkInputs(): void;
  49827. /** @hidden */
  49828. _decideIfNeedsToMove(): boolean;
  49829. /** @hidden */
  49830. _updatePosition(): void;
  49831. /**
  49832. * Restore the Roll to its target value at the rate specified.
  49833. * @param rate - Higher means slower restoring.
  49834. * @hidden
  49835. */
  49836. restoreRoll(rate: number): void;
  49837. /**
  49838. * Destroy the camera and release the current resources held by it.
  49839. */
  49840. dispose(): void;
  49841. /**
  49842. * Get the current object class name.
  49843. * @returns the class name.
  49844. */
  49845. getClassName(): string;
  49846. }
  49847. }
  49848. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49849. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49850. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49851. /**
  49852. * Listen to keyboard events to control the camera.
  49853. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49854. */
  49855. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49856. /**
  49857. * Defines the camera the input is attached to.
  49858. */
  49859. camera: FlyCamera;
  49860. /**
  49861. * The list of keyboard keys used to control the forward move of the camera.
  49862. */
  49863. keysForward: number[];
  49864. /**
  49865. * The list of keyboard keys used to control the backward move of the camera.
  49866. */
  49867. keysBackward: number[];
  49868. /**
  49869. * The list of keyboard keys used to control the forward move of the camera.
  49870. */
  49871. keysUp: number[];
  49872. /**
  49873. * The list of keyboard keys used to control the backward move of the camera.
  49874. */
  49875. keysDown: number[];
  49876. /**
  49877. * The list of keyboard keys used to control the right strafe move of the camera.
  49878. */
  49879. keysRight: number[];
  49880. /**
  49881. * The list of keyboard keys used to control the left strafe move of the camera.
  49882. */
  49883. keysLeft: number[];
  49884. private _keys;
  49885. private _onCanvasBlurObserver;
  49886. private _onKeyboardObserver;
  49887. private _engine;
  49888. private _scene;
  49889. /**
  49890. * Attach the input controls to a specific dom element to get the input from.
  49891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49892. */
  49893. attachControl(noPreventDefault?: boolean): void;
  49894. /**
  49895. * Detach the current controls from the specified dom element.
  49896. */
  49897. detachControl(): void;
  49898. /**
  49899. * Gets the class name of the current intput.
  49900. * @returns the class name
  49901. */
  49902. getClassName(): string;
  49903. /** @hidden */
  49904. _onLostFocus(e: FocusEvent): void;
  49905. /**
  49906. * Get the friendly name associated with the input class.
  49907. * @returns the input friendly name
  49908. */
  49909. getSimpleName(): string;
  49910. /**
  49911. * Update the current camera state depending on the inputs that have been used this frame.
  49912. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49913. */
  49914. checkInputs(): void;
  49915. }
  49916. }
  49917. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49918. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49919. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49920. /**
  49921. * Manage the mouse wheel inputs to control a follow camera.
  49922. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49923. */
  49924. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49925. /**
  49926. * Defines the camera the input is attached to.
  49927. */
  49928. camera: FollowCamera;
  49929. /**
  49930. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49931. */
  49932. axisControlRadius: boolean;
  49933. /**
  49934. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49935. */
  49936. axisControlHeight: boolean;
  49937. /**
  49938. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49939. */
  49940. axisControlRotation: boolean;
  49941. /**
  49942. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49943. * relation to mouseWheel events.
  49944. */
  49945. wheelPrecision: number;
  49946. /**
  49947. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49948. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49949. */
  49950. wheelDeltaPercentage: number;
  49951. private _wheel;
  49952. private _observer;
  49953. /**
  49954. * Attach the input controls to a specific dom element to get the input from.
  49955. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49956. */
  49957. attachControl(noPreventDefault?: boolean): void;
  49958. /**
  49959. * Detach the current controls from the specified dom element.
  49960. */
  49961. detachControl(): void;
  49962. /**
  49963. * Gets the class name of the current intput.
  49964. * @returns the class name
  49965. */
  49966. getClassName(): string;
  49967. /**
  49968. * Get the friendly name associated with the input class.
  49969. * @returns the input friendly name
  49970. */
  49971. getSimpleName(): string;
  49972. }
  49973. }
  49974. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49975. import { Nullable } from "babylonjs/types";
  49976. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49977. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49978. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49979. /**
  49980. * Manage the pointers inputs to control an follow camera.
  49981. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49982. */
  49983. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49984. /**
  49985. * Defines the camera the input is attached to.
  49986. */
  49987. camera: FollowCamera;
  49988. /**
  49989. * Gets the class name of the current input.
  49990. * @returns the class name
  49991. */
  49992. getClassName(): string;
  49993. /**
  49994. * Defines the pointer angular sensibility along the X axis or how fast is
  49995. * the camera rotating.
  49996. * A negative number will reverse the axis direction.
  49997. */
  49998. angularSensibilityX: number;
  49999. /**
  50000. * Defines the pointer angular sensibility along the Y axis or how fast is
  50001. * the camera rotating.
  50002. * A negative number will reverse the axis direction.
  50003. */
  50004. angularSensibilityY: number;
  50005. /**
  50006. * Defines the pointer pinch precision or how fast is the camera zooming.
  50007. * A negative number will reverse the axis direction.
  50008. */
  50009. pinchPrecision: number;
  50010. /**
  50011. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50012. * from 0.
  50013. * It defines the percentage of current camera.radius to use as delta when
  50014. * pinch zoom is used.
  50015. */
  50016. pinchDeltaPercentage: number;
  50017. /**
  50018. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  50019. */
  50020. axisXControlRadius: boolean;
  50021. /**
  50022. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  50023. */
  50024. axisXControlHeight: boolean;
  50025. /**
  50026. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  50027. */
  50028. axisXControlRotation: boolean;
  50029. /**
  50030. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  50031. */
  50032. axisYControlRadius: boolean;
  50033. /**
  50034. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50035. */
  50036. axisYControlHeight: boolean;
  50037. /**
  50038. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  50039. */
  50040. axisYControlRotation: boolean;
  50041. /**
  50042. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  50043. */
  50044. axisPinchControlRadius: boolean;
  50045. /**
  50046. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  50047. */
  50048. axisPinchControlHeight: boolean;
  50049. /**
  50050. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  50051. */
  50052. axisPinchControlRotation: boolean;
  50053. /**
  50054. * Log error messages if basic misconfiguration has occurred.
  50055. */
  50056. warningEnable: boolean;
  50057. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50058. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50059. private _warningCounter;
  50060. private _warning;
  50061. }
  50062. }
  50063. declare module "babylonjs/Cameras/followCameraInputsManager" {
  50064. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  50065. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50066. /**
  50067. * Default Inputs manager for the FollowCamera.
  50068. * It groups all the default supported inputs for ease of use.
  50069. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50070. */
  50071. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  50072. /**
  50073. * Instantiates a new FollowCameraInputsManager.
  50074. * @param camera Defines the camera the inputs belong to
  50075. */
  50076. constructor(camera: FollowCamera);
  50077. /**
  50078. * Add keyboard input support to the input manager.
  50079. * @returns the current input manager
  50080. */
  50081. addKeyboard(): FollowCameraInputsManager;
  50082. /**
  50083. * Add mouse wheel input support to the input manager.
  50084. * @returns the current input manager
  50085. */
  50086. addMouseWheel(): FollowCameraInputsManager;
  50087. /**
  50088. * Add pointers input support to the input manager.
  50089. * @returns the current input manager
  50090. */
  50091. addPointers(): FollowCameraInputsManager;
  50092. /**
  50093. * Add orientation input support to the input manager.
  50094. * @returns the current input manager
  50095. */
  50096. addVRDeviceOrientation(): FollowCameraInputsManager;
  50097. }
  50098. }
  50099. declare module "babylonjs/Cameras/followCamera" {
  50100. import { Nullable } from "babylonjs/types";
  50101. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  50102. import { Scene } from "babylonjs/scene";
  50103. import { Vector3 } from "babylonjs/Maths/math.vector";
  50104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50105. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  50106. /**
  50107. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  50108. * an arc rotate version arcFollowCamera are available.
  50109. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50110. */
  50111. export class FollowCamera extends TargetCamera {
  50112. /**
  50113. * Distance the follow camera should follow an object at
  50114. */
  50115. radius: number;
  50116. /**
  50117. * Minimum allowed distance of the camera to the axis of rotation
  50118. * (The camera can not get closer).
  50119. * This can help limiting how the Camera is able to move in the scene.
  50120. */
  50121. lowerRadiusLimit: Nullable<number>;
  50122. /**
  50123. * Maximum allowed distance of the camera to the axis of rotation
  50124. * (The camera can not get further).
  50125. * This can help limiting how the Camera is able to move in the scene.
  50126. */
  50127. upperRadiusLimit: Nullable<number>;
  50128. /**
  50129. * Define a rotation offset between the camera and the object it follows
  50130. */
  50131. rotationOffset: number;
  50132. /**
  50133. * Minimum allowed angle to camera position relative to target object.
  50134. * This can help limiting how the Camera is able to move in the scene.
  50135. */
  50136. lowerRotationOffsetLimit: Nullable<number>;
  50137. /**
  50138. * Maximum allowed angle to camera position relative to target object.
  50139. * This can help limiting how the Camera is able to move in the scene.
  50140. */
  50141. upperRotationOffsetLimit: Nullable<number>;
  50142. /**
  50143. * Define a height offset between the camera and the object it follows.
  50144. * It can help following an object from the top (like a car chaing a plane)
  50145. */
  50146. heightOffset: number;
  50147. /**
  50148. * Minimum allowed height of camera position relative to target object.
  50149. * This can help limiting how the Camera is able to move in the scene.
  50150. */
  50151. lowerHeightOffsetLimit: Nullable<number>;
  50152. /**
  50153. * Maximum allowed height of camera position relative to target object.
  50154. * This can help limiting how the Camera is able to move in the scene.
  50155. */
  50156. upperHeightOffsetLimit: Nullable<number>;
  50157. /**
  50158. * Define how fast the camera can accelerate to follow it s target.
  50159. */
  50160. cameraAcceleration: number;
  50161. /**
  50162. * Define the speed limit of the camera following an object.
  50163. */
  50164. maxCameraSpeed: number;
  50165. /**
  50166. * Define the target of the camera.
  50167. */
  50168. lockedTarget: Nullable<AbstractMesh>;
  50169. /**
  50170. * Defines the input associated with the camera.
  50171. */
  50172. inputs: FollowCameraInputsManager;
  50173. /**
  50174. * Instantiates the follow camera.
  50175. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50176. * @param name Define the name of the camera in the scene
  50177. * @param position Define the position of the camera
  50178. * @param scene Define the scene the camera belong to
  50179. * @param lockedTarget Define the target of the camera
  50180. */
  50181. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  50182. private _follow;
  50183. /**
  50184. * Attach the input controls to a specific dom element to get the input from.
  50185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50186. */
  50187. attachControl(noPreventDefault?: boolean): void;
  50188. /**
  50189. * Detach the current controls from the specified dom element.
  50190. */
  50191. detachControl(): void;
  50192. /** @hidden */
  50193. _checkInputs(): void;
  50194. private _checkLimits;
  50195. /**
  50196. * Gets the camera class name.
  50197. * @returns the class name
  50198. */
  50199. getClassName(): string;
  50200. }
  50201. /**
  50202. * Arc Rotate version of the follow camera.
  50203. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  50204. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50205. */
  50206. export class ArcFollowCamera extends TargetCamera {
  50207. /** The longitudinal angle of the camera */
  50208. alpha: number;
  50209. /** The latitudinal angle of the camera */
  50210. beta: number;
  50211. /** The radius of the camera from its target */
  50212. radius: number;
  50213. private _cartesianCoordinates;
  50214. /** Define the camera target (the mesh it should follow) */
  50215. private _meshTarget;
  50216. /**
  50217. * Instantiates a new ArcFollowCamera
  50218. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  50219. * @param name Define the name of the camera
  50220. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  50221. * @param beta Define the rotation angle of the camera around the elevation axis
  50222. * @param radius Define the radius of the camera from its target point
  50223. * @param target Define the target of the camera
  50224. * @param scene Define the scene the camera belongs to
  50225. */
  50226. constructor(name: string,
  50227. /** The longitudinal angle of the camera */
  50228. alpha: number,
  50229. /** The latitudinal angle of the camera */
  50230. beta: number,
  50231. /** The radius of the camera from its target */
  50232. radius: number,
  50233. /** Define the camera target (the mesh it should follow) */
  50234. target: Nullable<AbstractMesh>, scene: Scene);
  50235. private _follow;
  50236. /** @hidden */
  50237. _checkInputs(): void;
  50238. /**
  50239. * Returns the class name of the object.
  50240. * It is mostly used internally for serialization purposes.
  50241. */
  50242. getClassName(): string;
  50243. }
  50244. }
  50245. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  50246. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50247. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  50248. /**
  50249. * Manage the keyboard inputs to control the movement of a follow camera.
  50250. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50251. */
  50252. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  50253. /**
  50254. * Defines the camera the input is attached to.
  50255. */
  50256. camera: FollowCamera;
  50257. /**
  50258. * Defines the list of key codes associated with the up action (increase heightOffset)
  50259. */
  50260. keysHeightOffsetIncr: number[];
  50261. /**
  50262. * Defines the list of key codes associated with the down action (decrease heightOffset)
  50263. */
  50264. keysHeightOffsetDecr: number[];
  50265. /**
  50266. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  50267. */
  50268. keysHeightOffsetModifierAlt: boolean;
  50269. /**
  50270. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  50271. */
  50272. keysHeightOffsetModifierCtrl: boolean;
  50273. /**
  50274. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  50275. */
  50276. keysHeightOffsetModifierShift: boolean;
  50277. /**
  50278. * Defines the list of key codes associated with the left action (increase rotationOffset)
  50279. */
  50280. keysRotationOffsetIncr: number[];
  50281. /**
  50282. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  50283. */
  50284. keysRotationOffsetDecr: number[];
  50285. /**
  50286. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  50287. */
  50288. keysRotationOffsetModifierAlt: boolean;
  50289. /**
  50290. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  50291. */
  50292. keysRotationOffsetModifierCtrl: boolean;
  50293. /**
  50294. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  50295. */
  50296. keysRotationOffsetModifierShift: boolean;
  50297. /**
  50298. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  50299. */
  50300. keysRadiusIncr: number[];
  50301. /**
  50302. * Defines the list of key codes associated with the zoom-out action (increase radius)
  50303. */
  50304. keysRadiusDecr: number[];
  50305. /**
  50306. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  50307. */
  50308. keysRadiusModifierAlt: boolean;
  50309. /**
  50310. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  50311. */
  50312. keysRadiusModifierCtrl: boolean;
  50313. /**
  50314. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  50315. */
  50316. keysRadiusModifierShift: boolean;
  50317. /**
  50318. * Defines the rate of change of heightOffset.
  50319. */
  50320. heightSensibility: number;
  50321. /**
  50322. * Defines the rate of change of rotationOffset.
  50323. */
  50324. rotationSensibility: number;
  50325. /**
  50326. * Defines the rate of change of radius.
  50327. */
  50328. radiusSensibility: number;
  50329. private _keys;
  50330. private _ctrlPressed;
  50331. private _altPressed;
  50332. private _shiftPressed;
  50333. private _onCanvasBlurObserver;
  50334. private _onKeyboardObserver;
  50335. private _engine;
  50336. private _scene;
  50337. /**
  50338. * Attach the input controls to a specific dom element to get the input from.
  50339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50340. */
  50341. attachControl(noPreventDefault?: boolean): void;
  50342. /**
  50343. * Detach the current controls from the specified dom element.
  50344. */
  50345. detachControl(): void;
  50346. /**
  50347. * Update the current camera state depending on the inputs that have been used this frame.
  50348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50349. */
  50350. checkInputs(): void;
  50351. /**
  50352. * Gets the class name of the current input.
  50353. * @returns the class name
  50354. */
  50355. getClassName(): string;
  50356. /**
  50357. * Get the friendly name associated with the input class.
  50358. * @returns the input friendly name
  50359. */
  50360. getSimpleName(): string;
  50361. /**
  50362. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50363. * allow modification of the heightOffset value.
  50364. */
  50365. private _modifierHeightOffset;
  50366. /**
  50367. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50368. * allow modification of the rotationOffset value.
  50369. */
  50370. private _modifierRotationOffset;
  50371. /**
  50372. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50373. * allow modification of the radius value.
  50374. */
  50375. private _modifierRadius;
  50376. }
  50377. }
  50378. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50379. import { Nullable } from "babylonjs/types";
  50380. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50381. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50382. import { Observable } from "babylonjs/Misc/observable";
  50383. module "babylonjs/Cameras/freeCameraInputsManager" {
  50384. interface FreeCameraInputsManager {
  50385. /**
  50386. * @hidden
  50387. */
  50388. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50389. /**
  50390. * Add orientation input support to the input manager.
  50391. * @returns the current input manager
  50392. */
  50393. addDeviceOrientation(): FreeCameraInputsManager;
  50394. }
  50395. }
  50396. /**
  50397. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50398. * Screen rotation is taken into account.
  50399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50400. */
  50401. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50402. private _camera;
  50403. private _screenOrientationAngle;
  50404. private _constantTranform;
  50405. private _screenQuaternion;
  50406. private _alpha;
  50407. private _beta;
  50408. private _gamma;
  50409. /**
  50410. * Can be used to detect if a device orientation sensor is available on a device
  50411. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50412. * @returns a promise that will resolve on orientation change
  50413. */
  50414. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50415. /**
  50416. * @hidden
  50417. */
  50418. _onDeviceOrientationChangedObservable: Observable<void>;
  50419. /**
  50420. * Instantiates a new input
  50421. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50422. */
  50423. constructor();
  50424. /**
  50425. * Define the camera controlled by the input.
  50426. */
  50427. get camera(): FreeCamera;
  50428. set camera(camera: FreeCamera);
  50429. /**
  50430. * Attach the input controls to a specific dom element to get the input from.
  50431. */
  50432. attachControl(): void;
  50433. private _orientationChanged;
  50434. private _deviceOrientation;
  50435. /**
  50436. * Detach the current controls from the specified dom element.
  50437. */
  50438. detachControl(): void;
  50439. /**
  50440. * Update the current camera state depending on the inputs that have been used this frame.
  50441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50442. */
  50443. checkInputs(): void;
  50444. /**
  50445. * Gets the class name of the current intput.
  50446. * @returns the class name
  50447. */
  50448. getClassName(): string;
  50449. /**
  50450. * Get the friendly name associated with the input class.
  50451. * @returns the input friendly name
  50452. */
  50453. getSimpleName(): string;
  50454. }
  50455. }
  50456. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50457. import { Nullable } from "babylonjs/types";
  50458. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50459. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50460. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50461. /**
  50462. * Manage the gamepad inputs to control a free camera.
  50463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50464. */
  50465. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50466. /**
  50467. * Define the camera the input is attached to.
  50468. */
  50469. camera: FreeCamera;
  50470. /**
  50471. * Define the Gamepad controlling the input
  50472. */
  50473. gamepad: Nullable<Gamepad>;
  50474. /**
  50475. * Defines the gamepad rotation sensiblity.
  50476. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50477. */
  50478. gamepadAngularSensibility: number;
  50479. /**
  50480. * Defines the gamepad move sensiblity.
  50481. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50482. */
  50483. gamepadMoveSensibility: number;
  50484. private _yAxisScale;
  50485. /**
  50486. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50487. */
  50488. get invertYAxis(): boolean;
  50489. set invertYAxis(value: boolean);
  50490. private _onGamepadConnectedObserver;
  50491. private _onGamepadDisconnectedObserver;
  50492. private _cameraTransform;
  50493. private _deltaTransform;
  50494. private _vector3;
  50495. private _vector2;
  50496. /**
  50497. * Attach the input controls to a specific dom element to get the input from.
  50498. */
  50499. attachControl(): void;
  50500. /**
  50501. * Detach the current controls from the specified dom element.
  50502. */
  50503. detachControl(): void;
  50504. /**
  50505. * Update the current camera state depending on the inputs that have been used this frame.
  50506. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50507. */
  50508. checkInputs(): void;
  50509. /**
  50510. * Gets the class name of the current intput.
  50511. * @returns the class name
  50512. */
  50513. getClassName(): string;
  50514. /**
  50515. * Get the friendly name associated with the input class.
  50516. * @returns the input friendly name
  50517. */
  50518. getSimpleName(): string;
  50519. }
  50520. }
  50521. declare module "babylonjs/Misc/virtualJoystick" {
  50522. import { Nullable } from "babylonjs/types";
  50523. import { Vector3 } from "babylonjs/Maths/math.vector";
  50524. /**
  50525. * Defines the potential axis of a Joystick
  50526. */
  50527. export enum JoystickAxis {
  50528. /** X axis */
  50529. X = 0,
  50530. /** Y axis */
  50531. Y = 1,
  50532. /** Z axis */
  50533. Z = 2
  50534. }
  50535. /**
  50536. * Represents the different customization options available
  50537. * for VirtualJoystick
  50538. */
  50539. interface VirtualJoystickCustomizations {
  50540. /**
  50541. * Size of the joystick's puck
  50542. */
  50543. puckSize: number;
  50544. /**
  50545. * Size of the joystick's container
  50546. */
  50547. containerSize: number;
  50548. /**
  50549. * Color of the joystick && puck
  50550. */
  50551. color: string;
  50552. /**
  50553. * Image URL for the joystick's puck
  50554. */
  50555. puckImage?: string;
  50556. /**
  50557. * Image URL for the joystick's container
  50558. */
  50559. containerImage?: string;
  50560. /**
  50561. * Defines the unmoving position of the joystick container
  50562. */
  50563. position?: {
  50564. x: number;
  50565. y: number;
  50566. };
  50567. /**
  50568. * Defines whether or not the joystick container is always visible
  50569. */
  50570. alwaysVisible: boolean;
  50571. /**
  50572. * Defines whether or not to limit the movement of the puck to the joystick's container
  50573. */
  50574. limitToContainer: boolean;
  50575. }
  50576. /**
  50577. * Class used to define virtual joystick (used in touch mode)
  50578. */
  50579. export class VirtualJoystick {
  50580. /**
  50581. * Gets or sets a boolean indicating that left and right values must be inverted
  50582. */
  50583. reverseLeftRight: boolean;
  50584. /**
  50585. * Gets or sets a boolean indicating that up and down values must be inverted
  50586. */
  50587. reverseUpDown: boolean;
  50588. /**
  50589. * Gets the offset value for the position (ie. the change of the position value)
  50590. */
  50591. deltaPosition: Vector3;
  50592. /**
  50593. * Gets a boolean indicating if the virtual joystick was pressed
  50594. */
  50595. pressed: boolean;
  50596. /**
  50597. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50598. */
  50599. static Canvas: Nullable<HTMLCanvasElement>;
  50600. /**
  50601. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50602. */
  50603. limitToContainer: boolean;
  50604. private static _globalJoystickIndex;
  50605. private static _alwaysVisibleSticks;
  50606. private static vjCanvasContext;
  50607. private static vjCanvasWidth;
  50608. private static vjCanvasHeight;
  50609. private static halfWidth;
  50610. private static _GetDefaultOptions;
  50611. private _action;
  50612. private _axisTargetedByLeftAndRight;
  50613. private _axisTargetedByUpAndDown;
  50614. private _joystickSensibility;
  50615. private _inversedSensibility;
  50616. private _joystickPointerID;
  50617. private _joystickColor;
  50618. private _joystickPointerPos;
  50619. private _joystickPreviousPointerPos;
  50620. private _joystickPointerStartPos;
  50621. private _deltaJoystickVector;
  50622. private _leftJoystick;
  50623. private _touches;
  50624. private _joystickPosition;
  50625. private _alwaysVisible;
  50626. private _puckImage;
  50627. private _containerImage;
  50628. private _joystickPuckSize;
  50629. private _joystickContainerSize;
  50630. private _clearPuckSize;
  50631. private _clearContainerSize;
  50632. private _clearPuckSizeOffset;
  50633. private _clearContainerSizeOffset;
  50634. private _onPointerDownHandlerRef;
  50635. private _onPointerMoveHandlerRef;
  50636. private _onPointerUpHandlerRef;
  50637. private _onResize;
  50638. /**
  50639. * Creates a new virtual joystick
  50640. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50641. * @param customizations Defines the options we want to customize the VirtualJoystick
  50642. */
  50643. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50644. /**
  50645. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50646. * @param newJoystickSensibility defines the new sensibility
  50647. */
  50648. setJoystickSensibility(newJoystickSensibility: number): void;
  50649. private _onPointerDown;
  50650. private _onPointerMove;
  50651. private _onPointerUp;
  50652. /**
  50653. * Change the color of the virtual joystick
  50654. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50655. */
  50656. setJoystickColor(newColor: string): void;
  50657. /**
  50658. * Size of the joystick's container
  50659. */
  50660. set containerSize(newSize: number);
  50661. get containerSize(): number;
  50662. /**
  50663. * Size of the joystick's puck
  50664. */
  50665. set puckSize(newSize: number);
  50666. get puckSize(): number;
  50667. /**
  50668. * Clears the set position of the joystick
  50669. */
  50670. clearPosition(): void;
  50671. /**
  50672. * Defines whether or not the joystick container is always visible
  50673. */
  50674. set alwaysVisible(value: boolean);
  50675. get alwaysVisible(): boolean;
  50676. /**
  50677. * Sets the constant position of the Joystick container
  50678. * @param x X axis coordinate
  50679. * @param y Y axis coordinate
  50680. */
  50681. setPosition(x: number, y: number): void;
  50682. /**
  50683. * Defines a callback to call when the joystick is touched
  50684. * @param action defines the callback
  50685. */
  50686. setActionOnTouch(action: () => any): void;
  50687. /**
  50688. * Defines which axis you'd like to control for left & right
  50689. * @param axis defines the axis to use
  50690. */
  50691. setAxisForLeftRight(axis: JoystickAxis): void;
  50692. /**
  50693. * Defines which axis you'd like to control for up & down
  50694. * @param axis defines the axis to use
  50695. */
  50696. setAxisForUpDown(axis: JoystickAxis): void;
  50697. /**
  50698. * Clears the canvas from the previous puck / container draw
  50699. */
  50700. private _clearPreviousDraw;
  50701. /**
  50702. * Loads `urlPath` to be used for the container's image
  50703. * @param urlPath defines the urlPath of an image to use
  50704. */
  50705. setContainerImage(urlPath: string): void;
  50706. /**
  50707. * Loads `urlPath` to be used for the puck's image
  50708. * @param urlPath defines the urlPath of an image to use
  50709. */
  50710. setPuckImage(urlPath: string): void;
  50711. /**
  50712. * Draws the Virtual Joystick's container
  50713. */
  50714. private _drawContainer;
  50715. /**
  50716. * Draws the Virtual Joystick's puck
  50717. */
  50718. private _drawPuck;
  50719. private _drawVirtualJoystick;
  50720. /**
  50721. * Release internal HTML canvas
  50722. */
  50723. releaseCanvas(): void;
  50724. }
  50725. }
  50726. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50727. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50728. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50729. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50730. module "babylonjs/Cameras/freeCameraInputsManager" {
  50731. interface FreeCameraInputsManager {
  50732. /**
  50733. * Add virtual joystick input support to the input manager.
  50734. * @returns the current input manager
  50735. */
  50736. addVirtualJoystick(): FreeCameraInputsManager;
  50737. }
  50738. }
  50739. /**
  50740. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50741. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50742. */
  50743. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50744. /**
  50745. * Defines the camera the input is attached to.
  50746. */
  50747. camera: FreeCamera;
  50748. private _leftjoystick;
  50749. private _rightjoystick;
  50750. /**
  50751. * Gets the left stick of the virtual joystick.
  50752. * @returns The virtual Joystick
  50753. */
  50754. getLeftJoystick(): VirtualJoystick;
  50755. /**
  50756. * Gets the right stick of the virtual joystick.
  50757. * @returns The virtual Joystick
  50758. */
  50759. getRightJoystick(): VirtualJoystick;
  50760. /**
  50761. * Update the current camera state depending on the inputs that have been used this frame.
  50762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50763. */
  50764. checkInputs(): void;
  50765. /**
  50766. * Attach the input controls to a specific dom element to get the input from.
  50767. */
  50768. attachControl(): void;
  50769. /**
  50770. * Detach the current controls from the specified dom element.
  50771. */
  50772. detachControl(): void;
  50773. /**
  50774. * Gets the class name of the current intput.
  50775. * @returns the class name
  50776. */
  50777. getClassName(): string;
  50778. /**
  50779. * Get the friendly name associated with the input class.
  50780. * @returns the input friendly name
  50781. */
  50782. getSimpleName(): string;
  50783. }
  50784. }
  50785. declare module "babylonjs/Cameras/Inputs/index" {
  50786. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50787. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50788. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50789. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50790. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50791. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50792. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50793. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50794. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50795. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50796. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50797. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50798. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50799. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50800. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50801. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50802. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50803. }
  50804. declare module "babylonjs/Cameras/touchCamera" {
  50805. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50806. import { Scene } from "babylonjs/scene";
  50807. import { Vector3 } from "babylonjs/Maths/math.vector";
  50808. /**
  50809. * This represents a FPS type of camera controlled by touch.
  50810. * This is like a universal camera minus the Gamepad controls.
  50811. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50812. */
  50813. export class TouchCamera extends FreeCamera {
  50814. /**
  50815. * Defines the touch sensibility for rotation.
  50816. * The higher the faster.
  50817. */
  50818. get touchAngularSensibility(): number;
  50819. set touchAngularSensibility(value: number);
  50820. /**
  50821. * Defines the touch sensibility for move.
  50822. * The higher the faster.
  50823. */
  50824. get touchMoveSensibility(): number;
  50825. set touchMoveSensibility(value: number);
  50826. /**
  50827. * Instantiates a new touch camera.
  50828. * This represents a FPS type of camera controlled by touch.
  50829. * This is like a universal camera minus the Gamepad controls.
  50830. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50831. * @param name Define the name of the camera in the scene
  50832. * @param position Define the start position of the camera in the scene
  50833. * @param scene Define the scene the camera belongs to
  50834. */
  50835. constructor(name: string, position: Vector3, scene: Scene);
  50836. /**
  50837. * Gets the current object class name.
  50838. * @return the class name
  50839. */
  50840. getClassName(): string;
  50841. /** @hidden */
  50842. _setupInputs(): void;
  50843. }
  50844. }
  50845. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50846. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50847. import { Scene } from "babylonjs/scene";
  50848. import { Vector3 } from "babylonjs/Maths/math.vector";
  50849. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50850. import { Axis } from "babylonjs/Maths/math.axis";
  50851. /**
  50852. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50853. * being tilted forward or back and left or right.
  50854. */
  50855. export class DeviceOrientationCamera extends FreeCamera {
  50856. private _initialQuaternion;
  50857. private _quaternionCache;
  50858. private _tmpDragQuaternion;
  50859. private _disablePointerInputWhenUsingDeviceOrientation;
  50860. /**
  50861. * Creates a new device orientation camera
  50862. * @param name The name of the camera
  50863. * @param position The start position camera
  50864. * @param scene The scene the camera belongs to
  50865. */
  50866. constructor(name: string, position: Vector3, scene: Scene);
  50867. /**
  50868. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50869. */
  50870. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50871. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50872. private _dragFactor;
  50873. /**
  50874. * Enabled turning on the y axis when the orientation sensor is active
  50875. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50876. */
  50877. enableHorizontalDragging(dragFactor?: number): void;
  50878. /**
  50879. * Gets the current instance class name ("DeviceOrientationCamera").
  50880. * This helps avoiding instanceof at run time.
  50881. * @returns the class name
  50882. */
  50883. getClassName(): string;
  50884. /**
  50885. * @hidden
  50886. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50887. */
  50888. _checkInputs(): void;
  50889. /**
  50890. * Reset the camera to its default orientation on the specified axis only.
  50891. * @param axis The axis to reset
  50892. */
  50893. resetToCurrentRotation(axis?: Axis): void;
  50894. }
  50895. }
  50896. declare module "babylonjs/Gamepads/xboxGamepad" {
  50897. import { Observable } from "babylonjs/Misc/observable";
  50898. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50899. /**
  50900. * Defines supported buttons for XBox360 compatible gamepads
  50901. */
  50902. export enum Xbox360Button {
  50903. /** A */
  50904. A = 0,
  50905. /** B */
  50906. B = 1,
  50907. /** X */
  50908. X = 2,
  50909. /** Y */
  50910. Y = 3,
  50911. /** Left button */
  50912. LB = 4,
  50913. /** Right button */
  50914. RB = 5,
  50915. /** Back */
  50916. Back = 8,
  50917. /** Start */
  50918. Start = 9,
  50919. /** Left stick */
  50920. LeftStick = 10,
  50921. /** Right stick */
  50922. RightStick = 11
  50923. }
  50924. /** Defines values for XBox360 DPad */
  50925. export enum Xbox360Dpad {
  50926. /** Up */
  50927. Up = 12,
  50928. /** Down */
  50929. Down = 13,
  50930. /** Left */
  50931. Left = 14,
  50932. /** Right */
  50933. Right = 15
  50934. }
  50935. /**
  50936. * Defines a XBox360 gamepad
  50937. */
  50938. export class Xbox360Pad extends Gamepad {
  50939. private _leftTrigger;
  50940. private _rightTrigger;
  50941. private _onlefttriggerchanged;
  50942. private _onrighttriggerchanged;
  50943. private _onbuttondown;
  50944. private _onbuttonup;
  50945. private _ondpaddown;
  50946. private _ondpadup;
  50947. /** Observable raised when a button is pressed */
  50948. onButtonDownObservable: Observable<Xbox360Button>;
  50949. /** Observable raised when a button is released */
  50950. onButtonUpObservable: Observable<Xbox360Button>;
  50951. /** Observable raised when a pad is pressed */
  50952. onPadDownObservable: Observable<Xbox360Dpad>;
  50953. /** Observable raised when a pad is released */
  50954. onPadUpObservable: Observable<Xbox360Dpad>;
  50955. private _buttonA;
  50956. private _buttonB;
  50957. private _buttonX;
  50958. private _buttonY;
  50959. private _buttonBack;
  50960. private _buttonStart;
  50961. private _buttonLB;
  50962. private _buttonRB;
  50963. private _buttonLeftStick;
  50964. private _buttonRightStick;
  50965. private _dPadUp;
  50966. private _dPadDown;
  50967. private _dPadLeft;
  50968. private _dPadRight;
  50969. private _isXboxOnePad;
  50970. /**
  50971. * Creates a new XBox360 gamepad object
  50972. * @param id defines the id of this gamepad
  50973. * @param index defines its index
  50974. * @param gamepad defines the internal HTML gamepad object
  50975. * @param xboxOne defines if it is a XBox One gamepad
  50976. */
  50977. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50978. /**
  50979. * Defines the callback to call when left trigger is pressed
  50980. * @param callback defines the callback to use
  50981. */
  50982. onlefttriggerchanged(callback: (value: number) => void): void;
  50983. /**
  50984. * Defines the callback to call when right trigger is pressed
  50985. * @param callback defines the callback to use
  50986. */
  50987. onrighttriggerchanged(callback: (value: number) => void): void;
  50988. /**
  50989. * Gets the left trigger value
  50990. */
  50991. get leftTrigger(): number;
  50992. /**
  50993. * Sets the left trigger value
  50994. */
  50995. set leftTrigger(newValue: number);
  50996. /**
  50997. * Gets the right trigger value
  50998. */
  50999. get rightTrigger(): number;
  51000. /**
  51001. * Sets the right trigger value
  51002. */
  51003. set rightTrigger(newValue: number);
  51004. /**
  51005. * Defines the callback to call when a button is pressed
  51006. * @param callback defines the callback to use
  51007. */
  51008. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  51009. /**
  51010. * Defines the callback to call when a button is released
  51011. * @param callback defines the callback to use
  51012. */
  51013. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  51014. /**
  51015. * Defines the callback to call when a pad is pressed
  51016. * @param callback defines the callback to use
  51017. */
  51018. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51019. /**
  51020. * Defines the callback to call when a pad is released
  51021. * @param callback defines the callback to use
  51022. */
  51023. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51024. private _setButtonValue;
  51025. private _setDPadValue;
  51026. /**
  51027. * Gets the value of the `A` button
  51028. */
  51029. get buttonA(): number;
  51030. /**
  51031. * Sets the value of the `A` button
  51032. */
  51033. set buttonA(value: number);
  51034. /**
  51035. * Gets the value of the `B` button
  51036. */
  51037. get buttonB(): number;
  51038. /**
  51039. * Sets the value of the `B` button
  51040. */
  51041. set buttonB(value: number);
  51042. /**
  51043. * Gets the value of the `X` button
  51044. */
  51045. get buttonX(): number;
  51046. /**
  51047. * Sets the value of the `X` button
  51048. */
  51049. set buttonX(value: number);
  51050. /**
  51051. * Gets the value of the `Y` button
  51052. */
  51053. get buttonY(): number;
  51054. /**
  51055. * Sets the value of the `Y` button
  51056. */
  51057. set buttonY(value: number);
  51058. /**
  51059. * Gets the value of the `Start` button
  51060. */
  51061. get buttonStart(): number;
  51062. /**
  51063. * Sets the value of the `Start` button
  51064. */
  51065. set buttonStart(value: number);
  51066. /**
  51067. * Gets the value of the `Back` button
  51068. */
  51069. get buttonBack(): number;
  51070. /**
  51071. * Sets the value of the `Back` button
  51072. */
  51073. set buttonBack(value: number);
  51074. /**
  51075. * Gets the value of the `Left` button
  51076. */
  51077. get buttonLB(): number;
  51078. /**
  51079. * Sets the value of the `Left` button
  51080. */
  51081. set buttonLB(value: number);
  51082. /**
  51083. * Gets the value of the `Right` button
  51084. */
  51085. get buttonRB(): number;
  51086. /**
  51087. * Sets the value of the `Right` button
  51088. */
  51089. set buttonRB(value: number);
  51090. /**
  51091. * Gets the value of the Left joystick
  51092. */
  51093. get buttonLeftStick(): number;
  51094. /**
  51095. * Sets the value of the Left joystick
  51096. */
  51097. set buttonLeftStick(value: number);
  51098. /**
  51099. * Gets the value of the Right joystick
  51100. */
  51101. get buttonRightStick(): number;
  51102. /**
  51103. * Sets the value of the Right joystick
  51104. */
  51105. set buttonRightStick(value: number);
  51106. /**
  51107. * Gets the value of D-pad up
  51108. */
  51109. get dPadUp(): number;
  51110. /**
  51111. * Sets the value of D-pad up
  51112. */
  51113. set dPadUp(value: number);
  51114. /**
  51115. * Gets the value of D-pad down
  51116. */
  51117. get dPadDown(): number;
  51118. /**
  51119. * Sets the value of D-pad down
  51120. */
  51121. set dPadDown(value: number);
  51122. /**
  51123. * Gets the value of D-pad left
  51124. */
  51125. get dPadLeft(): number;
  51126. /**
  51127. * Sets the value of D-pad left
  51128. */
  51129. set dPadLeft(value: number);
  51130. /**
  51131. * Gets the value of D-pad right
  51132. */
  51133. get dPadRight(): number;
  51134. /**
  51135. * Sets the value of D-pad right
  51136. */
  51137. set dPadRight(value: number);
  51138. /**
  51139. * Force the gamepad to synchronize with device values
  51140. */
  51141. update(): void;
  51142. /**
  51143. * Disposes the gamepad
  51144. */
  51145. dispose(): void;
  51146. }
  51147. }
  51148. declare module "babylonjs/Gamepads/dualShockGamepad" {
  51149. import { Observable } from "babylonjs/Misc/observable";
  51150. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51151. /**
  51152. * Defines supported buttons for DualShock compatible gamepads
  51153. */
  51154. export enum DualShockButton {
  51155. /** Cross */
  51156. Cross = 0,
  51157. /** Circle */
  51158. Circle = 1,
  51159. /** Square */
  51160. Square = 2,
  51161. /** Triangle */
  51162. Triangle = 3,
  51163. /** L1 */
  51164. L1 = 4,
  51165. /** R1 */
  51166. R1 = 5,
  51167. /** Share */
  51168. Share = 8,
  51169. /** Options */
  51170. Options = 9,
  51171. /** Left stick */
  51172. LeftStick = 10,
  51173. /** Right stick */
  51174. RightStick = 11
  51175. }
  51176. /** Defines values for DualShock DPad */
  51177. export enum DualShockDpad {
  51178. /** Up */
  51179. Up = 12,
  51180. /** Down */
  51181. Down = 13,
  51182. /** Left */
  51183. Left = 14,
  51184. /** Right */
  51185. Right = 15
  51186. }
  51187. /**
  51188. * Defines a DualShock gamepad
  51189. */
  51190. export class DualShockPad extends Gamepad {
  51191. private _leftTrigger;
  51192. private _rightTrigger;
  51193. private _onlefttriggerchanged;
  51194. private _onrighttriggerchanged;
  51195. private _onbuttondown;
  51196. private _onbuttonup;
  51197. private _ondpaddown;
  51198. private _ondpadup;
  51199. /** Observable raised when a button is pressed */
  51200. onButtonDownObservable: Observable<DualShockButton>;
  51201. /** Observable raised when a button is released */
  51202. onButtonUpObservable: Observable<DualShockButton>;
  51203. /** Observable raised when a pad is pressed */
  51204. onPadDownObservable: Observable<DualShockDpad>;
  51205. /** Observable raised when a pad is released */
  51206. onPadUpObservable: Observable<DualShockDpad>;
  51207. private _buttonCross;
  51208. private _buttonCircle;
  51209. private _buttonSquare;
  51210. private _buttonTriangle;
  51211. private _buttonShare;
  51212. private _buttonOptions;
  51213. private _buttonL1;
  51214. private _buttonR1;
  51215. private _buttonLeftStick;
  51216. private _buttonRightStick;
  51217. private _dPadUp;
  51218. private _dPadDown;
  51219. private _dPadLeft;
  51220. private _dPadRight;
  51221. /**
  51222. * Creates a new DualShock gamepad object
  51223. * @param id defines the id of this gamepad
  51224. * @param index defines its index
  51225. * @param gamepad defines the internal HTML gamepad object
  51226. */
  51227. constructor(id: string, index: number, gamepad: any);
  51228. /**
  51229. * Defines the callback to call when left trigger is pressed
  51230. * @param callback defines the callback to use
  51231. */
  51232. onlefttriggerchanged(callback: (value: number) => void): void;
  51233. /**
  51234. * Defines the callback to call when right trigger is pressed
  51235. * @param callback defines the callback to use
  51236. */
  51237. onrighttriggerchanged(callback: (value: number) => void): void;
  51238. /**
  51239. * Gets the left trigger value
  51240. */
  51241. get leftTrigger(): number;
  51242. /**
  51243. * Sets the left trigger value
  51244. */
  51245. set leftTrigger(newValue: number);
  51246. /**
  51247. * Gets the right trigger value
  51248. */
  51249. get rightTrigger(): number;
  51250. /**
  51251. * Sets the right trigger value
  51252. */
  51253. set rightTrigger(newValue: number);
  51254. /**
  51255. * Defines the callback to call when a button is pressed
  51256. * @param callback defines the callback to use
  51257. */
  51258. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  51259. /**
  51260. * Defines the callback to call when a button is released
  51261. * @param callback defines the callback to use
  51262. */
  51263. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  51264. /**
  51265. * Defines the callback to call when a pad is pressed
  51266. * @param callback defines the callback to use
  51267. */
  51268. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  51269. /**
  51270. * Defines the callback to call when a pad is released
  51271. * @param callback defines the callback to use
  51272. */
  51273. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  51274. private _setButtonValue;
  51275. private _setDPadValue;
  51276. /**
  51277. * Gets the value of the `Cross` button
  51278. */
  51279. get buttonCross(): number;
  51280. /**
  51281. * Sets the value of the `Cross` button
  51282. */
  51283. set buttonCross(value: number);
  51284. /**
  51285. * Gets the value of the `Circle` button
  51286. */
  51287. get buttonCircle(): number;
  51288. /**
  51289. * Sets the value of the `Circle` button
  51290. */
  51291. set buttonCircle(value: number);
  51292. /**
  51293. * Gets the value of the `Square` button
  51294. */
  51295. get buttonSquare(): number;
  51296. /**
  51297. * Sets the value of the `Square` button
  51298. */
  51299. set buttonSquare(value: number);
  51300. /**
  51301. * Gets the value of the `Triangle` button
  51302. */
  51303. get buttonTriangle(): number;
  51304. /**
  51305. * Sets the value of the `Triangle` button
  51306. */
  51307. set buttonTriangle(value: number);
  51308. /**
  51309. * Gets the value of the `Options` button
  51310. */
  51311. get buttonOptions(): number;
  51312. /**
  51313. * Sets the value of the `Options` button
  51314. */
  51315. set buttonOptions(value: number);
  51316. /**
  51317. * Gets the value of the `Share` button
  51318. */
  51319. get buttonShare(): number;
  51320. /**
  51321. * Sets the value of the `Share` button
  51322. */
  51323. set buttonShare(value: number);
  51324. /**
  51325. * Gets the value of the `L1` button
  51326. */
  51327. get buttonL1(): number;
  51328. /**
  51329. * Sets the value of the `L1` button
  51330. */
  51331. set buttonL1(value: number);
  51332. /**
  51333. * Gets the value of the `R1` button
  51334. */
  51335. get buttonR1(): number;
  51336. /**
  51337. * Sets the value of the `R1` button
  51338. */
  51339. set buttonR1(value: number);
  51340. /**
  51341. * Gets the value of the Left joystick
  51342. */
  51343. get buttonLeftStick(): number;
  51344. /**
  51345. * Sets the value of the Left joystick
  51346. */
  51347. set buttonLeftStick(value: number);
  51348. /**
  51349. * Gets the value of the Right joystick
  51350. */
  51351. get buttonRightStick(): number;
  51352. /**
  51353. * Sets the value of the Right joystick
  51354. */
  51355. set buttonRightStick(value: number);
  51356. /**
  51357. * Gets the value of D-pad up
  51358. */
  51359. get dPadUp(): number;
  51360. /**
  51361. * Sets the value of D-pad up
  51362. */
  51363. set dPadUp(value: number);
  51364. /**
  51365. * Gets the value of D-pad down
  51366. */
  51367. get dPadDown(): number;
  51368. /**
  51369. * Sets the value of D-pad down
  51370. */
  51371. set dPadDown(value: number);
  51372. /**
  51373. * Gets the value of D-pad left
  51374. */
  51375. get dPadLeft(): number;
  51376. /**
  51377. * Sets the value of D-pad left
  51378. */
  51379. set dPadLeft(value: number);
  51380. /**
  51381. * Gets the value of D-pad right
  51382. */
  51383. get dPadRight(): number;
  51384. /**
  51385. * Sets the value of D-pad right
  51386. */
  51387. set dPadRight(value: number);
  51388. /**
  51389. * Force the gamepad to synchronize with device values
  51390. */
  51391. update(): void;
  51392. /**
  51393. * Disposes the gamepad
  51394. */
  51395. dispose(): void;
  51396. }
  51397. }
  51398. declare module "babylonjs/Gamepads/gamepadManager" {
  51399. import { Observable } from "babylonjs/Misc/observable";
  51400. import { Nullable } from "babylonjs/types";
  51401. import { Scene } from "babylonjs/scene";
  51402. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51403. /**
  51404. * Manager for handling gamepads
  51405. */
  51406. export class GamepadManager {
  51407. private _scene?;
  51408. private _babylonGamepads;
  51409. private _oneGamepadConnected;
  51410. /** @hidden */
  51411. _isMonitoring: boolean;
  51412. private _gamepadEventSupported;
  51413. private _gamepadSupport?;
  51414. /**
  51415. * observable to be triggered when the gamepad controller has been connected
  51416. */
  51417. onGamepadConnectedObservable: Observable<Gamepad>;
  51418. /**
  51419. * observable to be triggered when the gamepad controller has been disconnected
  51420. */
  51421. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51422. private _onGamepadConnectedEvent;
  51423. private _onGamepadDisconnectedEvent;
  51424. /**
  51425. * Initializes the gamepad manager
  51426. * @param _scene BabylonJS scene
  51427. */
  51428. constructor(_scene?: Scene | undefined);
  51429. /**
  51430. * The gamepads in the game pad manager
  51431. */
  51432. get gamepads(): Gamepad[];
  51433. /**
  51434. * Get the gamepad controllers based on type
  51435. * @param type The type of gamepad controller
  51436. * @returns Nullable gamepad
  51437. */
  51438. getGamepadByType(type?: number): Nullable<Gamepad>;
  51439. /**
  51440. * Disposes the gamepad manager
  51441. */
  51442. dispose(): void;
  51443. private _addNewGamepad;
  51444. private _startMonitoringGamepads;
  51445. private _stopMonitoringGamepads;
  51446. /** @hidden */
  51447. _checkGamepadsStatus(): void;
  51448. private _updateGamepadObjects;
  51449. }
  51450. }
  51451. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51452. import { Nullable } from "babylonjs/types";
  51453. import { Scene } from "babylonjs/scene";
  51454. import { ISceneComponent } from "babylonjs/sceneComponent";
  51455. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51456. module "babylonjs/scene" {
  51457. interface Scene {
  51458. /** @hidden */
  51459. _gamepadManager: Nullable<GamepadManager>;
  51460. /**
  51461. * Gets the gamepad manager associated with the scene
  51462. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51463. */
  51464. gamepadManager: GamepadManager;
  51465. }
  51466. }
  51467. module "babylonjs/Cameras/freeCameraInputsManager" {
  51468. /**
  51469. * Interface representing a free camera inputs manager
  51470. */
  51471. interface FreeCameraInputsManager {
  51472. /**
  51473. * Adds gamepad input support to the FreeCameraInputsManager.
  51474. * @returns the FreeCameraInputsManager
  51475. */
  51476. addGamepad(): FreeCameraInputsManager;
  51477. }
  51478. }
  51479. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51480. /**
  51481. * Interface representing an arc rotate camera inputs manager
  51482. */
  51483. interface ArcRotateCameraInputsManager {
  51484. /**
  51485. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51486. * @returns the camera inputs manager
  51487. */
  51488. addGamepad(): ArcRotateCameraInputsManager;
  51489. }
  51490. }
  51491. /**
  51492. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51493. */
  51494. export class GamepadSystemSceneComponent implements ISceneComponent {
  51495. /**
  51496. * The component name helpfull to identify the component in the list of scene components.
  51497. */
  51498. readonly name: string;
  51499. /**
  51500. * The scene the component belongs to.
  51501. */
  51502. scene: Scene;
  51503. /**
  51504. * Creates a new instance of the component for the given scene
  51505. * @param scene Defines the scene to register the component in
  51506. */
  51507. constructor(scene: Scene);
  51508. /**
  51509. * Registers the component in a given scene
  51510. */
  51511. register(): void;
  51512. /**
  51513. * Rebuilds the elements related to this component in case of
  51514. * context lost for instance.
  51515. */
  51516. rebuild(): void;
  51517. /**
  51518. * Disposes the component and the associated ressources
  51519. */
  51520. dispose(): void;
  51521. private _beforeCameraUpdate;
  51522. }
  51523. }
  51524. declare module "babylonjs/Cameras/universalCamera" {
  51525. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51526. import { Scene } from "babylonjs/scene";
  51527. import { Vector3 } from "babylonjs/Maths/math.vector";
  51528. import "babylonjs/Gamepads/gamepadSceneComponent";
  51529. /**
  51530. * 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,
  51531. * which still works and will still be found in many Playgrounds.
  51532. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51533. */
  51534. export class UniversalCamera extends TouchCamera {
  51535. /**
  51536. * Defines the gamepad rotation sensiblity.
  51537. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51538. */
  51539. get gamepadAngularSensibility(): number;
  51540. set gamepadAngularSensibility(value: number);
  51541. /**
  51542. * Defines the gamepad move sensiblity.
  51543. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51544. */
  51545. get gamepadMoveSensibility(): number;
  51546. set gamepadMoveSensibility(value: number);
  51547. /**
  51548. * 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,
  51549. * which still works and will still be found in many Playgrounds.
  51550. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51551. * @param name Define the name of the camera in the scene
  51552. * @param position Define the start position of the camera in the scene
  51553. * @param scene Define the scene the camera belongs to
  51554. */
  51555. constructor(name: string, position: Vector3, scene: Scene);
  51556. /**
  51557. * Gets the current object class name.
  51558. * @return the class name
  51559. */
  51560. getClassName(): string;
  51561. }
  51562. }
  51563. declare module "babylonjs/Cameras/gamepadCamera" {
  51564. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51565. import { Scene } from "babylonjs/scene";
  51566. import { Vector3 } from "babylonjs/Maths/math.vector";
  51567. /**
  51568. * This represents a FPS type of camera. This is only here for back compat purpose.
  51569. * Please use the UniversalCamera instead as both are identical.
  51570. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51571. */
  51572. export class GamepadCamera extends UniversalCamera {
  51573. /**
  51574. * Instantiates a new Gamepad Camera
  51575. * This represents a FPS type of camera. This is only here for back compat purpose.
  51576. * Please use the UniversalCamera instead as both are identical.
  51577. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51578. * @param name Define the name of the camera in the scene
  51579. * @param position Define the start position of the camera in the scene
  51580. * @param scene Define the scene the camera belongs to
  51581. */
  51582. constructor(name: string, position: Vector3, scene: Scene);
  51583. /**
  51584. * Gets the current object class name.
  51585. * @return the class name
  51586. */
  51587. getClassName(): string;
  51588. }
  51589. }
  51590. declare module "babylonjs/Shaders/pass.fragment" {
  51591. /** @hidden */
  51592. export var passPixelShader: {
  51593. name: string;
  51594. shader: string;
  51595. };
  51596. }
  51597. declare module "babylonjs/Shaders/passCube.fragment" {
  51598. /** @hidden */
  51599. export var passCubePixelShader: {
  51600. name: string;
  51601. shader: string;
  51602. };
  51603. }
  51604. declare module "babylonjs/PostProcesses/passPostProcess" {
  51605. import { Nullable } from "babylonjs/types";
  51606. import { Camera } from "babylonjs/Cameras/camera";
  51607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51608. import { Engine } from "babylonjs/Engines/engine";
  51609. import "babylonjs/Shaders/pass.fragment";
  51610. import "babylonjs/Shaders/passCube.fragment";
  51611. import { Scene } from "babylonjs/scene";
  51612. /**
  51613. * PassPostProcess which produces an output the same as it's input
  51614. */
  51615. export class PassPostProcess extends PostProcess {
  51616. /**
  51617. * Gets a string identifying the name of the class
  51618. * @returns "PassPostProcess" string
  51619. */
  51620. getClassName(): string;
  51621. /**
  51622. * Creates the PassPostProcess
  51623. * @param name The name of the effect.
  51624. * @param options The required width/height ratio to downsize to before computing the render pass.
  51625. * @param camera The camera to apply the render pass to.
  51626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51627. * @param engine The engine which the post process will be applied. (default: current engine)
  51628. * @param reusable If the post process can be reused on the same frame. (default: false)
  51629. * @param textureType The type of texture to be used when performing the post processing.
  51630. * @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)
  51631. */
  51632. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51633. /** @hidden */
  51634. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51635. }
  51636. /**
  51637. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51638. */
  51639. export class PassCubePostProcess extends PostProcess {
  51640. private _face;
  51641. /**
  51642. * Gets or sets the cube face to display.
  51643. * * 0 is +X
  51644. * * 1 is -X
  51645. * * 2 is +Y
  51646. * * 3 is -Y
  51647. * * 4 is +Z
  51648. * * 5 is -Z
  51649. */
  51650. get face(): number;
  51651. set face(value: number);
  51652. /**
  51653. * Gets a string identifying the name of the class
  51654. * @returns "PassCubePostProcess" string
  51655. */
  51656. getClassName(): string;
  51657. /**
  51658. * Creates the PassCubePostProcess
  51659. * @param name The name of the effect.
  51660. * @param options The required width/height ratio to downsize to before computing the render pass.
  51661. * @param camera The camera to apply the render pass to.
  51662. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51663. * @param engine The engine which the post process will be applied. (default: current engine)
  51664. * @param reusable If the post process can be reused on the same frame. (default: false)
  51665. * @param textureType The type of texture to be used when performing the post processing.
  51666. * @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)
  51667. */
  51668. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51669. /** @hidden */
  51670. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51671. }
  51672. }
  51673. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51674. /** @hidden */
  51675. export var anaglyphPixelShader: {
  51676. name: string;
  51677. shader: string;
  51678. };
  51679. }
  51680. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51681. import { Engine } from "babylonjs/Engines/engine";
  51682. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51683. import { Camera } from "babylonjs/Cameras/camera";
  51684. import "babylonjs/Shaders/anaglyph.fragment";
  51685. /**
  51686. * Postprocess used to generate anaglyphic rendering
  51687. */
  51688. export class AnaglyphPostProcess extends PostProcess {
  51689. private _passedProcess;
  51690. /**
  51691. * Gets a string identifying the name of the class
  51692. * @returns "AnaglyphPostProcess" string
  51693. */
  51694. getClassName(): string;
  51695. /**
  51696. * Creates a new AnaglyphPostProcess
  51697. * @param name defines postprocess name
  51698. * @param options defines creation options or target ratio scale
  51699. * @param rigCameras defines cameras using this postprocess
  51700. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51701. * @param engine defines hosting engine
  51702. * @param reusable defines if the postprocess will be reused multiple times per frame
  51703. */
  51704. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51705. }
  51706. }
  51707. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51708. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51709. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51710. import { Scene } from "babylonjs/scene";
  51711. import { Vector3 } from "babylonjs/Maths/math.vector";
  51712. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51713. /**
  51714. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51715. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51716. */
  51717. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51718. /**
  51719. * Creates a new AnaglyphArcRotateCamera
  51720. * @param name defines camera name
  51721. * @param alpha defines alpha angle (in radians)
  51722. * @param beta defines beta angle (in radians)
  51723. * @param radius defines radius
  51724. * @param target defines camera target
  51725. * @param interaxialDistance defines distance between each color axis
  51726. * @param scene defines the hosting scene
  51727. */
  51728. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51729. /**
  51730. * Gets camera class name
  51731. * @returns AnaglyphArcRotateCamera
  51732. */
  51733. getClassName(): string;
  51734. }
  51735. }
  51736. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51737. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51738. import { Scene } from "babylonjs/scene";
  51739. import { Vector3 } from "babylonjs/Maths/math.vector";
  51740. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51741. /**
  51742. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51743. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51744. */
  51745. export class AnaglyphFreeCamera extends FreeCamera {
  51746. /**
  51747. * Creates a new AnaglyphFreeCamera
  51748. * @param name defines camera name
  51749. * @param position defines initial position
  51750. * @param interaxialDistance defines distance between each color axis
  51751. * @param scene defines the hosting scene
  51752. */
  51753. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51754. /**
  51755. * Gets camera class name
  51756. * @returns AnaglyphFreeCamera
  51757. */
  51758. getClassName(): string;
  51759. }
  51760. }
  51761. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51762. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51763. import { Scene } from "babylonjs/scene";
  51764. import { Vector3 } from "babylonjs/Maths/math.vector";
  51765. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51766. /**
  51767. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51768. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51769. */
  51770. export class AnaglyphGamepadCamera extends GamepadCamera {
  51771. /**
  51772. * Creates a new AnaglyphGamepadCamera
  51773. * @param name defines camera name
  51774. * @param position defines initial position
  51775. * @param interaxialDistance defines distance between each color axis
  51776. * @param scene defines the hosting scene
  51777. */
  51778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51779. /**
  51780. * Gets camera class name
  51781. * @returns AnaglyphGamepadCamera
  51782. */
  51783. getClassName(): string;
  51784. }
  51785. }
  51786. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51787. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51788. import { Scene } from "babylonjs/scene";
  51789. import { Vector3 } from "babylonjs/Maths/math.vector";
  51790. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51791. /**
  51792. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51793. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51794. */
  51795. export class AnaglyphUniversalCamera extends UniversalCamera {
  51796. /**
  51797. * Creates a new AnaglyphUniversalCamera
  51798. * @param name defines camera name
  51799. * @param position defines initial position
  51800. * @param interaxialDistance defines distance between each color axis
  51801. * @param scene defines the hosting scene
  51802. */
  51803. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51804. /**
  51805. * Gets camera class name
  51806. * @returns AnaglyphUniversalCamera
  51807. */
  51808. getClassName(): string;
  51809. }
  51810. }
  51811. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51812. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51813. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51814. import { Scene } from "babylonjs/scene";
  51815. import { Vector3 } from "babylonjs/Maths/math.vector";
  51816. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51817. /**
  51818. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51819. * @see https://doc.babylonjs.com/features/cameras
  51820. */
  51821. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51822. /**
  51823. * Creates a new StereoscopicArcRotateCamera
  51824. * @param name defines camera name
  51825. * @param alpha defines alpha angle (in radians)
  51826. * @param beta defines beta angle (in radians)
  51827. * @param radius defines radius
  51828. * @param target defines camera target
  51829. * @param interaxialDistance defines distance between each color axis
  51830. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51831. * @param scene defines the hosting scene
  51832. */
  51833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51834. /**
  51835. * Gets camera class name
  51836. * @returns StereoscopicArcRotateCamera
  51837. */
  51838. getClassName(): string;
  51839. }
  51840. }
  51841. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51842. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51843. import { Scene } from "babylonjs/scene";
  51844. import { Vector3 } from "babylonjs/Maths/math.vector";
  51845. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51846. /**
  51847. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51848. * @see https://doc.babylonjs.com/features/cameras
  51849. */
  51850. export class StereoscopicFreeCamera extends FreeCamera {
  51851. /**
  51852. * Creates a new StereoscopicFreeCamera
  51853. * @param name defines camera name
  51854. * @param position defines initial position
  51855. * @param interaxialDistance defines distance between each color axis
  51856. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51857. * @param scene defines the hosting scene
  51858. */
  51859. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51860. /**
  51861. * Gets camera class name
  51862. * @returns StereoscopicFreeCamera
  51863. */
  51864. getClassName(): string;
  51865. }
  51866. }
  51867. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51868. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51869. import { Scene } from "babylonjs/scene";
  51870. import { Vector3 } from "babylonjs/Maths/math.vector";
  51871. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51872. /**
  51873. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51874. * @see https://doc.babylonjs.com/features/cameras
  51875. */
  51876. export class StereoscopicGamepadCamera extends GamepadCamera {
  51877. /**
  51878. * Creates a new StereoscopicGamepadCamera
  51879. * @param name defines camera name
  51880. * @param position defines initial position
  51881. * @param interaxialDistance defines distance between each color axis
  51882. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51883. * @param scene defines the hosting scene
  51884. */
  51885. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51886. /**
  51887. * Gets camera class name
  51888. * @returns StereoscopicGamepadCamera
  51889. */
  51890. getClassName(): string;
  51891. }
  51892. }
  51893. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51894. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51895. import { Scene } from "babylonjs/scene";
  51896. import { Vector3 } from "babylonjs/Maths/math.vector";
  51897. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51898. /**
  51899. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51900. * @see https://doc.babylonjs.com/features/cameras
  51901. */
  51902. export class StereoscopicUniversalCamera extends UniversalCamera {
  51903. /**
  51904. * Creates a new StereoscopicUniversalCamera
  51905. * @param name defines camera name
  51906. * @param position defines initial position
  51907. * @param interaxialDistance defines distance between each color axis
  51908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51909. * @param scene defines the hosting scene
  51910. */
  51911. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51912. /**
  51913. * Gets camera class name
  51914. * @returns StereoscopicUniversalCamera
  51915. */
  51916. getClassName(): string;
  51917. }
  51918. }
  51919. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51920. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51921. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51922. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51923. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51924. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51925. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51926. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51927. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51928. }
  51929. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51930. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51931. import { Scene } from "babylonjs/scene";
  51932. import { Vector3 } from "babylonjs/Maths/math.vector";
  51933. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51934. /**
  51935. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51936. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51937. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51938. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51939. */
  51940. export class VirtualJoysticksCamera extends FreeCamera {
  51941. /**
  51942. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51943. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51944. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51945. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51946. * @param name Define the name of the camera in the scene
  51947. * @param position Define the start position of the camera in the scene
  51948. * @param scene Define the scene the camera belongs to
  51949. */
  51950. constructor(name: string, position: Vector3, scene: Scene);
  51951. /**
  51952. * Gets the current object class name.
  51953. * @return the class name
  51954. */
  51955. getClassName(): string;
  51956. }
  51957. }
  51958. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51959. import { Matrix } from "babylonjs/Maths/math.vector";
  51960. /**
  51961. * This represents all the required metrics to create a VR camera.
  51962. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51963. */
  51964. export class VRCameraMetrics {
  51965. /**
  51966. * Define the horizontal resolution off the screen.
  51967. */
  51968. hResolution: number;
  51969. /**
  51970. * Define the vertical resolution off the screen.
  51971. */
  51972. vResolution: number;
  51973. /**
  51974. * Define the horizontal screen size.
  51975. */
  51976. hScreenSize: number;
  51977. /**
  51978. * Define the vertical screen size.
  51979. */
  51980. vScreenSize: number;
  51981. /**
  51982. * Define the vertical screen center position.
  51983. */
  51984. vScreenCenter: number;
  51985. /**
  51986. * Define the distance of the eyes to the screen.
  51987. */
  51988. eyeToScreenDistance: number;
  51989. /**
  51990. * Define the distance between both lenses
  51991. */
  51992. lensSeparationDistance: number;
  51993. /**
  51994. * Define the distance between both viewer's eyes.
  51995. */
  51996. interpupillaryDistance: number;
  51997. /**
  51998. * Define the distortion factor of the VR postprocess.
  51999. * Please, touch with care.
  52000. */
  52001. distortionK: number[];
  52002. /**
  52003. * Define the chromatic aberration correction factors for the VR post process.
  52004. */
  52005. chromaAbCorrection: number[];
  52006. /**
  52007. * Define the scale factor of the post process.
  52008. * The smaller the better but the slower.
  52009. */
  52010. postProcessScaleFactor: number;
  52011. /**
  52012. * Define an offset for the lens center.
  52013. */
  52014. lensCenterOffset: number;
  52015. /**
  52016. * Define if the current vr camera should compensate the distortion of the lense or not.
  52017. */
  52018. compensateDistortion: boolean;
  52019. /**
  52020. * Defines if multiview should be enabled when rendering (Default: false)
  52021. */
  52022. multiviewEnabled: boolean;
  52023. /**
  52024. * Gets the rendering aspect ratio based on the provided resolutions.
  52025. */
  52026. get aspectRatio(): number;
  52027. /**
  52028. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52029. */
  52030. get aspectRatioFov(): number;
  52031. /**
  52032. * @hidden
  52033. */
  52034. get leftHMatrix(): Matrix;
  52035. /**
  52036. * @hidden
  52037. */
  52038. get rightHMatrix(): Matrix;
  52039. /**
  52040. * @hidden
  52041. */
  52042. get leftPreViewMatrix(): Matrix;
  52043. /**
  52044. * @hidden
  52045. */
  52046. get rightPreViewMatrix(): Matrix;
  52047. /**
  52048. * Get the default VRMetrics based on the most generic setup.
  52049. * @returns the default vr metrics
  52050. */
  52051. static GetDefault(): VRCameraMetrics;
  52052. }
  52053. }
  52054. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  52055. /** @hidden */
  52056. export var vrDistortionCorrectionPixelShader: {
  52057. name: string;
  52058. shader: string;
  52059. };
  52060. }
  52061. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  52062. import { Camera } from "babylonjs/Cameras/camera";
  52063. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52064. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  52065. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  52066. /**
  52067. * VRDistortionCorrectionPostProcess used for mobile VR
  52068. */
  52069. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52070. private _isRightEye;
  52071. private _distortionFactors;
  52072. private _postProcessScaleFactor;
  52073. private _lensCenterOffset;
  52074. private _scaleIn;
  52075. private _scaleFactor;
  52076. private _lensCenter;
  52077. /**
  52078. * Gets a string identifying the name of the class
  52079. * @returns "VRDistortionCorrectionPostProcess" string
  52080. */
  52081. getClassName(): string;
  52082. /**
  52083. * Initializes the VRDistortionCorrectionPostProcess
  52084. * @param name The name of the effect.
  52085. * @param camera The camera to apply the render pass to.
  52086. * @param isRightEye If this is for the right eye distortion
  52087. * @param vrMetrics All the required metrics for the VR camera
  52088. */
  52089. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52090. }
  52091. }
  52092. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  52093. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  52094. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  52095. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52096. import { Scene } from "babylonjs/scene";
  52097. import { Vector3 } from "babylonjs/Maths/math.vector";
  52098. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  52099. import "babylonjs/Cameras/RigModes/vrRigMode";
  52100. /**
  52101. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52102. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52103. */
  52104. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52105. /**
  52106. * Creates a new VRDeviceOrientationArcRotateCamera
  52107. * @param name defines camera name
  52108. * @param alpha defines the camera rotation along the logitudinal axis
  52109. * @param beta defines the camera rotation along the latitudinal axis
  52110. * @param radius defines the camera distance from its target
  52111. * @param target defines the camera target
  52112. * @param scene defines the scene the camera belongs to
  52113. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52114. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52115. */
  52116. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52117. /**
  52118. * Gets camera class name
  52119. * @returns VRDeviceOrientationArcRotateCamera
  52120. */
  52121. getClassName(): string;
  52122. }
  52123. }
  52124. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  52125. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  52126. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52127. import { Scene } from "babylonjs/scene";
  52128. import { Vector3 } from "babylonjs/Maths/math.vector";
  52129. import "babylonjs/Cameras/RigModes/vrRigMode";
  52130. /**
  52131. * Camera used to simulate VR rendering (based on FreeCamera)
  52132. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52133. */
  52134. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52135. /**
  52136. * Creates a new VRDeviceOrientationFreeCamera
  52137. * @param name defines camera name
  52138. * @param position defines the start position of the camera
  52139. * @param scene defines the scene the camera belongs to
  52140. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52141. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52142. */
  52143. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52144. /**
  52145. * Gets camera class name
  52146. * @returns VRDeviceOrientationFreeCamera
  52147. */
  52148. getClassName(): string;
  52149. }
  52150. }
  52151. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  52152. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52153. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  52154. import { Scene } from "babylonjs/scene";
  52155. import { Vector3 } from "babylonjs/Maths/math.vector";
  52156. import "babylonjs/Gamepads/gamepadSceneComponent";
  52157. /**
  52158. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52159. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52160. */
  52161. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52162. /**
  52163. * Creates a new VRDeviceOrientationGamepadCamera
  52164. * @param name defines camera name
  52165. * @param position defines the start position of the camera
  52166. * @param scene defines the scene the camera belongs to
  52167. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52168. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52169. */
  52170. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52171. /**
  52172. * Gets camera class name
  52173. * @returns VRDeviceOrientationGamepadCamera
  52174. */
  52175. getClassName(): string;
  52176. }
  52177. }
  52178. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  52179. import { Scene } from "babylonjs/scene";
  52180. import { Texture } from "babylonjs/Materials/Textures/texture";
  52181. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  52182. /**
  52183. * A class extending Texture allowing drawing on a texture
  52184. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52185. */
  52186. export class DynamicTexture extends Texture {
  52187. private _generateMipMaps;
  52188. private _canvas;
  52189. private _context;
  52190. /**
  52191. * Creates a DynamicTexture
  52192. * @param name defines the name of the texture
  52193. * @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
  52194. * @param scene defines the scene where you want the texture
  52195. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52196. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52197. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52198. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52199. */
  52200. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52201. /**
  52202. * Get the current class name of the texture useful for serialization or dynamic coding.
  52203. * @returns "DynamicTexture"
  52204. */
  52205. getClassName(): string;
  52206. /**
  52207. * Gets the current state of canRescale
  52208. */
  52209. get canRescale(): boolean;
  52210. private _recreate;
  52211. /**
  52212. * Scales the texture
  52213. * @param ratio the scale factor to apply to both width and height
  52214. */
  52215. scale(ratio: number): void;
  52216. /**
  52217. * Resizes the texture
  52218. * @param width the new width
  52219. * @param height the new height
  52220. */
  52221. scaleTo(width: number, height: number): void;
  52222. /**
  52223. * Gets the context of the canvas used by the texture
  52224. * @returns the canvas context of the dynamic texture
  52225. */
  52226. getContext(): CanvasRenderingContext2D;
  52227. /**
  52228. * Clears the texture
  52229. */
  52230. clear(): void;
  52231. /**
  52232. * Updates the texture
  52233. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52234. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52235. */
  52236. update(invertY?: boolean, premulAlpha?: boolean): void;
  52237. /**
  52238. * Draws text onto the texture
  52239. * @param text defines the text to be drawn
  52240. * @param x defines the placement of the text from the left
  52241. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52242. * @param font defines the font to be used with font-style, font-size, font-name
  52243. * @param color defines the color used for the text
  52244. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52245. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52246. * @param update defines whether texture is immediately update (default is true)
  52247. */
  52248. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52249. /**
  52250. * Clones the texture
  52251. * @returns the clone of the texture.
  52252. */
  52253. clone(): DynamicTexture;
  52254. /**
  52255. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52256. * @returns a serialized dynamic texture object
  52257. */
  52258. serialize(): any;
  52259. private _IsCanvasElement;
  52260. /** @hidden */
  52261. _rebuild(): void;
  52262. }
  52263. }
  52264. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  52265. import { Scene } from "babylonjs/scene";
  52266. import { Color3 } from "babylonjs/Maths/math.color";
  52267. import { Mesh } from "babylonjs/Meshes/mesh";
  52268. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52269. import { Nullable } from "babylonjs/types";
  52270. /**
  52271. * Class containing static functions to help procedurally build meshes
  52272. */
  52273. export class GroundBuilder {
  52274. /**
  52275. * Creates a ground mesh
  52276. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52277. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52279. * @param name defines the name of the mesh
  52280. * @param options defines the options used to create the mesh
  52281. * @param scene defines the hosting scene
  52282. * @returns the ground mesh
  52283. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52284. */
  52285. static CreateGround(name: string, options: {
  52286. width?: number;
  52287. height?: number;
  52288. subdivisions?: number;
  52289. subdivisionsX?: number;
  52290. subdivisionsY?: number;
  52291. updatable?: boolean;
  52292. }, scene: any): Mesh;
  52293. /**
  52294. * Creates a tiled ground mesh
  52295. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52296. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52297. * * 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
  52298. * * 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
  52299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52300. * @param name defines the name of the mesh
  52301. * @param options defines the options used to create the mesh
  52302. * @param scene defines the hosting scene
  52303. * @returns the tiled ground mesh
  52304. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52305. */
  52306. static CreateTiledGround(name: string, options: {
  52307. xmin: number;
  52308. zmin: number;
  52309. xmax: number;
  52310. zmax: number;
  52311. subdivisions?: {
  52312. w: number;
  52313. h: number;
  52314. };
  52315. precision?: {
  52316. w: number;
  52317. h: number;
  52318. };
  52319. updatable?: boolean;
  52320. }, scene?: Nullable<Scene>): Mesh;
  52321. /**
  52322. * Creates a ground mesh from a height map
  52323. * * The parameter `url` sets the URL of the height map image resource.
  52324. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52325. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52326. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52327. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52328. * * 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.
  52329. * * 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).
  52330. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52332. * @param name defines the name of the mesh
  52333. * @param url defines the url to the height map
  52334. * @param options defines the options used to create the mesh
  52335. * @param scene defines the hosting scene
  52336. * @returns the ground mesh
  52337. * @see https://doc.babylonjs.com/babylon101/height_map
  52338. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52339. */
  52340. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52341. width?: number;
  52342. height?: number;
  52343. subdivisions?: number;
  52344. minHeight?: number;
  52345. maxHeight?: number;
  52346. colorFilter?: Color3;
  52347. alphaFilter?: number;
  52348. updatable?: boolean;
  52349. onReady?: (mesh: GroundMesh) => void;
  52350. }, scene?: Nullable<Scene>): GroundMesh;
  52351. }
  52352. }
  52353. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52354. import { Vector4 } from "babylonjs/Maths/math.vector";
  52355. import { Mesh } from "babylonjs/Meshes/mesh";
  52356. /**
  52357. * Class containing static functions to help procedurally build meshes
  52358. */
  52359. export class TorusBuilder {
  52360. /**
  52361. * Creates a torus mesh
  52362. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52363. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52364. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52368. * @param name defines the name of the mesh
  52369. * @param options defines the options used to create the mesh
  52370. * @param scene defines the hosting scene
  52371. * @returns the torus mesh
  52372. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52373. */
  52374. static CreateTorus(name: string, options: {
  52375. diameter?: number;
  52376. thickness?: number;
  52377. tessellation?: number;
  52378. updatable?: boolean;
  52379. sideOrientation?: number;
  52380. frontUVs?: Vector4;
  52381. backUVs?: Vector4;
  52382. }, scene: any): Mesh;
  52383. }
  52384. }
  52385. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52386. import { Vector4 } from "babylonjs/Maths/math.vector";
  52387. import { Color4 } from "babylonjs/Maths/math.color";
  52388. import { Mesh } from "babylonjs/Meshes/mesh";
  52389. /**
  52390. * Class containing static functions to help procedurally build meshes
  52391. */
  52392. export class CylinderBuilder {
  52393. /**
  52394. * Creates a cylinder or a cone mesh
  52395. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52396. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52397. * * 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.
  52398. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52399. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52400. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52401. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52402. * * 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).
  52403. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52404. * * 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).
  52405. * * 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
  52406. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52407. * * 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
  52408. * * 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.
  52409. * * If `enclose` is false, a ring surface is one element.
  52410. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52411. * * 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
  52412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52415. * @param name defines the name of the mesh
  52416. * @param options defines the options used to create the mesh
  52417. * @param scene defines the hosting scene
  52418. * @returns the cylinder mesh
  52419. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52420. */
  52421. static CreateCylinder(name: string, options: {
  52422. height?: number;
  52423. diameterTop?: number;
  52424. diameterBottom?: number;
  52425. diameter?: number;
  52426. tessellation?: number;
  52427. subdivisions?: number;
  52428. arc?: number;
  52429. faceColors?: Color4[];
  52430. faceUV?: Vector4[];
  52431. updatable?: boolean;
  52432. hasRings?: boolean;
  52433. enclose?: boolean;
  52434. cap?: number;
  52435. sideOrientation?: number;
  52436. frontUVs?: Vector4;
  52437. backUVs?: Vector4;
  52438. }, scene: any): Mesh;
  52439. }
  52440. }
  52441. declare module "babylonjs/XR/webXRTypes" {
  52442. import { Nullable } from "babylonjs/types";
  52443. import { IDisposable } from "babylonjs/scene";
  52444. /**
  52445. * States of the webXR experience
  52446. */
  52447. export enum WebXRState {
  52448. /**
  52449. * Transitioning to being in XR mode
  52450. */
  52451. ENTERING_XR = 0,
  52452. /**
  52453. * Transitioning to non XR mode
  52454. */
  52455. EXITING_XR = 1,
  52456. /**
  52457. * In XR mode and presenting
  52458. */
  52459. IN_XR = 2,
  52460. /**
  52461. * Not entered XR mode
  52462. */
  52463. NOT_IN_XR = 3
  52464. }
  52465. /**
  52466. * The state of the XR camera's tracking
  52467. */
  52468. export enum WebXRTrackingState {
  52469. /**
  52470. * No transformation received, device is not being tracked
  52471. */
  52472. NOT_TRACKING = 0,
  52473. /**
  52474. * Tracking lost - using emulated position
  52475. */
  52476. TRACKING_LOST = 1,
  52477. /**
  52478. * Transformation tracking works normally
  52479. */
  52480. TRACKING = 2
  52481. }
  52482. /**
  52483. * Abstraction of the XR render target
  52484. */
  52485. export interface WebXRRenderTarget extends IDisposable {
  52486. /**
  52487. * xrpresent context of the canvas which can be used to display/mirror xr content
  52488. */
  52489. canvasContext: WebGLRenderingContext;
  52490. /**
  52491. * xr layer for the canvas
  52492. */
  52493. xrLayer: Nullable<XRWebGLLayer>;
  52494. /**
  52495. * Initializes the xr layer for the session
  52496. * @param xrSession xr session
  52497. * @returns a promise that will resolve once the XR Layer has been created
  52498. */
  52499. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52500. }
  52501. }
  52502. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52503. import { Nullable } from "babylonjs/types";
  52504. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52505. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52506. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52507. import { Observable } from "babylonjs/Misc/observable";
  52508. /**
  52509. * COnfiguration object for WebXR output canvas
  52510. */
  52511. export class WebXRManagedOutputCanvasOptions {
  52512. /**
  52513. * An optional canvas in case you wish to create it yourself and provide it here.
  52514. * If not provided, a new canvas will be created
  52515. */
  52516. canvasElement?: HTMLCanvasElement;
  52517. /**
  52518. * Options for this XR Layer output
  52519. */
  52520. canvasOptions?: XRWebGLLayerInit;
  52521. /**
  52522. * CSS styling for a newly created canvas (if not provided)
  52523. */
  52524. newCanvasCssStyle?: string;
  52525. /**
  52526. * Get the default values of the configuration object
  52527. * @param engine defines the engine to use (can be null)
  52528. * @returns default values of this configuration object
  52529. */
  52530. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52531. }
  52532. /**
  52533. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52534. */
  52535. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52536. private _options;
  52537. private _canvas;
  52538. private _engine;
  52539. private _originalCanvasSize;
  52540. /**
  52541. * Rendering context of the canvas which can be used to display/mirror xr content
  52542. */
  52543. canvasContext: WebGLRenderingContext;
  52544. /**
  52545. * xr layer for the canvas
  52546. */
  52547. xrLayer: Nullable<XRWebGLLayer>;
  52548. /**
  52549. * Obseervers registered here will be triggered when the xr layer was initialized
  52550. */
  52551. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52552. /**
  52553. * Initializes the canvas to be added/removed upon entering/exiting xr
  52554. * @param _xrSessionManager The XR Session manager
  52555. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52556. */
  52557. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52558. /**
  52559. * Disposes of the object
  52560. */
  52561. dispose(): void;
  52562. /**
  52563. * Initializes the xr layer for the session
  52564. * @param xrSession xr session
  52565. * @returns a promise that will resolve once the XR Layer has been created
  52566. */
  52567. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52568. private _addCanvas;
  52569. private _removeCanvas;
  52570. private _setCanvasSize;
  52571. private _setManagedOutputCanvas;
  52572. }
  52573. }
  52574. declare module "babylonjs/XR/webXRSessionManager" {
  52575. import { Observable } from "babylonjs/Misc/observable";
  52576. import { Nullable } from "babylonjs/types";
  52577. import { IDisposable, Scene } from "babylonjs/scene";
  52578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52579. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52580. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52581. /**
  52582. * Manages an XRSession to work with Babylon's engine
  52583. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52584. */
  52585. export class WebXRSessionManager implements IDisposable {
  52586. /** The scene which the session should be created for */
  52587. scene: Scene;
  52588. private _referenceSpace;
  52589. private _rttProvider;
  52590. private _sessionEnded;
  52591. private _xrNavigator;
  52592. private baseLayer;
  52593. /**
  52594. * The base reference space from which the session started. good if you want to reset your
  52595. * reference space
  52596. */
  52597. baseReferenceSpace: XRReferenceSpace;
  52598. /**
  52599. * Current XR frame
  52600. */
  52601. currentFrame: Nullable<XRFrame>;
  52602. /** WebXR timestamp updated every frame */
  52603. currentTimestamp: number;
  52604. /**
  52605. * Used just in case of a failure to initialize an immersive session.
  52606. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52607. */
  52608. defaultHeightCompensation: number;
  52609. /**
  52610. * Fires every time a new xrFrame arrives which can be used to update the camera
  52611. */
  52612. onXRFrameObservable: Observable<XRFrame>;
  52613. /**
  52614. * Fires when the reference space changed
  52615. */
  52616. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52617. /**
  52618. * Fires when the xr session is ended either by the device or manually done
  52619. */
  52620. onXRSessionEnded: Observable<any>;
  52621. /**
  52622. * Fires when the xr session is ended either by the device or manually done
  52623. */
  52624. onXRSessionInit: Observable<XRSession>;
  52625. /**
  52626. * Underlying xr session
  52627. */
  52628. session: XRSession;
  52629. /**
  52630. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52631. * or get the offset the player is currently at.
  52632. */
  52633. viewerReferenceSpace: XRReferenceSpace;
  52634. /**
  52635. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52636. * @param scene The scene which the session should be created for
  52637. */
  52638. constructor(
  52639. /** The scene which the session should be created for */
  52640. scene: Scene);
  52641. /**
  52642. * The current reference space used in this session. This reference space can constantly change!
  52643. * It is mainly used to offset the camera's position.
  52644. */
  52645. get referenceSpace(): XRReferenceSpace;
  52646. /**
  52647. * Set a new reference space and triggers the observable
  52648. */
  52649. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52650. /**
  52651. * Disposes of the session manager
  52652. */
  52653. dispose(): void;
  52654. /**
  52655. * Stops the xrSession and restores the render loop
  52656. * @returns Promise which resolves after it exits XR
  52657. */
  52658. exitXRAsync(): Promise<void>;
  52659. /**
  52660. * Gets the correct render target texture to be rendered this frame for this eye
  52661. * @param eye the eye for which to get the render target
  52662. * @returns the render target for the specified eye
  52663. */
  52664. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52665. /**
  52666. * Creates a WebXRRenderTarget object for the XR session
  52667. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52668. * @param options optional options to provide when creating a new render target
  52669. * @returns a WebXR render target to which the session can render
  52670. */
  52671. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52672. /**
  52673. * Initializes the manager
  52674. * After initialization enterXR can be called to start an XR session
  52675. * @returns Promise which resolves after it is initialized
  52676. */
  52677. initializeAsync(): Promise<void>;
  52678. /**
  52679. * Initializes an xr session
  52680. * @param xrSessionMode mode to initialize
  52681. * @param xrSessionInit defines optional and required values to pass to the session builder
  52682. * @returns a promise which will resolve once the session has been initialized
  52683. */
  52684. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52685. /**
  52686. * Checks if a session would be supported for the creation options specified
  52687. * @param sessionMode session mode to check if supported eg. immersive-vr
  52688. * @returns A Promise that resolves to true if supported and false if not
  52689. */
  52690. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52691. /**
  52692. * Resets the reference space to the one started the session
  52693. */
  52694. resetReferenceSpace(): void;
  52695. /**
  52696. * Starts rendering to the xr layer
  52697. */
  52698. runXRRenderLoop(): void;
  52699. /**
  52700. * Sets the reference space on the xr session
  52701. * @param referenceSpaceType space to set
  52702. * @returns a promise that will resolve once the reference space has been set
  52703. */
  52704. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52705. /**
  52706. * Updates the render state of the session
  52707. * @param state state to set
  52708. * @returns a promise that resolves once the render state has been updated
  52709. */
  52710. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52711. /**
  52712. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52713. * @param sessionMode defines the session to test
  52714. * @returns a promise with boolean as final value
  52715. */
  52716. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52717. private _createRenderTargetTexture;
  52718. }
  52719. }
  52720. declare module "babylonjs/XR/webXRCamera" {
  52721. import { Vector3 } from "babylonjs/Maths/math.vector";
  52722. import { Scene } from "babylonjs/scene";
  52723. import { Camera } from "babylonjs/Cameras/camera";
  52724. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52725. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52726. import { Observable } from "babylonjs/Misc/observable";
  52727. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52728. /**
  52729. * WebXR Camera which holds the views for the xrSession
  52730. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52731. */
  52732. export class WebXRCamera extends FreeCamera {
  52733. private _xrSessionManager;
  52734. private _firstFrame;
  52735. private _referenceQuaternion;
  52736. private _referencedPosition;
  52737. private _xrInvPositionCache;
  52738. private _xrInvQuaternionCache;
  52739. private _trackingState;
  52740. /**
  52741. * Observable raised before camera teleportation
  52742. */
  52743. onBeforeCameraTeleport: Observable<Vector3>;
  52744. /**
  52745. * Observable raised after camera teleportation
  52746. */
  52747. onAfterCameraTeleport: Observable<Vector3>;
  52748. /**
  52749. * Notifies when the camera's tracking state has changed.
  52750. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52751. */
  52752. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52753. /**
  52754. * Should position compensation execute on first frame.
  52755. * This is used when copying the position from a native (non XR) camera
  52756. */
  52757. compensateOnFirstFrame: boolean;
  52758. /**
  52759. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52760. * @param name the name of the camera
  52761. * @param scene the scene to add the camera to
  52762. * @param _xrSessionManager a constructed xr session manager
  52763. */
  52764. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52765. /**
  52766. * Get the current XR tracking state of the camera
  52767. */
  52768. get trackingState(): WebXRTrackingState;
  52769. private _setTrackingState;
  52770. /**
  52771. * Return the user's height, unrelated to the current ground.
  52772. * This will be the y position of this camera, when ground level is 0.
  52773. */
  52774. get realWorldHeight(): number;
  52775. /** @hidden */
  52776. _updateForDualEyeDebugging(): void;
  52777. /**
  52778. * Sets this camera's transformation based on a non-vr camera
  52779. * @param otherCamera the non-vr camera to copy the transformation from
  52780. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52781. */
  52782. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52783. /**
  52784. * Gets the current instance class name ("WebXRCamera").
  52785. * @returns the class name
  52786. */
  52787. getClassName(): string;
  52788. private _rotate180;
  52789. private _updateFromXRSession;
  52790. private _updateNumberOfRigCameras;
  52791. private _updateReferenceSpace;
  52792. private _updateReferenceSpaceOffset;
  52793. }
  52794. }
  52795. declare module "babylonjs/XR/webXRFeaturesManager" {
  52796. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52797. import { IDisposable } from "babylonjs/scene";
  52798. /**
  52799. * Defining the interface required for a (webxr) feature
  52800. */
  52801. export interface IWebXRFeature extends IDisposable {
  52802. /**
  52803. * Is this feature attached
  52804. */
  52805. attached: boolean;
  52806. /**
  52807. * Should auto-attach be disabled?
  52808. */
  52809. disableAutoAttach: boolean;
  52810. /**
  52811. * Attach the feature to the session
  52812. * Will usually be called by the features manager
  52813. *
  52814. * @param force should attachment be forced (even when already attached)
  52815. * @returns true if successful.
  52816. */
  52817. attach(force?: boolean): boolean;
  52818. /**
  52819. * Detach the feature from the session
  52820. * Will usually be called by the features manager
  52821. *
  52822. * @returns true if successful.
  52823. */
  52824. detach(): boolean;
  52825. /**
  52826. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52827. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52828. *
  52829. * @returns whether or not the feature is compatible in this environment
  52830. */
  52831. isCompatible(): boolean;
  52832. /**
  52833. * Was this feature disposed;
  52834. */
  52835. isDisposed: boolean;
  52836. /**
  52837. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52838. */
  52839. xrNativeFeatureName?: string;
  52840. /**
  52841. * A list of (Babylon WebXR) features this feature depends on
  52842. */
  52843. dependsOn?: string[];
  52844. }
  52845. /**
  52846. * A list of the currently available features without referencing them
  52847. */
  52848. export class WebXRFeatureName {
  52849. /**
  52850. * The name of the anchor system feature
  52851. */
  52852. static readonly ANCHOR_SYSTEM: string;
  52853. /**
  52854. * The name of the background remover feature
  52855. */
  52856. static readonly BACKGROUND_REMOVER: string;
  52857. /**
  52858. * The name of the hit test feature
  52859. */
  52860. static readonly HIT_TEST: string;
  52861. /**
  52862. * physics impostors for xr controllers feature
  52863. */
  52864. static readonly PHYSICS_CONTROLLERS: string;
  52865. /**
  52866. * The name of the plane detection feature
  52867. */
  52868. static readonly PLANE_DETECTION: string;
  52869. /**
  52870. * The name of the pointer selection feature
  52871. */
  52872. static readonly POINTER_SELECTION: string;
  52873. /**
  52874. * The name of the teleportation feature
  52875. */
  52876. static readonly TELEPORTATION: string;
  52877. /**
  52878. * The name of the feature points feature.
  52879. */
  52880. static readonly FEATURE_POINTS: string;
  52881. /**
  52882. * The name of the hand tracking feature.
  52883. */
  52884. static readonly HAND_TRACKING: string;
  52885. }
  52886. /**
  52887. * Defining the constructor of a feature. Used to register the modules.
  52888. */
  52889. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52890. /**
  52891. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52892. * It is mainly used in AR sessions.
  52893. *
  52894. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52895. */
  52896. export class WebXRFeaturesManager implements IDisposable {
  52897. private _xrSessionManager;
  52898. private static readonly _AvailableFeatures;
  52899. private _features;
  52900. /**
  52901. * constructs a new features manages.
  52902. *
  52903. * @param _xrSessionManager an instance of WebXRSessionManager
  52904. */
  52905. constructor(_xrSessionManager: WebXRSessionManager);
  52906. /**
  52907. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52908. * Mainly used internally.
  52909. *
  52910. * @param featureName the name of the feature to register
  52911. * @param constructorFunction the function used to construct the module
  52912. * @param version the (babylon) version of the module
  52913. * @param stable is that a stable version of this module
  52914. */
  52915. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52916. /**
  52917. * Returns a constructor of a specific feature.
  52918. *
  52919. * @param featureName the name of the feature to construct
  52920. * @param version the version of the feature to load
  52921. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52922. * @param options optional options provided to the module.
  52923. * @returns a function that, when called, will return a new instance of this feature
  52924. */
  52925. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52926. /**
  52927. * Can be used to return the list of features currently registered
  52928. *
  52929. * @returns an Array of available features
  52930. */
  52931. static GetAvailableFeatures(): string[];
  52932. /**
  52933. * Gets the versions available for a specific feature
  52934. * @param featureName the name of the feature
  52935. * @returns an array with the available versions
  52936. */
  52937. static GetAvailableVersions(featureName: string): string[];
  52938. /**
  52939. * Return the latest unstable version of this feature
  52940. * @param featureName the name of the feature to search
  52941. * @returns the version number. if not found will return -1
  52942. */
  52943. static GetLatestVersionOfFeature(featureName: string): number;
  52944. /**
  52945. * Return the latest stable version of this feature
  52946. * @param featureName the name of the feature to search
  52947. * @returns the version number. if not found will return -1
  52948. */
  52949. static GetStableVersionOfFeature(featureName: string): number;
  52950. /**
  52951. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52952. * Can be used during a session to start a feature
  52953. * @param featureName the name of feature to attach
  52954. */
  52955. attachFeature(featureName: string): void;
  52956. /**
  52957. * Can be used inside a session or when the session ends to detach a specific feature
  52958. * @param featureName the name of the feature to detach
  52959. */
  52960. detachFeature(featureName: string): void;
  52961. /**
  52962. * Used to disable an already-enabled feature
  52963. * The feature will be disposed and will be recreated once enabled.
  52964. * @param featureName the feature to disable
  52965. * @returns true if disable was successful
  52966. */
  52967. disableFeature(featureName: string | {
  52968. Name: string;
  52969. }): boolean;
  52970. /**
  52971. * dispose this features manager
  52972. */
  52973. dispose(): void;
  52974. /**
  52975. * 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.
  52976. * 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.
  52977. *
  52978. * @param featureName the name of the feature to load or the class of the feature
  52979. * @param version optional version to load. if not provided the latest version will be enabled
  52980. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52981. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52982. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52983. * @returns a new constructed feature or throws an error if feature not found.
  52984. */
  52985. enableFeature(featureName: string | {
  52986. Name: string;
  52987. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52988. /**
  52989. * get the implementation of an enabled feature.
  52990. * @param featureName the name of the feature to load
  52991. * @returns the feature class, if found
  52992. */
  52993. getEnabledFeature(featureName: string): IWebXRFeature;
  52994. /**
  52995. * Get the list of enabled features
  52996. * @returns an array of enabled features
  52997. */
  52998. getEnabledFeatures(): string[];
  52999. /**
  53000. * This function will exten the session creation configuration object with enabled features.
  53001. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53002. * according to the defined "required" variable, provided during enableFeature call
  53003. * @param xrSessionInit the xr Session init object to extend
  53004. *
  53005. * @returns an extended XRSessionInit object
  53006. */
  53007. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  53008. }
  53009. }
  53010. declare module "babylonjs/XR/webXRExperienceHelper" {
  53011. import { Observable } from "babylonjs/Misc/observable";
  53012. import { IDisposable, Scene } from "babylonjs/scene";
  53013. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  53014. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  53015. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  53016. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  53017. /**
  53018. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53019. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53020. */
  53021. export class WebXRExperienceHelper implements IDisposable {
  53022. private scene;
  53023. private _nonVRCamera;
  53024. private _originalSceneAutoClear;
  53025. private _supported;
  53026. /**
  53027. * Camera used to render xr content
  53028. */
  53029. camera: WebXRCamera;
  53030. /** A features manager for this xr session */
  53031. featuresManager: WebXRFeaturesManager;
  53032. /**
  53033. * Observers registered here will be triggered after the camera's initial transformation is set
  53034. * This can be used to set a different ground level or an extra rotation.
  53035. *
  53036. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53037. * to the position set after this observable is done executing.
  53038. */
  53039. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53040. /**
  53041. * Fires when the state of the experience helper has changed
  53042. */
  53043. onStateChangedObservable: Observable<WebXRState>;
  53044. /** Session manager used to keep track of xr session */
  53045. sessionManager: WebXRSessionManager;
  53046. /**
  53047. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53048. */
  53049. state: WebXRState;
  53050. /**
  53051. * Creates a WebXRExperienceHelper
  53052. * @param scene The scene the helper should be created in
  53053. */
  53054. private constructor();
  53055. /**
  53056. * Creates the experience helper
  53057. * @param scene the scene to attach the experience helper to
  53058. * @returns a promise for the experience helper
  53059. */
  53060. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53061. /**
  53062. * Disposes of the experience helper
  53063. */
  53064. dispose(): void;
  53065. /**
  53066. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53067. * @param sessionMode options for the XR session
  53068. * @param referenceSpaceType frame of reference of the XR session
  53069. * @param renderTarget the output canvas that will be used to enter XR mode
  53070. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53071. * @returns promise that resolves after xr mode has entered
  53072. */
  53073. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53074. /**
  53075. * Exits XR mode and returns the scene to its original state
  53076. * @returns promise that resolves after xr mode has exited
  53077. */
  53078. exitXRAsync(): Promise<void>;
  53079. private _nonXRToXRCamera;
  53080. private _setState;
  53081. }
  53082. }
  53083. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  53084. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53085. import { Observable } from "babylonjs/Misc/observable";
  53086. import { IDisposable } from "babylonjs/scene";
  53087. /**
  53088. * X-Y values for axes in WebXR
  53089. */
  53090. export interface IWebXRMotionControllerAxesValue {
  53091. /**
  53092. * The value of the x axis
  53093. */
  53094. x: number;
  53095. /**
  53096. * The value of the y-axis
  53097. */
  53098. y: number;
  53099. }
  53100. /**
  53101. * changed / previous values for the values of this component
  53102. */
  53103. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53104. /**
  53105. * current (this frame) value
  53106. */
  53107. current: T;
  53108. /**
  53109. * previous (last change) value
  53110. */
  53111. previous: T;
  53112. }
  53113. /**
  53114. * Represents changes in the component between current frame and last values recorded
  53115. */
  53116. export interface IWebXRMotionControllerComponentChanges {
  53117. /**
  53118. * will be populated with previous and current values if axes changed
  53119. */
  53120. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53121. /**
  53122. * will be populated with previous and current values if pressed changed
  53123. */
  53124. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53125. /**
  53126. * will be populated with previous and current values if touched changed
  53127. */
  53128. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53129. /**
  53130. * will be populated with previous and current values if value changed
  53131. */
  53132. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53133. }
  53134. /**
  53135. * This class represents a single component (for example button or thumbstick) of a motion controller
  53136. */
  53137. export class WebXRControllerComponent implements IDisposable {
  53138. /**
  53139. * the id of this component
  53140. */
  53141. id: string;
  53142. /**
  53143. * the type of the component
  53144. */
  53145. type: MotionControllerComponentType;
  53146. private _buttonIndex;
  53147. private _axesIndices;
  53148. private _axes;
  53149. private _changes;
  53150. private _currentValue;
  53151. private _hasChanges;
  53152. private _pressed;
  53153. private _touched;
  53154. /**
  53155. * button component type
  53156. */
  53157. static BUTTON_TYPE: MotionControllerComponentType;
  53158. /**
  53159. * squeeze component type
  53160. */
  53161. static SQUEEZE_TYPE: MotionControllerComponentType;
  53162. /**
  53163. * Thumbstick component type
  53164. */
  53165. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53166. /**
  53167. * Touchpad component type
  53168. */
  53169. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53170. /**
  53171. * trigger component type
  53172. */
  53173. static TRIGGER_TYPE: MotionControllerComponentType;
  53174. /**
  53175. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53176. * the axes data changes
  53177. */
  53178. onAxisValueChangedObservable: Observable<{
  53179. x: number;
  53180. y: number;
  53181. }>;
  53182. /**
  53183. * Observers registered here will be triggered when the state of a button changes
  53184. * State change is either pressed / touched / value
  53185. */
  53186. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53187. /**
  53188. * Creates a new component for a motion controller.
  53189. * It is created by the motion controller itself
  53190. *
  53191. * @param id the id of this component
  53192. * @param type the type of the component
  53193. * @param _buttonIndex index in the buttons array of the gamepad
  53194. * @param _axesIndices indices of the values in the axes array of the gamepad
  53195. */
  53196. constructor(
  53197. /**
  53198. * the id of this component
  53199. */
  53200. id: string,
  53201. /**
  53202. * the type of the component
  53203. */
  53204. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53205. /**
  53206. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53207. */
  53208. get axes(): IWebXRMotionControllerAxesValue;
  53209. /**
  53210. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53211. */
  53212. get changes(): IWebXRMotionControllerComponentChanges;
  53213. /**
  53214. * Return whether or not the component changed the last frame
  53215. */
  53216. get hasChanges(): boolean;
  53217. /**
  53218. * is the button currently pressed
  53219. */
  53220. get pressed(): boolean;
  53221. /**
  53222. * is the button currently touched
  53223. */
  53224. get touched(): boolean;
  53225. /**
  53226. * Get the current value of this component
  53227. */
  53228. get value(): number;
  53229. /**
  53230. * Dispose this component
  53231. */
  53232. dispose(): void;
  53233. /**
  53234. * Are there axes correlating to this component
  53235. * @return true is axes data is available
  53236. */
  53237. isAxes(): boolean;
  53238. /**
  53239. * Is this component a button (hence - pressable)
  53240. * @returns true if can be pressed
  53241. */
  53242. isButton(): boolean;
  53243. /**
  53244. * update this component using the gamepad object it is in. Called on every frame
  53245. * @param nativeController the native gamepad controller object
  53246. */
  53247. update(nativeController: IMinimalMotionControllerObject): void;
  53248. }
  53249. }
  53250. declare module "babylonjs/Loading/sceneLoader" {
  53251. import { Observable } from "babylonjs/Misc/observable";
  53252. import { Nullable } from "babylonjs/types";
  53253. import { Scene } from "babylonjs/scene";
  53254. import { Engine } from "babylonjs/Engines/engine";
  53255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53256. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  53257. import { AssetContainer } from "babylonjs/assetContainer";
  53258. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53259. import { Skeleton } from "babylonjs/Bones/skeleton";
  53260. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  53261. import { WebRequest } from "babylonjs/Misc/webRequest";
  53262. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53263. import { Geometry } from "babylonjs/Meshes/geometry";
  53264. import { Light } from "babylonjs/Lights/light";
  53265. /**
  53266. * Type used for the success callback of ImportMesh
  53267. */
  53268. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  53269. /**
  53270. * Interface used for the result of ImportMeshAsync
  53271. */
  53272. export interface ISceneLoaderAsyncResult {
  53273. /**
  53274. * The array of loaded meshes
  53275. */
  53276. readonly meshes: AbstractMesh[];
  53277. /**
  53278. * The array of loaded particle systems
  53279. */
  53280. readonly particleSystems: IParticleSystem[];
  53281. /**
  53282. * The array of loaded skeletons
  53283. */
  53284. readonly skeletons: Skeleton[];
  53285. /**
  53286. * The array of loaded animation groups
  53287. */
  53288. readonly animationGroups: AnimationGroup[];
  53289. /**
  53290. * The array of loaded transform nodes
  53291. */
  53292. readonly transformNodes: TransformNode[];
  53293. /**
  53294. * The array of loaded geometries
  53295. */
  53296. readonly geometries: Geometry[];
  53297. /**
  53298. * The array of loaded lights
  53299. */
  53300. readonly lights: Light[];
  53301. }
  53302. /**
  53303. * Interface used to represent data loading progression
  53304. */
  53305. export interface ISceneLoaderProgressEvent {
  53306. /**
  53307. * Defines if data length to load can be evaluated
  53308. */
  53309. readonly lengthComputable: boolean;
  53310. /**
  53311. * Defines the loaded data length
  53312. */
  53313. readonly loaded: number;
  53314. /**
  53315. * Defines the data length to load
  53316. */
  53317. readonly total: number;
  53318. }
  53319. /**
  53320. * Interface used by SceneLoader plugins to define supported file extensions
  53321. */
  53322. export interface ISceneLoaderPluginExtensions {
  53323. /**
  53324. * Defines the list of supported extensions
  53325. */
  53326. [extension: string]: {
  53327. isBinary: boolean;
  53328. };
  53329. }
  53330. /**
  53331. * Interface used by SceneLoader plugin factory
  53332. */
  53333. export interface ISceneLoaderPluginFactory {
  53334. /**
  53335. * Defines the name of the factory
  53336. */
  53337. name: string;
  53338. /**
  53339. * Function called to create a new plugin
  53340. * @return the new plugin
  53341. */
  53342. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  53343. /**
  53344. * The callback that returns true if the data can be directly loaded.
  53345. * @param data string containing the file data
  53346. * @returns if the data can be loaded directly
  53347. */
  53348. canDirectLoad?(data: string): boolean;
  53349. }
  53350. /**
  53351. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53352. */
  53353. export interface ISceneLoaderPluginBase {
  53354. /**
  53355. * The friendly name of this plugin.
  53356. */
  53357. name: string;
  53358. /**
  53359. * The file extensions supported by this plugin.
  53360. */
  53361. extensions: string | ISceneLoaderPluginExtensions;
  53362. /**
  53363. * The callback called when loading from a url.
  53364. * @param scene scene loading this url
  53365. * @param url url to load
  53366. * @param onSuccess callback called when the file successfully loads
  53367. * @param onProgress callback called while file is loading (if the server supports this mode)
  53368. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  53369. * @param onError callback called when the file fails to load
  53370. * @returns a file request object
  53371. */
  53372. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53373. /**
  53374. * The callback called when loading from a file object.
  53375. * @param scene scene loading this file
  53376. * @param file defines the file to load
  53377. * @param onSuccess defines the callback to call when data is loaded
  53378. * @param onProgress defines the callback to call during loading process
  53379. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53380. * @param onError defines the callback to call when an error occurs
  53381. * @returns a file request object
  53382. */
  53383. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53384. /**
  53385. * The callback that returns true if the data can be directly loaded.
  53386. * @param data string containing the file data
  53387. * @returns if the data can be loaded directly
  53388. */
  53389. canDirectLoad?(data: string): boolean;
  53390. /**
  53391. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53392. * @param scene scene loading this data
  53393. * @param data string containing the data
  53394. * @returns data to pass to the plugin
  53395. */
  53396. directLoad?(scene: Scene, data: string): any;
  53397. /**
  53398. * The callback that allows custom handling of the root url based on the response url.
  53399. * @param rootUrl the original root url
  53400. * @param responseURL the response url if available
  53401. * @returns the new root url
  53402. */
  53403. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53404. }
  53405. /**
  53406. * Interface used to define a SceneLoader plugin
  53407. */
  53408. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53409. /**
  53410. * Import meshes into a scene.
  53411. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53412. * @param scene The scene to import into
  53413. * @param data The data to import
  53414. * @param rootUrl The root url for scene and resources
  53415. * @param meshes The meshes array to import into
  53416. * @param particleSystems The particle systems array to import into
  53417. * @param skeletons The skeletons array to import into
  53418. * @param onError The callback when import fails
  53419. * @returns True if successful or false otherwise
  53420. */
  53421. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53422. /**
  53423. * Load into a scene.
  53424. * @param scene The scene to load into
  53425. * @param data The data to import
  53426. * @param rootUrl The root url for scene and resources
  53427. * @param onError The callback when import fails
  53428. * @returns True if successful or false otherwise
  53429. */
  53430. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53431. /**
  53432. * Load into an asset container.
  53433. * @param scene The scene to load into
  53434. * @param data The data to import
  53435. * @param rootUrl The root url for scene and resources
  53436. * @param onError The callback when import fails
  53437. * @returns The loaded asset container
  53438. */
  53439. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53440. }
  53441. /**
  53442. * Interface used to define an async SceneLoader plugin
  53443. */
  53444. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53445. /**
  53446. * Import meshes into a scene.
  53447. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53448. * @param scene The scene to import into
  53449. * @param data The data to import
  53450. * @param rootUrl The root url for scene and resources
  53451. * @param onProgress The callback when the load progresses
  53452. * @param fileName Defines the name of the file to load
  53453. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  53454. */
  53455. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  53456. /**
  53457. * Load into a scene.
  53458. * @param scene The scene to load into
  53459. * @param data The data to import
  53460. * @param rootUrl The root url for scene and resources
  53461. * @param onProgress The callback when the load progresses
  53462. * @param fileName Defines the name of the file to load
  53463. * @returns Nothing
  53464. */
  53465. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53466. /**
  53467. * Load into an asset container.
  53468. * @param scene The scene to load into
  53469. * @param data The data to import
  53470. * @param rootUrl The root url for scene and resources
  53471. * @param onProgress The callback when the load progresses
  53472. * @param fileName Defines the name of the file to load
  53473. * @returns The loaded asset container
  53474. */
  53475. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53476. }
  53477. /**
  53478. * Mode that determines how to handle old animation groups before loading new ones.
  53479. */
  53480. export enum SceneLoaderAnimationGroupLoadingMode {
  53481. /**
  53482. * Reset all old animations to initial state then dispose them.
  53483. */
  53484. Clean = 0,
  53485. /**
  53486. * Stop all old animations.
  53487. */
  53488. Stop = 1,
  53489. /**
  53490. * Restart old animations from first frame.
  53491. */
  53492. Sync = 2,
  53493. /**
  53494. * Old animations remains untouched.
  53495. */
  53496. NoSync = 3
  53497. }
  53498. /**
  53499. * Defines a plugin registered by the SceneLoader
  53500. */
  53501. interface IRegisteredPlugin {
  53502. /**
  53503. * Defines the plugin to use
  53504. */
  53505. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53506. /**
  53507. * Defines if the plugin supports binary data
  53508. */
  53509. isBinary: boolean;
  53510. }
  53511. /**
  53512. * Class used to load scene from various file formats using registered plugins
  53513. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53514. */
  53515. export class SceneLoader {
  53516. /**
  53517. * No logging while loading
  53518. */
  53519. static readonly NO_LOGGING: number;
  53520. /**
  53521. * Minimal logging while loading
  53522. */
  53523. static readonly MINIMAL_LOGGING: number;
  53524. /**
  53525. * Summary logging while loading
  53526. */
  53527. static readonly SUMMARY_LOGGING: number;
  53528. /**
  53529. * Detailled logging while loading
  53530. */
  53531. static readonly DETAILED_LOGGING: number;
  53532. /**
  53533. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53534. */
  53535. static get ForceFullSceneLoadingForIncremental(): boolean;
  53536. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53537. /**
  53538. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53539. */
  53540. static get ShowLoadingScreen(): boolean;
  53541. static set ShowLoadingScreen(value: boolean);
  53542. /**
  53543. * Defines the current logging level (while loading the scene)
  53544. * @ignorenaming
  53545. */
  53546. static get loggingLevel(): number;
  53547. static set loggingLevel(value: number);
  53548. /**
  53549. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53550. */
  53551. static get CleanBoneMatrixWeights(): boolean;
  53552. static set CleanBoneMatrixWeights(value: boolean);
  53553. /**
  53554. * Event raised when a plugin is used to load a scene
  53555. */
  53556. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53557. private static _registeredPlugins;
  53558. private static _showingLoadingScreen;
  53559. /**
  53560. * Gets the default plugin (used to load Babylon files)
  53561. * @returns the .babylon plugin
  53562. */
  53563. static GetDefaultPlugin(): IRegisteredPlugin;
  53564. private static _GetPluginForExtension;
  53565. private static _GetPluginForDirectLoad;
  53566. private static _GetPluginForFilename;
  53567. private static _GetDirectLoad;
  53568. private static _LoadData;
  53569. private static _GetFileInfo;
  53570. /**
  53571. * Gets a plugin that can load the given extension
  53572. * @param extension defines the extension to load
  53573. * @returns a plugin or null if none works
  53574. */
  53575. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53576. /**
  53577. * Gets a boolean indicating that the given extension can be loaded
  53578. * @param extension defines the extension to load
  53579. * @returns true if the extension is supported
  53580. */
  53581. static IsPluginForExtensionAvailable(extension: string): boolean;
  53582. /**
  53583. * Adds a new plugin to the list of registered plugins
  53584. * @param plugin defines the plugin to add
  53585. */
  53586. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53587. /**
  53588. * Import meshes into a scene
  53589. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53590. * @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)
  53591. * @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)
  53592. * @param scene the instance of BABYLON.Scene to append to
  53593. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53594. * @param onProgress a callback with a progress event for each file being loaded
  53595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53596. * @param pluginExtension the extension used to determine the plugin
  53597. * @returns The loaded plugin
  53598. */
  53599. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53600. /**
  53601. * Import meshes into a scene
  53602. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53603. * @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)
  53604. * @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)
  53605. * @param scene the instance of BABYLON.Scene to append to
  53606. * @param onProgress a callback with a progress event for each file being loaded
  53607. * @param pluginExtension the extension used to determine the plugin
  53608. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53609. */
  53610. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  53611. /**
  53612. * Load a scene
  53613. * @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)
  53614. * @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)
  53615. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53616. * @param onSuccess a callback with the scene when import succeeds
  53617. * @param onProgress a callback with a progress event for each file being loaded
  53618. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53619. * @param pluginExtension the extension used to determine the plugin
  53620. * @returns The loaded plugin
  53621. */
  53622. 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>;
  53623. /**
  53624. * Load a scene
  53625. * @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)
  53626. * @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)
  53627. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53628. * @param onProgress a callback with a progress event for each file being loaded
  53629. * @param pluginExtension the extension used to determine the plugin
  53630. * @returns The loaded scene
  53631. */
  53632. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53633. /**
  53634. * Append a scene
  53635. * @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)
  53636. * @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)
  53637. * @param scene is the instance of BABYLON.Scene to append to
  53638. * @param onSuccess a callback with the scene when import succeeds
  53639. * @param onProgress a callback with a progress event for each file being loaded
  53640. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53641. * @param pluginExtension the extension used to determine the plugin
  53642. * @returns The loaded plugin
  53643. */
  53644. 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>;
  53645. /**
  53646. * Append a scene
  53647. * @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)
  53648. * @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)
  53649. * @param scene is the instance of BABYLON.Scene to append to
  53650. * @param onProgress a callback with a progress event for each file being loaded
  53651. * @param pluginExtension the extension used to determine the plugin
  53652. * @returns The given scene
  53653. */
  53654. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53655. /**
  53656. * Load a scene into an asset container
  53657. * @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)
  53658. * @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)
  53659. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53660. * @param onSuccess a callback with the scene when import succeeds
  53661. * @param onProgress a callback with a progress event for each file being loaded
  53662. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53663. * @param pluginExtension the extension used to determine the plugin
  53664. * @returns The loaded plugin
  53665. */
  53666. 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>;
  53667. /**
  53668. * Load a scene into an asset container
  53669. * @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)
  53670. * @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)
  53671. * @param scene is the instance of Scene to append to
  53672. * @param onProgress a callback with a progress event for each file being loaded
  53673. * @param pluginExtension the extension used to determine the plugin
  53674. * @returns The loaded asset container
  53675. */
  53676. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53677. /**
  53678. * Import animations from a file into a scene
  53679. * @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)
  53680. * @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)
  53681. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53682. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53683. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53684. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53685. * @param onSuccess a callback with the scene when import succeeds
  53686. * @param onProgress a callback with a progress event for each file being loaded
  53687. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53688. * @param pluginExtension the extension used to determine the plugin
  53689. */
  53690. 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;
  53691. /**
  53692. * Import animations from a file into a scene
  53693. * @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)
  53694. * @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)
  53695. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53696. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53697. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53698. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53699. * @param onSuccess a callback with the scene when import succeeds
  53700. * @param onProgress a callback with a progress event for each file being loaded
  53701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53702. * @param pluginExtension the extension used to determine the plugin
  53703. * @returns the updated scene with imported animations
  53704. */
  53705. 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>;
  53706. }
  53707. }
  53708. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53709. import { IDisposable, Scene } from "babylonjs/scene";
  53710. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53711. import { Observable } from "babylonjs/Misc/observable";
  53712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53713. import { Nullable } from "babylonjs/types";
  53714. /**
  53715. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53716. */
  53717. export type MotionControllerHandedness = "none" | "left" | "right";
  53718. /**
  53719. * The type of components available in motion controllers.
  53720. * This is not the name of the component.
  53721. */
  53722. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53723. /**
  53724. * The state of a controller component
  53725. */
  53726. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53727. /**
  53728. * The schema of motion controller layout.
  53729. * No object will be initialized using this interface
  53730. * This is used just to define the profile.
  53731. */
  53732. export interface IMotionControllerLayout {
  53733. /**
  53734. * Path to load the assets. Usually relative to the base path
  53735. */
  53736. assetPath: string;
  53737. /**
  53738. * Available components (unsorted)
  53739. */
  53740. components: {
  53741. /**
  53742. * A map of component Ids
  53743. */
  53744. [componentId: string]: {
  53745. /**
  53746. * The type of input the component outputs
  53747. */
  53748. type: MotionControllerComponentType;
  53749. /**
  53750. * The indices of this component in the gamepad object
  53751. */
  53752. gamepadIndices: {
  53753. /**
  53754. * Index of button
  53755. */
  53756. button?: number;
  53757. /**
  53758. * If available, index of x-axis
  53759. */
  53760. xAxis?: number;
  53761. /**
  53762. * If available, index of y-axis
  53763. */
  53764. yAxis?: number;
  53765. };
  53766. /**
  53767. * The mesh's root node name
  53768. */
  53769. rootNodeName: string;
  53770. /**
  53771. * Animation definitions for this model
  53772. */
  53773. visualResponses: {
  53774. [stateKey: string]: {
  53775. /**
  53776. * What property will be animated
  53777. */
  53778. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53779. /**
  53780. * What states influence this visual response
  53781. */
  53782. states: MotionControllerComponentStateType[];
  53783. /**
  53784. * Type of animation - movement or visibility
  53785. */
  53786. valueNodeProperty: "transform" | "visibility";
  53787. /**
  53788. * Base node name to move. Its position will be calculated according to the min and max nodes
  53789. */
  53790. valueNodeName?: string;
  53791. /**
  53792. * Minimum movement node
  53793. */
  53794. minNodeName?: string;
  53795. /**
  53796. * Max movement node
  53797. */
  53798. maxNodeName?: string;
  53799. };
  53800. };
  53801. /**
  53802. * If touch enabled, what is the name of node to display user feedback
  53803. */
  53804. touchPointNodeName?: string;
  53805. };
  53806. };
  53807. /**
  53808. * Is it xr standard mapping or not
  53809. */
  53810. gamepadMapping: "" | "xr-standard";
  53811. /**
  53812. * Base root node of this entire model
  53813. */
  53814. rootNodeName: string;
  53815. /**
  53816. * Defines the main button component id
  53817. */
  53818. selectComponentId: string;
  53819. }
  53820. /**
  53821. * A definition for the layout map in the input profile
  53822. */
  53823. export interface IMotionControllerLayoutMap {
  53824. /**
  53825. * Layouts with handedness type as a key
  53826. */
  53827. [handedness: string]: IMotionControllerLayout;
  53828. }
  53829. /**
  53830. * The XR Input profile schema
  53831. * Profiles can be found here:
  53832. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53833. */
  53834. export interface IMotionControllerProfile {
  53835. /**
  53836. * fallback profiles for this profileId
  53837. */
  53838. fallbackProfileIds: string[];
  53839. /**
  53840. * The layout map, with handedness as key
  53841. */
  53842. layouts: IMotionControllerLayoutMap;
  53843. /**
  53844. * The id of this profile
  53845. * correlates to the profile(s) in the xrInput.profiles array
  53846. */
  53847. profileId: string;
  53848. }
  53849. /**
  53850. * A helper-interface for the 3 meshes needed for controller button animation
  53851. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53852. */
  53853. export interface IMotionControllerButtonMeshMap {
  53854. /**
  53855. * the mesh that defines the pressed value mesh position.
  53856. * This is used to find the max-position of this button
  53857. */
  53858. pressedMesh: AbstractMesh;
  53859. /**
  53860. * the mesh that defines the unpressed value mesh position.
  53861. * This is used to find the min (or initial) position of this button
  53862. */
  53863. unpressedMesh: AbstractMesh;
  53864. /**
  53865. * The mesh that will be changed when value changes
  53866. */
  53867. valueMesh: AbstractMesh;
  53868. }
  53869. /**
  53870. * A helper-interface for the 3 meshes needed for controller axis animation.
  53871. * This will be expanded when touchpad animations are fully supported
  53872. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53873. */
  53874. export interface IMotionControllerMeshMap {
  53875. /**
  53876. * the mesh that defines the maximum value mesh position.
  53877. */
  53878. maxMesh?: AbstractMesh;
  53879. /**
  53880. * the mesh that defines the minimum value mesh position.
  53881. */
  53882. minMesh?: AbstractMesh;
  53883. /**
  53884. * The mesh that will be changed when axis value changes
  53885. */
  53886. valueMesh?: AbstractMesh;
  53887. }
  53888. /**
  53889. * The elements needed for change-detection of the gamepad objects in motion controllers
  53890. */
  53891. export interface IMinimalMotionControllerObject {
  53892. /**
  53893. * Available axes of this controller
  53894. */
  53895. axes: number[];
  53896. /**
  53897. * An array of available buttons
  53898. */
  53899. buttons: Array<{
  53900. /**
  53901. * Value of the button/trigger
  53902. */
  53903. value: number;
  53904. /**
  53905. * If the button/trigger is currently touched
  53906. */
  53907. touched: boolean;
  53908. /**
  53909. * If the button/trigger is currently pressed
  53910. */
  53911. pressed: boolean;
  53912. }>;
  53913. /**
  53914. * EXPERIMENTAL haptic support.
  53915. */
  53916. hapticActuators?: Array<{
  53917. pulse: (value: number, duration: number) => Promise<boolean>;
  53918. }>;
  53919. }
  53920. /**
  53921. * An Abstract Motion controller
  53922. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53923. * Each component has an observable to check for changes in value and state
  53924. */
  53925. export abstract class WebXRAbstractMotionController implements IDisposable {
  53926. protected scene: Scene;
  53927. protected layout: IMotionControllerLayout;
  53928. /**
  53929. * The gamepad object correlating to this controller
  53930. */
  53931. gamepadObject: IMinimalMotionControllerObject;
  53932. /**
  53933. * handedness (left/right/none) of this controller
  53934. */
  53935. handedness: MotionControllerHandedness;
  53936. private _initComponent;
  53937. private _modelReady;
  53938. /**
  53939. * A map of components (WebXRControllerComponent) in this motion controller
  53940. * Components have a ComponentType and can also have both button and axis definitions
  53941. */
  53942. readonly components: {
  53943. [id: string]: WebXRControllerComponent;
  53944. };
  53945. /**
  53946. * Disable the model's animation. Can be set at any time.
  53947. */
  53948. disableAnimation: boolean;
  53949. /**
  53950. * Observers registered here will be triggered when the model of this controller is done loading
  53951. */
  53952. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53953. /**
  53954. * The profile id of this motion controller
  53955. */
  53956. abstract profileId: string;
  53957. /**
  53958. * The root mesh of the model. It is null if the model was not yet initialized
  53959. */
  53960. rootMesh: Nullable<AbstractMesh>;
  53961. /**
  53962. * constructs a new abstract motion controller
  53963. * @param scene the scene to which the model of the controller will be added
  53964. * @param layout The profile layout to load
  53965. * @param gamepadObject The gamepad object correlating to this controller
  53966. * @param handedness handedness (left/right/none) of this controller
  53967. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53968. */
  53969. constructor(scene: Scene, layout: IMotionControllerLayout,
  53970. /**
  53971. * The gamepad object correlating to this controller
  53972. */
  53973. gamepadObject: IMinimalMotionControllerObject,
  53974. /**
  53975. * handedness (left/right/none) of this controller
  53976. */
  53977. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53978. /**
  53979. * Dispose this controller, the model mesh and all its components
  53980. */
  53981. dispose(): void;
  53982. /**
  53983. * Returns all components of specific type
  53984. * @param type the type to search for
  53985. * @return an array of components with this type
  53986. */
  53987. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53988. /**
  53989. * get a component based an its component id as defined in layout.components
  53990. * @param id the id of the component
  53991. * @returns the component correlates to the id or undefined if not found
  53992. */
  53993. getComponent(id: string): WebXRControllerComponent;
  53994. /**
  53995. * Get the list of components available in this motion controller
  53996. * @returns an array of strings correlating to available components
  53997. */
  53998. getComponentIds(): string[];
  53999. /**
  54000. * Get the first component of specific type
  54001. * @param type type of component to find
  54002. * @return a controller component or null if not found
  54003. */
  54004. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54005. /**
  54006. * Get the main (Select) component of this controller as defined in the layout
  54007. * @returns the main component of this controller
  54008. */
  54009. getMainComponent(): WebXRControllerComponent;
  54010. /**
  54011. * Loads the model correlating to this controller
  54012. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54013. * @returns A promise fulfilled with the result of the model loading
  54014. */
  54015. loadModel(): Promise<boolean>;
  54016. /**
  54017. * Update this model using the current XRFrame
  54018. * @param xrFrame the current xr frame to use and update the model
  54019. */
  54020. updateFromXRFrame(xrFrame: XRFrame): void;
  54021. /**
  54022. * Backwards compatibility due to a deeply-integrated typo
  54023. */
  54024. get handness(): XREye;
  54025. /**
  54026. * Pulse (vibrate) this controller
  54027. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54028. * Consecutive calls to this function will cancel the last pulse call
  54029. *
  54030. * @param value the strength of the pulse in 0.0...1.0 range
  54031. * @param duration Duration of the pulse in milliseconds
  54032. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54033. * @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
  54034. */
  54035. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54036. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54037. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54038. /**
  54039. * Moves the axis on the controller mesh based on its current state
  54040. * @param axis the index of the axis
  54041. * @param axisValue the value of the axis which determines the meshes new position
  54042. * @hidden
  54043. */
  54044. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54045. /**
  54046. * Update the model itself with the current frame data
  54047. * @param xrFrame the frame to use for updating the model mesh
  54048. */
  54049. protected updateModel(xrFrame: XRFrame): void;
  54050. /**
  54051. * Get the filename and path for this controller's model
  54052. * @returns a map of filename and path
  54053. */
  54054. protected abstract _getFilenameAndPath(): {
  54055. filename: string;
  54056. path: string;
  54057. };
  54058. /**
  54059. * This function is called before the mesh is loaded. It checks for loading constraints.
  54060. * For example, this function can check if the GLB loader is available
  54061. * If this function returns false, the generic controller will be loaded instead
  54062. * @returns Is the client ready to load the mesh
  54063. */
  54064. protected abstract _getModelLoadingConstraints(): boolean;
  54065. /**
  54066. * This function will be called after the model was successfully loaded and can be used
  54067. * for mesh transformations before it is available for the user
  54068. * @param meshes the loaded meshes
  54069. */
  54070. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54071. /**
  54072. * Set the root mesh for this controller. Important for the WebXR controller class
  54073. * @param meshes the loaded meshes
  54074. */
  54075. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54076. /**
  54077. * A function executed each frame that updates the mesh (if needed)
  54078. * @param xrFrame the current xrFrame
  54079. */
  54080. protected abstract _updateModel(xrFrame: XRFrame): void;
  54081. private _getGenericFilenameAndPath;
  54082. private _getGenericParentMesh;
  54083. }
  54084. }
  54085. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  54086. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54088. import { Scene } from "babylonjs/scene";
  54089. /**
  54090. * A generic trigger-only motion controller for WebXR
  54091. */
  54092. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54093. /**
  54094. * Static version of the profile id of this controller
  54095. */
  54096. static ProfileId: string;
  54097. profileId: string;
  54098. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54099. protected _getFilenameAndPath(): {
  54100. filename: string;
  54101. path: string;
  54102. };
  54103. protected _getModelLoadingConstraints(): boolean;
  54104. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54105. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54106. protected _updateModel(): void;
  54107. }
  54108. }
  54109. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  54110. import { Vector4 } from "babylonjs/Maths/math.vector";
  54111. import { Mesh } from "babylonjs/Meshes/mesh";
  54112. import { Scene } from "babylonjs/scene";
  54113. import { Nullable } from "babylonjs/types";
  54114. /**
  54115. * Class containing static functions to help procedurally build meshes
  54116. */
  54117. export class SphereBuilder {
  54118. /**
  54119. * Creates a sphere mesh
  54120. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54121. * * 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`)
  54122. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54123. * * 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
  54124. * * 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)
  54125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54128. * @param name defines the name of the mesh
  54129. * @param options defines the options used to create the mesh
  54130. * @param scene defines the hosting scene
  54131. * @returns the sphere mesh
  54132. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54133. */
  54134. static CreateSphere(name: string, options: {
  54135. segments?: number;
  54136. diameter?: number;
  54137. diameterX?: number;
  54138. diameterY?: number;
  54139. diameterZ?: number;
  54140. arc?: number;
  54141. slice?: number;
  54142. sideOrientation?: number;
  54143. frontUVs?: Vector4;
  54144. backUVs?: Vector4;
  54145. updatable?: boolean;
  54146. }, scene?: Nullable<Scene>): Mesh;
  54147. }
  54148. }
  54149. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  54150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54151. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54152. import { Scene } from "babylonjs/scene";
  54153. /**
  54154. * A profiled motion controller has its profile loaded from an online repository.
  54155. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54156. */
  54157. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54158. private _repositoryUrl;
  54159. private _buttonMeshMapping;
  54160. private _touchDots;
  54161. /**
  54162. * The profile ID of this controller. Will be populated when the controller initializes.
  54163. */
  54164. profileId: string;
  54165. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54166. dispose(): void;
  54167. protected _getFilenameAndPath(): {
  54168. filename: string;
  54169. path: string;
  54170. };
  54171. protected _getModelLoadingConstraints(): boolean;
  54172. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54173. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54174. protected _updateModel(_xrFrame: XRFrame): void;
  54175. }
  54176. }
  54177. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  54178. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54179. import { Scene } from "babylonjs/scene";
  54180. /**
  54181. * A construction function type to create a new controller based on an xrInput object
  54182. */
  54183. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54184. /**
  54185. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54186. *
  54187. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54188. * it should be replaced with auto-loaded controllers.
  54189. *
  54190. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54191. */
  54192. export class WebXRMotionControllerManager {
  54193. private static _AvailableControllers;
  54194. private static _Fallbacks;
  54195. private static _ProfileLoadingPromises;
  54196. private static _ProfilesList;
  54197. /**
  54198. * The base URL of the online controller repository. Can be changed at any time.
  54199. */
  54200. static BaseRepositoryUrl: string;
  54201. /**
  54202. * Which repository gets priority - local or online
  54203. */
  54204. static PrioritizeOnlineRepository: boolean;
  54205. /**
  54206. * Use the online repository, or use only locally-defined controllers
  54207. */
  54208. static UseOnlineRepository: boolean;
  54209. /**
  54210. * Clear the cache used for profile loading and reload when requested again
  54211. */
  54212. static ClearProfilesCache(): void;
  54213. /**
  54214. * Register the default fallbacks.
  54215. * This function is called automatically when this file is imported.
  54216. */
  54217. static DefaultFallbacks(): void;
  54218. /**
  54219. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54220. * @param profileId the profile to which a fallback needs to be found
  54221. * @return an array with corresponding fallback profiles
  54222. */
  54223. static FindFallbackWithProfileId(profileId: string): string[];
  54224. /**
  54225. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54226. * The order of search:
  54227. *
  54228. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54229. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54230. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54231. * 4) return the generic trigger controller if none were found
  54232. *
  54233. * @param xrInput the xrInput to which a new controller is initialized
  54234. * @param scene the scene to which the model will be added
  54235. * @param forceProfile force a certain profile for this controller
  54236. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54237. */
  54238. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54239. /**
  54240. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54241. *
  54242. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54243. *
  54244. * @param type the profile type to register
  54245. * @param constructFunction the function to be called when loading this profile
  54246. */
  54247. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54248. /**
  54249. * Register a fallback to a specific profile.
  54250. * @param profileId the profileId that will receive the fallbacks
  54251. * @param fallbacks A list of fallback profiles
  54252. */
  54253. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54254. /**
  54255. * Will update the list of profiles available in the repository
  54256. * @return a promise that resolves to a map of profiles available online
  54257. */
  54258. static UpdateProfilesList(): Promise<{
  54259. [profile: string]: string;
  54260. }>;
  54261. private static _LoadProfileFromRepository;
  54262. private static _LoadProfilesFromAvailableControllers;
  54263. }
  54264. }
  54265. declare module "babylonjs/XR/webXRInputSource" {
  54266. import { Observable } from "babylonjs/Misc/observable";
  54267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54268. import { Ray } from "babylonjs/Culling/ray";
  54269. import { Scene } from "babylonjs/scene";
  54270. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  54271. /**
  54272. * Configuration options for the WebXR controller creation
  54273. */
  54274. export interface IWebXRControllerOptions {
  54275. /**
  54276. * Should the controller mesh be animated when a user interacts with it
  54277. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54278. */
  54279. disableMotionControllerAnimation?: boolean;
  54280. /**
  54281. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54282. */
  54283. doNotLoadControllerMesh?: boolean;
  54284. /**
  54285. * Force a specific controller type for this controller.
  54286. * This can be used when creating your own profile or when testing different controllers
  54287. */
  54288. forceControllerProfile?: string;
  54289. /**
  54290. * Defines a rendering group ID for meshes that will be loaded.
  54291. * This is for the default controllers only.
  54292. */
  54293. renderingGroupId?: number;
  54294. }
  54295. /**
  54296. * Represents an XR controller
  54297. */
  54298. export class WebXRInputSource {
  54299. private _scene;
  54300. /** The underlying input source for the controller */
  54301. inputSource: XRInputSource;
  54302. private _options;
  54303. private _tmpVector;
  54304. private _uniqueId;
  54305. private _disposed;
  54306. /**
  54307. * 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
  54308. */
  54309. grip?: AbstractMesh;
  54310. /**
  54311. * If available, this is the gamepad object related to this controller.
  54312. * Using this object it is possible to get click events and trackpad changes of the
  54313. * webxr controller that is currently being used.
  54314. */
  54315. motionController?: WebXRAbstractMotionController;
  54316. /**
  54317. * Event that fires when the controller is removed/disposed.
  54318. * The object provided as event data is this controller, after associated assets were disposed.
  54319. * uniqueId is still available.
  54320. */
  54321. onDisposeObservable: Observable<WebXRInputSource>;
  54322. /**
  54323. * Will be triggered when the mesh associated with the motion controller is done loading.
  54324. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54325. * A shortened version of controller -> motion controller -> on mesh loaded.
  54326. */
  54327. onMeshLoadedObservable: Observable<AbstractMesh>;
  54328. /**
  54329. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54330. */
  54331. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54332. /**
  54333. * Pointer which can be used to select objects or attach a visible laser to
  54334. */
  54335. pointer: AbstractMesh;
  54336. /**
  54337. * Creates the input source object
  54338. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54339. * @param _scene the scene which the controller should be associated to
  54340. * @param inputSource the underlying input source for the controller
  54341. * @param _options options for this controller creation
  54342. */
  54343. constructor(_scene: Scene,
  54344. /** The underlying input source for the controller */
  54345. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54346. /**
  54347. * Get this controllers unique id
  54348. */
  54349. get uniqueId(): string;
  54350. /**
  54351. * Disposes of the object
  54352. */
  54353. dispose(): void;
  54354. /**
  54355. * Gets a world space ray coming from the pointer or grip
  54356. * @param result the resulting ray
  54357. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54358. */
  54359. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54360. /**
  54361. * Updates the controller pose based on the given XRFrame
  54362. * @param xrFrame xr frame to update the pose with
  54363. * @param referenceSpace reference space to use
  54364. */
  54365. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54366. }
  54367. }
  54368. declare module "babylonjs/XR/webXRInput" {
  54369. import { Observable } from "babylonjs/Misc/observable";
  54370. import { IDisposable } from "babylonjs/scene";
  54371. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54372. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54373. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54374. /**
  54375. * The schema for initialization options of the XR Input class
  54376. */
  54377. export interface IWebXRInputOptions {
  54378. /**
  54379. * If set to true no model will be automatically loaded
  54380. */
  54381. doNotLoadControllerMeshes?: boolean;
  54382. /**
  54383. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54384. * If not found, the xr input profile data will be used.
  54385. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54386. */
  54387. forceInputProfile?: string;
  54388. /**
  54389. * Do not send a request to the controller repository to load the profile.
  54390. *
  54391. * Instead, use the controllers available in babylon itself.
  54392. */
  54393. disableOnlineControllerRepository?: boolean;
  54394. /**
  54395. * A custom URL for the controllers repository
  54396. */
  54397. customControllersRepositoryURL?: string;
  54398. /**
  54399. * Should the controller model's components not move according to the user input
  54400. */
  54401. disableControllerAnimation?: boolean;
  54402. /**
  54403. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54404. */
  54405. controllerOptions?: IWebXRControllerOptions;
  54406. }
  54407. /**
  54408. * XR input used to track XR inputs such as controllers/rays
  54409. */
  54410. export class WebXRInput implements IDisposable {
  54411. /**
  54412. * the xr session manager for this session
  54413. */
  54414. xrSessionManager: WebXRSessionManager;
  54415. /**
  54416. * the WebXR camera for this session. Mainly used for teleportation
  54417. */
  54418. xrCamera: WebXRCamera;
  54419. private readonly options;
  54420. /**
  54421. * XR controllers being tracked
  54422. */
  54423. controllers: Array<WebXRInputSource>;
  54424. private _frameObserver;
  54425. private _sessionEndedObserver;
  54426. private _sessionInitObserver;
  54427. /**
  54428. * Event when a controller has been connected/added
  54429. */
  54430. onControllerAddedObservable: Observable<WebXRInputSource>;
  54431. /**
  54432. * Event when a controller has been removed/disconnected
  54433. */
  54434. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54435. /**
  54436. * Initializes the WebXRInput
  54437. * @param xrSessionManager the xr session manager for this session
  54438. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54439. * @param options = initialization options for this xr input
  54440. */
  54441. constructor(
  54442. /**
  54443. * the xr session manager for this session
  54444. */
  54445. xrSessionManager: WebXRSessionManager,
  54446. /**
  54447. * the WebXR camera for this session. Mainly used for teleportation
  54448. */
  54449. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54450. private _onInputSourcesChange;
  54451. private _addAndRemoveControllers;
  54452. /**
  54453. * Disposes of the object
  54454. */
  54455. dispose(): void;
  54456. }
  54457. }
  54458. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54459. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54460. import { Observable, EventState } from "babylonjs/Misc/observable";
  54461. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54462. /**
  54463. * This is the base class for all WebXR features.
  54464. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54465. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54466. */
  54467. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54468. protected _xrSessionManager: WebXRSessionManager;
  54469. private _attached;
  54470. private _removeOnDetach;
  54471. /**
  54472. * Is this feature disposed?
  54473. */
  54474. isDisposed: boolean;
  54475. /**
  54476. * Should auto-attach be disabled?
  54477. */
  54478. disableAutoAttach: boolean;
  54479. /**
  54480. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54481. */
  54482. xrNativeFeatureName: string;
  54483. /**
  54484. * Construct a new (abstract) WebXR feature
  54485. * @param _xrSessionManager the xr session manager for this feature
  54486. */
  54487. constructor(_xrSessionManager: WebXRSessionManager);
  54488. /**
  54489. * Is this feature attached
  54490. */
  54491. get attached(): boolean;
  54492. /**
  54493. * attach this feature
  54494. *
  54495. * @param force should attachment be forced (even when already attached)
  54496. * @returns true if successful, false is failed or already attached
  54497. */
  54498. attach(force?: boolean): boolean;
  54499. /**
  54500. * detach this feature.
  54501. *
  54502. * @returns true if successful, false if failed or already detached
  54503. */
  54504. detach(): boolean;
  54505. /**
  54506. * Dispose this feature and all of the resources attached
  54507. */
  54508. dispose(): void;
  54509. /**
  54510. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54511. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54512. *
  54513. * @returns whether or not the feature is compatible in this environment
  54514. */
  54515. isCompatible(): boolean;
  54516. /**
  54517. * This is used to register callbacks that will automatically be removed when detach is called.
  54518. * @param observable the observable to which the observer will be attached
  54519. * @param callback the callback to register
  54520. */
  54521. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54522. /**
  54523. * Code in this function will be executed on each xrFrame received from the browser.
  54524. * This function will not execute after the feature is detached.
  54525. * @param _xrFrame the current frame
  54526. */
  54527. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54528. }
  54529. }
  54530. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54531. import { IDisposable, Scene } from "babylonjs/scene";
  54532. import { Nullable } from "babylonjs/types";
  54533. import { Observable } from "babylonjs/Misc/observable";
  54534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54535. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54536. import { Camera } from "babylonjs/Cameras/camera";
  54537. /**
  54538. * Renders a layer on top of an existing scene
  54539. */
  54540. export class UtilityLayerRenderer implements IDisposable {
  54541. /** the original scene that will be rendered on top of */
  54542. originalScene: Scene;
  54543. private _pointerCaptures;
  54544. private _lastPointerEvents;
  54545. private static _DefaultUtilityLayer;
  54546. private static _DefaultKeepDepthUtilityLayer;
  54547. private _sharedGizmoLight;
  54548. private _renderCamera;
  54549. /**
  54550. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54551. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54552. * @returns the camera that is used when rendering the utility layer
  54553. */
  54554. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54555. /**
  54556. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54557. * @param cam the camera that should be used when rendering the utility layer
  54558. */
  54559. setRenderCamera(cam: Nullable<Camera>): void;
  54560. /**
  54561. * @hidden
  54562. * Light which used by gizmos to get light shading
  54563. */
  54564. _getSharedGizmoLight(): HemisphericLight;
  54565. /**
  54566. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54567. */
  54568. pickUtilitySceneFirst: boolean;
  54569. /**
  54570. * 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)
  54571. */
  54572. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54573. /**
  54574. * 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)
  54575. */
  54576. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54577. /**
  54578. * The scene that is rendered on top of the original scene
  54579. */
  54580. utilityLayerScene: Scene;
  54581. /**
  54582. * If the utility layer should automatically be rendered on top of existing scene
  54583. */
  54584. shouldRender: boolean;
  54585. /**
  54586. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54587. */
  54588. onlyCheckPointerDownEvents: boolean;
  54589. /**
  54590. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54591. */
  54592. processAllEvents: boolean;
  54593. /**
  54594. * Observable raised when the pointer move from the utility layer scene to the main scene
  54595. */
  54596. onPointerOutObservable: Observable<number>;
  54597. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54598. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54599. private _afterRenderObserver;
  54600. private _sceneDisposeObserver;
  54601. private _originalPointerObserver;
  54602. /**
  54603. * Instantiates a UtilityLayerRenderer
  54604. * @param originalScene the original scene that will be rendered on top of
  54605. * @param handleEvents boolean indicating if the utility layer should handle events
  54606. */
  54607. constructor(
  54608. /** the original scene that will be rendered on top of */
  54609. originalScene: Scene, handleEvents?: boolean);
  54610. private _notifyObservers;
  54611. /**
  54612. * Renders the utility layers scene on top of the original scene
  54613. */
  54614. render(): void;
  54615. /**
  54616. * Disposes of the renderer
  54617. */
  54618. dispose(): void;
  54619. private _updateCamera;
  54620. }
  54621. }
  54622. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54623. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54625. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54626. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54627. import { Scene } from "babylonjs/scene";
  54628. import { Nullable } from "babylonjs/types";
  54629. import { Color3 } from "babylonjs/Maths/math.color";
  54630. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54631. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54632. /**
  54633. * Options interface for the pointer selection module
  54634. */
  54635. export interface IWebXRControllerPointerSelectionOptions {
  54636. /**
  54637. * if provided, this scene will be used to render meshes.
  54638. */
  54639. customUtilityLayerScene?: Scene;
  54640. /**
  54641. * 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)
  54642. * If not disabled, the last picked point will be used to execute a pointer up event
  54643. * If disabled, pointer up event will be triggered right after the pointer down event.
  54644. * Used in screen and gaze target ray mode only
  54645. */
  54646. disablePointerUpOnTouchOut: boolean;
  54647. /**
  54648. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54649. */
  54650. forceGazeMode: boolean;
  54651. /**
  54652. * 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
  54653. * to start a new countdown to the pointer down event.
  54654. * Defaults to 1.
  54655. */
  54656. gazeModePointerMovedFactor?: number;
  54657. /**
  54658. * Different button type to use instead of the main component
  54659. */
  54660. overrideButtonId?: string;
  54661. /**
  54662. * use this rendering group id for the meshes (optional)
  54663. */
  54664. renderingGroupId?: number;
  54665. /**
  54666. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54667. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54668. * 3000 means 3 seconds between pointing at something and selecting it
  54669. */
  54670. timeToSelect?: number;
  54671. /**
  54672. * Should meshes created here be added to a utility layer or the main scene
  54673. */
  54674. useUtilityLayer?: boolean;
  54675. /**
  54676. * Optional WebXR camera to be used for gaze selection
  54677. */
  54678. gazeCamera?: WebXRCamera;
  54679. /**
  54680. * the xr input to use with this pointer selection
  54681. */
  54682. xrInput: WebXRInput;
  54683. /**
  54684. * Should the scene pointerX and pointerY update be disabled
  54685. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54686. * Disable in VR, if not needed.
  54687. * The first rig camera (left eye) will be used to calculate the projection
  54688. */
  54689. disableScenePointerVectorUpdate: boolean;
  54690. /**
  54691. * Enable pointer selection on all controllers instead of switching between them
  54692. */
  54693. enablePointerSelectionOnAllControllers?: boolean;
  54694. /**
  54695. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54696. * If switch is enabled, it will still allow the user to switch between the different controllers
  54697. */
  54698. preferredHandedness?: XRHandedness;
  54699. /**
  54700. * Disable switching the pointer selection from one controller to the other.
  54701. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  54702. */
  54703. disableSwitchOnClick?: boolean;
  54704. /**
  54705. * The maximum distance of the pointer selection feature. Defaults to 100.
  54706. */
  54707. maxPointerDistance?: number;
  54708. }
  54709. /**
  54710. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54711. */
  54712. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54713. private readonly _options;
  54714. private static _idCounter;
  54715. private _attachController;
  54716. private _controllers;
  54717. private _scene;
  54718. private _tmpVectorForPickCompare;
  54719. private _attachedController;
  54720. /**
  54721. * The module's name
  54722. */
  54723. static readonly Name: string;
  54724. /**
  54725. * The (Babylon) version of this module.
  54726. * This is an integer representing the implementation version.
  54727. * This number does not correspond to the WebXR specs version
  54728. */
  54729. static readonly Version: number;
  54730. /**
  54731. * Disable lighting on the laser pointer (so it will always be visible)
  54732. */
  54733. disablePointerLighting: boolean;
  54734. /**
  54735. * Disable lighting on the selection mesh (so it will always be visible)
  54736. */
  54737. disableSelectionMeshLighting: boolean;
  54738. /**
  54739. * Should the laser pointer be displayed
  54740. */
  54741. displayLaserPointer: boolean;
  54742. /**
  54743. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54744. */
  54745. displaySelectionMesh: boolean;
  54746. /**
  54747. * This color will be set to the laser pointer when selection is triggered
  54748. */
  54749. laserPointerPickedColor: Color3;
  54750. /**
  54751. * Default color of the laser pointer
  54752. */
  54753. laserPointerDefaultColor: Color3;
  54754. /**
  54755. * default color of the selection ring
  54756. */
  54757. selectionMeshDefaultColor: Color3;
  54758. /**
  54759. * This color will be applied to the selection ring when selection is triggered
  54760. */
  54761. selectionMeshPickedColor: Color3;
  54762. /**
  54763. * Optional filter to be used for ray selection. This predicate shares behavior with
  54764. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54765. */
  54766. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54767. /**
  54768. * constructs a new background remover module
  54769. * @param _xrSessionManager the session manager for this module
  54770. * @param _options read-only options to be used in this module
  54771. */
  54772. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54773. /**
  54774. * attach this feature
  54775. * Will usually be called by the features manager
  54776. *
  54777. * @returns true if successful.
  54778. */
  54779. attach(): boolean;
  54780. /**
  54781. * detach this feature.
  54782. * Will usually be called by the features manager
  54783. *
  54784. * @returns true if successful.
  54785. */
  54786. detach(): boolean;
  54787. /**
  54788. * Will get the mesh under a specific pointer.
  54789. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54790. * @param controllerId the controllerId to check
  54791. * @returns The mesh under pointer or null if no mesh is under the pointer
  54792. */
  54793. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54794. /**
  54795. * Get the xr controller that correlates to the pointer id in the pointer event
  54796. *
  54797. * @param id the pointer id to search for
  54798. * @returns the controller that correlates to this id or null if not found
  54799. */
  54800. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54801. private _identityMatrix;
  54802. private _screenCoordinatesRef;
  54803. private _viewportRef;
  54804. protected _onXRFrame(_xrFrame: XRFrame): void;
  54805. private _attachGazeMode;
  54806. private _attachScreenRayMode;
  54807. private _attachTrackedPointerRayMode;
  54808. private _convertNormalToDirectionOfRay;
  54809. private _detachController;
  54810. private _generateNewMeshPair;
  54811. private _pickingMoved;
  54812. private _updatePointerDistance;
  54813. /** @hidden */
  54814. get lasterPointerDefaultColor(): Color3;
  54815. }
  54816. }
  54817. declare module "babylonjs/XR/webXREnterExitUI" {
  54818. import { Nullable } from "babylonjs/types";
  54819. import { Observable } from "babylonjs/Misc/observable";
  54820. import { IDisposable, Scene } from "babylonjs/scene";
  54821. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54822. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54823. /**
  54824. * Button which can be used to enter a different mode of XR
  54825. */
  54826. export class WebXREnterExitUIButton {
  54827. /** button element */
  54828. element: HTMLElement;
  54829. /** XR initialization options for the button */
  54830. sessionMode: XRSessionMode;
  54831. /** Reference space type */
  54832. referenceSpaceType: XRReferenceSpaceType;
  54833. /**
  54834. * Creates a WebXREnterExitUIButton
  54835. * @param element button element
  54836. * @param sessionMode XR initialization session mode
  54837. * @param referenceSpaceType the type of reference space to be used
  54838. */
  54839. constructor(
  54840. /** button element */
  54841. element: HTMLElement,
  54842. /** XR initialization options for the button */
  54843. sessionMode: XRSessionMode,
  54844. /** Reference space type */
  54845. referenceSpaceType: XRReferenceSpaceType);
  54846. /**
  54847. * Extendable function which can be used to update the button's visuals when the state changes
  54848. * @param activeButton the current active button in the UI
  54849. */
  54850. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54851. }
  54852. /**
  54853. * Options to create the webXR UI
  54854. */
  54855. export class WebXREnterExitUIOptions {
  54856. /**
  54857. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54858. */
  54859. customButtons?: Array<WebXREnterExitUIButton>;
  54860. /**
  54861. * A reference space type to use when creating the default button.
  54862. * Default is local-floor
  54863. */
  54864. referenceSpaceType?: XRReferenceSpaceType;
  54865. /**
  54866. * Context to enter xr with
  54867. */
  54868. renderTarget?: Nullable<WebXRRenderTarget>;
  54869. /**
  54870. * A session mode to use when creating the default button.
  54871. * Default is immersive-vr
  54872. */
  54873. sessionMode?: XRSessionMode;
  54874. /**
  54875. * A list of optional features to init the session with
  54876. */
  54877. optionalFeatures?: string[];
  54878. /**
  54879. * A list of optional features to init the session with
  54880. */
  54881. requiredFeatures?: string[];
  54882. /**
  54883. * If defined, this function will be executed if the UI encounters an error when entering XR
  54884. */
  54885. onError?: (error: any) => void;
  54886. }
  54887. /**
  54888. * UI to allow the user to enter/exit XR mode
  54889. */
  54890. export class WebXREnterExitUI implements IDisposable {
  54891. private scene;
  54892. /** version of the options passed to this UI */
  54893. options: WebXREnterExitUIOptions;
  54894. private _activeButton;
  54895. private _buttons;
  54896. /**
  54897. * The HTML Div Element to which buttons are added.
  54898. */
  54899. readonly overlay: HTMLDivElement;
  54900. /**
  54901. * Fired every time the active button is changed.
  54902. *
  54903. * When xr is entered via a button that launches xr that button will be the callback parameter
  54904. *
  54905. * When exiting xr the callback parameter will be null)
  54906. */
  54907. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54908. /**
  54909. *
  54910. * @param scene babylon scene object to use
  54911. * @param options (read-only) version of the options passed to this UI
  54912. */
  54913. private constructor();
  54914. /**
  54915. * Creates UI to allow the user to enter/exit XR mode
  54916. * @param scene the scene to add the ui to
  54917. * @param helper the xr experience helper to enter/exit xr with
  54918. * @param options options to configure the UI
  54919. * @returns the created ui
  54920. */
  54921. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54922. /**
  54923. * Disposes of the XR UI component
  54924. */
  54925. dispose(): void;
  54926. private _updateButtons;
  54927. }
  54928. }
  54929. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54930. import { Vector3 } from "babylonjs/Maths/math.vector";
  54931. import { Color4 } from "babylonjs/Maths/math.color";
  54932. import { Nullable } from "babylonjs/types";
  54933. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54934. import { Scene } from "babylonjs/scene";
  54935. /**
  54936. * Class containing static functions to help procedurally build meshes
  54937. */
  54938. export class LinesBuilder {
  54939. /**
  54940. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54941. * * 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
  54942. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54943. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54944. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54945. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54946. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54947. * * 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
  54948. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54950. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54951. * @param name defines the name of the new line system
  54952. * @param options defines the options used to create the line system
  54953. * @param scene defines the hosting scene
  54954. * @returns a new line system mesh
  54955. */
  54956. static CreateLineSystem(name: string, options: {
  54957. lines: Vector3[][];
  54958. updatable?: boolean;
  54959. instance?: Nullable<LinesMesh>;
  54960. colors?: Nullable<Color4[][]>;
  54961. useVertexAlpha?: boolean;
  54962. }, scene: Nullable<Scene>): LinesMesh;
  54963. /**
  54964. * Creates a line mesh
  54965. * 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
  54966. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54967. * * The parameter `points` is an array successive Vector3
  54968. * * 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
  54969. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54970. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54971. * * When updating an instance, remember that only point positions can change, not the number of points
  54972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54973. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54974. * @param name defines the name of the new line system
  54975. * @param options defines the options used to create the line system
  54976. * @param scene defines the hosting scene
  54977. * @returns a new line mesh
  54978. */
  54979. static CreateLines(name: string, options: {
  54980. points: Vector3[];
  54981. updatable?: boolean;
  54982. instance?: Nullable<LinesMesh>;
  54983. colors?: Color4[];
  54984. useVertexAlpha?: boolean;
  54985. }, scene?: Nullable<Scene>): LinesMesh;
  54986. /**
  54987. * Creates a dashed line mesh
  54988. * * 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
  54989. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54990. * * The parameter `points` is an array successive Vector3
  54991. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54992. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54993. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54994. * * 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
  54995. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54996. * * When updating an instance, remember that only point positions can change, not the number of points
  54997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54998. * @param name defines the name of the mesh
  54999. * @param options defines the options used to create the mesh
  55000. * @param scene defines the hosting scene
  55001. * @returns the dashed line mesh
  55002. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55003. */
  55004. static CreateDashedLines(name: string, options: {
  55005. points: Vector3[];
  55006. dashSize?: number;
  55007. gapSize?: number;
  55008. dashNb?: number;
  55009. updatable?: boolean;
  55010. instance?: LinesMesh;
  55011. useVertexAlpha?: boolean;
  55012. }, scene?: Nullable<Scene>): LinesMesh;
  55013. }
  55014. }
  55015. declare module "babylonjs/Misc/timer" {
  55016. import { Observable, Observer } from "babylonjs/Misc/observable";
  55017. import { Nullable } from "babylonjs/types";
  55018. import { IDisposable } from "babylonjs/scene";
  55019. /**
  55020. * Construction options for a timer
  55021. */
  55022. export interface ITimerOptions<T> {
  55023. /**
  55024. * Time-to-end
  55025. */
  55026. timeout: number;
  55027. /**
  55028. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55029. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55030. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55031. */
  55032. contextObservable: Observable<T>;
  55033. /**
  55034. * Optional parameters when adding an observer to the observable
  55035. */
  55036. observableParameters?: {
  55037. mask?: number;
  55038. insertFirst?: boolean;
  55039. scope?: any;
  55040. };
  55041. /**
  55042. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55043. */
  55044. breakCondition?: (data?: ITimerData<T>) => boolean;
  55045. /**
  55046. * Will be triggered when the time condition has met
  55047. */
  55048. onEnded?: (data: ITimerData<any>) => void;
  55049. /**
  55050. * Will be triggered when the break condition has met (prematurely ended)
  55051. */
  55052. onAborted?: (data: ITimerData<any>) => void;
  55053. /**
  55054. * Optional function to execute on each tick (or count)
  55055. */
  55056. onTick?: (data: ITimerData<any>) => void;
  55057. }
  55058. /**
  55059. * An interface defining the data sent by the timer
  55060. */
  55061. export interface ITimerData<T> {
  55062. /**
  55063. * When did it start
  55064. */
  55065. startTime: number;
  55066. /**
  55067. * Time now
  55068. */
  55069. currentTime: number;
  55070. /**
  55071. * Time passed since started
  55072. */
  55073. deltaTime: number;
  55074. /**
  55075. * How much is completed, in [0.0...1.0].
  55076. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55077. */
  55078. completeRate: number;
  55079. /**
  55080. * What the registered observable sent in the last count
  55081. */
  55082. payload: T;
  55083. }
  55084. /**
  55085. * The current state of the timer
  55086. */
  55087. export enum TimerState {
  55088. /**
  55089. * Timer initialized, not yet started
  55090. */
  55091. INIT = 0,
  55092. /**
  55093. * Timer started and counting
  55094. */
  55095. STARTED = 1,
  55096. /**
  55097. * Timer ended (whether aborted or time reached)
  55098. */
  55099. ENDED = 2
  55100. }
  55101. /**
  55102. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55103. *
  55104. * @param options options with which to initialize this timer
  55105. */
  55106. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55107. /**
  55108. * An advanced implementation of a timer class
  55109. */
  55110. export class AdvancedTimer<T = any> implements IDisposable {
  55111. /**
  55112. * Will notify each time the timer calculates the remaining time
  55113. */
  55114. onEachCountObservable: Observable<ITimerData<T>>;
  55115. /**
  55116. * Will trigger when the timer was aborted due to the break condition
  55117. */
  55118. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55119. /**
  55120. * Will trigger when the timer ended successfully
  55121. */
  55122. onTimerEndedObservable: Observable<ITimerData<T>>;
  55123. /**
  55124. * Will trigger when the timer state has changed
  55125. */
  55126. onStateChangedObservable: Observable<TimerState>;
  55127. private _observer;
  55128. private _contextObservable;
  55129. private _observableParameters;
  55130. private _startTime;
  55131. private _timer;
  55132. private _state;
  55133. private _breakCondition;
  55134. private _timeToEnd;
  55135. private _breakOnNextTick;
  55136. /**
  55137. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55138. * @param options construction options for this advanced timer
  55139. */
  55140. constructor(options: ITimerOptions<T>);
  55141. /**
  55142. * set a breaking condition for this timer. Default is to never break during count
  55143. * @param predicate the new break condition. Returns true to break, false otherwise
  55144. */
  55145. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55146. /**
  55147. * Reset ALL associated observables in this advanced timer
  55148. */
  55149. clearObservables(): void;
  55150. /**
  55151. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55152. *
  55153. * @param timeToEnd how much time to measure until timer ended
  55154. */
  55155. start(timeToEnd?: number): void;
  55156. /**
  55157. * Will force a stop on the next tick.
  55158. */
  55159. stop(): void;
  55160. /**
  55161. * Dispose this timer, clearing all resources
  55162. */
  55163. dispose(): void;
  55164. private _setState;
  55165. private _tick;
  55166. private _stop;
  55167. }
  55168. }
  55169. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  55170. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  55171. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  55172. import { Nullable } from "babylonjs/types";
  55173. import { WebXRInput } from "babylonjs/XR/webXRInput";
  55174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55175. import { Vector3 } from "babylonjs/Maths/math.vector";
  55176. import { Material } from "babylonjs/Materials/material";
  55177. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  55178. import { Scene } from "babylonjs/scene";
  55179. /**
  55180. * The options container for the teleportation module
  55181. */
  55182. export interface IWebXRTeleportationOptions {
  55183. /**
  55184. * if provided, this scene will be used to render meshes.
  55185. */
  55186. customUtilityLayerScene?: Scene;
  55187. /**
  55188. * Values to configure the default target mesh
  55189. */
  55190. defaultTargetMeshOptions?: {
  55191. /**
  55192. * Fill color of the teleportation area
  55193. */
  55194. teleportationFillColor?: string;
  55195. /**
  55196. * Border color for the teleportation area
  55197. */
  55198. teleportationBorderColor?: string;
  55199. /**
  55200. * Disable the mesh's animation sequence
  55201. */
  55202. disableAnimation?: boolean;
  55203. /**
  55204. * Disable lighting on the material or the ring and arrow
  55205. */
  55206. disableLighting?: boolean;
  55207. /**
  55208. * Override the default material of the torus and arrow
  55209. */
  55210. torusArrowMaterial?: Material;
  55211. };
  55212. /**
  55213. * A list of meshes to use as floor meshes.
  55214. * Meshes can be added and removed after initializing the feature using the
  55215. * addFloorMesh and removeFloorMesh functions
  55216. * If empty, rotation will still work
  55217. */
  55218. floorMeshes?: AbstractMesh[];
  55219. /**
  55220. * use this rendering group id for the meshes (optional)
  55221. */
  55222. renderingGroupId?: number;
  55223. /**
  55224. * Should teleportation move only to snap points
  55225. */
  55226. snapPointsOnly?: boolean;
  55227. /**
  55228. * An array of points to which the teleportation will snap to.
  55229. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55230. */
  55231. snapPositions?: Vector3[];
  55232. /**
  55233. * How close should the teleportation ray be in order to snap to position.
  55234. * Default to 0.8 units (meters)
  55235. */
  55236. snapToPositionRadius?: number;
  55237. /**
  55238. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55239. * If you want to support rotation, make sure your mesh has a direction indicator.
  55240. *
  55241. * When left untouched, the default mesh will be initialized.
  55242. */
  55243. teleportationTargetMesh?: AbstractMesh;
  55244. /**
  55245. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55246. */
  55247. timeToTeleport?: number;
  55248. /**
  55249. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55250. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55251. */
  55252. useMainComponentOnly?: boolean;
  55253. /**
  55254. * Should meshes created here be added to a utility layer or the main scene
  55255. */
  55256. useUtilityLayer?: boolean;
  55257. /**
  55258. * Babylon XR Input class for controller
  55259. */
  55260. xrInput: WebXRInput;
  55261. /**
  55262. * Meshes that the teleportation ray cannot go through
  55263. */
  55264. pickBlockerMeshes?: AbstractMesh[];
  55265. /**
  55266. * Should teleport work only on a specific hand?
  55267. */
  55268. forceHandedness?: XRHandedness;
  55269. /**
  55270. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55271. */
  55272. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55273. }
  55274. /**
  55275. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55276. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55277. * the input of the attached controllers.
  55278. */
  55279. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55280. private _options;
  55281. private _controllers;
  55282. private _currentTeleportationControllerId;
  55283. private _floorMeshes;
  55284. private _quadraticBezierCurve;
  55285. private _selectionFeature;
  55286. private _snapToPositions;
  55287. private _snappedToPoint;
  55288. private _teleportationRingMaterial?;
  55289. private _tmpRay;
  55290. private _tmpVector;
  55291. private _tmpQuaternion;
  55292. /**
  55293. * The module's name
  55294. */
  55295. static readonly Name: string;
  55296. /**
  55297. * The (Babylon) version of this module.
  55298. * This is an integer representing the implementation version.
  55299. * This number does not correspond to the webxr specs version
  55300. */
  55301. static readonly Version: number;
  55302. /**
  55303. * Is movement backwards enabled
  55304. */
  55305. backwardsMovementEnabled: boolean;
  55306. /**
  55307. * Distance to travel when moving backwards
  55308. */
  55309. backwardsTeleportationDistance: number;
  55310. /**
  55311. * The distance from the user to the inspection point in the direction of the controller
  55312. * A higher number will allow the user to move further
  55313. * defaults to 5 (meters, in xr units)
  55314. */
  55315. parabolicCheckRadius: number;
  55316. /**
  55317. * Should the module support parabolic ray on top of direct ray
  55318. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55319. * Very helpful when moving between floors / different heights
  55320. */
  55321. parabolicRayEnabled: boolean;
  55322. /**
  55323. * The second type of ray - straight line.
  55324. * Should it be enabled or should the parabolic line be the only one.
  55325. */
  55326. straightRayEnabled: boolean;
  55327. /**
  55328. * How much rotation should be applied when rotating right and left
  55329. */
  55330. rotationAngle: number;
  55331. private _rotationEnabled;
  55332. /**
  55333. * Is rotation enabled when moving forward?
  55334. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55335. */
  55336. get rotationEnabled(): boolean;
  55337. /**
  55338. * Sets wether rotation is enabled or not
  55339. * @param enabled is rotation enabled when teleportation is shown
  55340. */
  55341. set rotationEnabled(enabled: boolean);
  55342. /**
  55343. * Exposes the currently set teleportation target mesh.
  55344. */
  55345. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55346. /**
  55347. * constructs a new anchor system
  55348. * @param _xrSessionManager an instance of WebXRSessionManager
  55349. * @param _options configuration object for this feature
  55350. */
  55351. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55352. /**
  55353. * Get the snapPointsOnly flag
  55354. */
  55355. get snapPointsOnly(): boolean;
  55356. /**
  55357. * Sets the snapPointsOnly flag
  55358. * @param snapToPoints should teleportation be exclusively to snap points
  55359. */
  55360. set snapPointsOnly(snapToPoints: boolean);
  55361. /**
  55362. * Add a new mesh to the floor meshes array
  55363. * @param mesh the mesh to use as floor mesh
  55364. */
  55365. addFloorMesh(mesh: AbstractMesh): void;
  55366. /**
  55367. * Add a new snap-to point to fix teleportation to this position
  55368. * @param newSnapPoint The new Snap-To point
  55369. */
  55370. addSnapPoint(newSnapPoint: Vector3): void;
  55371. attach(): boolean;
  55372. detach(): boolean;
  55373. dispose(): void;
  55374. /**
  55375. * Remove a mesh from the floor meshes array
  55376. * @param mesh the mesh to remove
  55377. */
  55378. removeFloorMesh(mesh: AbstractMesh): void;
  55379. /**
  55380. * Remove a mesh from the floor meshes array using its name
  55381. * @param name the mesh name to remove
  55382. */
  55383. removeFloorMeshByName(name: string): void;
  55384. /**
  55385. * 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
  55386. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55387. * @returns was the point found and removed or not
  55388. */
  55389. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55390. /**
  55391. * This function sets a selection feature that will be disabled when
  55392. * the forward ray is shown and will be reattached when hidden.
  55393. * This is used to remove the selection rays when moving.
  55394. * @param selectionFeature the feature to disable when forward movement is enabled
  55395. */
  55396. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55397. protected _onXRFrame(_xrFrame: XRFrame): void;
  55398. private _attachController;
  55399. private _createDefaultTargetMesh;
  55400. private _detachController;
  55401. private _findClosestSnapPointWithRadius;
  55402. private _setTargetMeshPosition;
  55403. private _setTargetMeshVisibility;
  55404. private _showParabolicPath;
  55405. private _teleportForward;
  55406. }
  55407. }
  55408. declare module "babylonjs/XR/webXRDefaultExperience" {
  55409. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55410. import { Scene } from "babylonjs/scene";
  55411. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55412. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55413. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55414. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55415. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55416. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55417. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55418. /**
  55419. * Options for the default xr helper
  55420. */
  55421. export class WebXRDefaultExperienceOptions {
  55422. /**
  55423. * Enable or disable default UI to enter XR
  55424. */
  55425. disableDefaultUI?: boolean;
  55426. /**
  55427. * Should teleportation not initialize. defaults to false.
  55428. */
  55429. disableTeleportation?: boolean;
  55430. /**
  55431. * Floor meshes that will be used for teleport
  55432. */
  55433. floorMeshes?: Array<AbstractMesh>;
  55434. /**
  55435. * If set to true, the first frame will not be used to reset position
  55436. * The first frame is mainly used when copying transformation from the old camera
  55437. * Mainly used in AR
  55438. */
  55439. ignoreNativeCameraTransformation?: boolean;
  55440. /**
  55441. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55442. */
  55443. inputOptions?: IWebXRInputOptions;
  55444. /**
  55445. * optional configuration for the output canvas
  55446. */
  55447. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55448. /**
  55449. * optional UI options. This can be used among other to change session mode and reference space type
  55450. */
  55451. uiOptions?: WebXREnterExitUIOptions;
  55452. /**
  55453. * When loading teleportation and pointer select, use stable versions instead of latest.
  55454. */
  55455. useStablePlugins?: boolean;
  55456. /**
  55457. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55458. */
  55459. renderingGroupId?: number;
  55460. /**
  55461. * A list of optional features to init the session with
  55462. * If set to true, all features we support will be added
  55463. */
  55464. optionalFeatures?: boolean | string[];
  55465. }
  55466. /**
  55467. * Default experience which provides a similar setup to the previous webVRExperience
  55468. */
  55469. export class WebXRDefaultExperience {
  55470. /**
  55471. * Base experience
  55472. */
  55473. baseExperience: WebXRExperienceHelper;
  55474. /**
  55475. * Enables ui for entering/exiting xr
  55476. */
  55477. enterExitUI: WebXREnterExitUI;
  55478. /**
  55479. * Input experience extension
  55480. */
  55481. input: WebXRInput;
  55482. /**
  55483. * Enables laser pointer and selection
  55484. */
  55485. pointerSelection: WebXRControllerPointerSelection;
  55486. /**
  55487. * Default target xr should render to
  55488. */
  55489. renderTarget: WebXRRenderTarget;
  55490. /**
  55491. * Enables teleportation
  55492. */
  55493. teleportation: WebXRMotionControllerTeleportation;
  55494. private constructor();
  55495. /**
  55496. * Creates the default xr experience
  55497. * @param scene scene
  55498. * @param options options for basic configuration
  55499. * @returns resulting WebXRDefaultExperience
  55500. */
  55501. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55502. /**
  55503. * DIsposes of the experience helper
  55504. */
  55505. dispose(): void;
  55506. }
  55507. }
  55508. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55509. import { Observable } from "babylonjs/Misc/observable";
  55510. import { Nullable } from "babylonjs/types";
  55511. import { Camera } from "babylonjs/Cameras/camera";
  55512. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55513. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55514. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55515. import { Scene } from "babylonjs/scene";
  55516. import { Vector3 } from "babylonjs/Maths/math.vector";
  55517. import { Color3 } from "babylonjs/Maths/math.color";
  55518. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55520. import { Mesh } from "babylonjs/Meshes/mesh";
  55521. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55522. import { EasingFunction } from "babylonjs/Animations/easing";
  55523. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55524. import "babylonjs/Meshes/Builders/groundBuilder";
  55525. import "babylonjs/Meshes/Builders/torusBuilder";
  55526. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55527. import "babylonjs/Gamepads/gamepadSceneComponent";
  55528. import "babylonjs/Animations/animatable";
  55529. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55530. /**
  55531. * Options to modify the vr teleportation behavior.
  55532. */
  55533. export interface VRTeleportationOptions {
  55534. /**
  55535. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55536. */
  55537. floorMeshName?: string;
  55538. /**
  55539. * A list of meshes to be used as the teleportation floor. (default: empty)
  55540. */
  55541. floorMeshes?: Mesh[];
  55542. /**
  55543. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55544. */
  55545. teleportationMode?: number;
  55546. /**
  55547. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55548. */
  55549. teleportationTime?: number;
  55550. /**
  55551. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55552. */
  55553. teleportationSpeed?: number;
  55554. /**
  55555. * The easing function used in the animation or null for Linear. (default CircleEase)
  55556. */
  55557. easingFunction?: EasingFunction;
  55558. }
  55559. /**
  55560. * Options to modify the vr experience helper's behavior.
  55561. */
  55562. export interface VRExperienceHelperOptions extends WebVROptions {
  55563. /**
  55564. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55565. */
  55566. createDeviceOrientationCamera?: boolean;
  55567. /**
  55568. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55569. */
  55570. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55571. /**
  55572. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55573. */
  55574. laserToggle?: boolean;
  55575. /**
  55576. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55577. */
  55578. floorMeshes?: Mesh[];
  55579. /**
  55580. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55581. */
  55582. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55583. /**
  55584. * Defines if WebXR should be used instead of WebVR (if available)
  55585. */
  55586. useXR?: boolean;
  55587. }
  55588. /**
  55589. * Event containing information after VR has been entered
  55590. */
  55591. export class OnAfterEnteringVRObservableEvent {
  55592. /**
  55593. * If entering vr was successful
  55594. */
  55595. success: boolean;
  55596. }
  55597. /**
  55598. * Helps to quickly add VR support to an existing scene.
  55599. * See https://doc.babylonjs.com/how_to/webvr_helper
  55600. */
  55601. export class VRExperienceHelper {
  55602. /** Options to modify the vr experience helper's behavior. */
  55603. webVROptions: VRExperienceHelperOptions;
  55604. private _scene;
  55605. private _position;
  55606. private _btnVR;
  55607. private _btnVRDisplayed;
  55608. private _webVRsupported;
  55609. private _webVRready;
  55610. private _webVRrequesting;
  55611. private _webVRpresenting;
  55612. private _hasEnteredVR;
  55613. private _fullscreenVRpresenting;
  55614. private _inputElement;
  55615. private _webVRCamera;
  55616. private _vrDeviceOrientationCamera;
  55617. private _deviceOrientationCamera;
  55618. private _existingCamera;
  55619. private _onKeyDown;
  55620. private _onVrDisplayPresentChange;
  55621. private _onVRDisplayChanged;
  55622. private _onVRRequestPresentStart;
  55623. private _onVRRequestPresentComplete;
  55624. /**
  55625. * 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)
  55626. */
  55627. enableGazeEvenWhenNoPointerLock: boolean;
  55628. /**
  55629. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55630. */
  55631. exitVROnDoubleTap: boolean;
  55632. /**
  55633. * Observable raised right before entering VR.
  55634. */
  55635. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55636. /**
  55637. * Observable raised when entering VR has completed.
  55638. */
  55639. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55640. /**
  55641. * Observable raised when exiting VR.
  55642. */
  55643. onExitingVRObservable: Observable<VRExperienceHelper>;
  55644. /**
  55645. * Observable raised when controller mesh is loaded.
  55646. */
  55647. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55648. /** Return this.onEnteringVRObservable
  55649. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55650. */
  55651. get onEnteringVR(): Observable<VRExperienceHelper>;
  55652. /** Return this.onExitingVRObservable
  55653. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55654. */
  55655. get onExitingVR(): Observable<VRExperienceHelper>;
  55656. /** Return this.onControllerMeshLoadedObservable
  55657. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55658. */
  55659. get onControllerMeshLoaded(): Observable<WebVRController>;
  55660. private _rayLength;
  55661. private _useCustomVRButton;
  55662. private _teleportationRequested;
  55663. private _teleportActive;
  55664. private _floorMeshName;
  55665. private _floorMeshesCollection;
  55666. private _teleportationMode;
  55667. private _teleportationTime;
  55668. private _teleportationSpeed;
  55669. private _teleportationEasing;
  55670. private _rotationAllowed;
  55671. private _teleportBackwardsVector;
  55672. private _teleportationTarget;
  55673. private _isDefaultTeleportationTarget;
  55674. private _postProcessMove;
  55675. private _teleportationFillColor;
  55676. private _teleportationBorderColor;
  55677. private _rotationAngle;
  55678. private _haloCenter;
  55679. private _cameraGazer;
  55680. private _padSensibilityUp;
  55681. private _padSensibilityDown;
  55682. private _leftController;
  55683. private _rightController;
  55684. private _gazeColor;
  55685. private _laserColor;
  55686. private _pickedLaserColor;
  55687. private _pickedGazeColor;
  55688. /**
  55689. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55690. */
  55691. onNewMeshSelected: Observable<AbstractMesh>;
  55692. /**
  55693. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55694. * This observable will provide the mesh and the controller used to select the mesh
  55695. */
  55696. onMeshSelectedWithController: Observable<{
  55697. mesh: AbstractMesh;
  55698. controller: WebVRController;
  55699. }>;
  55700. /**
  55701. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55702. */
  55703. onNewMeshPicked: Observable<PickingInfo>;
  55704. private _circleEase;
  55705. /**
  55706. * Observable raised before camera teleportation
  55707. */
  55708. onBeforeCameraTeleport: Observable<Vector3>;
  55709. /**
  55710. * Observable raised after camera teleportation
  55711. */
  55712. onAfterCameraTeleport: Observable<Vector3>;
  55713. /**
  55714. * Observable raised when current selected mesh gets unselected
  55715. */
  55716. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55717. private _raySelectionPredicate;
  55718. /**
  55719. * To be optionaly changed by user to define custom ray selection
  55720. */
  55721. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55722. /**
  55723. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55724. */
  55725. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55726. /**
  55727. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55728. */
  55729. teleportationEnabled: boolean;
  55730. private _defaultHeight;
  55731. private _teleportationInitialized;
  55732. private _interactionsEnabled;
  55733. private _interactionsRequested;
  55734. private _displayGaze;
  55735. private _displayLaserPointer;
  55736. /**
  55737. * The mesh used to display where the user is going to teleport.
  55738. */
  55739. get teleportationTarget(): Mesh;
  55740. /**
  55741. * Sets the mesh to be used to display where the user is going to teleport.
  55742. */
  55743. set teleportationTarget(value: Mesh);
  55744. /**
  55745. * 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
  55746. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55747. * See https://doc.babylonjs.com/resources/baking_transformations
  55748. */
  55749. get gazeTrackerMesh(): Mesh;
  55750. set gazeTrackerMesh(value: Mesh);
  55751. /**
  55752. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55753. */
  55754. updateGazeTrackerScale: boolean;
  55755. /**
  55756. * If the gaze trackers color should be updated when selecting meshes
  55757. */
  55758. updateGazeTrackerColor: boolean;
  55759. /**
  55760. * If the controller laser color should be updated when selecting meshes
  55761. */
  55762. updateControllerLaserColor: boolean;
  55763. /**
  55764. * The gaze tracking mesh corresponding to the left controller
  55765. */
  55766. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55767. /**
  55768. * The gaze tracking mesh corresponding to the right controller
  55769. */
  55770. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55771. /**
  55772. * If the ray of the gaze should be displayed.
  55773. */
  55774. get displayGaze(): boolean;
  55775. /**
  55776. * Sets if the ray of the gaze should be displayed.
  55777. */
  55778. set displayGaze(value: boolean);
  55779. /**
  55780. * If the ray of the LaserPointer should be displayed.
  55781. */
  55782. get displayLaserPointer(): boolean;
  55783. /**
  55784. * Sets if the ray of the LaserPointer should be displayed.
  55785. */
  55786. set displayLaserPointer(value: boolean);
  55787. /**
  55788. * The deviceOrientationCamera used as the camera when not in VR.
  55789. */
  55790. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55791. /**
  55792. * Based on the current WebVR support, returns the current VR camera used.
  55793. */
  55794. get currentVRCamera(): Nullable<Camera>;
  55795. /**
  55796. * The webVRCamera which is used when in VR.
  55797. */
  55798. get webVRCamera(): WebVRFreeCamera;
  55799. /**
  55800. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55801. */
  55802. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55803. /**
  55804. * The html button that is used to trigger entering into VR.
  55805. */
  55806. get vrButton(): Nullable<HTMLButtonElement>;
  55807. private get _teleportationRequestInitiated();
  55808. /**
  55809. * Defines whether or not Pointer lock should be requested when switching to
  55810. * full screen.
  55811. */
  55812. requestPointerLockOnFullScreen: boolean;
  55813. /**
  55814. * If asking to force XR, this will be populated with the default xr experience
  55815. */
  55816. xr: WebXRDefaultExperience;
  55817. /**
  55818. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55819. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55820. */
  55821. xrTestDone: boolean;
  55822. /**
  55823. * Instantiates a VRExperienceHelper.
  55824. * Helps to quickly add VR support to an existing scene.
  55825. * @param scene The scene the VRExperienceHelper belongs to.
  55826. * @param webVROptions Options to modify the vr experience helper's behavior.
  55827. */
  55828. constructor(scene: Scene,
  55829. /** Options to modify the vr experience helper's behavior. */
  55830. webVROptions?: VRExperienceHelperOptions);
  55831. private completeVRInit;
  55832. private _onDefaultMeshLoaded;
  55833. private _onResize;
  55834. private _onFullscreenChange;
  55835. /**
  55836. * Gets a value indicating if we are currently in VR mode.
  55837. */
  55838. get isInVRMode(): boolean;
  55839. private onVrDisplayPresentChange;
  55840. private onVRDisplayChanged;
  55841. private moveButtonToBottomRight;
  55842. private displayVRButton;
  55843. private updateButtonVisibility;
  55844. private _cachedAngularSensibility;
  55845. /**
  55846. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55847. * Otherwise, will use the fullscreen API.
  55848. */
  55849. enterVR(): void;
  55850. /**
  55851. * Attempt to exit VR, or fullscreen.
  55852. */
  55853. exitVR(): void;
  55854. /**
  55855. * The position of the vr experience helper.
  55856. */
  55857. get position(): Vector3;
  55858. /**
  55859. * Sets the position of the vr experience helper.
  55860. */
  55861. set position(value: Vector3);
  55862. /**
  55863. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55864. */
  55865. enableInteractions(): void;
  55866. private get _noControllerIsActive();
  55867. private beforeRender;
  55868. private _isTeleportationFloor;
  55869. /**
  55870. * Adds a floor mesh to be used for teleportation.
  55871. * @param floorMesh the mesh to be used for teleportation.
  55872. */
  55873. addFloorMesh(floorMesh: Mesh): void;
  55874. /**
  55875. * Removes a floor mesh from being used for teleportation.
  55876. * @param floorMesh the mesh to be removed.
  55877. */
  55878. removeFloorMesh(floorMesh: Mesh): void;
  55879. /**
  55880. * Enables interactions and teleportation using the VR controllers and gaze.
  55881. * @param vrTeleportationOptions options to modify teleportation behavior.
  55882. */
  55883. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55884. private _onNewGamepadConnected;
  55885. private _tryEnableInteractionOnController;
  55886. private _onNewGamepadDisconnected;
  55887. private _enableInteractionOnController;
  55888. private _checkTeleportWithRay;
  55889. private _checkRotate;
  55890. private _checkTeleportBackwards;
  55891. private _enableTeleportationOnController;
  55892. private _createTeleportationCircles;
  55893. private _displayTeleportationTarget;
  55894. private _hideTeleportationTarget;
  55895. private _rotateCamera;
  55896. private _moveTeleportationSelectorTo;
  55897. private _workingVector;
  55898. private _workingQuaternion;
  55899. private _workingMatrix;
  55900. /**
  55901. * Time Constant Teleportation Mode
  55902. */
  55903. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55904. /**
  55905. * Speed Constant Teleportation Mode
  55906. */
  55907. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55908. /**
  55909. * Teleports the users feet to the desired location
  55910. * @param location The location where the user's feet should be placed
  55911. */
  55912. teleportCamera(location: Vector3): void;
  55913. private _convertNormalToDirectionOfRay;
  55914. private _castRayAndSelectObject;
  55915. private _notifySelectedMeshUnselected;
  55916. /**
  55917. * Permanently set new colors for the laser pointer
  55918. * @param color the new laser color
  55919. * @param pickedColor the new laser color when picked mesh detected
  55920. */
  55921. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55922. /**
  55923. * Set lighting enabled / disabled on the laser pointer of both controllers
  55924. * @param enabled should the lighting be enabled on the laser pointer
  55925. */
  55926. setLaserLightingState(enabled?: boolean): void;
  55927. /**
  55928. * Permanently set new colors for the gaze pointer
  55929. * @param color the new gaze color
  55930. * @param pickedColor the new gaze color when picked mesh detected
  55931. */
  55932. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55933. /**
  55934. * Sets the color of the laser ray from the vr controllers.
  55935. * @param color new color for the ray.
  55936. */
  55937. changeLaserColor(color: Color3): void;
  55938. /**
  55939. * Sets the color of the ray from the vr headsets gaze.
  55940. * @param color new color for the ray.
  55941. */
  55942. changeGazeColor(color: Color3): void;
  55943. /**
  55944. * Exits VR and disposes of the vr experience helper
  55945. */
  55946. dispose(): void;
  55947. /**
  55948. * Gets the name of the VRExperienceHelper class
  55949. * @returns "VRExperienceHelper"
  55950. */
  55951. getClassName(): string;
  55952. }
  55953. }
  55954. declare module "babylonjs/Cameras/VR/index" {
  55955. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55956. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55957. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55958. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55959. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55960. export * from "babylonjs/Cameras/VR/webVRCamera";
  55961. }
  55962. declare module "babylonjs/Cameras/RigModes/index" {
  55963. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55964. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55965. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55966. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55967. }
  55968. declare module "babylonjs/Cameras/index" {
  55969. export * from "babylonjs/Cameras/Inputs/index";
  55970. export * from "babylonjs/Cameras/cameraInputsManager";
  55971. export * from "babylonjs/Cameras/camera";
  55972. export * from "babylonjs/Cameras/targetCamera";
  55973. export * from "babylonjs/Cameras/freeCamera";
  55974. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55975. export * from "babylonjs/Cameras/touchCamera";
  55976. export * from "babylonjs/Cameras/arcRotateCamera";
  55977. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55978. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55979. export * from "babylonjs/Cameras/flyCamera";
  55980. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55981. export * from "babylonjs/Cameras/followCamera";
  55982. export * from "babylonjs/Cameras/followCameraInputsManager";
  55983. export * from "babylonjs/Cameras/gamepadCamera";
  55984. export * from "babylonjs/Cameras/Stereoscopic/index";
  55985. export * from "babylonjs/Cameras/universalCamera";
  55986. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55987. export * from "babylonjs/Cameras/VR/index";
  55988. export * from "babylonjs/Cameras/RigModes/index";
  55989. }
  55990. declare module "babylonjs/Collisions/index" {
  55991. export * from "babylonjs/Collisions/collider";
  55992. export * from "babylonjs/Collisions/collisionCoordinator";
  55993. export * from "babylonjs/Collisions/pickingInfo";
  55994. export * from "babylonjs/Collisions/intersectionInfo";
  55995. export * from "babylonjs/Collisions/meshCollisionData";
  55996. }
  55997. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55998. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55999. import { Vector3 } from "babylonjs/Maths/math.vector";
  56000. import { Ray } from "babylonjs/Culling/ray";
  56001. import { Plane } from "babylonjs/Maths/math.plane";
  56002. /**
  56003. * Contains an array of blocks representing the octree
  56004. */
  56005. export interface IOctreeContainer<T> {
  56006. /**
  56007. * Blocks within the octree
  56008. */
  56009. blocks: Array<OctreeBlock<T>>;
  56010. }
  56011. /**
  56012. * Class used to store a cell in an octree
  56013. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56014. */
  56015. export class OctreeBlock<T> {
  56016. /**
  56017. * Gets the content of the current block
  56018. */
  56019. entries: T[];
  56020. /**
  56021. * Gets the list of block children
  56022. */
  56023. blocks: Array<OctreeBlock<T>>;
  56024. private _depth;
  56025. private _maxDepth;
  56026. private _capacity;
  56027. private _minPoint;
  56028. private _maxPoint;
  56029. private _boundingVectors;
  56030. private _creationFunc;
  56031. /**
  56032. * Creates a new block
  56033. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56034. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56035. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56036. * @param depth defines the current depth of this block in the octree
  56037. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56038. * @param creationFunc defines a callback to call when an element is added to the block
  56039. */
  56040. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56041. /**
  56042. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56043. */
  56044. get capacity(): number;
  56045. /**
  56046. * Gets the minimum vector (in world space) of the block's bounding box
  56047. */
  56048. get minPoint(): Vector3;
  56049. /**
  56050. * Gets the maximum vector (in world space) of the block's bounding box
  56051. */
  56052. get maxPoint(): Vector3;
  56053. /**
  56054. * Add a new element to this block
  56055. * @param entry defines the element to add
  56056. */
  56057. addEntry(entry: T): void;
  56058. /**
  56059. * Remove an element from this block
  56060. * @param entry defines the element to remove
  56061. */
  56062. removeEntry(entry: T): void;
  56063. /**
  56064. * Add an array of elements to this block
  56065. * @param entries defines the array of elements to add
  56066. */
  56067. addEntries(entries: T[]): void;
  56068. /**
  56069. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56070. * @param frustumPlanes defines the frustum planes to test
  56071. * @param selection defines the array to store current content if selection is positive
  56072. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56073. */
  56074. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56075. /**
  56076. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56077. * @param sphereCenter defines the bounding sphere center
  56078. * @param sphereRadius defines the bounding sphere radius
  56079. * @param selection defines the array to store current content if selection is positive
  56080. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56081. */
  56082. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56083. /**
  56084. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56085. * @param ray defines the ray to test with
  56086. * @param selection defines the array to store current content if selection is positive
  56087. */
  56088. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56089. /**
  56090. * Subdivide the content into child blocks (this block will then be empty)
  56091. */
  56092. createInnerBlocks(): void;
  56093. /**
  56094. * @hidden
  56095. */
  56096. 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;
  56097. }
  56098. }
  56099. declare module "babylonjs/Culling/Octrees/octree" {
  56100. import { SmartArray } from "babylonjs/Misc/smartArray";
  56101. import { Vector3 } from "babylonjs/Maths/math.vector";
  56102. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56104. import { Ray } from "babylonjs/Culling/ray";
  56105. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  56106. import { Plane } from "babylonjs/Maths/math.plane";
  56107. /**
  56108. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56109. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56110. */
  56111. export class Octree<T> {
  56112. /** 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.) */
  56113. maxDepth: number;
  56114. /**
  56115. * Blocks within the octree containing objects
  56116. */
  56117. blocks: Array<OctreeBlock<T>>;
  56118. /**
  56119. * Content stored in the octree
  56120. */
  56121. dynamicContent: T[];
  56122. private _maxBlockCapacity;
  56123. private _selectionContent;
  56124. private _creationFunc;
  56125. /**
  56126. * Creates a octree
  56127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56128. * @param creationFunc function to be used to instatiate the octree
  56129. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56130. * @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.)
  56131. */
  56132. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56133. /** 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.) */
  56134. maxDepth?: number);
  56135. /**
  56136. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56137. * @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);
  56138. * @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);
  56139. * @param entries meshes to be added to the octree blocks
  56140. */
  56141. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56142. /**
  56143. * Adds a mesh to the octree
  56144. * @param entry Mesh to add to the octree
  56145. */
  56146. addMesh(entry: T): void;
  56147. /**
  56148. * Remove an element from the octree
  56149. * @param entry defines the element to remove
  56150. */
  56151. removeMesh(entry: T): void;
  56152. /**
  56153. * Selects an array of meshes within the frustum
  56154. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56155. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56156. * @returns array of meshes within the frustum
  56157. */
  56158. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56159. /**
  56160. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56161. * @param sphereCenter defines the bounding sphere center
  56162. * @param sphereRadius defines the bounding sphere radius
  56163. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56164. * @returns an array of objects that intersect the sphere
  56165. */
  56166. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56167. /**
  56168. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56169. * @param ray defines the ray to test with
  56170. * @returns array of intersected objects
  56171. */
  56172. intersectsRay(ray: Ray): SmartArray<T>;
  56173. /**
  56174. * Adds a mesh into the octree block if it intersects the block
  56175. */
  56176. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56177. /**
  56178. * Adds a submesh into the octree block if it intersects the block
  56179. */
  56180. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56181. }
  56182. }
  56183. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  56184. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  56185. import { Scene } from "babylonjs/scene";
  56186. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56188. import { Ray } from "babylonjs/Culling/ray";
  56189. import { Octree } from "babylonjs/Culling/Octrees/octree";
  56190. import { Collider } from "babylonjs/Collisions/collider";
  56191. module "babylonjs/scene" {
  56192. interface Scene {
  56193. /**
  56194. * @hidden
  56195. * Backing Filed
  56196. */
  56197. _selectionOctree: Octree<AbstractMesh>;
  56198. /**
  56199. * Gets the octree used to boost mesh selection (picking)
  56200. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56201. */
  56202. selectionOctree: Octree<AbstractMesh>;
  56203. /**
  56204. * Creates or updates the octree used to boost selection (picking)
  56205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56206. * @param maxCapacity defines the maximum capacity per leaf
  56207. * @param maxDepth defines the maximum depth of the octree
  56208. * @returns an octree of AbstractMesh
  56209. */
  56210. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56211. }
  56212. }
  56213. module "babylonjs/Meshes/abstractMesh" {
  56214. interface AbstractMesh {
  56215. /**
  56216. * @hidden
  56217. * Backing Field
  56218. */
  56219. _submeshesOctree: Octree<SubMesh>;
  56220. /**
  56221. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56222. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56223. * @param maxCapacity defines the maximum size of each block (64 by default)
  56224. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56225. * @returns the new octree
  56226. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56228. */
  56229. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56230. }
  56231. }
  56232. /**
  56233. * Defines the octree scene component responsible to manage any octrees
  56234. * in a given scene.
  56235. */
  56236. export class OctreeSceneComponent {
  56237. /**
  56238. * The component name help to identify the component in the list of scene components.
  56239. */
  56240. readonly name: string;
  56241. /**
  56242. * The scene the component belongs to.
  56243. */
  56244. scene: Scene;
  56245. /**
  56246. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56247. */
  56248. readonly checksIsEnabled: boolean;
  56249. /**
  56250. * Creates a new instance of the component for the given scene
  56251. * @param scene Defines the scene to register the component in
  56252. */
  56253. constructor(scene: Scene);
  56254. /**
  56255. * Registers the component in a given scene
  56256. */
  56257. register(): void;
  56258. /**
  56259. * Return the list of active meshes
  56260. * @returns the list of active meshes
  56261. */
  56262. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56263. /**
  56264. * Return the list of active sub meshes
  56265. * @param mesh The mesh to get the candidates sub meshes from
  56266. * @returns the list of active sub meshes
  56267. */
  56268. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56269. private _tempRay;
  56270. /**
  56271. * Return the list of sub meshes intersecting with a given local ray
  56272. * @param mesh defines the mesh to find the submesh for
  56273. * @param localRay defines the ray in local space
  56274. * @returns the list of intersecting sub meshes
  56275. */
  56276. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56277. /**
  56278. * Return the list of sub meshes colliding with a collider
  56279. * @param mesh defines the mesh to find the submesh for
  56280. * @param collider defines the collider to evaluate the collision against
  56281. * @returns the list of colliding sub meshes
  56282. */
  56283. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56284. /**
  56285. * Rebuilds the elements related to this component in case of
  56286. * context lost for instance.
  56287. */
  56288. rebuild(): void;
  56289. /**
  56290. * Disposes the component and the associated ressources.
  56291. */
  56292. dispose(): void;
  56293. }
  56294. }
  56295. declare module "babylonjs/Culling/Octrees/index" {
  56296. export * from "babylonjs/Culling/Octrees/octree";
  56297. export * from "babylonjs/Culling/Octrees/octreeBlock";
  56298. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  56299. }
  56300. declare module "babylonjs/Culling/index" {
  56301. export * from "babylonjs/Culling/boundingBox";
  56302. export * from "babylonjs/Culling/boundingInfo";
  56303. export * from "babylonjs/Culling/boundingSphere";
  56304. export * from "babylonjs/Culling/Octrees/index";
  56305. export * from "babylonjs/Culling/ray";
  56306. }
  56307. declare module "babylonjs/Gizmos/gizmo" {
  56308. import { Observer } from "babylonjs/Misc/observable";
  56309. import { Nullable } from "babylonjs/types";
  56310. import { IDisposable } from "babylonjs/scene";
  56311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56312. import { Mesh } from "babylonjs/Meshes/mesh";
  56313. import { Node } from "babylonjs/node";
  56314. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56315. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56316. import { PointerInfo } from "babylonjs/Events/pointerEvents";
  56317. /**
  56318. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56319. */
  56320. export interface GizmoAxisCache {
  56321. /** Mesh used to runder the Gizmo */
  56322. gizmoMeshes: Mesh[];
  56323. /** Mesh used to detect user interaction with Gizmo */
  56324. colliderMeshes: Mesh[];
  56325. /** Material used to inicate color of gizmo mesh */
  56326. material: StandardMaterial;
  56327. /** Material used to inicate hover state of the Gizmo */
  56328. hoverMaterial: StandardMaterial;
  56329. /** Material used to inicate disabled state of the Gizmo */
  56330. disableMaterial: StandardMaterial;
  56331. /** Used to indicate Active state of the Gizmo */
  56332. active: boolean;
  56333. }
  56334. /**
  56335. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56336. */
  56337. export class Gizmo implements IDisposable {
  56338. /** The utility layer the gizmo will be added to */
  56339. gizmoLayer: UtilityLayerRenderer;
  56340. /**
  56341. * The root mesh of the gizmo
  56342. */
  56343. _rootMesh: Mesh;
  56344. private _attachedMesh;
  56345. private _attachedNode;
  56346. /**
  56347. * Ratio for the scale of the gizmo (Default: 1)
  56348. */
  56349. protected _scaleRatio: number;
  56350. /**
  56351. * boolean updated by pointermove when a gizmo mesh is hovered
  56352. */
  56353. protected _isHovered: boolean;
  56354. /**
  56355. * Ratio for the scale of the gizmo (Default: 1)
  56356. */
  56357. set scaleRatio(value: number);
  56358. get scaleRatio(): number;
  56359. /**
  56360. * True when the mouse pointer is hovered a gizmo mesh
  56361. */
  56362. get isHovered(): boolean;
  56363. /**
  56364. * If a custom mesh has been set (Default: false)
  56365. */
  56366. protected _customMeshSet: boolean;
  56367. /**
  56368. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56369. * * When set, interactions will be enabled
  56370. */
  56371. get attachedMesh(): Nullable<AbstractMesh>;
  56372. set attachedMesh(value: Nullable<AbstractMesh>);
  56373. /**
  56374. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56375. * * When set, interactions will be enabled
  56376. */
  56377. get attachedNode(): Nullable<Node>;
  56378. set attachedNode(value: Nullable<Node>);
  56379. /**
  56380. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56381. * @param mesh The mesh to replace the default mesh of the gizmo
  56382. */
  56383. setCustomMesh(mesh: Mesh): void;
  56384. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56385. /**
  56386. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56387. */
  56388. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56389. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56390. /**
  56391. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56392. */
  56393. updateGizmoPositionToMatchAttachedMesh: boolean;
  56394. /**
  56395. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56396. */
  56397. updateScale: boolean;
  56398. protected _interactionsEnabled: boolean;
  56399. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56400. private _beforeRenderObserver;
  56401. private _tempQuaternion;
  56402. private _tempVector;
  56403. private _tempVector2;
  56404. private _tempMatrix1;
  56405. private _tempMatrix2;
  56406. private _rightHandtoLeftHandMatrix;
  56407. /**
  56408. * Creates a gizmo
  56409. * @param gizmoLayer The utility layer the gizmo will be added to
  56410. */
  56411. constructor(
  56412. /** The utility layer the gizmo will be added to */
  56413. gizmoLayer?: UtilityLayerRenderer);
  56414. /**
  56415. * Updates the gizmo to match the attached mesh's position/rotation
  56416. */
  56417. protected _update(): void;
  56418. /**
  56419. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56420. * @param value Node, TransformNode or mesh
  56421. */
  56422. protected _matrixChanged(): void;
  56423. /**
  56424. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56425. * @param gizmoLayer The utility layer the gizmo will be added to
  56426. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56427. * @returns {Observer<PointerInfo>} pointerObserver
  56428. */
  56429. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56430. /**
  56431. * Disposes of the gizmo
  56432. */
  56433. dispose(): void;
  56434. }
  56435. }
  56436. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56437. import { Observable } from "babylonjs/Misc/observable";
  56438. import { Nullable } from "babylonjs/types";
  56439. import { Vector3 } from "babylonjs/Maths/math.vector";
  56440. import { Color3 } from "babylonjs/Maths/math.color";
  56441. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56442. import { Node } from "babylonjs/node";
  56443. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56444. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56445. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56446. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56447. import { Scene } from "babylonjs/scene";
  56448. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56449. /**
  56450. * Single plane drag gizmo
  56451. */
  56452. export class PlaneDragGizmo extends Gizmo {
  56453. /**
  56454. * Drag behavior responsible for the gizmos dragging interactions
  56455. */
  56456. dragBehavior: PointerDragBehavior;
  56457. private _pointerObserver;
  56458. /**
  56459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56460. */
  56461. snapDistance: number;
  56462. /**
  56463. * Event that fires each time the gizmo snaps to a new location.
  56464. * * snapDistance is the the change in distance
  56465. */
  56466. onSnapObservable: Observable<{
  56467. snapDistance: number;
  56468. }>;
  56469. private _gizmoMesh;
  56470. private _coloredMaterial;
  56471. private _hoverMaterial;
  56472. private _disableMaterial;
  56473. private _isEnabled;
  56474. private _parent;
  56475. private _dragging;
  56476. /** @hidden */
  56477. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56478. /**
  56479. * Creates a PlaneDragGizmo
  56480. * @param gizmoLayer The utility layer the gizmo will be added to
  56481. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56482. * @param color The color of the gizmo
  56483. */
  56484. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56485. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56486. /**
  56487. * If the gizmo is enabled
  56488. */
  56489. set isEnabled(value: boolean);
  56490. get isEnabled(): boolean;
  56491. /**
  56492. * Disposes of the gizmo
  56493. */
  56494. dispose(): void;
  56495. }
  56496. }
  56497. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56498. import { Observable } from "babylonjs/Misc/observable";
  56499. import { Nullable } from "babylonjs/types";
  56500. import { Vector3 } from "babylonjs/Maths/math.vector";
  56501. import { Color3 } from "babylonjs/Maths/math.color";
  56502. import "babylonjs/Meshes/Builders/linesBuilder";
  56503. import { Node } from "babylonjs/node";
  56504. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56505. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56506. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56507. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56508. /**
  56509. * Single plane rotation gizmo
  56510. */
  56511. export class PlaneRotationGizmo extends Gizmo {
  56512. /**
  56513. * Drag behavior responsible for the gizmos dragging interactions
  56514. */
  56515. dragBehavior: PointerDragBehavior;
  56516. private _pointerObserver;
  56517. /**
  56518. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56519. */
  56520. snapDistance: number;
  56521. /**
  56522. * Event that fires each time the gizmo snaps to a new location.
  56523. * * snapDistance is the the change in distance
  56524. */
  56525. onSnapObservable: Observable<{
  56526. snapDistance: number;
  56527. }>;
  56528. private _isEnabled;
  56529. private _parent;
  56530. private _coloredMaterial;
  56531. private _hoverMaterial;
  56532. private _disableMaterial;
  56533. private _gizmoMesh;
  56534. private _rotationCircle;
  56535. private _dragging;
  56536. private static _CircleConstants;
  56537. /**
  56538. * Creates a PlaneRotationGizmo
  56539. * @param gizmoLayer The utility layer the gizmo will be added to
  56540. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56541. * @param color The color of the gizmo
  56542. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56543. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56544. * @param thickness display gizmo axis thickness
  56545. */
  56546. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56547. /** Create Geometry for Gizmo */
  56548. private _createGizmoMesh;
  56549. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56550. private setupRotationCircle;
  56551. private updateRotationPath;
  56552. private updateRotationCircle;
  56553. /**
  56554. * If the gizmo is enabled
  56555. */
  56556. set isEnabled(value: boolean);
  56557. get isEnabled(): boolean;
  56558. /**
  56559. * Disposes of the gizmo
  56560. */
  56561. dispose(): void;
  56562. }
  56563. }
  56564. declare module "babylonjs/Gizmos/rotationGizmo" {
  56565. import { Observable } from "babylonjs/Misc/observable";
  56566. import { Nullable } from "babylonjs/types";
  56567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56568. import { Mesh } from "babylonjs/Meshes/mesh";
  56569. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56570. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56571. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56572. import { Node } from "babylonjs/node";
  56573. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56574. /**
  56575. * Gizmo that enables rotating a mesh along 3 axis
  56576. */
  56577. export class RotationGizmo extends Gizmo {
  56578. /**
  56579. * Internal gizmo used for interactions on the x axis
  56580. */
  56581. xGizmo: PlaneRotationGizmo;
  56582. /**
  56583. * Internal gizmo used for interactions on the y axis
  56584. */
  56585. yGizmo: PlaneRotationGizmo;
  56586. /**
  56587. * Internal gizmo used for interactions on the z axis
  56588. */
  56589. zGizmo: PlaneRotationGizmo;
  56590. /** Fires an event when any of it's sub gizmos are dragged */
  56591. onDragStartObservable: Observable<unknown>;
  56592. /** Fires an event when any of it's sub gizmos are released from dragging */
  56593. onDragEndObservable: Observable<unknown>;
  56594. private _meshAttached;
  56595. private _nodeAttached;
  56596. private _observables;
  56597. /** Node Caching for quick lookup */
  56598. private _gizmoAxisCache;
  56599. get attachedMesh(): Nullable<AbstractMesh>;
  56600. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56601. get attachedNode(): Nullable<Node>;
  56602. set attachedNode(node: Nullable<Node>);
  56603. protected _checkBillboardTransform(): void;
  56604. /**
  56605. * True when the mouse pointer is hovering a gizmo mesh
  56606. */
  56607. get isHovered(): boolean;
  56608. /**
  56609. * Creates a RotationGizmo
  56610. * @param gizmoLayer The utility layer the gizmo will be added to
  56611. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56612. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56613. * @param thickness display gizmo axis thickness
  56614. */
  56615. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  56616. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56617. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56618. /**
  56619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56620. */
  56621. set snapDistance(value: number);
  56622. get snapDistance(): number;
  56623. /**
  56624. * Ratio for the scale of the gizmo (Default: 1)
  56625. */
  56626. set scaleRatio(value: number);
  56627. get scaleRatio(): number;
  56628. /**
  56629. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56630. * @param mesh Axis gizmo mesh
  56631. * @param cache Gizmo axis definition used for reactive gizmo UI
  56632. */
  56633. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56634. /**
  56635. * Disposes of the gizmo
  56636. */
  56637. dispose(): void;
  56638. /**
  56639. * CustomMeshes are not supported by this gizmo
  56640. * @param mesh The mesh to replace the default mesh of the gizmo
  56641. */
  56642. setCustomMesh(mesh: Mesh): void;
  56643. }
  56644. }
  56645. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  56646. import { Scene } from "babylonjs/scene";
  56647. import { Vector4 } from "babylonjs/Maths/math.vector";
  56648. import { Color4 } from "babylonjs/Maths/math.color";
  56649. import { Mesh } from "babylonjs/Meshes/mesh";
  56650. import { Nullable } from "babylonjs/types";
  56651. /**
  56652. * Class containing static functions to help procedurally build meshes
  56653. */
  56654. export class PolyhedronBuilder {
  56655. /**
  56656. * Creates a polyhedron mesh
  56657. * * 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
  56658. * * The parameter `size` (positive float, default 1) sets the polygon size
  56659. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56660. * * 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`
  56661. * * 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
  56662. * * 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)`)
  56663. * * 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
  56664. * * 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
  56665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56668. * @param name defines the name of the mesh
  56669. * @param options defines the options used to create the mesh
  56670. * @param scene defines the hosting scene
  56671. * @returns the polyhedron mesh
  56672. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56673. */
  56674. static CreatePolyhedron(name: string, options: {
  56675. type?: number;
  56676. size?: number;
  56677. sizeX?: number;
  56678. sizeY?: number;
  56679. sizeZ?: number;
  56680. custom?: any;
  56681. faceUV?: Vector4[];
  56682. faceColors?: Color4[];
  56683. flat?: boolean;
  56684. updatable?: boolean;
  56685. sideOrientation?: number;
  56686. frontUVs?: Vector4;
  56687. backUVs?: Vector4;
  56688. }, scene?: Nullable<Scene>): Mesh;
  56689. }
  56690. }
  56691. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56692. import { Nullable } from "babylonjs/types";
  56693. import { Scene } from "babylonjs/scene";
  56694. import { Vector4 } from "babylonjs/Maths/math.vector";
  56695. import { Color4 } from "babylonjs/Maths/math.color";
  56696. import { Mesh } from "babylonjs/Meshes/mesh";
  56697. /**
  56698. * Class containing static functions to help procedurally build meshes
  56699. */
  56700. export class BoxBuilder {
  56701. /**
  56702. * Creates a box mesh
  56703. * * The parameter `size` sets the size (float) of each box side (default 1)
  56704. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56705. * * 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)
  56706. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56710. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56711. * @param name defines the name of the mesh
  56712. * @param options defines the options used to create the mesh
  56713. * @param scene defines the hosting scene
  56714. * @returns the box mesh
  56715. */
  56716. static CreateBox(name: string, options: {
  56717. size?: number;
  56718. width?: number;
  56719. height?: number;
  56720. depth?: number;
  56721. faceUV?: Vector4[];
  56722. faceColors?: Color4[];
  56723. sideOrientation?: number;
  56724. frontUVs?: Vector4;
  56725. backUVs?: Vector4;
  56726. wrap?: boolean;
  56727. topBaseAt?: number;
  56728. bottomBaseAt?: number;
  56729. updatable?: boolean;
  56730. }, scene?: Nullable<Scene>): Mesh;
  56731. }
  56732. }
  56733. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56734. import { Observable } from "babylonjs/Misc/observable";
  56735. import { Nullable } from "babylonjs/types";
  56736. import { Vector3 } from "babylonjs/Maths/math.vector";
  56737. import { Node } from "babylonjs/node";
  56738. import { Mesh } from "babylonjs/Meshes/mesh";
  56739. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56740. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56741. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56742. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56743. import { Color3 } from "babylonjs/Maths/math.color";
  56744. /**
  56745. * Single axis scale gizmo
  56746. */
  56747. export class AxisScaleGizmo extends Gizmo {
  56748. /**
  56749. * Drag behavior responsible for the gizmos dragging interactions
  56750. */
  56751. dragBehavior: PointerDragBehavior;
  56752. private _pointerObserver;
  56753. /**
  56754. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56755. */
  56756. snapDistance: number;
  56757. /**
  56758. * Event that fires each time the gizmo snaps to a new location.
  56759. * * snapDistance is the the change in distance
  56760. */
  56761. onSnapObservable: Observable<{
  56762. snapDistance: number;
  56763. }>;
  56764. /**
  56765. * If the scaling operation should be done on all axis (default: false)
  56766. */
  56767. uniformScaling: boolean;
  56768. /**
  56769. * Custom sensitivity value for the drag strength
  56770. */
  56771. sensitivity: number;
  56772. private _isEnabled;
  56773. private _parent;
  56774. private _gizmoMesh;
  56775. private _coloredMaterial;
  56776. private _hoverMaterial;
  56777. private _disableMaterial;
  56778. private _dragging;
  56779. private _tmpVector;
  56780. private _tmpMatrix;
  56781. private _tmpMatrix2;
  56782. /**
  56783. * Creates an AxisScaleGizmo
  56784. * @param gizmoLayer The utility layer the gizmo will be added to
  56785. * @param dragAxis The axis which the gizmo will be able to scale on
  56786. * @param color The color of the gizmo
  56787. * @param thickness display gizmo axis thickness
  56788. */
  56789. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56790. /** Create Geometry for Gizmo */
  56791. private _createGizmoMesh;
  56792. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56793. /**
  56794. * If the gizmo is enabled
  56795. */
  56796. set isEnabled(value: boolean);
  56797. get isEnabled(): boolean;
  56798. /**
  56799. * Disposes of the gizmo
  56800. */
  56801. dispose(): void;
  56802. /**
  56803. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56804. * @param mesh The mesh to replace the default mesh of the gizmo
  56805. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56806. */
  56807. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56808. }
  56809. }
  56810. declare module "babylonjs/Gizmos/scaleGizmo" {
  56811. import { Observable } from "babylonjs/Misc/observable";
  56812. import { Nullable } from "babylonjs/types";
  56813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56814. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  56815. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56816. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56817. import { Mesh } from "babylonjs/Meshes/mesh";
  56818. import { Node } from "babylonjs/node";
  56819. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  56820. /**
  56821. * Gizmo that enables scaling a mesh along 3 axis
  56822. */
  56823. export class ScaleGizmo extends Gizmo {
  56824. /**
  56825. * Internal gizmo used for interactions on the x axis
  56826. */
  56827. xGizmo: AxisScaleGizmo;
  56828. /**
  56829. * Internal gizmo used for interactions on the y axis
  56830. */
  56831. yGizmo: AxisScaleGizmo;
  56832. /**
  56833. * Internal gizmo used for interactions on the z axis
  56834. */
  56835. zGizmo: AxisScaleGizmo;
  56836. /**
  56837. * Internal gizmo used to scale all axis equally
  56838. */
  56839. uniformScaleGizmo: AxisScaleGizmo;
  56840. private _meshAttached;
  56841. private _nodeAttached;
  56842. private _snapDistance;
  56843. private _uniformScalingMesh;
  56844. private _octahedron;
  56845. private _sensitivity;
  56846. private _coloredMaterial;
  56847. private _hoverMaterial;
  56848. private _disableMaterial;
  56849. private _observables;
  56850. /** Node Caching for quick lookup */
  56851. private _gizmoAxisCache;
  56852. /** Fires an event when any of it's sub gizmos are dragged */
  56853. onDragStartObservable: Observable<unknown>;
  56854. /** Fires an event when any of it's sub gizmos are released from dragging */
  56855. onDragEndObservable: Observable<unknown>;
  56856. get attachedMesh(): Nullable<AbstractMesh>;
  56857. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56858. get attachedNode(): Nullable<Node>;
  56859. set attachedNode(node: Nullable<Node>);
  56860. /**
  56861. * True when the mouse pointer is hovering a gizmo mesh
  56862. */
  56863. get isHovered(): boolean;
  56864. /**
  56865. * Creates a ScaleGizmo
  56866. * @param gizmoLayer The utility layer the gizmo will be added to
  56867. * @param thickness display gizmo axis thickness
  56868. */
  56869. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  56870. /** Create Geometry for Gizmo */
  56871. private _createUniformScaleMesh;
  56872. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56873. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56874. /**
  56875. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56876. */
  56877. set snapDistance(value: number);
  56878. get snapDistance(): number;
  56879. /**
  56880. * Ratio for the scale of the gizmo (Default: 1)
  56881. */
  56882. set scaleRatio(value: number);
  56883. get scaleRatio(): number;
  56884. /**
  56885. * Sensitivity factor for dragging (Default: 1)
  56886. */
  56887. set sensitivity(value: number);
  56888. get sensitivity(): number;
  56889. /**
  56890. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  56891. * @param mesh Axis gizmo mesh
  56892. * @param cache Gizmo axis definition used for reactive gizmo UI
  56893. */
  56894. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  56895. /**
  56896. * Disposes of the gizmo
  56897. */
  56898. dispose(): void;
  56899. }
  56900. }
  56901. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56902. import { Observable } from "babylonjs/Misc/observable";
  56903. import { Nullable } from "babylonjs/types";
  56904. import { Vector3 } from "babylonjs/Maths/math.vector";
  56905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56906. import { Mesh } from "babylonjs/Meshes/mesh";
  56907. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56908. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56909. import { Color3 } from "babylonjs/Maths/math.color";
  56910. import "babylonjs/Meshes/Builders/boxBuilder";
  56911. /**
  56912. * Bounding box gizmo
  56913. */
  56914. export class BoundingBoxGizmo extends Gizmo {
  56915. private _lineBoundingBox;
  56916. private _rotateSpheresParent;
  56917. private _scaleBoxesParent;
  56918. private _boundingDimensions;
  56919. private _renderObserver;
  56920. private _pointerObserver;
  56921. private _scaleDragSpeed;
  56922. private _tmpQuaternion;
  56923. private _tmpVector;
  56924. private _tmpRotationMatrix;
  56925. /**
  56926. * 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)
  56927. */
  56928. ignoreChildren: boolean;
  56929. /**
  56930. * 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)
  56931. */
  56932. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56933. /**
  56934. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56935. */
  56936. rotationSphereSize: number;
  56937. /**
  56938. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56939. */
  56940. scaleBoxSize: number;
  56941. /**
  56942. * 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)
  56943. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  56944. */
  56945. fixedDragMeshScreenSize: boolean;
  56946. /**
  56947. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  56948. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  56949. */
  56950. fixedDragMeshBoundsSize: boolean;
  56951. /**
  56952. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56953. */
  56954. fixedDragMeshScreenSizeDistanceFactor: number;
  56955. /**
  56956. * Fired when a rotation sphere or scale box is dragged
  56957. */
  56958. onDragStartObservable: Observable<{}>;
  56959. /**
  56960. * Fired when a scale box is dragged
  56961. */
  56962. onScaleBoxDragObservable: Observable<{}>;
  56963. /**
  56964. * Fired when a scale box drag is ended
  56965. */
  56966. onScaleBoxDragEndObservable: Observable<{}>;
  56967. /**
  56968. * Fired when a rotation sphere is dragged
  56969. */
  56970. onRotationSphereDragObservable: Observable<{}>;
  56971. /**
  56972. * Fired when a rotation sphere drag is ended
  56973. */
  56974. onRotationSphereDragEndObservable: Observable<{}>;
  56975. /**
  56976. * 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)
  56977. */
  56978. scalePivot: Nullable<Vector3>;
  56979. /**
  56980. * Mesh used as a pivot to rotate the attached node
  56981. */
  56982. private _anchorMesh;
  56983. private _existingMeshScale;
  56984. private _dragMesh;
  56985. private pointerDragBehavior;
  56986. private coloredMaterial;
  56987. private hoverColoredMaterial;
  56988. /**
  56989. * Sets the color of the bounding box gizmo
  56990. * @param color the color to set
  56991. */
  56992. setColor(color: Color3): void;
  56993. /**
  56994. * Creates an BoundingBoxGizmo
  56995. * @param gizmoLayer The utility layer the gizmo will be added to
  56996. * @param color The color of the gizmo
  56997. */
  56998. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56999. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57000. private _selectNode;
  57001. /**
  57002. * Updates the bounding box information for the Gizmo
  57003. */
  57004. updateBoundingBox(): void;
  57005. private _updateRotationSpheres;
  57006. private _updateScaleBoxes;
  57007. /**
  57008. * Enables rotation on the specified axis and disables rotation on the others
  57009. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57010. */
  57011. setEnabledRotationAxis(axis: string): void;
  57012. /**
  57013. * Enables/disables scaling
  57014. * @param enable if scaling should be enabled
  57015. * @param homogeneousScaling defines if scaling should only be homogeneous
  57016. */
  57017. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57018. private _updateDummy;
  57019. /**
  57020. * Enables a pointer drag behavior on the bounding box of the gizmo
  57021. */
  57022. enableDragBehavior(): void;
  57023. /**
  57024. * Disposes of the gizmo
  57025. */
  57026. dispose(): void;
  57027. /**
  57028. * 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)
  57029. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57030. * @returns the bounding box mesh with the passed in mesh as a child
  57031. */
  57032. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57033. /**
  57034. * CustomMeshes are not supported by this gizmo
  57035. * @param mesh The mesh to replace the default mesh of the gizmo
  57036. */
  57037. setCustomMesh(mesh: Mesh): void;
  57038. }
  57039. }
  57040. declare module "babylonjs/Gizmos/gizmoManager" {
  57041. import { Observable } from "babylonjs/Misc/observable";
  57042. import { Nullable } from "babylonjs/types";
  57043. import { Scene, IDisposable } from "babylonjs/scene";
  57044. import { Node } from "babylonjs/node";
  57045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57046. import { Mesh } from "babylonjs/Meshes/mesh";
  57047. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57048. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  57049. import { GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57050. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  57051. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57052. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  57053. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  57054. /**
  57055. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57056. */
  57057. export class GizmoManager implements IDisposable {
  57058. private scene;
  57059. /**
  57060. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57061. */
  57062. gizmos: {
  57063. positionGizmo: Nullable<PositionGizmo>;
  57064. rotationGizmo: Nullable<RotationGizmo>;
  57065. scaleGizmo: Nullable<ScaleGizmo>;
  57066. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57067. };
  57068. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57069. clearGizmoOnEmptyPointerEvent: boolean;
  57070. /** Fires an event when the manager is attached to a mesh */
  57071. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57072. /** Fires an event when the manager is attached to a node */
  57073. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57074. private _gizmosEnabled;
  57075. private _pointerObservers;
  57076. private _attachedMesh;
  57077. private _attachedNode;
  57078. private _boundingBoxColor;
  57079. private _defaultUtilityLayer;
  57080. private _defaultKeepDepthUtilityLayer;
  57081. private _thickness;
  57082. /** Node Caching for quick lookup */
  57083. private _gizmoAxisCache;
  57084. /**
  57085. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57086. */
  57087. boundingBoxDragBehavior: SixDofDragBehavior;
  57088. /**
  57089. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57090. */
  57091. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57092. /**
  57093. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57094. */
  57095. attachableNodes: Nullable<Array<Node>>;
  57096. /**
  57097. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57098. */
  57099. usePointerToAttachGizmos: boolean;
  57100. /**
  57101. * Utility layer that the bounding box gizmo belongs to
  57102. */
  57103. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57104. /**
  57105. * Utility layer that all gizmos besides bounding box belong to
  57106. */
  57107. get utilityLayer(): UtilityLayerRenderer;
  57108. /**
  57109. * True when the mouse pointer is hovering a gizmo mesh
  57110. */
  57111. get isHovered(): boolean;
  57112. /**
  57113. * Instatiates a gizmo manager
  57114. * @param scene the scene to overlay the gizmos on top of
  57115. * @param thickness display gizmo axis thickness
  57116. * @param utilityLayer the layer where gizmos are rendered
  57117. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57118. */
  57119. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57120. /**
  57121. * Subscribes to pointer down events, for attaching and detaching mesh
  57122. * @param scene The sceme layer the observer will be added to
  57123. */
  57124. private _attachToMeshPointerObserver;
  57125. /**
  57126. * Attaches a set of gizmos to the specified mesh
  57127. * @param mesh The mesh the gizmo's should be attached to
  57128. */
  57129. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57130. /**
  57131. * Attaches a set of gizmos to the specified node
  57132. * @param node The node the gizmo's should be attached to
  57133. */
  57134. attachToNode(node: Nullable<Node>): void;
  57135. /**
  57136. * If the position gizmo is enabled
  57137. */
  57138. set positionGizmoEnabled(value: boolean);
  57139. get positionGizmoEnabled(): boolean;
  57140. /**
  57141. * If the rotation gizmo is enabled
  57142. */
  57143. set rotationGizmoEnabled(value: boolean);
  57144. get rotationGizmoEnabled(): boolean;
  57145. /**
  57146. * If the scale gizmo is enabled
  57147. */
  57148. set scaleGizmoEnabled(value: boolean);
  57149. get scaleGizmoEnabled(): boolean;
  57150. /**
  57151. * If the boundingBox gizmo is enabled
  57152. */
  57153. set boundingBoxGizmoEnabled(value: boolean);
  57154. get boundingBoxGizmoEnabled(): boolean;
  57155. /**
  57156. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57157. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57158. */
  57159. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57160. /**
  57161. * Disposes of the gizmo manager
  57162. */
  57163. dispose(): void;
  57164. }
  57165. }
  57166. declare module "babylonjs/Gizmos/positionGizmo" {
  57167. import { Observable } from "babylonjs/Misc/observable";
  57168. import { Nullable } from "babylonjs/types";
  57169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57170. import { Node } from "babylonjs/node";
  57171. import { Mesh } from "babylonjs/Meshes/mesh";
  57172. import { Gizmo, GizmoAxisCache } from "babylonjs/Gizmos/gizmo";
  57173. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  57174. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  57175. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57176. import { GizmoManager } from "babylonjs/Gizmos/gizmoManager";
  57177. /**
  57178. * Gizmo that enables dragging a mesh along 3 axis
  57179. */
  57180. export class PositionGizmo extends Gizmo {
  57181. /**
  57182. * Internal gizmo used for interactions on the x axis
  57183. */
  57184. xGizmo: AxisDragGizmo;
  57185. /**
  57186. * Internal gizmo used for interactions on the y axis
  57187. */
  57188. yGizmo: AxisDragGizmo;
  57189. /**
  57190. * Internal gizmo used for interactions on the z axis
  57191. */
  57192. zGizmo: AxisDragGizmo;
  57193. /**
  57194. * Internal gizmo used for interactions on the yz plane
  57195. */
  57196. xPlaneGizmo: PlaneDragGizmo;
  57197. /**
  57198. * Internal gizmo used for interactions on the xz plane
  57199. */
  57200. yPlaneGizmo: PlaneDragGizmo;
  57201. /**
  57202. * Internal gizmo used for interactions on the xy plane
  57203. */
  57204. zPlaneGizmo: PlaneDragGizmo;
  57205. /**
  57206. * private variables
  57207. */
  57208. private _meshAttached;
  57209. private _nodeAttached;
  57210. private _snapDistance;
  57211. private _observables;
  57212. /** Node Caching for quick lookup */
  57213. private _gizmoAxisCache;
  57214. /** Fires an event when any of it's sub gizmos are dragged */
  57215. onDragStartObservable: Observable<unknown>;
  57216. /** Fires an event when any of it's sub gizmos are released from dragging */
  57217. onDragEndObservable: Observable<unknown>;
  57218. /**
  57219. * If set to true, planar drag is enabled
  57220. */
  57221. private _planarGizmoEnabled;
  57222. get attachedMesh(): Nullable<AbstractMesh>;
  57223. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57224. get attachedNode(): Nullable<Node>;
  57225. set attachedNode(node: Nullable<Node>);
  57226. /**
  57227. * True when the mouse pointer is hovering a gizmo mesh
  57228. */
  57229. get isHovered(): boolean;
  57230. /**
  57231. * Creates a PositionGizmo
  57232. * @param gizmoLayer The utility layer the gizmo will be added to
  57233. @param thickness display gizmo axis thickness
  57234. */
  57235. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57236. /**
  57237. * If the planar drag gizmo is enabled
  57238. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57239. */
  57240. set planarGizmoEnabled(value: boolean);
  57241. get planarGizmoEnabled(): boolean;
  57242. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57243. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57244. /**
  57245. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57246. */
  57247. set snapDistance(value: number);
  57248. get snapDistance(): number;
  57249. /**
  57250. * Ratio for the scale of the gizmo (Default: 1)
  57251. */
  57252. set scaleRatio(value: number);
  57253. get scaleRatio(): number;
  57254. /**
  57255. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57256. * @param mesh Axis gizmo mesh
  57257. * @param cache Gizmo axis definition used for reactive gizmo UI
  57258. */
  57259. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57260. /**
  57261. * Disposes of the gizmo
  57262. */
  57263. dispose(): void;
  57264. /**
  57265. * CustomMeshes are not supported by this gizmo
  57266. * @param mesh The mesh to replace the default mesh of the gizmo
  57267. */
  57268. setCustomMesh(mesh: Mesh): void;
  57269. }
  57270. }
  57271. declare module "babylonjs/Gizmos/axisDragGizmo" {
  57272. import { Observable } from "babylonjs/Misc/observable";
  57273. import { Nullable } from "babylonjs/types";
  57274. import { Vector3 } from "babylonjs/Maths/math.vector";
  57275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57276. import { Node } from "babylonjs/node";
  57277. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  57278. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  57279. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57280. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  57281. import { Scene } from "babylonjs/scene";
  57282. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  57283. import { Color3 } from "babylonjs/Maths/math.color";
  57284. /**
  57285. * Single axis drag gizmo
  57286. */
  57287. export class AxisDragGizmo extends Gizmo {
  57288. /**
  57289. * Drag behavior responsible for the gizmos dragging interactions
  57290. */
  57291. dragBehavior: PointerDragBehavior;
  57292. private _pointerObserver;
  57293. /**
  57294. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57295. */
  57296. snapDistance: number;
  57297. /**
  57298. * Event that fires each time the gizmo snaps to a new location.
  57299. * * snapDistance is the the change in distance
  57300. */
  57301. onSnapObservable: Observable<{
  57302. snapDistance: number;
  57303. }>;
  57304. private _isEnabled;
  57305. private _parent;
  57306. private _gizmoMesh;
  57307. private _coloredMaterial;
  57308. private _hoverMaterial;
  57309. private _disableMaterial;
  57310. private _dragging;
  57311. /** @hidden */
  57312. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57313. /** @hidden */
  57314. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57315. /**
  57316. * Creates an AxisDragGizmo
  57317. * @param gizmoLayer The utility layer the gizmo will be added to
  57318. * @param dragAxis The axis which the gizmo will be able to drag on
  57319. * @param color The color of the gizmo
  57320. * @param thickness display gizmo axis thickness
  57321. */
  57322. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57323. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57324. /**
  57325. * If the gizmo is enabled
  57326. */
  57327. set isEnabled(value: boolean);
  57328. get isEnabled(): boolean;
  57329. /**
  57330. * Disposes of the gizmo
  57331. */
  57332. dispose(): void;
  57333. }
  57334. }
  57335. declare module "babylonjs/Debug/axesViewer" {
  57336. import { Vector3 } from "babylonjs/Maths/math.vector";
  57337. import { Nullable } from "babylonjs/types";
  57338. import { Scene } from "babylonjs/scene";
  57339. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57340. /**
  57341. * The Axes viewer will show 3 axes in a specific point in space
  57342. */
  57343. export class AxesViewer {
  57344. private _xAxis;
  57345. private _yAxis;
  57346. private _zAxis;
  57347. private _scaleLinesFactor;
  57348. private _instanced;
  57349. /**
  57350. * Gets the hosting scene
  57351. */
  57352. scene: Nullable<Scene>;
  57353. /**
  57354. * Gets or sets a number used to scale line length
  57355. */
  57356. scaleLines: number;
  57357. /** Gets the node hierarchy used to render x-axis */
  57358. get xAxis(): TransformNode;
  57359. /** Gets the node hierarchy used to render y-axis */
  57360. get yAxis(): TransformNode;
  57361. /** Gets the node hierarchy used to render z-axis */
  57362. get zAxis(): TransformNode;
  57363. /**
  57364. * Creates a new AxesViewer
  57365. * @param scene defines the hosting scene
  57366. * @param scaleLines defines a number used to scale line length (1 by default)
  57367. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57368. * @param xAxis defines the node hierarchy used to render the x-axis
  57369. * @param yAxis defines the node hierarchy used to render the y-axis
  57370. * @param zAxis defines the node hierarchy used to render the z-axis
  57371. */
  57372. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57373. /**
  57374. * Force the viewer to update
  57375. * @param position defines the position of the viewer
  57376. * @param xaxis defines the x axis of the viewer
  57377. * @param yaxis defines the y axis of the viewer
  57378. * @param zaxis defines the z axis of the viewer
  57379. */
  57380. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57381. /**
  57382. * Creates an instance of this axes viewer.
  57383. * @returns a new axes viewer with instanced meshes
  57384. */
  57385. createInstance(): AxesViewer;
  57386. /** Releases resources */
  57387. dispose(): void;
  57388. private static _SetRenderingGroupId;
  57389. }
  57390. }
  57391. declare module "babylonjs/Debug/boneAxesViewer" {
  57392. import { Nullable } from "babylonjs/types";
  57393. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  57394. import { Vector3 } from "babylonjs/Maths/math.vector";
  57395. import { Mesh } from "babylonjs/Meshes/mesh";
  57396. import { Bone } from "babylonjs/Bones/bone";
  57397. import { Scene } from "babylonjs/scene";
  57398. /**
  57399. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57400. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57401. */
  57402. export class BoneAxesViewer extends AxesViewer {
  57403. /**
  57404. * Gets or sets the target mesh where to display the axes viewer
  57405. */
  57406. mesh: Nullable<Mesh>;
  57407. /**
  57408. * Gets or sets the target bone where to display the axes viewer
  57409. */
  57410. bone: Nullable<Bone>;
  57411. /** Gets current position */
  57412. pos: Vector3;
  57413. /** Gets direction of X axis */
  57414. xaxis: Vector3;
  57415. /** Gets direction of Y axis */
  57416. yaxis: Vector3;
  57417. /** Gets direction of Z axis */
  57418. zaxis: Vector3;
  57419. /**
  57420. * Creates a new BoneAxesViewer
  57421. * @param scene defines the hosting scene
  57422. * @param bone defines the target bone
  57423. * @param mesh defines the target mesh
  57424. * @param scaleLines defines a scaling factor for line length (1 by default)
  57425. */
  57426. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57427. /**
  57428. * Force the viewer to update
  57429. */
  57430. update(): void;
  57431. /** Releases resources */
  57432. dispose(): void;
  57433. }
  57434. }
  57435. declare module "babylonjs/Debug/debugLayer" {
  57436. import { Scene } from "babylonjs/scene";
  57437. /**
  57438. * Interface used to define scene explorer extensibility option
  57439. */
  57440. export interface IExplorerExtensibilityOption {
  57441. /**
  57442. * Define the option label
  57443. */
  57444. label: string;
  57445. /**
  57446. * Defines the action to execute on click
  57447. */
  57448. action: (entity: any) => void;
  57449. }
  57450. /**
  57451. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57452. */
  57453. export interface IExplorerExtensibilityGroup {
  57454. /**
  57455. * Defines a predicate to test if a given type mut be extended
  57456. */
  57457. predicate: (entity: any) => boolean;
  57458. /**
  57459. * Gets the list of options added to a type
  57460. */
  57461. entries: IExplorerExtensibilityOption[];
  57462. }
  57463. /**
  57464. * Interface used to define the options to use to create the Inspector
  57465. */
  57466. export interface IInspectorOptions {
  57467. /**
  57468. * Display in overlay mode (default: false)
  57469. */
  57470. overlay?: boolean;
  57471. /**
  57472. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57473. */
  57474. globalRoot?: HTMLElement;
  57475. /**
  57476. * Display the Scene explorer
  57477. */
  57478. showExplorer?: boolean;
  57479. /**
  57480. * Display the property inspector
  57481. */
  57482. showInspector?: boolean;
  57483. /**
  57484. * Display in embed mode (both panes on the right)
  57485. */
  57486. embedMode?: boolean;
  57487. /**
  57488. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57489. */
  57490. handleResize?: boolean;
  57491. /**
  57492. * Allow the panes to popup (default: true)
  57493. */
  57494. enablePopup?: boolean;
  57495. /**
  57496. * Allow the panes to be closed by users (default: true)
  57497. */
  57498. enableClose?: boolean;
  57499. /**
  57500. * Optional list of extensibility entries
  57501. */
  57502. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57503. /**
  57504. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57505. */
  57506. inspectorURL?: string;
  57507. /**
  57508. * Optional initial tab (default to DebugLayerTab.Properties)
  57509. */
  57510. initialTab?: DebugLayerTab;
  57511. }
  57512. module "babylonjs/scene" {
  57513. interface Scene {
  57514. /**
  57515. * @hidden
  57516. * Backing field
  57517. */
  57518. _debugLayer: DebugLayer;
  57519. /**
  57520. * Gets the debug layer (aka Inspector) associated with the scene
  57521. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57522. */
  57523. debugLayer: DebugLayer;
  57524. }
  57525. }
  57526. /**
  57527. * Enum of inspector action tab
  57528. */
  57529. export enum DebugLayerTab {
  57530. /**
  57531. * Properties tag (default)
  57532. */
  57533. Properties = 0,
  57534. /**
  57535. * Debug tab
  57536. */
  57537. Debug = 1,
  57538. /**
  57539. * Statistics tab
  57540. */
  57541. Statistics = 2,
  57542. /**
  57543. * Tools tab
  57544. */
  57545. Tools = 3,
  57546. /**
  57547. * Settings tab
  57548. */
  57549. Settings = 4
  57550. }
  57551. /**
  57552. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57553. * what is happening in your scene
  57554. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57555. */
  57556. export class DebugLayer {
  57557. /**
  57558. * Define the url to get the inspector script from.
  57559. * By default it uses the babylonjs CDN.
  57560. * @ignoreNaming
  57561. */
  57562. static InspectorURL: string;
  57563. private _scene;
  57564. private BJSINSPECTOR;
  57565. private _onPropertyChangedObservable?;
  57566. /**
  57567. * Observable triggered when a property is changed through the inspector.
  57568. */
  57569. get onPropertyChangedObservable(): any;
  57570. /**
  57571. * Instantiates a new debug layer.
  57572. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57573. * what is happening in your scene
  57574. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57575. * @param scene Defines the scene to inspect
  57576. */
  57577. constructor(scene: Scene);
  57578. /** Creates the inspector window. */
  57579. private _createInspector;
  57580. /**
  57581. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57582. * @param entity defines the entity to select
  57583. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57584. */
  57585. select(entity: any, lineContainerTitles?: string | string[]): void;
  57586. /** Get the inspector from bundle or global */
  57587. private _getGlobalInspector;
  57588. /**
  57589. * Get if the inspector is visible or not.
  57590. * @returns true if visible otherwise, false
  57591. */
  57592. isVisible(): boolean;
  57593. /**
  57594. * Hide the inspector and close its window.
  57595. */
  57596. hide(): void;
  57597. /**
  57598. * Update the scene in the inspector
  57599. */
  57600. setAsActiveScene(): void;
  57601. /**
  57602. * Launch the debugLayer.
  57603. * @param config Define the configuration of the inspector
  57604. * @return a promise fulfilled when the debug layer is visible
  57605. */
  57606. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57607. }
  57608. }
  57609. declare module "babylonjs/Debug/physicsViewer" {
  57610. import { Nullable } from "babylonjs/types";
  57611. import { Scene } from "babylonjs/scene";
  57612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57613. import { Mesh } from "babylonjs/Meshes/mesh";
  57614. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57615. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57616. /**
  57617. * Used to show the physics impostor around the specific mesh
  57618. */
  57619. export class PhysicsViewer {
  57620. /** @hidden */
  57621. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57622. /** @hidden */
  57623. protected _meshes: Array<Nullable<AbstractMesh>>;
  57624. /** @hidden */
  57625. protected _scene: Nullable<Scene>;
  57626. /** @hidden */
  57627. protected _numMeshes: number;
  57628. /** @hidden */
  57629. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57630. private _renderFunction;
  57631. private _utilityLayer;
  57632. private _debugBoxMesh;
  57633. private _debugSphereMesh;
  57634. private _debugCylinderMesh;
  57635. private _debugMaterial;
  57636. private _debugMeshMeshes;
  57637. /**
  57638. * Creates a new PhysicsViewer
  57639. * @param scene defines the hosting scene
  57640. */
  57641. constructor(scene: Scene);
  57642. /** @hidden */
  57643. protected _updateDebugMeshes(): void;
  57644. /**
  57645. * Renders a specified physic impostor
  57646. * @param impostor defines the impostor to render
  57647. * @param targetMesh defines the mesh represented by the impostor
  57648. * @returns the new debug mesh used to render the impostor
  57649. */
  57650. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  57651. /**
  57652. * Hides a specified physic impostor
  57653. * @param impostor defines the impostor to hide
  57654. */
  57655. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  57656. private _getDebugMaterial;
  57657. private _getDebugBoxMesh;
  57658. private _getDebugSphereMesh;
  57659. private _getDebugCylinderMesh;
  57660. private _getDebugMeshMesh;
  57661. private _getDebugMesh;
  57662. /** Releases all resources */
  57663. dispose(): void;
  57664. }
  57665. }
  57666. declare module "babylonjs/Debug/rayHelper" {
  57667. import { Nullable } from "babylonjs/types";
  57668. import { Ray } from "babylonjs/Culling/ray";
  57669. import { Vector3 } from "babylonjs/Maths/math.vector";
  57670. import { Color3 } from "babylonjs/Maths/math.color";
  57671. import { Scene } from "babylonjs/scene";
  57672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57673. import "babylonjs/Meshes/Builders/linesBuilder";
  57674. /**
  57675. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57676. * in order to better appreciate the issue one might have.
  57677. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57678. */
  57679. export class RayHelper {
  57680. /**
  57681. * Defines the ray we are currently tryin to visualize.
  57682. */
  57683. ray: Nullable<Ray>;
  57684. private _renderPoints;
  57685. private _renderLine;
  57686. private _renderFunction;
  57687. private _scene;
  57688. private _onAfterRenderObserver;
  57689. private _onAfterStepObserver;
  57690. private _attachedToMesh;
  57691. private _meshSpaceDirection;
  57692. private _meshSpaceOrigin;
  57693. /**
  57694. * Helper function to create a colored helper in a scene in one line.
  57695. * @param ray Defines the ray we are currently tryin to visualize
  57696. * @param scene Defines the scene the ray is used in
  57697. * @param color Defines the color we want to see the ray in
  57698. * @returns The newly created ray helper.
  57699. */
  57700. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  57701. /**
  57702. * Instantiate a new ray helper.
  57703. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  57704. * in order to better appreciate the issue one might have.
  57705. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  57706. * @param ray Defines the ray we are currently tryin to visualize
  57707. */
  57708. constructor(ray: Ray);
  57709. /**
  57710. * Shows the ray we are willing to debug.
  57711. * @param scene Defines the scene the ray needs to be rendered in
  57712. * @param color Defines the color the ray needs to be rendered in
  57713. */
  57714. show(scene: Scene, color?: Color3): void;
  57715. /**
  57716. * Hides the ray we are debugging.
  57717. */
  57718. hide(): void;
  57719. private _render;
  57720. /**
  57721. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  57722. * @param mesh Defines the mesh we want the helper attached to
  57723. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  57724. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  57725. * @param length Defines the length of the ray
  57726. */
  57727. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  57728. /**
  57729. * Detach the ray helper from the mesh it has previously been attached to.
  57730. */
  57731. detachFromMesh(): void;
  57732. private _updateToMesh;
  57733. /**
  57734. * Dispose the helper and release its associated resources.
  57735. */
  57736. dispose(): void;
  57737. }
  57738. }
  57739. declare module "babylonjs/Debug/ISkeletonViewer" {
  57740. import { Skeleton } from "babylonjs/Bones/skeleton";
  57741. import { Color3 } from "babylonjs/Maths/math.color";
  57742. /**
  57743. * Defines the options associated with the creation of a SkeletonViewer.
  57744. */
  57745. export interface ISkeletonViewerOptions {
  57746. /** Should the system pause animations before building the Viewer? */
  57747. pauseAnimations: boolean;
  57748. /** Should the system return the skeleton to rest before building? */
  57749. returnToRest: boolean;
  57750. /** public Display Mode of the Viewer */
  57751. displayMode: number;
  57752. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57753. displayOptions: ISkeletonViewerDisplayOptions;
  57754. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  57755. computeBonesUsingShaders: boolean;
  57756. /** Flag ignore non weighted bones */
  57757. useAllBones: boolean;
  57758. }
  57759. /**
  57760. * Defines how to display the various bone meshes for the viewer.
  57761. */
  57762. export interface ISkeletonViewerDisplayOptions {
  57763. /** How far down to start tapering the bone spurs */
  57764. midStep?: number;
  57765. /** How big is the midStep? */
  57766. midStepFactor?: number;
  57767. /** Base for the Sphere Size */
  57768. sphereBaseSize?: number;
  57769. /** The ratio of the sphere to the longest bone in units */
  57770. sphereScaleUnit?: number;
  57771. /** Ratio for the Sphere Size */
  57772. sphereFactor?: number;
  57773. /** Whether a spur should attach its far end to the child bone position */
  57774. spurFollowsChild?: boolean;
  57775. /** Whether to show local axes or not */
  57776. showLocalAxes?: boolean;
  57777. /** Length of each local axis */
  57778. localAxesSize?: number;
  57779. }
  57780. /**
  57781. * Defines the constructor options for the BoneWeight Shader.
  57782. */
  57783. export interface IBoneWeightShaderOptions {
  57784. /** Skeleton to Map */
  57785. skeleton: Skeleton;
  57786. /** Colors for Uninfluenced bones */
  57787. colorBase?: Color3;
  57788. /** Colors for 0.0-0.25 Weight bones */
  57789. colorZero?: Color3;
  57790. /** Color for 0.25-0.5 Weight Influence */
  57791. colorQuarter?: Color3;
  57792. /** Color for 0.5-0.75 Weight Influence */
  57793. colorHalf?: Color3;
  57794. /** Color for 0.75-1 Weight Influence */
  57795. colorFull?: Color3;
  57796. /** Color for Zero Weight Influence */
  57797. targetBoneIndex?: number;
  57798. }
  57799. /**
  57800. * Simple structure of the gradient steps for the Color Map.
  57801. */
  57802. export interface ISkeletonMapShaderColorMapKnot {
  57803. /** Color of the Knot */
  57804. color: Color3;
  57805. /** Location of the Knot */
  57806. location: number;
  57807. }
  57808. /**
  57809. * Defines the constructor options for the SkeletonMap Shader.
  57810. */
  57811. export interface ISkeletonMapShaderOptions {
  57812. /** Skeleton to Map */
  57813. skeleton: Skeleton;
  57814. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  57815. colorMap?: ISkeletonMapShaderColorMapKnot[];
  57816. }
  57817. }
  57818. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57819. import { Nullable } from "babylonjs/types";
  57820. import { Scene } from "babylonjs/scene";
  57821. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57822. import { Color4 } from "babylonjs/Maths/math.color";
  57823. import { Mesh } from "babylonjs/Meshes/mesh";
  57824. /**
  57825. * Class containing static functions to help procedurally build meshes
  57826. */
  57827. export class RibbonBuilder {
  57828. /**
  57829. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57830. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57831. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57832. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57833. * * 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
  57834. * * 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
  57835. * * 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
  57836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57838. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57839. * * 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
  57840. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57841. * * 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
  57842. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57844. * @param name defines the name of the mesh
  57845. * @param options defines the options used to create the mesh
  57846. * @param scene defines the hosting scene
  57847. * @returns the ribbon mesh
  57848. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57849. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57850. */
  57851. static CreateRibbon(name: string, options: {
  57852. pathArray: Vector3[][];
  57853. closeArray?: boolean;
  57854. closePath?: boolean;
  57855. offset?: number;
  57856. updatable?: boolean;
  57857. sideOrientation?: number;
  57858. frontUVs?: Vector4;
  57859. backUVs?: Vector4;
  57860. instance?: Mesh;
  57861. invertUV?: boolean;
  57862. uvs?: Vector2[];
  57863. colors?: Color4[];
  57864. }, scene?: Nullable<Scene>): Mesh;
  57865. }
  57866. }
  57867. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57868. import { Nullable } from "babylonjs/types";
  57869. import { Scene } from "babylonjs/scene";
  57870. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57871. import { Mesh } from "babylonjs/Meshes/mesh";
  57872. /**
  57873. * Class containing static functions to help procedurally build meshes
  57874. */
  57875. export class ShapeBuilder {
  57876. /**
  57877. * 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.
  57878. * * 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.
  57879. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57880. * * 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.
  57881. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57882. * * 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
  57883. * * 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
  57884. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57889. * @param name defines the name of the mesh
  57890. * @param options defines the options used to create the mesh
  57891. * @param scene defines the hosting scene
  57892. * @returns the extruded shape mesh
  57893. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57894. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57895. */
  57896. static ExtrudeShape(name: string, options: {
  57897. shape: Vector3[];
  57898. path: Vector3[];
  57899. scale?: number;
  57900. rotation?: number;
  57901. cap?: number;
  57902. updatable?: boolean;
  57903. sideOrientation?: number;
  57904. frontUVs?: Vector4;
  57905. backUVs?: Vector4;
  57906. instance?: Mesh;
  57907. invertUV?: boolean;
  57908. }, scene?: Nullable<Scene>): Mesh;
  57909. /**
  57910. * Creates an custom extruded shape mesh.
  57911. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57912. * * 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.
  57913. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57914. * * 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
  57915. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57916. * * 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
  57917. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57918. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57919. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57920. * * 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
  57921. * * 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
  57922. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57925. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57927. * @param name defines the name of the mesh
  57928. * @param options defines the options used to create the mesh
  57929. * @param scene defines the hosting scene
  57930. * @returns the custom extruded shape mesh
  57931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57932. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57933. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57934. */
  57935. static ExtrudeShapeCustom(name: string, options: {
  57936. shape: Vector3[];
  57937. path: Vector3[];
  57938. scaleFunction?: any;
  57939. rotationFunction?: any;
  57940. ribbonCloseArray?: boolean;
  57941. ribbonClosePath?: boolean;
  57942. cap?: number;
  57943. updatable?: boolean;
  57944. sideOrientation?: number;
  57945. frontUVs?: Vector4;
  57946. backUVs?: Vector4;
  57947. instance?: Mesh;
  57948. invertUV?: boolean;
  57949. }, scene?: Nullable<Scene>): Mesh;
  57950. private static _ExtrudeShapeGeneric;
  57951. }
  57952. }
  57953. declare module "babylonjs/Debug/skeletonViewer" {
  57954. import { Color3 } from "babylonjs/Maths/math.color";
  57955. import { Scene } from "babylonjs/scene";
  57956. import { Nullable } from "babylonjs/types";
  57957. import { Skeleton } from "babylonjs/Bones/skeleton";
  57958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57959. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  57960. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  57961. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  57962. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  57963. /**
  57964. * Class used to render a debug view of a given skeleton
  57965. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  57966. */
  57967. export class SkeletonViewer {
  57968. /** defines the skeleton to render */
  57969. skeleton: Skeleton;
  57970. /** defines the mesh attached to the skeleton */
  57971. mesh: AbstractMesh;
  57972. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57973. autoUpdateBonesMatrices: boolean;
  57974. /** defines the rendering group id to use with the viewer */
  57975. renderingGroupId: number;
  57976. /** is the options for the viewer */
  57977. options: Partial<ISkeletonViewerOptions>;
  57978. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  57979. static readonly DISPLAY_LINES: number;
  57980. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  57981. static readonly DISPLAY_SPHERES: number;
  57982. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  57983. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  57984. /** public static method to create a BoneWeight Shader
  57985. * @param options The constructor options
  57986. * @param scene The scene that the shader is scoped to
  57987. * @returns The created ShaderMaterial
  57988. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  57989. */
  57990. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  57991. /** public static method to create a BoneWeight Shader
  57992. * @param options The constructor options
  57993. * @param scene The scene that the shader is scoped to
  57994. * @returns The created ShaderMaterial
  57995. */
  57996. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  57997. /** private static method to create a BoneWeight Shader
  57998. * @param size The size of the buffer to create (usually the bone count)
  57999. * @param colorMap The gradient data to generate
  58000. * @param scene The scene that the shader is scoped to
  58001. * @returns an Array of floats from the color gradient values
  58002. */
  58003. private static _CreateBoneMapColorBuffer;
  58004. /** If SkeletonViewer scene scope. */
  58005. private _scene;
  58006. /** Gets or sets the color used to render the skeleton */
  58007. color: Color3;
  58008. /** Array of the points of the skeleton fo the line view. */
  58009. private _debugLines;
  58010. /** The SkeletonViewers Mesh. */
  58011. private _debugMesh;
  58012. /** The local axes Meshes. */
  58013. private _localAxes;
  58014. /** If SkeletonViewer is enabled. */
  58015. private _isEnabled;
  58016. /** If SkeletonViewer is ready. */
  58017. private _ready;
  58018. /** SkeletonViewer render observable. */
  58019. private _obs;
  58020. /** The Utility Layer to render the gizmos in. */
  58021. private _utilityLayer;
  58022. private _boneIndices;
  58023. /** Gets the Scene. */
  58024. get scene(): Scene;
  58025. /** Gets the utilityLayer. */
  58026. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58027. /** Checks Ready Status. */
  58028. get isReady(): Boolean;
  58029. /** Sets Ready Status. */
  58030. set ready(value: boolean);
  58031. /** Gets the debugMesh */
  58032. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58033. /** Sets the debugMesh */
  58034. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58035. /** Gets the displayMode */
  58036. get displayMode(): number;
  58037. /** Sets the displayMode */
  58038. set displayMode(value: number);
  58039. /**
  58040. * Creates a new SkeletonViewer
  58041. * @param skeleton defines the skeleton to render
  58042. * @param mesh defines the mesh attached to the skeleton
  58043. * @param scene defines the hosting scene
  58044. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58045. * @param renderingGroupId defines the rendering group id to use with the viewer
  58046. * @param options All of the extra constructor options for the SkeletonViewer
  58047. */
  58048. constructor(
  58049. /** defines the skeleton to render */
  58050. skeleton: Skeleton,
  58051. /** defines the mesh attached to the skeleton */
  58052. mesh: AbstractMesh,
  58053. /** The Scene scope*/
  58054. scene: Scene,
  58055. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58056. autoUpdateBonesMatrices?: boolean,
  58057. /** defines the rendering group id to use with the viewer */
  58058. renderingGroupId?: number,
  58059. /** is the options for the viewer */
  58060. options?: Partial<ISkeletonViewerOptions>);
  58061. /** The Dynamic bindings for the update functions */
  58062. private _bindObs;
  58063. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58064. update(): void;
  58065. /** Gets or sets a boolean indicating if the viewer is enabled */
  58066. set isEnabled(value: boolean);
  58067. get isEnabled(): boolean;
  58068. private _getBonePosition;
  58069. private _getLinesForBonesWithLength;
  58070. private _getLinesForBonesNoLength;
  58071. /** function to revert the mesh and scene back to the initial state. */
  58072. private _revert;
  58073. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58074. private _getAbsoluteBindPoseToRef;
  58075. /** function to build and bind sphere joint points and spur bone representations. */
  58076. private _buildSpheresAndSpurs;
  58077. private _buildLocalAxes;
  58078. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58079. private _displayLinesUpdate;
  58080. /** Changes the displayMode of the skeleton viewer
  58081. * @param mode The displayMode numerical value
  58082. */
  58083. changeDisplayMode(mode: number): void;
  58084. /** Sets a display option of the skeleton viewer
  58085. *
  58086. * | Option | Type | Default | Description |
  58087. * | ---------------- | ------- | ------- | ----------- |
  58088. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58089. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58090. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58091. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58092. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58093. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58094. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58095. *
  58096. * @param option String of the option name
  58097. * @param value The numerical option value
  58098. */
  58099. changeDisplayOptions(option: string, value: number): void;
  58100. /** Release associated resources */
  58101. dispose(): void;
  58102. }
  58103. }
  58104. declare module "babylonjs/Debug/index" {
  58105. export * from "babylonjs/Debug/axesViewer";
  58106. export * from "babylonjs/Debug/boneAxesViewer";
  58107. export * from "babylonjs/Debug/debugLayer";
  58108. export * from "babylonjs/Debug/physicsViewer";
  58109. export * from "babylonjs/Debug/rayHelper";
  58110. export * from "babylonjs/Debug/skeletonViewer";
  58111. export * from "babylonjs/Debug/ISkeletonViewer";
  58112. }
  58113. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  58114. /**
  58115. * Enum for Device Types
  58116. */
  58117. export enum DeviceType {
  58118. /** Generic */
  58119. Generic = 0,
  58120. /** Keyboard */
  58121. Keyboard = 1,
  58122. /** Mouse */
  58123. Mouse = 2,
  58124. /** Touch Pointers */
  58125. Touch = 3,
  58126. /** PS4 Dual Shock */
  58127. DualShock = 4,
  58128. /** Xbox */
  58129. Xbox = 5,
  58130. /** Switch Controller */
  58131. Switch = 6
  58132. }
  58133. /**
  58134. * Enum for All Pointers (Touch/Mouse)
  58135. */
  58136. export enum PointerInput {
  58137. /** Horizontal Axis */
  58138. Horizontal = 0,
  58139. /** Vertical Axis */
  58140. Vertical = 1,
  58141. /** Left Click or Touch */
  58142. LeftClick = 2,
  58143. /** Middle Click */
  58144. MiddleClick = 3,
  58145. /** Right Click */
  58146. RightClick = 4,
  58147. /** Browser Back */
  58148. BrowserBack = 5,
  58149. /** Browser Forward */
  58150. BrowserForward = 6
  58151. }
  58152. /**
  58153. * Enum for Dual Shock Gamepad
  58154. */
  58155. export enum DualShockInput {
  58156. /** Cross */
  58157. Cross = 0,
  58158. /** Circle */
  58159. Circle = 1,
  58160. /** Square */
  58161. Square = 2,
  58162. /** Triangle */
  58163. Triangle = 3,
  58164. /** L1 */
  58165. L1 = 4,
  58166. /** R1 */
  58167. R1 = 5,
  58168. /** L2 */
  58169. L2 = 6,
  58170. /** R2 */
  58171. R2 = 7,
  58172. /** Share */
  58173. Share = 8,
  58174. /** Options */
  58175. Options = 9,
  58176. /** L3 */
  58177. L3 = 10,
  58178. /** R3 */
  58179. R3 = 11,
  58180. /** DPadUp */
  58181. DPadUp = 12,
  58182. /** DPadDown */
  58183. DPadDown = 13,
  58184. /** DPadLeft */
  58185. DPadLeft = 14,
  58186. /** DRight */
  58187. DPadRight = 15,
  58188. /** Home */
  58189. Home = 16,
  58190. /** TouchPad */
  58191. TouchPad = 17,
  58192. /** LStickXAxis */
  58193. LStickXAxis = 18,
  58194. /** LStickYAxis */
  58195. LStickYAxis = 19,
  58196. /** RStickXAxis */
  58197. RStickXAxis = 20,
  58198. /** RStickYAxis */
  58199. RStickYAxis = 21
  58200. }
  58201. /**
  58202. * Enum for Xbox Gamepad
  58203. */
  58204. export enum XboxInput {
  58205. /** A */
  58206. A = 0,
  58207. /** B */
  58208. B = 1,
  58209. /** X */
  58210. X = 2,
  58211. /** Y */
  58212. Y = 3,
  58213. /** LB */
  58214. LB = 4,
  58215. /** RB */
  58216. RB = 5,
  58217. /** LT */
  58218. LT = 6,
  58219. /** RT */
  58220. RT = 7,
  58221. /** Back */
  58222. Back = 8,
  58223. /** Start */
  58224. Start = 9,
  58225. /** LS */
  58226. LS = 10,
  58227. /** RS */
  58228. RS = 11,
  58229. /** DPadUp */
  58230. DPadUp = 12,
  58231. /** DPadDown */
  58232. DPadDown = 13,
  58233. /** DPadLeft */
  58234. DPadLeft = 14,
  58235. /** DRight */
  58236. DPadRight = 15,
  58237. /** Home */
  58238. Home = 16,
  58239. /** LStickXAxis */
  58240. LStickXAxis = 17,
  58241. /** LStickYAxis */
  58242. LStickYAxis = 18,
  58243. /** RStickXAxis */
  58244. RStickXAxis = 19,
  58245. /** RStickYAxis */
  58246. RStickYAxis = 20
  58247. }
  58248. /**
  58249. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58250. */
  58251. export enum SwitchInput {
  58252. /** B */
  58253. B = 0,
  58254. /** A */
  58255. A = 1,
  58256. /** Y */
  58257. Y = 2,
  58258. /** X */
  58259. X = 3,
  58260. /** L */
  58261. L = 4,
  58262. /** R */
  58263. R = 5,
  58264. /** ZL */
  58265. ZL = 6,
  58266. /** ZR */
  58267. ZR = 7,
  58268. /** Minus */
  58269. Minus = 8,
  58270. /** Plus */
  58271. Plus = 9,
  58272. /** LS */
  58273. LS = 10,
  58274. /** RS */
  58275. RS = 11,
  58276. /** DPadUp */
  58277. DPadUp = 12,
  58278. /** DPadDown */
  58279. DPadDown = 13,
  58280. /** DPadLeft */
  58281. DPadLeft = 14,
  58282. /** DRight */
  58283. DPadRight = 15,
  58284. /** Home */
  58285. Home = 16,
  58286. /** Capture */
  58287. Capture = 17,
  58288. /** LStickXAxis */
  58289. LStickXAxis = 18,
  58290. /** LStickYAxis */
  58291. LStickYAxis = 19,
  58292. /** RStickXAxis */
  58293. RStickXAxis = 20,
  58294. /** RStickYAxis */
  58295. RStickYAxis = 21
  58296. }
  58297. }
  58298. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  58299. import { Engine } from "babylonjs/Engines/engine";
  58300. import { IDisposable } from "babylonjs/scene";
  58301. import { Nullable } from "babylonjs/types";
  58302. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58303. /**
  58304. * This class will take all inputs from Keyboard, Pointer, and
  58305. * any Gamepads and provide a polling system that all devices
  58306. * will use. This class assumes that there will only be one
  58307. * pointer device and one keyboard.
  58308. */
  58309. export class DeviceInputSystem implements IDisposable {
  58310. /**
  58311. * Returns onDeviceConnected callback property
  58312. * @returns Callback with function to execute when a device is connected
  58313. */
  58314. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58315. /**
  58316. * Sets callback function when a device is connected and executes against all connected devices
  58317. * @param callback Function to execute when a device is connected
  58318. */
  58319. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58320. /**
  58321. * Callback to be triggered when a device is disconnected
  58322. */
  58323. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58324. /**
  58325. * Callback to be triggered when event driven input is updated
  58326. */
  58327. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58328. private _inputs;
  58329. private _gamepads;
  58330. private _keyboardActive;
  58331. private _pointerActive;
  58332. private _elementToAttachTo;
  58333. private _keyboardDownEvent;
  58334. private _keyboardUpEvent;
  58335. private _pointerMoveEvent;
  58336. private _pointerDownEvent;
  58337. private _pointerUpEvent;
  58338. private _gamepadConnectedEvent;
  58339. private _gamepadDisconnectedEvent;
  58340. private _onDeviceConnected;
  58341. private static _MAX_KEYCODES;
  58342. private static _MAX_POINTER_INPUTS;
  58343. private constructor();
  58344. /**
  58345. * Creates a new DeviceInputSystem instance
  58346. * @param engine Engine to pull input element from
  58347. * @returns The new instance
  58348. */
  58349. static Create(engine: Engine): DeviceInputSystem;
  58350. /**
  58351. * Checks for current device input value, given an id and input index
  58352. * @param deviceName Id of connected device
  58353. * @param inputIndex Index of device input
  58354. * @returns Current value of input
  58355. */
  58356. /**
  58357. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58358. * @param deviceType Enum specifiying device type
  58359. * @param deviceSlot "Slot" or index that device is referenced in
  58360. * @param inputIndex Id of input to be checked
  58361. * @returns Current value of input
  58362. */
  58363. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58364. /**
  58365. * Dispose of all the eventlisteners
  58366. */
  58367. dispose(): void;
  58368. /**
  58369. * Checks for existing connections to devices and register them, if necessary
  58370. * Currently handles gamepads and mouse
  58371. */
  58372. private _checkForConnectedDevices;
  58373. /**
  58374. * Add a gamepad to the DeviceInputSystem
  58375. * @param gamepad A single DOM Gamepad object
  58376. */
  58377. private _addGamePad;
  58378. /**
  58379. * Add pointer device to DeviceInputSystem
  58380. * @param deviceType Type of Pointer to add
  58381. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58382. * @param currentX Current X at point of adding
  58383. * @param currentY Current Y at point of adding
  58384. */
  58385. private _addPointerDevice;
  58386. /**
  58387. * Add device and inputs to device array
  58388. * @param deviceType Enum specifiying device type
  58389. * @param deviceSlot "Slot" or index that device is referenced in
  58390. * @param numberOfInputs Number of input entries to create for given device
  58391. */
  58392. private _registerDevice;
  58393. /**
  58394. * Given a specific device name, remove that device from the device map
  58395. * @param deviceType Enum specifiying device type
  58396. * @param deviceSlot "Slot" or index that device is referenced in
  58397. */
  58398. private _unregisterDevice;
  58399. /**
  58400. * Handle all actions that come from keyboard interaction
  58401. */
  58402. private _handleKeyActions;
  58403. /**
  58404. * Handle all actions that come from pointer interaction
  58405. */
  58406. private _handlePointerActions;
  58407. /**
  58408. * Handle all actions that come from gamepad interaction
  58409. */
  58410. private _handleGamepadActions;
  58411. /**
  58412. * Update all non-event based devices with each frame
  58413. * @param deviceType Enum specifiying device type
  58414. * @param deviceSlot "Slot" or index that device is referenced in
  58415. * @param inputIndex Id of input to be checked
  58416. */
  58417. private _updateDevice;
  58418. /**
  58419. * Gets DeviceType from the device name
  58420. * @param deviceName Name of Device from DeviceInputSystem
  58421. * @returns DeviceType enum value
  58422. */
  58423. private _getGamepadDeviceType;
  58424. }
  58425. }
  58426. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  58427. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58428. /**
  58429. * Type to handle enforcement of inputs
  58430. */
  58431. 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;
  58432. }
  58433. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  58434. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  58435. import { Engine } from "babylonjs/Engines/engine";
  58436. import { IDisposable } from "babylonjs/scene";
  58437. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58438. import { Nullable } from "babylonjs/types";
  58439. import { Observable } from "babylonjs/Misc/observable";
  58440. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58441. /**
  58442. * Class that handles all input for a specific device
  58443. */
  58444. export class DeviceSource<T extends DeviceType> {
  58445. /** Type of device */
  58446. readonly deviceType: DeviceType;
  58447. /** "Slot" or index that device is referenced in */
  58448. readonly deviceSlot: number;
  58449. /**
  58450. * Observable to handle device input changes per device
  58451. */
  58452. readonly onInputChangedObservable: Observable<{
  58453. inputIndex: DeviceInput<T>;
  58454. previousState: Nullable<number>;
  58455. currentState: Nullable<number>;
  58456. }>;
  58457. private readonly _deviceInputSystem;
  58458. /**
  58459. * Default Constructor
  58460. * @param deviceInputSystem Reference to DeviceInputSystem
  58461. * @param deviceType Type of device
  58462. * @param deviceSlot "Slot" or index that device is referenced in
  58463. */
  58464. constructor(deviceInputSystem: DeviceInputSystem,
  58465. /** Type of device */
  58466. deviceType: DeviceType,
  58467. /** "Slot" or index that device is referenced in */
  58468. deviceSlot?: number);
  58469. /**
  58470. * Get input for specific input
  58471. * @param inputIndex index of specific input on device
  58472. * @returns Input value from DeviceInputSystem
  58473. */
  58474. getInput(inputIndex: DeviceInput<T>): number;
  58475. }
  58476. /**
  58477. * Class to keep track of devices
  58478. */
  58479. export class DeviceSourceManager implements IDisposable {
  58480. /**
  58481. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58482. */
  58483. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58484. /**
  58485. * Observable to be triggered when after a device is disconnected
  58486. */
  58487. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58488. private readonly _devices;
  58489. private readonly _firstDevice;
  58490. private readonly _deviceInputSystem;
  58491. /**
  58492. * Default Constructor
  58493. * @param engine engine to pull input element from
  58494. */
  58495. constructor(engine: Engine);
  58496. /**
  58497. * Gets a DeviceSource, given a type and slot
  58498. * @param deviceType Enum specifying device type
  58499. * @param deviceSlot "Slot" or index that device is referenced in
  58500. * @returns DeviceSource object
  58501. */
  58502. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58503. /**
  58504. * Gets an array of DeviceSource objects for a given device type
  58505. * @param deviceType Enum specifying device type
  58506. * @returns Array of DeviceSource objects
  58507. */
  58508. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58509. /**
  58510. * Returns a read-only list of all available devices
  58511. * @returns Read-only array with active devices
  58512. */
  58513. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58514. /**
  58515. * Dispose of DeviceInputSystem and other parts
  58516. */
  58517. dispose(): void;
  58518. /**
  58519. * Function to add device name to device list
  58520. * @param deviceType Enum specifying device type
  58521. * @param deviceSlot "Slot" or index that device is referenced in
  58522. */
  58523. private _addDevice;
  58524. /**
  58525. * Function to remove device name to device list
  58526. * @param deviceType Enum specifying device type
  58527. * @param deviceSlot "Slot" or index that device is referenced in
  58528. */
  58529. private _removeDevice;
  58530. /**
  58531. * Updates array storing first connected device of each type
  58532. * @param type Type of Device
  58533. */
  58534. private _updateFirstDevices;
  58535. }
  58536. }
  58537. declare module "babylonjs/DeviceInput/index" {
  58538. export * from "babylonjs/DeviceInput/deviceInputSystem";
  58539. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  58540. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  58541. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58542. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  58543. }
  58544. declare module "babylonjs/Engines/nullEngine" {
  58545. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  58546. import { Engine } from "babylonjs/Engines/engine";
  58547. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58548. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58550. import { Effect } from "babylonjs/Materials/effect";
  58551. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58552. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58553. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  58554. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58555. /**
  58556. * Options to create the null engine
  58557. */
  58558. export class NullEngineOptions {
  58559. /**
  58560. * Render width (Default: 512)
  58561. */
  58562. renderWidth: number;
  58563. /**
  58564. * Render height (Default: 256)
  58565. */
  58566. renderHeight: number;
  58567. /**
  58568. * Texture size (Default: 512)
  58569. */
  58570. textureSize: number;
  58571. /**
  58572. * If delta time between frames should be constant
  58573. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58574. */
  58575. deterministicLockstep: boolean;
  58576. /**
  58577. * Maximum about of steps between frames (Default: 4)
  58578. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58579. */
  58580. lockstepMaxSteps: number;
  58581. /**
  58582. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58583. */
  58584. useHighPrecisionMatrix?: boolean;
  58585. }
  58586. /**
  58587. * The null engine class provides support for headless version of babylon.js.
  58588. * This can be used in server side scenario or for testing purposes
  58589. */
  58590. export class NullEngine extends Engine {
  58591. private _options;
  58592. /**
  58593. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58594. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58595. * @returns true if engine is in deterministic lock step mode
  58596. */
  58597. isDeterministicLockStep(): boolean;
  58598. /**
  58599. * Gets the max steps when engine is running in deterministic lock step
  58600. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58601. * @returns the max steps
  58602. */
  58603. getLockstepMaxSteps(): number;
  58604. /**
  58605. * Gets the current hardware scaling level.
  58606. * By default the hardware scaling level is computed from the window device ratio.
  58607. * 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.
  58608. * @returns a number indicating the current hardware scaling level
  58609. */
  58610. getHardwareScalingLevel(): number;
  58611. constructor(options?: NullEngineOptions);
  58612. /**
  58613. * Creates a vertex buffer
  58614. * @param vertices the data for the vertex buffer
  58615. * @returns the new WebGL static buffer
  58616. */
  58617. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58618. /**
  58619. * Creates a new index buffer
  58620. * @param indices defines the content of the index buffer
  58621. * @param updatable defines if the index buffer must be updatable
  58622. * @returns a new webGL buffer
  58623. */
  58624. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58625. /**
  58626. * Clear the current render buffer or the current render target (if any is set up)
  58627. * @param color defines the color to use
  58628. * @param backBuffer defines if the back buffer must be cleared
  58629. * @param depth defines if the depth buffer must be cleared
  58630. * @param stencil defines if the stencil buffer must be cleared
  58631. */
  58632. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58633. /**
  58634. * Gets the current render width
  58635. * @param useScreen defines if screen size must be used (or the current render target if any)
  58636. * @returns a number defining the current render width
  58637. */
  58638. getRenderWidth(useScreen?: boolean): number;
  58639. /**
  58640. * Gets the current render height
  58641. * @param useScreen defines if screen size must be used (or the current render target if any)
  58642. * @returns a number defining the current render height
  58643. */
  58644. getRenderHeight(useScreen?: boolean): number;
  58645. /**
  58646. * Set the WebGL's viewport
  58647. * @param viewport defines the viewport element to be used
  58648. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58649. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58650. */
  58651. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58652. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58653. /**
  58654. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58655. * @param pipelineContext defines the pipeline context to use
  58656. * @param uniformsNames defines the list of uniform names
  58657. * @returns an array of webGL uniform locations
  58658. */
  58659. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58660. /**
  58661. * Gets the lsit of active attributes for a given webGL program
  58662. * @param pipelineContext defines the pipeline context to use
  58663. * @param attributesNames defines the list of attribute names to get
  58664. * @returns an array of indices indicating the offset of each attribute
  58665. */
  58666. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58667. /**
  58668. * Binds an effect to the webGL context
  58669. * @param effect defines the effect to bind
  58670. */
  58671. bindSamplers(effect: Effect): void;
  58672. /**
  58673. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58674. * @param effect defines the effect to activate
  58675. */
  58676. enableEffect(effect: Effect): void;
  58677. /**
  58678. * Set various states to the webGL context
  58679. * @param culling defines backface culling state
  58680. * @param zOffset defines the value to apply to zOffset (0 by default)
  58681. * @param force defines if states must be applied even if cache is up to date
  58682. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58683. */
  58684. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58685. /**
  58686. * Set the value of an uniform to an array of int32
  58687. * @param uniform defines the webGL uniform location where to store the value
  58688. * @param array defines the array of int32 to store
  58689. * @returns true if value was set
  58690. */
  58691. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58692. /**
  58693. * Set the value of an uniform to an array of int32 (stored as vec2)
  58694. * @param uniform defines the webGL uniform location where to store the value
  58695. * @param array defines the array of int32 to store
  58696. * @returns true if value was set
  58697. */
  58698. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58699. /**
  58700. * Set the value of an uniform to an array of int32 (stored as vec3)
  58701. * @param uniform defines the webGL uniform location where to store the value
  58702. * @param array defines the array of int32 to store
  58703. * @returns true if value was set
  58704. */
  58705. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58706. /**
  58707. * Set the value of an uniform to an array of int32 (stored as vec4)
  58708. * @param uniform defines the webGL uniform location where to store the value
  58709. * @param array defines the array of int32 to store
  58710. * @returns true if value was set
  58711. */
  58712. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58713. /**
  58714. * Set the value of an uniform to an array of float32
  58715. * @param uniform defines the webGL uniform location where to store the value
  58716. * @param array defines the array of float32 to store
  58717. * @returns true if value was set
  58718. */
  58719. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58720. /**
  58721. * Set the value of an uniform to an array of float32 (stored as vec2)
  58722. * @param uniform defines the webGL uniform location where to store the value
  58723. * @param array defines the array of float32 to store
  58724. * @returns true if value was set
  58725. */
  58726. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58727. /**
  58728. * Set the value of an uniform to an array of float32 (stored as vec3)
  58729. * @param uniform defines the webGL uniform location where to store the value
  58730. * @param array defines the array of float32 to store
  58731. * @returns true if value was set
  58732. */
  58733. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58734. /**
  58735. * Set the value of an uniform to an array of float32 (stored as vec4)
  58736. * @param uniform defines the webGL uniform location where to store the value
  58737. * @param array defines the array of float32 to store
  58738. * @returns true if value was set
  58739. */
  58740. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58741. /**
  58742. * Set the value of an uniform to an array of number
  58743. * @param uniform defines the webGL uniform location where to store the value
  58744. * @param array defines the array of number to store
  58745. * @returns true if value was set
  58746. */
  58747. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58748. /**
  58749. * Set the value of an uniform to an array of number (stored as vec2)
  58750. * @param uniform defines the webGL uniform location where to store the value
  58751. * @param array defines the array of number to store
  58752. * @returns true if value was set
  58753. */
  58754. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58755. /**
  58756. * Set the value of an uniform to an array of number (stored as vec3)
  58757. * @param uniform defines the webGL uniform location where to store the value
  58758. * @param array defines the array of number to store
  58759. * @returns true if value was set
  58760. */
  58761. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58762. /**
  58763. * Set the value of an uniform to an array of number (stored as vec4)
  58764. * @param uniform defines the webGL uniform location where to store the value
  58765. * @param array defines the array of number to store
  58766. * @returns true if value was set
  58767. */
  58768. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58769. /**
  58770. * Set the value of an uniform to an array of float32 (stored as matrices)
  58771. * @param uniform defines the webGL uniform location where to store the value
  58772. * @param matrices defines the array of float32 to store
  58773. * @returns true if value was set
  58774. */
  58775. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58776. /**
  58777. * Set the value of an uniform to a matrix (3x3)
  58778. * @param uniform defines the webGL uniform location where to store the value
  58779. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  58780. * @returns true if value was set
  58781. */
  58782. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58783. /**
  58784. * Set the value of an uniform to a matrix (2x2)
  58785. * @param uniform defines the webGL uniform location where to store the value
  58786. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  58787. * @returns true if value was set
  58788. */
  58789. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58790. /**
  58791. * Set the value of an uniform to a number (float)
  58792. * @param uniform defines the webGL uniform location where to store the value
  58793. * @param value defines the float number to store
  58794. * @returns true if value was set
  58795. */
  58796. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58797. /**
  58798. * Set the value of an uniform to a vec2
  58799. * @param uniform defines the webGL uniform location where to store the value
  58800. * @param x defines the 1st component of the value
  58801. * @param y defines the 2nd component of the value
  58802. * @returns true if value was set
  58803. */
  58804. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58805. /**
  58806. * Set the value of an uniform to a vec3
  58807. * @param uniform defines the webGL uniform location where to store the value
  58808. * @param x defines the 1st component of the value
  58809. * @param y defines the 2nd component of the value
  58810. * @param z defines the 3rd component of the value
  58811. * @returns true if value was set
  58812. */
  58813. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58814. /**
  58815. * Set the value of an uniform to a boolean
  58816. * @param uniform defines the webGL uniform location where to store the value
  58817. * @param bool defines the boolean to store
  58818. * @returns true if value was set
  58819. */
  58820. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  58821. /**
  58822. * Set the value of an uniform to a vec4
  58823. * @param uniform defines the webGL uniform location where to store the value
  58824. * @param x defines the 1st component of the value
  58825. * @param y defines the 2nd component of the value
  58826. * @param z defines the 3rd component of the value
  58827. * @param w defines the 4th component of the value
  58828. * @returns true if value was set
  58829. */
  58830. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58831. /**
  58832. * Sets the current alpha mode
  58833. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  58834. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58835. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58836. */
  58837. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58838. /**
  58839. * Bind webGl buffers directly to the webGL context
  58840. * @param vertexBuffers defines the vertex buffer to bind
  58841. * @param indexBuffer defines the index buffer to bind
  58842. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  58843. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  58844. * @param effect defines the effect associated with the vertex buffer
  58845. */
  58846. bindBuffers(vertexBuffers: {
  58847. [key: string]: VertexBuffer;
  58848. }, indexBuffer: DataBuffer, effect: Effect): void;
  58849. /**
  58850. * Force the entire cache to be cleared
  58851. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  58852. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  58853. */
  58854. wipeCaches(bruteForce?: boolean): void;
  58855. /**
  58856. * Send a draw order
  58857. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  58858. * @param indexStart defines the starting index
  58859. * @param indexCount defines the number of index to draw
  58860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58861. */
  58862. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  58863. /**
  58864. * Draw a list of indexed primitives
  58865. * @param fillMode defines the primitive to use
  58866. * @param indexStart defines the starting index
  58867. * @param indexCount defines the number of index to draw
  58868. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58869. */
  58870. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58871. /**
  58872. * Draw a list of unindexed primitives
  58873. * @param fillMode defines the primitive to use
  58874. * @param verticesStart defines the index of first vertex to draw
  58875. * @param verticesCount defines the count of vertices to draw
  58876. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58877. */
  58878. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58879. /** @hidden */
  58880. _createTexture(): WebGLTexture;
  58881. /** @hidden */
  58882. _releaseTexture(texture: InternalTexture): void;
  58883. /**
  58884. * Usually called from Texture.ts.
  58885. * Passed information to create a WebGLTexture
  58886. * @param urlArg defines a value which contains one of the following:
  58887. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58888. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58889. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58890. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58891. * @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)
  58892. * @param scene needed for loading to the correct scene
  58893. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58894. * @param onLoad optional callback to be called upon successful completion
  58895. * @param onError optional callback to be called upon failure
  58896. * @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
  58897. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58898. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58899. * @param forcedExtension defines the extension to use to pick the right loader
  58900. * @param mimeType defines an optional mime type
  58901. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58902. */
  58903. 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;
  58904. /**
  58905. * Creates a new render target texture
  58906. * @param size defines the size of the texture
  58907. * @param options defines the options used to create the texture
  58908. * @returns a new render target texture stored in an InternalTexture
  58909. */
  58910. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  58911. /**
  58912. * Update the sampling mode of a given texture
  58913. * @param samplingMode defines the required sampling mode
  58914. * @param texture defines the texture to update
  58915. */
  58916. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58917. /**
  58918. * Binds the frame buffer to the specified texture.
  58919. * @param texture The texture to render to or null for the default canvas
  58920. * @param faceIndex The face of the texture to render to in case of cube texture
  58921. * @param requiredWidth The width of the target to render to
  58922. * @param requiredHeight The height of the target to render to
  58923. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  58924. * @param lodLevel defines le lod level to bind to the frame buffer
  58925. */
  58926. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58927. /**
  58928. * Unbind the current render target texture from the webGL context
  58929. * @param texture defines the render target texture to unbind
  58930. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  58931. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  58932. */
  58933. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58934. /**
  58935. * Creates a dynamic vertex buffer
  58936. * @param vertices the data for the dynamic vertex buffer
  58937. * @returns the new WebGL dynamic buffer
  58938. */
  58939. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  58940. /**
  58941. * Update the content of a dynamic texture
  58942. * @param texture defines the texture to update
  58943. * @param canvas defines the canvas containing the source
  58944. * @param invertY defines if data must be stored with Y axis inverted
  58945. * @param premulAlpha defines if alpha is stored as premultiplied
  58946. * @param format defines the format of the data
  58947. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58948. */
  58949. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58950. /**
  58951. * Gets a boolean indicating if all created effects are ready
  58952. * @returns true if all effects are ready
  58953. */
  58954. areAllEffectsReady(): boolean;
  58955. /**
  58956. * @hidden
  58957. * Get the current error code of the webGL context
  58958. * @returns the error code
  58959. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  58960. */
  58961. getError(): number;
  58962. /** @hidden */
  58963. _getUnpackAlignement(): number;
  58964. /** @hidden */
  58965. _unpackFlipY(value: boolean): void;
  58966. /**
  58967. * Update a dynamic index buffer
  58968. * @param indexBuffer defines the target index buffer
  58969. * @param indices defines the data to update
  58970. * @param offset defines the offset in the target index buffer where update should start
  58971. */
  58972. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  58973. /**
  58974. * Updates a dynamic vertex buffer.
  58975. * @param vertexBuffer the vertex buffer to update
  58976. * @param vertices the data used to update the vertex buffer
  58977. * @param byteOffset the byte offset of the data (optional)
  58978. * @param byteLength the byte length of the data (optional)
  58979. */
  58980. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  58981. /** @hidden */
  58982. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  58983. /** @hidden */
  58984. _bindTexture(channel: number, texture: InternalTexture): void;
  58985. protected _deleteBuffer(buffer: WebGLBuffer): void;
  58986. /**
  58987. * 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
  58988. */
  58989. releaseEffects(): void;
  58990. displayLoadingUI(): void;
  58991. hideLoadingUI(): void;
  58992. /** @hidden */
  58993. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58994. /** @hidden */
  58995. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58996. /** @hidden */
  58997. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58998. /** @hidden */
  58999. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59000. }
  59001. }
  59002. declare module "babylonjs/Instrumentation/timeToken" {
  59003. import { Nullable } from "babylonjs/types";
  59004. /**
  59005. * @hidden
  59006. **/
  59007. export class _TimeToken {
  59008. _startTimeQuery: Nullable<WebGLQuery>;
  59009. _endTimeQuery: Nullable<WebGLQuery>;
  59010. _timeElapsedQuery: Nullable<WebGLQuery>;
  59011. _timeElapsedQueryEnded: boolean;
  59012. }
  59013. }
  59014. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  59015. import { Nullable, int } from "babylonjs/types";
  59016. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  59017. /** @hidden */
  59018. export class _OcclusionDataStorage {
  59019. /** @hidden */
  59020. occlusionInternalRetryCounter: number;
  59021. /** @hidden */
  59022. isOcclusionQueryInProgress: boolean;
  59023. /** @hidden */
  59024. isOccluded: boolean;
  59025. /** @hidden */
  59026. occlusionRetryCount: number;
  59027. /** @hidden */
  59028. occlusionType: number;
  59029. /** @hidden */
  59030. occlusionQueryAlgorithmType: number;
  59031. }
  59032. module "babylonjs/Engines/engine" {
  59033. interface Engine {
  59034. /**
  59035. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59036. * @return the new query
  59037. */
  59038. createQuery(): WebGLQuery;
  59039. /**
  59040. * Delete and release a webGL query
  59041. * @param query defines the query to delete
  59042. * @return the current engine
  59043. */
  59044. deleteQuery(query: WebGLQuery): Engine;
  59045. /**
  59046. * Check if a given query has resolved and got its value
  59047. * @param query defines the query to check
  59048. * @returns true if the query got its value
  59049. */
  59050. isQueryResultAvailable(query: WebGLQuery): boolean;
  59051. /**
  59052. * Gets the value of a given query
  59053. * @param query defines the query to check
  59054. * @returns the value of the query
  59055. */
  59056. getQueryResult(query: WebGLQuery): number;
  59057. /**
  59058. * Initiates an occlusion query
  59059. * @param algorithmType defines the algorithm to use
  59060. * @param query defines the query to use
  59061. * @returns the current engine
  59062. * @see https://doc.babylonjs.com/features/occlusionquery
  59063. */
  59064. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59065. /**
  59066. * Ends an occlusion query
  59067. * @see https://doc.babylonjs.com/features/occlusionquery
  59068. * @param algorithmType defines the algorithm to use
  59069. * @returns the current engine
  59070. */
  59071. endOcclusionQuery(algorithmType: number): Engine;
  59072. /**
  59073. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59074. * Please note that only one query can be issued at a time
  59075. * @returns a time token used to track the time span
  59076. */
  59077. startTimeQuery(): Nullable<_TimeToken>;
  59078. /**
  59079. * Ends a time query
  59080. * @param token defines the token used to measure the time span
  59081. * @returns the time spent (in ns)
  59082. */
  59083. endTimeQuery(token: _TimeToken): int;
  59084. /** @hidden */
  59085. _currentNonTimestampToken: Nullable<_TimeToken>;
  59086. /** @hidden */
  59087. _createTimeQuery(): WebGLQuery;
  59088. /** @hidden */
  59089. _deleteTimeQuery(query: WebGLQuery): void;
  59090. /** @hidden */
  59091. _getGlAlgorithmType(algorithmType: number): number;
  59092. /** @hidden */
  59093. _getTimeQueryResult(query: WebGLQuery): any;
  59094. /** @hidden */
  59095. _getTimeQueryAvailability(query: WebGLQuery): any;
  59096. }
  59097. }
  59098. module "babylonjs/Meshes/abstractMesh" {
  59099. interface AbstractMesh {
  59100. /**
  59101. * Backing filed
  59102. * @hidden
  59103. */
  59104. __occlusionDataStorage: _OcclusionDataStorage;
  59105. /**
  59106. * Access property
  59107. * @hidden
  59108. */
  59109. _occlusionDataStorage: _OcclusionDataStorage;
  59110. /**
  59111. * 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.
  59112. * The default value is -1 which means don't break the query and wait till the result
  59113. * @see https://doc.babylonjs.com/features/occlusionquery
  59114. */
  59115. occlusionRetryCount: number;
  59116. /**
  59117. * 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:
  59118. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59119. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59120. * * 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.
  59121. * @see https://doc.babylonjs.com/features/occlusionquery
  59122. */
  59123. occlusionType: number;
  59124. /**
  59125. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59126. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59127. * * 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.
  59128. * @see https://doc.babylonjs.com/features/occlusionquery
  59129. */
  59130. occlusionQueryAlgorithmType: number;
  59131. /**
  59132. * 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
  59133. * @see https://doc.babylonjs.com/features/occlusionquery
  59134. */
  59135. isOccluded: boolean;
  59136. /**
  59137. * Flag to check the progress status of the query
  59138. * @see https://doc.babylonjs.com/features/occlusionquery
  59139. */
  59140. isOcclusionQueryInProgress: boolean;
  59141. }
  59142. }
  59143. }
  59144. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  59145. import { Nullable } from "babylonjs/types";
  59146. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59147. /** @hidden */
  59148. export var _forceTransformFeedbackToBundle: boolean;
  59149. module "babylonjs/Engines/engine" {
  59150. interface Engine {
  59151. /**
  59152. * Creates a webGL transform feedback object
  59153. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59154. * @returns the webGL transform feedback object
  59155. */
  59156. createTransformFeedback(): WebGLTransformFeedback;
  59157. /**
  59158. * Delete a webGL transform feedback object
  59159. * @param value defines the webGL transform feedback object to delete
  59160. */
  59161. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59162. /**
  59163. * Bind a webGL transform feedback object to the webgl context
  59164. * @param value defines the webGL transform feedback object to bind
  59165. */
  59166. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59167. /**
  59168. * Begins a transform feedback operation
  59169. * @param usePoints defines if points or triangles must be used
  59170. */
  59171. beginTransformFeedback(usePoints: boolean): void;
  59172. /**
  59173. * Ends a transform feedback operation
  59174. */
  59175. endTransformFeedback(): void;
  59176. /**
  59177. * Specify the varyings to use with transform feedback
  59178. * @param program defines the associated webGL program
  59179. * @param value defines the list of strings representing the varying names
  59180. */
  59181. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59182. /**
  59183. * Bind a webGL buffer for a transform feedback operation
  59184. * @param value defines the webGL buffer to bind
  59185. */
  59186. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59187. }
  59188. }
  59189. }
  59190. declare module "babylonjs/Engines/Extensions/engine.views" {
  59191. import { Camera } from "babylonjs/Cameras/camera";
  59192. import { Nullable } from "babylonjs/types";
  59193. /**
  59194. * Class used to define an additional view for the engine
  59195. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59196. */
  59197. export class EngineView {
  59198. /** Defines the canvas where to render the view */
  59199. target: HTMLCanvasElement;
  59200. /** Defines an optional camera used to render the view (will use active camera else) */
  59201. camera?: Camera;
  59202. }
  59203. module "babylonjs/Engines/engine" {
  59204. interface Engine {
  59205. /**
  59206. * Gets or sets the HTML element to use for attaching events
  59207. */
  59208. inputElement: Nullable<HTMLElement>;
  59209. /**
  59210. * Gets the current engine view
  59211. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59212. */
  59213. activeView: Nullable<EngineView>;
  59214. /** Gets or sets the list of views */
  59215. views: EngineView[];
  59216. /**
  59217. * Register a new child canvas
  59218. * @param canvas defines the canvas to register
  59219. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59220. * @returns the associated view
  59221. */
  59222. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59223. /**
  59224. * Remove a registered child canvas
  59225. * @param canvas defines the canvas to remove
  59226. * @returns the current engine
  59227. */
  59228. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59229. }
  59230. }
  59231. }
  59232. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  59233. import { Nullable } from "babylonjs/types";
  59234. module "babylonjs/Engines/engine" {
  59235. interface Engine {
  59236. /** @hidden */
  59237. _excludedCompressedTextures: string[];
  59238. /** @hidden */
  59239. _textureFormatInUse: string;
  59240. /**
  59241. * Gets the list of texture formats supported
  59242. */
  59243. readonly texturesSupported: Array<string>;
  59244. /**
  59245. * Gets the texture format in use
  59246. */
  59247. readonly textureFormatInUse: Nullable<string>;
  59248. /**
  59249. * Set the compressed texture extensions or file names to skip.
  59250. *
  59251. * @param skippedFiles defines the list of those texture files you want to skip
  59252. * Example: [".dds", ".env", "myfile.png"]
  59253. */
  59254. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59255. /**
  59256. * Set the compressed texture format to use, based on the formats you have, and the formats
  59257. * supported by the hardware / browser.
  59258. *
  59259. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59260. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59261. * to API arguments needed to compressed textures. This puts the burden on the container
  59262. * generator to house the arcane code for determining these for current & future formats.
  59263. *
  59264. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59265. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59266. *
  59267. * Note: The result of this call is not taken into account when a texture is base64.
  59268. *
  59269. * @param formatsAvailable defines the list of those format families you have created
  59270. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59271. *
  59272. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59273. * @returns The extension selected.
  59274. */
  59275. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59276. }
  59277. }
  59278. }
  59279. declare module "babylonjs/Engines/Extensions/index" {
  59280. export * from "babylonjs/Engines/Extensions/engine.alpha";
  59281. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  59282. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  59283. export * from "babylonjs/Engines/Extensions/engine.multiview";
  59284. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  59285. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59286. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  59287. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  59288. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  59289. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  59290. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59291. export * from "babylonjs/Engines/Extensions/engine.webVR";
  59292. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  59293. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  59294. export * from "babylonjs/Engines/Extensions/engine.views";
  59295. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  59296. import "babylonjs/Engines/Extensions/engine.textureSelector";
  59297. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  59298. }
  59299. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  59300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59301. /** @hidden */
  59302. export var rgbdEncodePixelShader: {
  59303. name: string;
  59304. shader: string;
  59305. };
  59306. }
  59307. declare module "babylonjs/Misc/environmentTextureTools" {
  59308. import { Nullable } from "babylonjs/types";
  59309. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59310. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59312. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  59313. import "babylonjs/Engines/Extensions/engine.readTexture";
  59314. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59315. import "babylonjs/Shaders/rgbdEncode.fragment";
  59316. import "babylonjs/Shaders/rgbdDecode.fragment";
  59317. /**
  59318. * Raw texture data and descriptor sufficient for WebGL texture upload
  59319. */
  59320. export interface EnvironmentTextureInfo {
  59321. /**
  59322. * Version of the environment map
  59323. */
  59324. version: number;
  59325. /**
  59326. * Width of image
  59327. */
  59328. width: number;
  59329. /**
  59330. * Irradiance information stored in the file.
  59331. */
  59332. irradiance: any;
  59333. /**
  59334. * Specular information stored in the file.
  59335. */
  59336. specular: any;
  59337. }
  59338. /**
  59339. * Defines One Image in the file. It requires only the position in the file
  59340. * as well as the length.
  59341. */
  59342. interface BufferImageData {
  59343. /**
  59344. * Length of the image data.
  59345. */
  59346. length: number;
  59347. /**
  59348. * Position of the data from the null terminator delimiting the end of the JSON.
  59349. */
  59350. position: number;
  59351. }
  59352. /**
  59353. * Defines the specular data enclosed in the file.
  59354. * This corresponds to the version 1 of the data.
  59355. */
  59356. export interface EnvironmentTextureSpecularInfoV1 {
  59357. /**
  59358. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59359. */
  59360. specularDataPosition?: number;
  59361. /**
  59362. * This contains all the images data needed to reconstruct the cubemap.
  59363. */
  59364. mipmaps: Array<BufferImageData>;
  59365. /**
  59366. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59367. */
  59368. lodGenerationScale: number;
  59369. }
  59370. /**
  59371. * Sets of helpers addressing the serialization and deserialization of environment texture
  59372. * stored in a BabylonJS env file.
  59373. * Those files are usually stored as .env files.
  59374. */
  59375. export class EnvironmentTextureTools {
  59376. /**
  59377. * Magic number identifying the env file.
  59378. */
  59379. private static _MagicBytes;
  59380. /**
  59381. * Gets the environment info from an env file.
  59382. * @param data The array buffer containing the .env bytes.
  59383. * @returns the environment file info (the json header) if successfully parsed.
  59384. */
  59385. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59386. /**
  59387. * Creates an environment texture from a loaded cube texture.
  59388. * @param texture defines the cube texture to convert in env file
  59389. * @return a promise containing the environment data if succesfull.
  59390. */
  59391. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59392. /**
  59393. * Creates a JSON representation of the spherical data.
  59394. * @param texture defines the texture containing the polynomials
  59395. * @return the JSON representation of the spherical info
  59396. */
  59397. private static _CreateEnvTextureIrradiance;
  59398. /**
  59399. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59400. * @param data the image data
  59401. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59402. * @return the views described by info providing access to the underlying buffer
  59403. */
  59404. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59405. /**
  59406. * Uploads the texture info contained in the env file to the GPU.
  59407. * @param texture defines the internal texture to upload to
  59408. * @param data defines the data to load
  59409. * @param info defines the texture info retrieved through the GetEnvInfo method
  59410. * @returns a promise
  59411. */
  59412. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59413. private static _OnImageReadyAsync;
  59414. /**
  59415. * Uploads the levels of image data to the GPU.
  59416. * @param texture defines the internal texture to upload to
  59417. * @param imageData defines the array buffer views of image data [mipmap][face]
  59418. * @returns a promise
  59419. */
  59420. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59421. /**
  59422. * Uploads spherical polynomials information to the texture.
  59423. * @param texture defines the texture we are trying to upload the information to
  59424. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59425. */
  59426. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59427. /** @hidden */
  59428. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59429. }
  59430. }
  59431. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  59432. /**
  59433. * Class used to inline functions in shader code
  59434. */
  59435. export class ShaderCodeInliner {
  59436. private static readonly _RegexpFindFunctionNameAndType;
  59437. private _sourceCode;
  59438. private _functionDescr;
  59439. private _numMaxIterations;
  59440. /** Gets or sets the token used to mark the functions to inline */
  59441. inlineToken: string;
  59442. /** Gets or sets the debug mode */
  59443. debug: boolean;
  59444. /** Gets the code after the inlining process */
  59445. get code(): string;
  59446. /**
  59447. * Initializes the inliner
  59448. * @param sourceCode shader code source to inline
  59449. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  59450. */
  59451. constructor(sourceCode: string, numMaxIterations?: number);
  59452. /**
  59453. * Start the processing of the shader code
  59454. */
  59455. processCode(): void;
  59456. private _collectFunctions;
  59457. private _processInlining;
  59458. private _extractBetweenMarkers;
  59459. private _skipWhitespaces;
  59460. private _removeComments;
  59461. private _replaceFunctionCallsByCode;
  59462. private _findBackward;
  59463. private _escapeRegExp;
  59464. private _replaceNames;
  59465. }
  59466. }
  59467. declare module "babylonjs/Engines/nativeEngine" {
  59468. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  59469. import { Engine } from "babylonjs/Engines/engine";
  59470. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  59471. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59473. import { Effect } from "babylonjs/Materials/effect";
  59474. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  59475. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  59476. import { IColor4Like } from "babylonjs/Maths/math.like";
  59477. import { Scene } from "babylonjs/scene";
  59478. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  59479. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  59480. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  59481. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  59482. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  59483. /**
  59484. * Container for accessors for natively-stored mesh data buffers.
  59485. */
  59486. class NativeDataBuffer extends DataBuffer {
  59487. /**
  59488. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59489. */
  59490. nativeIndexBuffer?: any;
  59491. /**
  59492. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59493. */
  59494. nativeVertexBuffer?: any;
  59495. }
  59496. /** @hidden */
  59497. class NativeTexture extends InternalTexture {
  59498. getInternalTexture(): InternalTexture;
  59499. getViewCount(): number;
  59500. }
  59501. /** @hidden */
  59502. export class NativeEngine extends Engine {
  59503. private readonly _native;
  59504. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59505. private readonly INVALID_HANDLE;
  59506. private _boundBuffersVertexArray;
  59507. private _currentDepthTest;
  59508. getHardwareScalingLevel(): number;
  59509. constructor();
  59510. dispose(): void;
  59511. /**
  59512. * Can be used to override the current requestAnimationFrame requester.
  59513. * @hidden
  59514. */
  59515. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59516. /**
  59517. * Override default engine behavior.
  59518. * @param color
  59519. * @param backBuffer
  59520. * @param depth
  59521. * @param stencil
  59522. */
  59523. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59524. /**
  59525. * Gets host document
  59526. * @returns the host document object
  59527. */
  59528. getHostDocument(): Nullable<Document>;
  59529. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59530. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59531. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59532. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59533. [key: string]: VertexBuffer;
  59534. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59535. bindBuffers(vertexBuffers: {
  59536. [key: string]: VertexBuffer;
  59537. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59538. recordVertexArrayObject(vertexBuffers: {
  59539. [key: string]: VertexBuffer;
  59540. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59541. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59542. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59543. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59544. /**
  59545. * Draw a list of indexed primitives
  59546. * @param fillMode defines the primitive to use
  59547. * @param indexStart defines the starting index
  59548. * @param indexCount defines the number of index to draw
  59549. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59550. */
  59551. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59552. /**
  59553. * Draw a list of unindexed primitives
  59554. * @param fillMode defines the primitive to use
  59555. * @param verticesStart defines the index of first vertex to draw
  59556. * @param verticesCount defines the count of vertices to draw
  59557. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59558. */
  59559. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59560. createPipelineContext(): IPipelineContext;
  59561. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59562. /** @hidden */
  59563. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59564. /** @hidden */
  59565. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59566. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59567. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59568. protected _setProgram(program: WebGLProgram): void;
  59569. _releaseEffect(effect: Effect): void;
  59570. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59571. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59572. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59573. bindSamplers(effect: Effect): void;
  59574. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  59575. getRenderWidth(useScreen?: boolean): number;
  59576. getRenderHeight(useScreen?: boolean): number;
  59577. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  59578. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59579. /**
  59580. * Set the z offset to apply to current rendering
  59581. * @param value defines the offset to apply
  59582. */
  59583. setZOffset(value: number): void;
  59584. /**
  59585. * Gets the current value of the zOffset
  59586. * @returns the current zOffset state
  59587. */
  59588. getZOffset(): number;
  59589. /**
  59590. * Enable or disable depth buffering
  59591. * @param enable defines the state to set
  59592. */
  59593. setDepthBuffer(enable: boolean): void;
  59594. /**
  59595. * Gets a boolean indicating if depth writing is enabled
  59596. * @returns the current depth writing state
  59597. */
  59598. getDepthWrite(): boolean;
  59599. setDepthFunctionToGreater(): void;
  59600. setDepthFunctionToGreaterOrEqual(): void;
  59601. setDepthFunctionToLess(): void;
  59602. setDepthFunctionToLessOrEqual(): void;
  59603. /**
  59604. * Enable or disable depth writing
  59605. * @param enable defines the state to set
  59606. */
  59607. setDepthWrite(enable: boolean): void;
  59608. /**
  59609. * Enable or disable color writing
  59610. * @param enable defines the state to set
  59611. */
  59612. setColorWrite(enable: boolean): void;
  59613. /**
  59614. * Gets a boolean indicating if color writing is enabled
  59615. * @returns the current color writing state
  59616. */
  59617. getColorWrite(): boolean;
  59618. /**
  59619. * Sets alpha constants used by some alpha blending modes
  59620. * @param r defines the red component
  59621. * @param g defines the green component
  59622. * @param b defines the blue component
  59623. * @param a defines the alpha component
  59624. */
  59625. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59626. /**
  59627. * Sets the current alpha mode
  59628. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59629. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59630. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59631. */
  59632. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59633. /**
  59634. * Gets the current alpha mode
  59635. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59636. * @returns the current alpha mode
  59637. */
  59638. getAlphaMode(): number;
  59639. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59640. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59641. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59642. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59643. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59644. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59645. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59646. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59647. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59648. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59649. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59650. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59651. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59652. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59653. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59654. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59655. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59656. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59657. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59658. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59659. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  59660. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  59661. wipeCaches(bruteForce?: boolean): void;
  59662. _createTexture(): WebGLTexture;
  59663. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59664. /**
  59665. * Update the content of a dynamic texture
  59666. * @param texture defines the texture to update
  59667. * @param canvas defines the canvas containing the source
  59668. * @param invertY defines if data must be stored with Y axis inverted
  59669. * @param premulAlpha defines if alpha is stored as premultiplied
  59670. * @param format defines the format of the data
  59671. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59672. */
  59673. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59674. /**
  59675. * Usually called from Texture.ts.
  59676. * Passed information to create a WebGLTexture
  59677. * @param url defines a value which contains one of the following:
  59678. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59679. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59680. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59682. * @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)
  59683. * @param scene needed for loading to the correct scene
  59684. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59685. * @param onLoad optional callback to be called upon successful completion
  59686. * @param onError optional callback to be called upon failure
  59687. * @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
  59688. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59689. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59690. * @param forcedExtension defines the extension to use to pick the right loader
  59691. * @param mimeType defines an optional mime type
  59692. * @param loaderOptions options to be passed to the loader
  59693. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59694. */
  59695. 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, loaderOptions?: any): InternalTexture;
  59696. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59697. _releaseFramebufferObjects(texture: InternalTexture): void;
  59698. /**
  59699. * Creates a cube texture
  59700. * @param rootUrl defines the url where the files to load is located
  59701. * @param scene defines the current scene
  59702. * @param files defines the list of files to load (1 per face)
  59703. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59704. * @param onLoad defines an optional callback raised when the texture is loaded
  59705. * @param onError defines an optional callback raised if there is an issue to load the texture
  59706. * @param format defines the format of the data
  59707. * @param forcedExtension defines the extension to use to pick the right loader
  59708. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59709. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59710. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59711. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59712. * @returns the cube texture as an InternalTexture
  59713. */
  59714. 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;
  59715. createRenderTargetTexture(size: number | {
  59716. width: number;
  59717. height: number;
  59718. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59719. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59720. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59721. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59722. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59723. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59724. /**
  59725. * Updates a dynamic vertex buffer.
  59726. * @param vertexBuffer the vertex buffer to update
  59727. * @param data the data used to update the vertex buffer
  59728. * @param byteOffset the byte offset of the data (optional)
  59729. * @param byteLength the byte length of the data (optional)
  59730. */
  59731. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59732. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59733. private _updateAnisotropicLevel;
  59734. private _getAddressMode;
  59735. /** @hidden */
  59736. _bindTexture(channel: number, texture: InternalTexture): void;
  59737. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59738. releaseEffects(): void;
  59739. /** @hidden */
  59740. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59741. /** @hidden */
  59742. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59743. /** @hidden */
  59744. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59745. /** @hidden */
  59746. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59747. private _getNativeSamplingMode;
  59748. private _getNativeTextureFormat;
  59749. private _getNativeAlphaMode;
  59750. private _getNativeAttribType;
  59751. }
  59752. }
  59753. declare module "babylonjs/Engines/index" {
  59754. export * from "babylonjs/Engines/constants";
  59755. export * from "babylonjs/Engines/engineCapabilities";
  59756. export * from "babylonjs/Engines/instancingAttributeInfo";
  59757. export * from "babylonjs/Engines/thinEngine";
  59758. export * from "babylonjs/Engines/engine";
  59759. export * from "babylonjs/Engines/engineStore";
  59760. export * from "babylonjs/Engines/nullEngine";
  59761. export * from "babylonjs/Engines/Extensions/index";
  59762. export * from "babylonjs/Engines/IPipelineContext";
  59763. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  59764. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  59765. export * from "babylonjs/Engines/nativeEngine";
  59766. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  59767. export * from "babylonjs/Engines/performanceConfigurator";
  59768. }
  59769. declare module "babylonjs/Events/clipboardEvents" {
  59770. /**
  59771. * Gather the list of clipboard event types as constants.
  59772. */
  59773. export class ClipboardEventTypes {
  59774. /**
  59775. * The clipboard event is fired when a copy command is active (pressed).
  59776. */
  59777. static readonly COPY: number;
  59778. /**
  59779. * The clipboard event is fired when a cut command is active (pressed).
  59780. */
  59781. static readonly CUT: number;
  59782. /**
  59783. * The clipboard event is fired when a paste command is active (pressed).
  59784. */
  59785. static readonly PASTE: number;
  59786. }
  59787. /**
  59788. * This class is used to store clipboard related info for the onClipboardObservable event.
  59789. */
  59790. export class ClipboardInfo {
  59791. /**
  59792. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59793. */
  59794. type: number;
  59795. /**
  59796. * Defines the related dom event
  59797. */
  59798. event: ClipboardEvent;
  59799. /**
  59800. *Creates an instance of ClipboardInfo.
  59801. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59802. * @param event Defines the related dom event
  59803. */
  59804. constructor(
  59805. /**
  59806. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59807. */
  59808. type: number,
  59809. /**
  59810. * Defines the related dom event
  59811. */
  59812. event: ClipboardEvent);
  59813. /**
  59814. * Get the clipboard event's type from the keycode.
  59815. * @param keyCode Defines the keyCode for the current keyboard event.
  59816. * @return {number}
  59817. */
  59818. static GetTypeFromCharacter(keyCode: number): number;
  59819. }
  59820. }
  59821. declare module "babylonjs/Events/index" {
  59822. export * from "babylonjs/Events/keyboardEvents";
  59823. export * from "babylonjs/Events/pointerEvents";
  59824. export * from "babylonjs/Events/clipboardEvents";
  59825. }
  59826. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  59827. import { Scene } from "babylonjs/scene";
  59828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59829. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59830. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59831. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59832. /**
  59833. * Google Daydream controller
  59834. */
  59835. export class DaydreamController extends WebVRController {
  59836. /**
  59837. * Base Url for the controller model.
  59838. */
  59839. static MODEL_BASE_URL: string;
  59840. /**
  59841. * File name for the controller model.
  59842. */
  59843. static MODEL_FILENAME: string;
  59844. /**
  59845. * Gamepad Id prefix used to identify Daydream Controller.
  59846. */
  59847. static readonly GAMEPAD_ID_PREFIX: string;
  59848. /**
  59849. * Creates a new DaydreamController from a gamepad
  59850. * @param vrGamepad the gamepad that the controller should be created from
  59851. */
  59852. constructor(vrGamepad: any);
  59853. /**
  59854. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59855. * @param scene scene in which to add meshes
  59856. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59857. */
  59858. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59859. /**
  59860. * Called once for each button that changed state since the last frame
  59861. * @param buttonIdx Which button index changed
  59862. * @param state New state of the button
  59863. * @param changes Which properties on the state changed since last frame
  59864. */
  59865. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59866. }
  59867. }
  59868. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  59869. import { Scene } from "babylonjs/scene";
  59870. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59871. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59872. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59873. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59874. /**
  59875. * Gear VR Controller
  59876. */
  59877. export class GearVRController extends WebVRController {
  59878. /**
  59879. * Base Url for the controller model.
  59880. */
  59881. static MODEL_BASE_URL: string;
  59882. /**
  59883. * File name for the controller model.
  59884. */
  59885. static MODEL_FILENAME: string;
  59886. /**
  59887. * Gamepad Id prefix used to identify this controller.
  59888. */
  59889. static readonly GAMEPAD_ID_PREFIX: string;
  59890. private readonly _buttonIndexToObservableNameMap;
  59891. /**
  59892. * Creates a new GearVRController from a gamepad
  59893. * @param vrGamepad the gamepad that the controller should be created from
  59894. */
  59895. constructor(vrGamepad: any);
  59896. /**
  59897. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59898. * @param scene scene in which to add meshes
  59899. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59900. */
  59901. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59902. /**
  59903. * Called once for each button that changed state since the last frame
  59904. * @param buttonIdx Which button index changed
  59905. * @param state New state of the button
  59906. * @param changes Which properties on the state changed since last frame
  59907. */
  59908. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59909. }
  59910. }
  59911. declare module "babylonjs/Gamepads/Controllers/genericController" {
  59912. import { Scene } from "babylonjs/scene";
  59913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59914. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59915. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59916. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59917. /**
  59918. * Generic Controller
  59919. */
  59920. export class GenericController extends WebVRController {
  59921. /**
  59922. * Base Url for the controller model.
  59923. */
  59924. static readonly MODEL_BASE_URL: string;
  59925. /**
  59926. * File name for the controller model.
  59927. */
  59928. static readonly MODEL_FILENAME: string;
  59929. /**
  59930. * Creates a new GenericController from a gamepad
  59931. * @param vrGamepad the gamepad that the controller should be created from
  59932. */
  59933. constructor(vrGamepad: any);
  59934. /**
  59935. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59936. * @param scene scene in which to add meshes
  59937. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59938. */
  59939. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59940. /**
  59941. * Called once for each button that changed state since the last frame
  59942. * @param buttonIdx Which button index changed
  59943. * @param state New state of the button
  59944. * @param changes Which properties on the state changed since last frame
  59945. */
  59946. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59947. }
  59948. }
  59949. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  59950. import { Observable } from "babylonjs/Misc/observable";
  59951. import { Scene } from "babylonjs/scene";
  59952. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59953. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59954. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59955. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59956. /**
  59957. * Oculus Touch Controller
  59958. */
  59959. export class OculusTouchController extends WebVRController {
  59960. /**
  59961. * Base Url for the controller model.
  59962. */
  59963. static MODEL_BASE_URL: string;
  59964. /**
  59965. * File name for the left controller model.
  59966. */
  59967. static MODEL_LEFT_FILENAME: string;
  59968. /**
  59969. * File name for the right controller model.
  59970. */
  59971. static MODEL_RIGHT_FILENAME: string;
  59972. /**
  59973. * Base Url for the Quest controller model.
  59974. */
  59975. static QUEST_MODEL_BASE_URL: string;
  59976. /**
  59977. * @hidden
  59978. * If the controllers are running on a device that needs the updated Quest controller models
  59979. */
  59980. static _IsQuest: boolean;
  59981. /**
  59982. * Fired when the secondary trigger on this controller is modified
  59983. */
  59984. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  59985. /**
  59986. * Fired when the thumb rest on this controller is modified
  59987. */
  59988. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  59989. /**
  59990. * Creates a new OculusTouchController from a gamepad
  59991. * @param vrGamepad the gamepad that the controller should be created from
  59992. */
  59993. constructor(vrGamepad: any);
  59994. /**
  59995. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59996. * @param scene scene in which to add meshes
  59997. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59998. */
  59999. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60000. /**
  60001. * Fired when the A button on this controller is modified
  60002. */
  60003. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60004. /**
  60005. * Fired when the B button on this controller is modified
  60006. */
  60007. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60008. /**
  60009. * Fired when the X button on this controller is modified
  60010. */
  60011. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60012. /**
  60013. * Fired when the Y button on this controller is modified
  60014. */
  60015. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60016. /**
  60017. * Called once for each button that changed state since the last frame
  60018. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60019. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60020. * 2) secondary trigger (same)
  60021. * 3) A (right) X (left), touch, pressed = value
  60022. * 4) B / Y
  60023. * 5) thumb rest
  60024. * @param buttonIdx Which button index changed
  60025. * @param state New state of the button
  60026. * @param changes Which properties on the state changed since last frame
  60027. */
  60028. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60029. }
  60030. }
  60031. declare module "babylonjs/Gamepads/Controllers/viveController" {
  60032. import { Scene } from "babylonjs/scene";
  60033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60034. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60035. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60036. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60037. import { Observable } from "babylonjs/Misc/observable";
  60038. /**
  60039. * Vive Controller
  60040. */
  60041. export class ViveController extends WebVRController {
  60042. /**
  60043. * Base Url for the controller model.
  60044. */
  60045. static MODEL_BASE_URL: string;
  60046. /**
  60047. * File name for the controller model.
  60048. */
  60049. static MODEL_FILENAME: string;
  60050. /**
  60051. * Creates a new ViveController from a gamepad
  60052. * @param vrGamepad the gamepad that the controller should be created from
  60053. */
  60054. constructor(vrGamepad: any);
  60055. /**
  60056. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60057. * @param scene scene in which to add meshes
  60058. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60059. */
  60060. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60061. /**
  60062. * Fired when the left button on this controller is modified
  60063. */
  60064. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60065. /**
  60066. * Fired when the right button on this controller is modified
  60067. */
  60068. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60069. /**
  60070. * Fired when the menu button on this controller is modified
  60071. */
  60072. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60073. /**
  60074. * Called once for each button that changed state since the last frame
  60075. * Vive mapping:
  60076. * 0: touchpad
  60077. * 1: trigger
  60078. * 2: left AND right buttons
  60079. * 3: menu button
  60080. * @param buttonIdx Which button index changed
  60081. * @param state New state of the button
  60082. * @param changes Which properties on the state changed since last frame
  60083. */
  60084. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60085. }
  60086. }
  60087. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  60088. import { Observable } from "babylonjs/Misc/observable";
  60089. import { Scene } from "babylonjs/scene";
  60090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60091. import { Ray } from "babylonjs/Culling/ray";
  60092. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  60093. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60094. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  60095. /**
  60096. * Defines the WindowsMotionController object that the state of the windows motion controller
  60097. */
  60098. export class WindowsMotionController extends WebVRController {
  60099. /**
  60100. * The base url used to load the left and right controller models
  60101. */
  60102. static MODEL_BASE_URL: string;
  60103. /**
  60104. * The name of the left controller model file
  60105. */
  60106. static MODEL_LEFT_FILENAME: string;
  60107. /**
  60108. * The name of the right controller model file
  60109. */
  60110. static MODEL_RIGHT_FILENAME: string;
  60111. /**
  60112. * The controller name prefix for this controller type
  60113. */
  60114. static readonly GAMEPAD_ID_PREFIX: string;
  60115. /**
  60116. * The controller id pattern for this controller type
  60117. */
  60118. private static readonly GAMEPAD_ID_PATTERN;
  60119. private _loadedMeshInfo;
  60120. protected readonly _mapping: {
  60121. buttons: string[];
  60122. buttonMeshNames: {
  60123. trigger: string;
  60124. menu: string;
  60125. grip: string;
  60126. thumbstick: string;
  60127. trackpad: string;
  60128. };
  60129. buttonObservableNames: {
  60130. trigger: string;
  60131. menu: string;
  60132. grip: string;
  60133. thumbstick: string;
  60134. trackpad: string;
  60135. };
  60136. axisMeshNames: string[];
  60137. pointingPoseMeshName: string;
  60138. };
  60139. /**
  60140. * Fired when the trackpad on this controller is clicked
  60141. */
  60142. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60143. /**
  60144. * Fired when the trackpad on this controller is modified
  60145. */
  60146. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60147. /**
  60148. * The current x and y values of this controller's trackpad
  60149. */
  60150. trackpad: StickValues;
  60151. /**
  60152. * Creates a new WindowsMotionController from a gamepad
  60153. * @param vrGamepad the gamepad that the controller should be created from
  60154. */
  60155. constructor(vrGamepad: any);
  60156. /**
  60157. * Fired when the trigger on this controller is modified
  60158. */
  60159. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60160. /**
  60161. * Fired when the menu button on this controller is modified
  60162. */
  60163. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60164. /**
  60165. * Fired when the grip button on this controller is modified
  60166. */
  60167. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60168. /**
  60169. * Fired when the thumbstick button on this controller is modified
  60170. */
  60171. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60172. /**
  60173. * Fired when the touchpad button on this controller is modified
  60174. */
  60175. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60176. /**
  60177. * Fired when the touchpad values on this controller are modified
  60178. */
  60179. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60180. protected _updateTrackpad(): void;
  60181. /**
  60182. * Called once per frame by the engine.
  60183. */
  60184. update(): void;
  60185. /**
  60186. * Called once for each button that changed state since the last frame
  60187. * @param buttonIdx Which button index changed
  60188. * @param state New state of the button
  60189. * @param changes Which properties on the state changed since last frame
  60190. */
  60191. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60192. /**
  60193. * Moves the buttons on the controller mesh based on their current state
  60194. * @param buttonName the name of the button to move
  60195. * @param buttonValue the value of the button which determines the buttons new position
  60196. */
  60197. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60198. /**
  60199. * Moves the axis on the controller mesh based on its current state
  60200. * @param axis the index of the axis
  60201. * @param axisValue the value of the axis which determines the meshes new position
  60202. * @hidden
  60203. */
  60204. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60205. /**
  60206. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60207. * @param scene scene in which to add meshes
  60208. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60209. */
  60210. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60211. /**
  60212. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60213. * can be transformed by button presses and axes values, based on this._mapping.
  60214. *
  60215. * @param scene scene in which the meshes exist
  60216. * @param meshes list of meshes that make up the controller model to process
  60217. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60218. */
  60219. private processModel;
  60220. private createMeshInfo;
  60221. /**
  60222. * Gets the ray of the controller in the direction the controller is pointing
  60223. * @param length the length the resulting ray should be
  60224. * @returns a ray in the direction the controller is pointing
  60225. */
  60226. getForwardRay(length?: number): Ray;
  60227. /**
  60228. * Disposes of the controller
  60229. */
  60230. dispose(): void;
  60231. }
  60232. /**
  60233. * This class represents a new windows motion controller in XR.
  60234. */
  60235. export class XRWindowsMotionController extends WindowsMotionController {
  60236. /**
  60237. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60238. */
  60239. protected readonly _mapping: {
  60240. buttons: string[];
  60241. buttonMeshNames: {
  60242. trigger: string;
  60243. menu: string;
  60244. grip: string;
  60245. thumbstick: string;
  60246. trackpad: string;
  60247. };
  60248. buttonObservableNames: {
  60249. trigger: string;
  60250. menu: string;
  60251. grip: string;
  60252. thumbstick: string;
  60253. trackpad: string;
  60254. };
  60255. axisMeshNames: string[];
  60256. pointingPoseMeshName: string;
  60257. };
  60258. /**
  60259. * Construct a new XR-Based windows motion controller
  60260. *
  60261. * @param gamepadInfo the gamepad object from the browser
  60262. */
  60263. constructor(gamepadInfo: any);
  60264. /**
  60265. * holds the thumbstick values (X,Y)
  60266. */
  60267. thumbstickValues: StickValues;
  60268. /**
  60269. * Fired when the thumbstick on this controller is clicked
  60270. */
  60271. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60272. /**
  60273. * Fired when the thumbstick on this controller is modified
  60274. */
  60275. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60276. /**
  60277. * Fired when the touchpad button on this controller is modified
  60278. */
  60279. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60280. /**
  60281. * Fired when the touchpad values on this controller are modified
  60282. */
  60283. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60284. /**
  60285. * Fired when the thumbstick button on this controller is modified
  60286. * here to prevent breaking changes
  60287. */
  60288. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60289. /**
  60290. * updating the thumbstick(!) and not the trackpad.
  60291. * This is named this way due to the difference between WebVR and XR and to avoid
  60292. * changing the parent class.
  60293. */
  60294. protected _updateTrackpad(): void;
  60295. /**
  60296. * Disposes the class with joy
  60297. */
  60298. dispose(): void;
  60299. }
  60300. }
  60301. declare module "babylonjs/Gamepads/Controllers/index" {
  60302. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  60303. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  60304. export * from "babylonjs/Gamepads/Controllers/genericController";
  60305. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  60306. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  60307. export * from "babylonjs/Gamepads/Controllers/viveController";
  60308. export * from "babylonjs/Gamepads/Controllers/webVRController";
  60309. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  60310. }
  60311. declare module "babylonjs/Gamepads/index" {
  60312. export * from "babylonjs/Gamepads/Controllers/index";
  60313. export * from "babylonjs/Gamepads/gamepad";
  60314. export * from "babylonjs/Gamepads/gamepadManager";
  60315. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  60316. export * from "babylonjs/Gamepads/xboxGamepad";
  60317. export * from "babylonjs/Gamepads/dualShockGamepad";
  60318. }
  60319. declare module "babylonjs/Lights/directionalLight" {
  60320. import { Camera } from "babylonjs/Cameras/camera";
  60321. import { Scene } from "babylonjs/scene";
  60322. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60324. import { Light } from "babylonjs/Lights/light";
  60325. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60326. import { Effect } from "babylonjs/Materials/effect";
  60327. /**
  60328. * A directional light is defined by a direction (what a surprise!).
  60329. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60330. * 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.
  60331. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60332. */
  60333. export class DirectionalLight extends ShadowLight {
  60334. private _shadowFrustumSize;
  60335. /**
  60336. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60337. */
  60338. get shadowFrustumSize(): number;
  60339. /**
  60340. * Specifies a fix frustum size for the shadow generation.
  60341. */
  60342. set shadowFrustumSize(value: number);
  60343. private _shadowOrthoScale;
  60344. /**
  60345. * Gets the shadow projection scale against the optimal computed one.
  60346. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60347. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60348. */
  60349. get shadowOrthoScale(): number;
  60350. /**
  60351. * Sets the shadow projection scale against the optimal computed one.
  60352. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60353. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60354. */
  60355. set shadowOrthoScale(value: number);
  60356. /**
  60357. * Automatically compute the projection matrix to best fit (including all the casters)
  60358. * on each frame.
  60359. */
  60360. autoUpdateExtends: boolean;
  60361. /**
  60362. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60363. * on each frame. autoUpdateExtends must be set to true for this to work
  60364. */
  60365. autoCalcShadowZBounds: boolean;
  60366. private _orthoLeft;
  60367. private _orthoRight;
  60368. private _orthoTop;
  60369. private _orthoBottom;
  60370. /**
  60371. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60372. * The directional light is emitted from everywhere in the given direction.
  60373. * It can cast shadows.
  60374. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60375. * @param name The friendly name of the light
  60376. * @param direction The direction of the light
  60377. * @param scene The scene the light belongs to
  60378. */
  60379. constructor(name: string, direction: Vector3, scene: Scene);
  60380. /**
  60381. * Returns the string "DirectionalLight".
  60382. * @return The class name
  60383. */
  60384. getClassName(): string;
  60385. /**
  60386. * Returns the integer 1.
  60387. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60388. */
  60389. getTypeID(): number;
  60390. /**
  60391. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60392. * Returns the DirectionalLight Shadow projection matrix.
  60393. */
  60394. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60395. /**
  60396. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60397. * Returns the DirectionalLight Shadow projection matrix.
  60398. */
  60399. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60400. /**
  60401. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60402. * Returns the DirectionalLight Shadow projection matrix.
  60403. */
  60404. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60405. protected _buildUniformLayout(): void;
  60406. /**
  60407. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60408. * @param effect The effect to update
  60409. * @param lightIndex The index of the light in the effect to update
  60410. * @returns The directional light
  60411. */
  60412. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60413. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60414. /**
  60415. * Gets the minZ used for shadow according to both the scene and the light.
  60416. *
  60417. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60418. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60419. * @param activeCamera The camera we are returning the min for
  60420. * @returns the depth min z
  60421. */
  60422. getDepthMinZ(activeCamera: Camera): number;
  60423. /**
  60424. * Gets the maxZ used for shadow according to both the scene and the light.
  60425. *
  60426. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60427. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60428. * @param activeCamera The camera we are returning the max for
  60429. * @returns the depth max z
  60430. */
  60431. getDepthMaxZ(activeCamera: Camera): number;
  60432. /**
  60433. * Prepares the list of defines specific to the light type.
  60434. * @param defines the list of defines
  60435. * @param lightIndex defines the index of the light for the effect
  60436. */
  60437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60438. }
  60439. }
  60440. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  60441. import { Mesh } from "babylonjs/Meshes/mesh";
  60442. /**
  60443. * Class containing static functions to help procedurally build meshes
  60444. */
  60445. export class HemisphereBuilder {
  60446. /**
  60447. * Creates a hemisphere mesh
  60448. * @param name defines the name of the mesh
  60449. * @param options defines the options used to create the mesh
  60450. * @param scene defines the hosting scene
  60451. * @returns the hemisphere mesh
  60452. */
  60453. static CreateHemisphere(name: string, options: {
  60454. segments?: number;
  60455. diameter?: number;
  60456. sideOrientation?: number;
  60457. }, scene: any): Mesh;
  60458. }
  60459. }
  60460. declare module "babylonjs/Lights/spotLight" {
  60461. import { Nullable } from "babylonjs/types";
  60462. import { Scene } from "babylonjs/scene";
  60463. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60465. import { Effect } from "babylonjs/Materials/effect";
  60466. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60467. import { Light } from "babylonjs/Lights/light";
  60468. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  60469. /**
  60470. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60471. * These values define a cone of light starting from the position, emitting toward the direction.
  60472. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60473. * and the exponent defines the speed of the decay of the light with distance (reach).
  60474. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60475. */
  60476. export class SpotLight extends ShadowLight {
  60477. private _angle;
  60478. private _innerAngle;
  60479. private _cosHalfAngle;
  60480. private _lightAngleScale;
  60481. private _lightAngleOffset;
  60482. /**
  60483. * Gets the cone angle of the spot light in Radians.
  60484. */
  60485. get angle(): number;
  60486. /**
  60487. * Sets the cone angle of the spot light in Radians.
  60488. */
  60489. set angle(value: number);
  60490. /**
  60491. * Only used in gltf falloff mode, this defines the angle where
  60492. * the directional falloff will start before cutting at angle which could be seen
  60493. * as outer angle.
  60494. */
  60495. get innerAngle(): number;
  60496. /**
  60497. * Only used in gltf falloff mode, this defines the angle where
  60498. * the directional falloff will start before cutting at angle which could be seen
  60499. * as outer angle.
  60500. */
  60501. set innerAngle(value: number);
  60502. private _shadowAngleScale;
  60503. /**
  60504. * Allows scaling the angle of the light for shadow generation only.
  60505. */
  60506. get shadowAngleScale(): number;
  60507. /**
  60508. * Allows scaling the angle of the light for shadow generation only.
  60509. */
  60510. set shadowAngleScale(value: number);
  60511. /**
  60512. * The light decay speed with the distance from the emission spot.
  60513. */
  60514. exponent: number;
  60515. private _projectionTextureMatrix;
  60516. /**
  60517. * Allows reading the projecton texture
  60518. */
  60519. get projectionTextureMatrix(): Matrix;
  60520. protected _projectionTextureLightNear: number;
  60521. /**
  60522. * Gets the near clip of the Spotlight for texture projection.
  60523. */
  60524. get projectionTextureLightNear(): number;
  60525. /**
  60526. * Sets the near clip of the Spotlight for texture projection.
  60527. */
  60528. set projectionTextureLightNear(value: number);
  60529. protected _projectionTextureLightFar: number;
  60530. /**
  60531. * Gets the far clip of the Spotlight for texture projection.
  60532. */
  60533. get projectionTextureLightFar(): number;
  60534. /**
  60535. * Sets the far clip of the Spotlight for texture projection.
  60536. */
  60537. set projectionTextureLightFar(value: number);
  60538. protected _projectionTextureUpDirection: Vector3;
  60539. /**
  60540. * Gets the Up vector of the Spotlight for texture projection.
  60541. */
  60542. get projectionTextureUpDirection(): Vector3;
  60543. /**
  60544. * Sets the Up vector of the Spotlight for texture projection.
  60545. */
  60546. set projectionTextureUpDirection(value: Vector3);
  60547. private _projectionTexture;
  60548. /**
  60549. * Gets the projection texture of the light.
  60550. */
  60551. get projectionTexture(): Nullable<BaseTexture>;
  60552. /**
  60553. * Sets the projection texture of the light.
  60554. */
  60555. set projectionTexture(value: Nullable<BaseTexture>);
  60556. private static _IsProceduralTexture;
  60557. private static _IsTexture;
  60558. private _projectionTextureViewLightDirty;
  60559. private _projectionTextureProjectionLightDirty;
  60560. private _projectionTextureDirty;
  60561. private _projectionTextureViewTargetVector;
  60562. private _projectionTextureViewLightMatrix;
  60563. private _projectionTextureProjectionLightMatrix;
  60564. private _projectionTextureScalingMatrix;
  60565. /**
  60566. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60567. * It can cast shadows.
  60568. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60569. * @param name The light friendly name
  60570. * @param position The position of the spot light in the scene
  60571. * @param direction The direction of the light in the scene
  60572. * @param angle The cone angle of the light in Radians
  60573. * @param exponent The light decay speed with the distance from the emission spot
  60574. * @param scene The scene the lights belongs to
  60575. */
  60576. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60577. /**
  60578. * Returns the string "SpotLight".
  60579. * @returns the class name
  60580. */
  60581. getClassName(): string;
  60582. /**
  60583. * Returns the integer 2.
  60584. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60585. */
  60586. getTypeID(): number;
  60587. /**
  60588. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60589. */
  60590. protected _setDirection(value: Vector3): void;
  60591. /**
  60592. * Overrides the position setter to recompute the projection texture view light Matrix.
  60593. */
  60594. protected _setPosition(value: Vector3): void;
  60595. /**
  60596. * 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.
  60597. * Returns the SpotLight.
  60598. */
  60599. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60600. protected _computeProjectionTextureViewLightMatrix(): void;
  60601. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60602. /**
  60603. * Main function for light texture projection matrix computing.
  60604. */
  60605. protected _computeProjectionTextureMatrix(): void;
  60606. protected _buildUniformLayout(): void;
  60607. private _computeAngleValues;
  60608. /**
  60609. * Sets the passed Effect "effect" with the Light textures.
  60610. * @param effect The effect to update
  60611. * @param lightIndex The index of the light in the effect to update
  60612. * @returns The light
  60613. */
  60614. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60615. /**
  60616. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60617. * @param effect The effect to update
  60618. * @param lightIndex The index of the light in the effect to update
  60619. * @returns The spot light
  60620. */
  60621. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60622. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60623. /**
  60624. * Disposes the light and the associated resources.
  60625. */
  60626. dispose(): void;
  60627. /**
  60628. * Prepares the list of defines specific to the light type.
  60629. * @param defines the list of defines
  60630. * @param lightIndex defines the index of the light for the effect
  60631. */
  60632. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60633. }
  60634. }
  60635. declare module "babylonjs/Gizmos/lightGizmo" {
  60636. import { Nullable } from "babylonjs/types";
  60637. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60638. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60639. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60640. import { Light } from "babylonjs/Lights/light";
  60641. import { Observable } from "babylonjs/Misc/observable";
  60642. /**
  60643. * Gizmo that enables viewing a light
  60644. */
  60645. export class LightGizmo extends Gizmo {
  60646. private _lightMesh;
  60647. private _material;
  60648. private _cachedPosition;
  60649. private _cachedForward;
  60650. private _attachedMeshParent;
  60651. private _pointerObserver;
  60652. /**
  60653. * Event that fires each time the gizmo is clicked
  60654. */
  60655. onClickedObservable: Observable<Light>;
  60656. /**
  60657. * Creates a LightGizmo
  60658. * @param gizmoLayer The utility layer the gizmo will be added to
  60659. */
  60660. constructor(gizmoLayer?: UtilityLayerRenderer);
  60661. private _light;
  60662. /**
  60663. * The light that the gizmo is attached to
  60664. */
  60665. set light(light: Nullable<Light>);
  60666. get light(): Nullable<Light>;
  60667. /**
  60668. * Gets the material used to render the light gizmo
  60669. */
  60670. get material(): StandardMaterial;
  60671. /**
  60672. * @hidden
  60673. * Updates the gizmo to match the attached mesh's position/rotation
  60674. */
  60675. protected _update(): void;
  60676. private static _Scale;
  60677. /**
  60678. * Creates the lines for a light mesh
  60679. */
  60680. private static _CreateLightLines;
  60681. /**
  60682. * Disposes of the light gizmo
  60683. */
  60684. dispose(): void;
  60685. private static _CreateHemisphericLightMesh;
  60686. private static _CreatePointLightMesh;
  60687. private static _CreateSpotLightMesh;
  60688. private static _CreateDirectionalLightMesh;
  60689. }
  60690. }
  60691. declare module "babylonjs/Gizmos/cameraGizmo" {
  60692. import { Nullable } from "babylonjs/types";
  60693. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60694. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60695. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60696. import { Camera } from "babylonjs/Cameras/camera";
  60697. import { Observable } from "babylonjs/Misc/observable";
  60698. /**
  60699. * Gizmo that enables viewing a camera
  60700. */
  60701. export class CameraGizmo extends Gizmo {
  60702. private _cameraMesh;
  60703. private _cameraLinesMesh;
  60704. private _material;
  60705. private _pointerObserver;
  60706. /**
  60707. * Event that fires each time the gizmo is clicked
  60708. */
  60709. onClickedObservable: Observable<Camera>;
  60710. /**
  60711. * Creates a CameraGizmo
  60712. * @param gizmoLayer The utility layer the gizmo will be added to
  60713. */
  60714. constructor(gizmoLayer?: UtilityLayerRenderer);
  60715. private _camera;
  60716. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60717. get displayFrustum(): boolean;
  60718. set displayFrustum(value: boolean);
  60719. /**
  60720. * The camera that the gizmo is attached to
  60721. */
  60722. set camera(camera: Nullable<Camera>);
  60723. get camera(): Nullable<Camera>;
  60724. /**
  60725. * Gets the material used to render the camera gizmo
  60726. */
  60727. get material(): StandardMaterial;
  60728. /**
  60729. * @hidden
  60730. * Updates the gizmo to match the attached mesh's position/rotation
  60731. */
  60732. protected _update(): void;
  60733. private static _Scale;
  60734. private _invProjection;
  60735. /**
  60736. * Disposes of the camera gizmo
  60737. */
  60738. dispose(): void;
  60739. private static _CreateCameraMesh;
  60740. private static _CreateCameraFrustum;
  60741. }
  60742. }
  60743. declare module "babylonjs/Gizmos/index" {
  60744. export * from "babylonjs/Gizmos/axisDragGizmo";
  60745. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60746. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60747. export * from "babylonjs/Gizmos/gizmo";
  60748. export * from "babylonjs/Gizmos/gizmoManager";
  60749. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60750. export * from "babylonjs/Gizmos/positionGizmo";
  60751. export * from "babylonjs/Gizmos/rotationGizmo";
  60752. export * from "babylonjs/Gizmos/scaleGizmo";
  60753. export * from "babylonjs/Gizmos/lightGizmo";
  60754. export * from "babylonjs/Gizmos/cameraGizmo";
  60755. export * from "babylonjs/Gizmos/planeDragGizmo";
  60756. }
  60757. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60758. /** @hidden */
  60759. export var backgroundFragmentDeclaration: {
  60760. name: string;
  60761. shader: string;
  60762. };
  60763. }
  60764. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60765. /** @hidden */
  60766. export var backgroundUboDeclaration: {
  60767. name: string;
  60768. shader: string;
  60769. };
  60770. }
  60771. declare module "babylonjs/Shaders/background.fragment" {
  60772. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60773. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60774. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60776. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60777. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60778. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60779. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60780. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60781. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60782. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60783. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60784. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60785. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60786. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60787. /** @hidden */
  60788. export var backgroundPixelShader: {
  60789. name: string;
  60790. shader: string;
  60791. };
  60792. }
  60793. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60794. /** @hidden */
  60795. export var backgroundVertexDeclaration: {
  60796. name: string;
  60797. shader: string;
  60798. };
  60799. }
  60800. declare module "babylonjs/Shaders/background.vertex" {
  60801. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60802. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60803. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60804. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60805. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60806. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60807. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60808. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60809. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60810. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60811. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60812. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60813. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60814. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60815. /** @hidden */
  60816. export var backgroundVertexShader: {
  60817. name: string;
  60818. shader: string;
  60819. };
  60820. }
  60821. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60822. import { Nullable, int, float } from "babylonjs/types";
  60823. import { Scene } from "babylonjs/scene";
  60824. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60825. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60826. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60827. import { Mesh } from "babylonjs/Meshes/mesh";
  60828. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60829. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60830. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60832. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60833. import { Color3 } from "babylonjs/Maths/math.color";
  60834. import "babylonjs/Shaders/background.fragment";
  60835. import "babylonjs/Shaders/background.vertex";
  60836. /**
  60837. * Background material used to create an efficient environement around your scene.
  60838. */
  60839. export class BackgroundMaterial extends PushMaterial {
  60840. /**
  60841. * Standard reflectance value at parallel view angle.
  60842. */
  60843. static StandardReflectance0: number;
  60844. /**
  60845. * Standard reflectance value at grazing angle.
  60846. */
  60847. static StandardReflectance90: number;
  60848. protected _primaryColor: Color3;
  60849. /**
  60850. * Key light Color (multiply against the environement texture)
  60851. */
  60852. primaryColor: Color3;
  60853. protected __perceptualColor: Nullable<Color3>;
  60854. /**
  60855. * Experimental Internal Use Only.
  60856. *
  60857. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60858. * This acts as a helper to set the primary color to a more "human friendly" value.
  60859. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60860. * output color as close as possible from the chosen value.
  60861. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60862. * part of lighting setup.)
  60863. */
  60864. get _perceptualColor(): Nullable<Color3>;
  60865. set _perceptualColor(value: Nullable<Color3>);
  60866. protected _primaryColorShadowLevel: float;
  60867. /**
  60868. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60869. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60870. */
  60871. get primaryColorShadowLevel(): float;
  60872. set primaryColorShadowLevel(value: float);
  60873. protected _primaryColorHighlightLevel: float;
  60874. /**
  60875. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60876. * The primary color is used at the level chosen to define what the white area would look.
  60877. */
  60878. get primaryColorHighlightLevel(): float;
  60879. set primaryColorHighlightLevel(value: float);
  60880. protected _reflectionTexture: Nullable<BaseTexture>;
  60881. /**
  60882. * Reflection Texture used in the material.
  60883. * Should be author in a specific way for the best result (refer to the documentation).
  60884. */
  60885. reflectionTexture: Nullable<BaseTexture>;
  60886. protected _reflectionBlur: float;
  60887. /**
  60888. * Reflection Texture level of blur.
  60889. *
  60890. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60891. * texture twice.
  60892. */
  60893. reflectionBlur: float;
  60894. protected _diffuseTexture: Nullable<BaseTexture>;
  60895. /**
  60896. * Diffuse Texture used in the material.
  60897. * Should be author in a specific way for the best result (refer to the documentation).
  60898. */
  60899. diffuseTexture: Nullable<BaseTexture>;
  60900. protected _shadowLights: Nullable<IShadowLight[]>;
  60901. /**
  60902. * Specify the list of lights casting shadow on the material.
  60903. * All scene shadow lights will be included if null.
  60904. */
  60905. shadowLights: Nullable<IShadowLight[]>;
  60906. protected _shadowLevel: float;
  60907. /**
  60908. * Helps adjusting the shadow to a softer level if required.
  60909. * 0 means black shadows and 1 means no shadows.
  60910. */
  60911. shadowLevel: float;
  60912. protected _sceneCenter: Vector3;
  60913. /**
  60914. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60915. * It is usually zero but might be interesting to modify according to your setup.
  60916. */
  60917. sceneCenter: Vector3;
  60918. protected _opacityFresnel: boolean;
  60919. /**
  60920. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60921. * This helps ensuring a nice transition when the camera goes under the ground.
  60922. */
  60923. opacityFresnel: boolean;
  60924. protected _reflectionFresnel: boolean;
  60925. /**
  60926. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60927. * This helps adding a mirror texture on the ground.
  60928. */
  60929. reflectionFresnel: boolean;
  60930. protected _reflectionFalloffDistance: number;
  60931. /**
  60932. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60933. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60934. */
  60935. reflectionFalloffDistance: number;
  60936. protected _reflectionAmount: number;
  60937. /**
  60938. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60939. */
  60940. reflectionAmount: number;
  60941. protected _reflectionReflectance0: number;
  60942. /**
  60943. * This specifies the weight of the reflection at grazing angle.
  60944. */
  60945. reflectionReflectance0: number;
  60946. protected _reflectionReflectance90: number;
  60947. /**
  60948. * This specifies the weight of the reflection at a perpendicular point of view.
  60949. */
  60950. reflectionReflectance90: number;
  60951. /**
  60952. * Sets the reflection reflectance fresnel values according to the default standard
  60953. * empirically know to work well :-)
  60954. */
  60955. set reflectionStandardFresnelWeight(value: number);
  60956. protected _useRGBColor: boolean;
  60957. /**
  60958. * Helps to directly use the maps channels instead of their level.
  60959. */
  60960. useRGBColor: boolean;
  60961. protected _enableNoise: boolean;
  60962. /**
  60963. * This helps reducing the banding effect that could occur on the background.
  60964. */
  60965. enableNoise: boolean;
  60966. /**
  60967. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60968. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60969. * Recommended to be keep at 1.0 except for special cases.
  60970. */
  60971. get fovMultiplier(): number;
  60972. set fovMultiplier(value: number);
  60973. private _fovMultiplier;
  60974. /**
  60975. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60976. */
  60977. useEquirectangularFOV: boolean;
  60978. private _maxSimultaneousLights;
  60979. /**
  60980. * Number of Simultaneous lights allowed on the material.
  60981. */
  60982. maxSimultaneousLights: int;
  60983. private _shadowOnly;
  60984. /**
  60985. * Make the material only render shadows
  60986. */
  60987. shadowOnly: boolean;
  60988. /**
  60989. * Default configuration related to image processing available in the Background Material.
  60990. */
  60991. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60992. /**
  60993. * Keep track of the image processing observer to allow dispose and replace.
  60994. */
  60995. private _imageProcessingObserver;
  60996. /**
  60997. * Attaches a new image processing configuration to the PBR Material.
  60998. * @param configuration (if null the scene configuration will be use)
  60999. */
  61000. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61001. /**
  61002. * Gets the image processing configuration used either in this material.
  61003. */
  61004. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61005. /**
  61006. * Sets the Default image processing configuration used either in the this material.
  61007. *
  61008. * If sets to null, the scene one is in use.
  61009. */
  61010. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61011. /**
  61012. * Gets wether the color curves effect is enabled.
  61013. */
  61014. get cameraColorCurvesEnabled(): boolean;
  61015. /**
  61016. * Sets wether the color curves effect is enabled.
  61017. */
  61018. set cameraColorCurvesEnabled(value: boolean);
  61019. /**
  61020. * Gets wether the color grading effect is enabled.
  61021. */
  61022. get cameraColorGradingEnabled(): boolean;
  61023. /**
  61024. * Gets wether the color grading effect is enabled.
  61025. */
  61026. set cameraColorGradingEnabled(value: boolean);
  61027. /**
  61028. * Gets wether tonemapping is enabled or not.
  61029. */
  61030. get cameraToneMappingEnabled(): boolean;
  61031. /**
  61032. * Sets wether tonemapping is enabled or not
  61033. */
  61034. set cameraToneMappingEnabled(value: boolean);
  61035. /**
  61036. * The camera exposure used on this material.
  61037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61038. * This corresponds to a photographic exposure.
  61039. */
  61040. get cameraExposure(): float;
  61041. /**
  61042. * The camera exposure used on this material.
  61043. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61044. * This corresponds to a photographic exposure.
  61045. */
  61046. set cameraExposure(value: float);
  61047. /**
  61048. * Gets The camera contrast used on this material.
  61049. */
  61050. get cameraContrast(): float;
  61051. /**
  61052. * Sets The camera contrast used on this material.
  61053. */
  61054. set cameraContrast(value: float);
  61055. /**
  61056. * Gets the Color Grading 2D Lookup Texture.
  61057. */
  61058. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61059. /**
  61060. * Sets the Color Grading 2D Lookup Texture.
  61061. */
  61062. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61063. /**
  61064. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61065. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61066. * 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;
  61067. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61068. */
  61069. get cameraColorCurves(): Nullable<ColorCurves>;
  61070. /**
  61071. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61072. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61073. * 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;
  61074. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61075. */
  61076. set cameraColorCurves(value: Nullable<ColorCurves>);
  61077. /**
  61078. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61079. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61080. */
  61081. switchToBGR: boolean;
  61082. private _renderTargets;
  61083. private _reflectionControls;
  61084. private _white;
  61085. private _primaryShadowColor;
  61086. private _primaryHighlightColor;
  61087. /**
  61088. * Instantiates a Background Material in the given scene
  61089. * @param name The friendly name of the material
  61090. * @param scene The scene to add the material to
  61091. */
  61092. constructor(name: string, scene: Scene);
  61093. /**
  61094. * Gets a boolean indicating that current material needs to register RTT
  61095. */
  61096. get hasRenderTargetTextures(): boolean;
  61097. /**
  61098. * The entire material has been created in order to prevent overdraw.
  61099. * @returns false
  61100. */
  61101. needAlphaTesting(): boolean;
  61102. /**
  61103. * The entire material has been created in order to prevent overdraw.
  61104. * @returns true if blending is enable
  61105. */
  61106. needAlphaBlending(): boolean;
  61107. /**
  61108. * Checks wether the material is ready to be rendered for a given mesh.
  61109. * @param mesh The mesh to render
  61110. * @param subMesh The submesh to check against
  61111. * @param useInstances Specify wether or not the material is used with instances
  61112. * @returns true if all the dependencies are ready (Textures, Effects...)
  61113. */
  61114. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61115. /**
  61116. * Compute the primary color according to the chosen perceptual color.
  61117. */
  61118. private _computePrimaryColorFromPerceptualColor;
  61119. /**
  61120. * Compute the highlights and shadow colors according to their chosen levels.
  61121. */
  61122. private _computePrimaryColors;
  61123. /**
  61124. * Build the uniform buffer used in the material.
  61125. */
  61126. buildUniformLayout(): void;
  61127. /**
  61128. * Unbind the material.
  61129. */
  61130. unbind(): void;
  61131. /**
  61132. * Bind only the world matrix to the material.
  61133. * @param world The world matrix to bind.
  61134. */
  61135. bindOnlyWorldMatrix(world: Matrix): void;
  61136. /**
  61137. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61138. * @param world The world matrix to bind.
  61139. * @param subMesh The submesh to bind for.
  61140. */
  61141. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61142. /**
  61143. * Checks to see if a texture is used in the material.
  61144. * @param texture - Base texture to use.
  61145. * @returns - Boolean specifying if a texture is used in the material.
  61146. */
  61147. hasTexture(texture: BaseTexture): boolean;
  61148. /**
  61149. * Dispose the material.
  61150. * @param forceDisposeEffect Force disposal of the associated effect.
  61151. * @param forceDisposeTextures Force disposal of the associated textures.
  61152. */
  61153. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61154. /**
  61155. * Clones the material.
  61156. * @param name The cloned name.
  61157. * @returns The cloned material.
  61158. */
  61159. clone(name: string): BackgroundMaterial;
  61160. /**
  61161. * Serializes the current material to its JSON representation.
  61162. * @returns The JSON representation.
  61163. */
  61164. serialize(): any;
  61165. /**
  61166. * Gets the class name of the material
  61167. * @returns "BackgroundMaterial"
  61168. */
  61169. getClassName(): string;
  61170. /**
  61171. * Parse a JSON input to create back a background material.
  61172. * @param source The JSON data to parse
  61173. * @param scene The scene to create the parsed material in
  61174. * @param rootUrl The root url of the assets the material depends upon
  61175. * @returns the instantiated BackgroundMaterial.
  61176. */
  61177. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61178. }
  61179. }
  61180. declare module "babylonjs/Helpers/environmentHelper" {
  61181. import { Observable } from "babylonjs/Misc/observable";
  61182. import { Nullable } from "babylonjs/types";
  61183. import { Scene } from "babylonjs/scene";
  61184. import { Vector3 } from "babylonjs/Maths/math.vector";
  61185. import { Color3 } from "babylonjs/Maths/math.color";
  61186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61187. import { Mesh } from "babylonjs/Meshes/mesh";
  61188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61189. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  61190. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61191. import "babylonjs/Meshes/Builders/planeBuilder";
  61192. import "babylonjs/Meshes/Builders/boxBuilder";
  61193. /**
  61194. * Represents the different options available during the creation of
  61195. * a Environment helper.
  61196. *
  61197. * This can control the default ground, skybox and image processing setup of your scene.
  61198. */
  61199. export interface IEnvironmentHelperOptions {
  61200. /**
  61201. * Specifies whether or not to create a ground.
  61202. * True by default.
  61203. */
  61204. createGround: boolean;
  61205. /**
  61206. * Specifies the ground size.
  61207. * 15 by default.
  61208. */
  61209. groundSize: number;
  61210. /**
  61211. * The texture used on the ground for the main color.
  61212. * Comes from the BabylonJS CDN by default.
  61213. *
  61214. * Remarks: Can be either a texture or a url.
  61215. */
  61216. groundTexture: string | BaseTexture;
  61217. /**
  61218. * The color mixed in the ground texture by default.
  61219. * BabylonJS clearColor by default.
  61220. */
  61221. groundColor: Color3;
  61222. /**
  61223. * Specifies the ground opacity.
  61224. * 1 by default.
  61225. */
  61226. groundOpacity: number;
  61227. /**
  61228. * Enables the ground to receive shadows.
  61229. * True by default.
  61230. */
  61231. enableGroundShadow: boolean;
  61232. /**
  61233. * Helps preventing the shadow to be fully black on the ground.
  61234. * 0.5 by default.
  61235. */
  61236. groundShadowLevel: number;
  61237. /**
  61238. * Creates a mirror texture attach to the ground.
  61239. * false by default.
  61240. */
  61241. enableGroundMirror: boolean;
  61242. /**
  61243. * Specifies the ground mirror size ratio.
  61244. * 0.3 by default as the default kernel is 64.
  61245. */
  61246. groundMirrorSizeRatio: number;
  61247. /**
  61248. * Specifies the ground mirror blur kernel size.
  61249. * 64 by default.
  61250. */
  61251. groundMirrorBlurKernel: number;
  61252. /**
  61253. * Specifies the ground mirror visibility amount.
  61254. * 1 by default
  61255. */
  61256. groundMirrorAmount: number;
  61257. /**
  61258. * Specifies the ground mirror reflectance weight.
  61259. * This uses the standard weight of the background material to setup the fresnel effect
  61260. * of the mirror.
  61261. * 1 by default.
  61262. */
  61263. groundMirrorFresnelWeight: number;
  61264. /**
  61265. * Specifies the ground mirror Falloff distance.
  61266. * This can helps reducing the size of the reflection.
  61267. * 0 by Default.
  61268. */
  61269. groundMirrorFallOffDistance: number;
  61270. /**
  61271. * Specifies the ground mirror texture type.
  61272. * Unsigned Int by Default.
  61273. */
  61274. groundMirrorTextureType: number;
  61275. /**
  61276. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61277. * the shown objects.
  61278. */
  61279. groundYBias: number;
  61280. /**
  61281. * Specifies whether or not to create a skybox.
  61282. * True by default.
  61283. */
  61284. createSkybox: boolean;
  61285. /**
  61286. * Specifies the skybox size.
  61287. * 20 by default.
  61288. */
  61289. skyboxSize: number;
  61290. /**
  61291. * The texture used on the skybox for the main color.
  61292. * Comes from the BabylonJS CDN by default.
  61293. *
  61294. * Remarks: Can be either a texture or a url.
  61295. */
  61296. skyboxTexture: string | BaseTexture;
  61297. /**
  61298. * The color mixed in the skybox texture by default.
  61299. * BabylonJS clearColor by default.
  61300. */
  61301. skyboxColor: Color3;
  61302. /**
  61303. * The background rotation around the Y axis of the scene.
  61304. * This helps aligning the key lights of your scene with the background.
  61305. * 0 by default.
  61306. */
  61307. backgroundYRotation: number;
  61308. /**
  61309. * Compute automatically the size of the elements to best fit with the scene.
  61310. */
  61311. sizeAuto: boolean;
  61312. /**
  61313. * Default position of the rootMesh if autoSize is not true.
  61314. */
  61315. rootPosition: Vector3;
  61316. /**
  61317. * Sets up the image processing in the scene.
  61318. * true by default.
  61319. */
  61320. setupImageProcessing: boolean;
  61321. /**
  61322. * The texture used as your environment texture in the scene.
  61323. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61324. *
  61325. * Remarks: Can be either a texture or a url.
  61326. */
  61327. environmentTexture: string | BaseTexture;
  61328. /**
  61329. * The value of the exposure to apply to the scene.
  61330. * 0.6 by default if setupImageProcessing is true.
  61331. */
  61332. cameraExposure: number;
  61333. /**
  61334. * The value of the contrast to apply to the scene.
  61335. * 1.6 by default if setupImageProcessing is true.
  61336. */
  61337. cameraContrast: number;
  61338. /**
  61339. * Specifies whether or not tonemapping should be enabled in the scene.
  61340. * true by default if setupImageProcessing is true.
  61341. */
  61342. toneMappingEnabled: boolean;
  61343. }
  61344. /**
  61345. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61346. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61347. * It also helps with the default setup of your imageProcessing configuration.
  61348. */
  61349. export class EnvironmentHelper {
  61350. /**
  61351. * Default ground texture URL.
  61352. */
  61353. private static _groundTextureCDNUrl;
  61354. /**
  61355. * Default skybox texture URL.
  61356. */
  61357. private static _skyboxTextureCDNUrl;
  61358. /**
  61359. * Default environment texture URL.
  61360. */
  61361. private static _environmentTextureCDNUrl;
  61362. /**
  61363. * Creates the default options for the helper.
  61364. */
  61365. private static _getDefaultOptions;
  61366. private _rootMesh;
  61367. /**
  61368. * Gets the root mesh created by the helper.
  61369. */
  61370. get rootMesh(): Mesh;
  61371. private _skybox;
  61372. /**
  61373. * Gets the skybox created by the helper.
  61374. */
  61375. get skybox(): Nullable<Mesh>;
  61376. private _skyboxTexture;
  61377. /**
  61378. * Gets the skybox texture created by the helper.
  61379. */
  61380. get skyboxTexture(): Nullable<BaseTexture>;
  61381. private _skyboxMaterial;
  61382. /**
  61383. * Gets the skybox material created by the helper.
  61384. */
  61385. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61386. private _ground;
  61387. /**
  61388. * Gets the ground mesh created by the helper.
  61389. */
  61390. get ground(): Nullable<Mesh>;
  61391. private _groundTexture;
  61392. /**
  61393. * Gets the ground texture created by the helper.
  61394. */
  61395. get groundTexture(): Nullable<BaseTexture>;
  61396. private _groundMirror;
  61397. /**
  61398. * Gets the ground mirror created by the helper.
  61399. */
  61400. get groundMirror(): Nullable<MirrorTexture>;
  61401. /**
  61402. * Gets the ground mirror render list to helps pushing the meshes
  61403. * you wish in the ground reflection.
  61404. */
  61405. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61406. private _groundMaterial;
  61407. /**
  61408. * Gets the ground material created by the helper.
  61409. */
  61410. get groundMaterial(): Nullable<BackgroundMaterial>;
  61411. /**
  61412. * Stores the creation options.
  61413. */
  61414. private readonly _scene;
  61415. private _options;
  61416. /**
  61417. * This observable will be notified with any error during the creation of the environment,
  61418. * mainly texture creation errors.
  61419. */
  61420. onErrorObservable: Observable<{
  61421. message?: string;
  61422. exception?: any;
  61423. }>;
  61424. /**
  61425. * constructor
  61426. * @param options Defines the options we want to customize the helper
  61427. * @param scene The scene to add the material to
  61428. */
  61429. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61430. /**
  61431. * Updates the background according to the new options
  61432. * @param options
  61433. */
  61434. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61435. /**
  61436. * Sets the primary color of all the available elements.
  61437. * @param color the main color to affect to the ground and the background
  61438. */
  61439. setMainColor(color: Color3): void;
  61440. /**
  61441. * Setup the image processing according to the specified options.
  61442. */
  61443. private _setupImageProcessing;
  61444. /**
  61445. * Setup the environment texture according to the specified options.
  61446. */
  61447. private _setupEnvironmentTexture;
  61448. /**
  61449. * Setup the background according to the specified options.
  61450. */
  61451. private _setupBackground;
  61452. /**
  61453. * Get the scene sizes according to the setup.
  61454. */
  61455. private _getSceneSize;
  61456. /**
  61457. * Setup the ground according to the specified options.
  61458. */
  61459. private _setupGround;
  61460. /**
  61461. * Setup the ground material according to the specified options.
  61462. */
  61463. private _setupGroundMaterial;
  61464. /**
  61465. * Setup the ground diffuse texture according to the specified options.
  61466. */
  61467. private _setupGroundDiffuseTexture;
  61468. /**
  61469. * Setup the ground mirror texture according to the specified options.
  61470. */
  61471. private _setupGroundMirrorTexture;
  61472. /**
  61473. * Setup the ground to receive the mirror texture.
  61474. */
  61475. private _setupMirrorInGroundMaterial;
  61476. /**
  61477. * Setup the skybox according to the specified options.
  61478. */
  61479. private _setupSkybox;
  61480. /**
  61481. * Setup the skybox material according to the specified options.
  61482. */
  61483. private _setupSkyboxMaterial;
  61484. /**
  61485. * Setup the skybox reflection texture according to the specified options.
  61486. */
  61487. private _setupSkyboxReflectionTexture;
  61488. private _errorHandler;
  61489. /**
  61490. * Dispose all the elements created by the Helper.
  61491. */
  61492. dispose(): void;
  61493. }
  61494. }
  61495. declare module "babylonjs/Helpers/textureDome" {
  61496. import { Scene } from "babylonjs/scene";
  61497. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61498. import { Mesh } from "babylonjs/Meshes/mesh";
  61499. import { Texture } from "babylonjs/Materials/Textures/texture";
  61500. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  61501. import "babylonjs/Meshes/Builders/sphereBuilder";
  61502. import { Nullable } from "babylonjs/types";
  61503. import { Observable } from "babylonjs/Misc/observable";
  61504. /**
  61505. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61506. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61507. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61508. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61509. */
  61510. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61511. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61512. /**
  61513. * Define the source as a Monoscopic panoramic 360/180.
  61514. */
  61515. static readonly MODE_MONOSCOPIC: number;
  61516. /**
  61517. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61518. */
  61519. static readonly MODE_TOPBOTTOM: number;
  61520. /**
  61521. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61522. */
  61523. static readonly MODE_SIDEBYSIDE: number;
  61524. private _halfDome;
  61525. private _crossEye;
  61526. protected _useDirectMapping: boolean;
  61527. /**
  61528. * The texture being displayed on the sphere
  61529. */
  61530. protected _texture: T;
  61531. /**
  61532. * Gets the texture being displayed on the sphere
  61533. */
  61534. get texture(): T;
  61535. /**
  61536. * Sets the texture being displayed on the sphere
  61537. */
  61538. set texture(newTexture: T);
  61539. /**
  61540. * The skybox material
  61541. */
  61542. protected _material: BackgroundMaterial;
  61543. /**
  61544. * The surface used for the dome
  61545. */
  61546. protected _mesh: Mesh;
  61547. /**
  61548. * Gets the mesh used for the dome.
  61549. */
  61550. get mesh(): Mesh;
  61551. /**
  61552. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61553. */
  61554. private _halfDomeMask;
  61555. /**
  61556. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61557. * Also see the options.resolution property.
  61558. */
  61559. get fovMultiplier(): number;
  61560. set fovMultiplier(value: number);
  61561. protected _textureMode: number;
  61562. /**
  61563. * Gets or set the current texture mode for the texture. It can be:
  61564. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61565. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61566. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61567. */
  61568. get textureMode(): number;
  61569. /**
  61570. * Sets the current texture mode for the texture. It can be:
  61571. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61572. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61573. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61574. */
  61575. set textureMode(value: number);
  61576. /**
  61577. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61578. */
  61579. get halfDome(): boolean;
  61580. /**
  61581. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61582. */
  61583. set halfDome(enabled: boolean);
  61584. /**
  61585. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61586. */
  61587. set crossEye(enabled: boolean);
  61588. /**
  61589. * Is it a cross-eye texture?
  61590. */
  61591. get crossEye(): boolean;
  61592. /**
  61593. * The background material of this dome.
  61594. */
  61595. get material(): BackgroundMaterial;
  61596. /**
  61597. * Oberserver used in Stereoscopic VR Mode.
  61598. */
  61599. private _onBeforeCameraRenderObserver;
  61600. /**
  61601. * Observable raised when an error occured while loading the 360 image
  61602. */
  61603. onLoadErrorObservable: Observable<string>;
  61604. /**
  61605. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61606. * @param name Element's name, child elements will append suffixes for their own names.
  61607. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61608. * @param options An object containing optional or exposed sub element properties
  61609. */
  61610. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61611. resolution?: number;
  61612. clickToPlay?: boolean;
  61613. autoPlay?: boolean;
  61614. loop?: boolean;
  61615. size?: number;
  61616. poster?: string;
  61617. faceForward?: boolean;
  61618. useDirectMapping?: boolean;
  61619. halfDomeMode?: boolean;
  61620. crossEyeMode?: boolean;
  61621. generateMipMaps?: boolean;
  61622. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61623. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61624. protected _changeTextureMode(value: number): void;
  61625. /**
  61626. * Releases resources associated with this node.
  61627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61629. */
  61630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61631. }
  61632. }
  61633. declare module "babylonjs/Helpers/photoDome" {
  61634. import { Scene } from "babylonjs/scene";
  61635. import { Texture } from "babylonjs/Materials/Textures/texture";
  61636. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61637. /**
  61638. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61639. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61640. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61641. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61642. */
  61643. export class PhotoDome extends TextureDome<Texture> {
  61644. /**
  61645. * Define the image as a Monoscopic panoramic 360 image.
  61646. */
  61647. static readonly MODE_MONOSCOPIC: number;
  61648. /**
  61649. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61650. */
  61651. static readonly MODE_TOPBOTTOM: number;
  61652. /**
  61653. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61654. */
  61655. static readonly MODE_SIDEBYSIDE: number;
  61656. /**
  61657. * Gets or sets the texture being displayed on the sphere
  61658. */
  61659. get photoTexture(): Texture;
  61660. /**
  61661. * sets the texture being displayed on the sphere
  61662. */
  61663. set photoTexture(value: Texture);
  61664. /**
  61665. * Gets the current video mode for the video. It can be:
  61666. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61667. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61668. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61669. */
  61670. get imageMode(): number;
  61671. /**
  61672. * Sets the current video mode for the video. It can be:
  61673. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61674. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61675. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61676. */
  61677. set imageMode(value: number);
  61678. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61679. }
  61680. }
  61681. declare module "babylonjs/Misc/dds" {
  61682. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61683. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61684. import { Nullable } from "babylonjs/types";
  61685. import { Scene } from "babylonjs/scene";
  61686. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61687. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61688. /**
  61689. * Direct draw surface info
  61690. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61691. */
  61692. export interface DDSInfo {
  61693. /**
  61694. * Width of the texture
  61695. */
  61696. width: number;
  61697. /**
  61698. * Width of the texture
  61699. */
  61700. height: number;
  61701. /**
  61702. * Number of Mipmaps for the texture
  61703. * @see https://en.wikipedia.org/wiki/Mipmap
  61704. */
  61705. mipmapCount: number;
  61706. /**
  61707. * If the textures format is a known fourCC format
  61708. * @see https://www.fourcc.org/
  61709. */
  61710. isFourCC: boolean;
  61711. /**
  61712. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61713. */
  61714. isRGB: boolean;
  61715. /**
  61716. * If the texture is a lumincance format
  61717. */
  61718. isLuminance: boolean;
  61719. /**
  61720. * If this is a cube texture
  61721. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61722. */
  61723. isCube: boolean;
  61724. /**
  61725. * If the texture is a compressed format eg. FOURCC_DXT1
  61726. */
  61727. isCompressed: boolean;
  61728. /**
  61729. * The dxgiFormat of the texture
  61730. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61731. */
  61732. dxgiFormat: number;
  61733. /**
  61734. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61735. */
  61736. textureType: number;
  61737. /**
  61738. * Sphericle polynomial created for the dds texture
  61739. */
  61740. sphericalPolynomial?: SphericalPolynomial;
  61741. }
  61742. /**
  61743. * Class used to provide DDS decompression tools
  61744. */
  61745. export class DDSTools {
  61746. /**
  61747. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61748. */
  61749. static StoreLODInAlphaChannel: boolean;
  61750. /**
  61751. * Gets DDS information from an array buffer
  61752. * @param data defines the array buffer view to read data from
  61753. * @returns the DDS information
  61754. */
  61755. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61756. private static _FloatView;
  61757. private static _Int32View;
  61758. private static _ToHalfFloat;
  61759. private static _FromHalfFloat;
  61760. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61761. private static _GetHalfFloatRGBAArrayBuffer;
  61762. private static _GetFloatRGBAArrayBuffer;
  61763. private static _GetFloatAsUIntRGBAArrayBuffer;
  61764. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61765. private static _GetRGBAArrayBuffer;
  61766. private static _ExtractLongWordOrder;
  61767. private static _GetRGBArrayBuffer;
  61768. private static _GetLuminanceArrayBuffer;
  61769. /**
  61770. * Uploads DDS Levels to a Babylon Texture
  61771. * @hidden
  61772. */
  61773. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61774. }
  61775. module "babylonjs/Engines/thinEngine" {
  61776. interface ThinEngine {
  61777. /**
  61778. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61779. * @param rootUrl defines the url where the file to load is located
  61780. * @param scene defines the current scene
  61781. * @param lodScale defines scale to apply to the mip map selection
  61782. * @param lodOffset defines offset to apply to the mip map selection
  61783. * @param onLoad defines an optional callback raised when the texture is loaded
  61784. * @param onError defines an optional callback raised if there is an issue to load the texture
  61785. * @param format defines the format of the data
  61786. * @param forcedExtension defines the extension to use to pick the right loader
  61787. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61788. * @returns the cube texture as an InternalTexture
  61789. */
  61790. 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;
  61791. }
  61792. }
  61793. }
  61794. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61795. import { Nullable } from "babylonjs/types";
  61796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61797. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61798. /**
  61799. * Implementation of the DDS Texture Loader.
  61800. * @hidden
  61801. */
  61802. export class _DDSTextureLoader implements IInternalTextureLoader {
  61803. /**
  61804. * Defines wether the loader supports cascade loading the different faces.
  61805. */
  61806. readonly supportCascades: boolean;
  61807. /**
  61808. * This returns if the loader support the current file information.
  61809. * @param extension defines the file extension of the file being loaded
  61810. * @returns true if the loader can load the specified file
  61811. */
  61812. canLoad(extension: string): boolean;
  61813. /**
  61814. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61815. * @param data contains the texture data
  61816. * @param texture defines the BabylonJS internal texture
  61817. * @param createPolynomials will be true if polynomials have been requested
  61818. * @param onLoad defines the callback to trigger once the texture is ready
  61819. * @param onError defines the callback to trigger in case of error
  61820. */
  61821. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61822. /**
  61823. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61824. * @param data contains the texture data
  61825. * @param texture defines the BabylonJS internal texture
  61826. * @param callback defines the method to call once ready to upload
  61827. */
  61828. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61829. }
  61830. }
  61831. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61832. import { Nullable } from "babylonjs/types";
  61833. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61834. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61835. /**
  61836. * Implementation of the ENV Texture Loader.
  61837. * @hidden
  61838. */
  61839. export class _ENVTextureLoader implements IInternalTextureLoader {
  61840. /**
  61841. * Defines wether the loader supports cascade loading the different faces.
  61842. */
  61843. readonly supportCascades: boolean;
  61844. /**
  61845. * This returns if the loader support the current file information.
  61846. * @param extension defines the file extension of the file being loaded
  61847. * @returns true if the loader can load the specified file
  61848. */
  61849. canLoad(extension: string): boolean;
  61850. /**
  61851. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61852. * @param data contains the texture data
  61853. * @param texture defines the BabylonJS internal texture
  61854. * @param createPolynomials will be true if polynomials have been requested
  61855. * @param onLoad defines the callback to trigger once the texture is ready
  61856. * @param onError defines the callback to trigger in case of error
  61857. */
  61858. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61859. /**
  61860. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61861. * @param data contains the texture data
  61862. * @param texture defines the BabylonJS internal texture
  61863. * @param callback defines the method to call once ready to upload
  61864. */
  61865. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61866. }
  61867. }
  61868. declare module "babylonjs/Misc/khronosTextureContainer" {
  61869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61870. /**
  61871. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61872. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61873. */
  61874. export class KhronosTextureContainer {
  61875. /** contents of the KTX container file */
  61876. data: ArrayBufferView;
  61877. private static HEADER_LEN;
  61878. private static COMPRESSED_2D;
  61879. private static COMPRESSED_3D;
  61880. private static TEX_2D;
  61881. private static TEX_3D;
  61882. /**
  61883. * Gets the openGL type
  61884. */
  61885. glType: number;
  61886. /**
  61887. * Gets the openGL type size
  61888. */
  61889. glTypeSize: number;
  61890. /**
  61891. * Gets the openGL format
  61892. */
  61893. glFormat: number;
  61894. /**
  61895. * Gets the openGL internal format
  61896. */
  61897. glInternalFormat: number;
  61898. /**
  61899. * Gets the base internal format
  61900. */
  61901. glBaseInternalFormat: number;
  61902. /**
  61903. * Gets image width in pixel
  61904. */
  61905. pixelWidth: number;
  61906. /**
  61907. * Gets image height in pixel
  61908. */
  61909. pixelHeight: number;
  61910. /**
  61911. * Gets image depth in pixels
  61912. */
  61913. pixelDepth: number;
  61914. /**
  61915. * Gets the number of array elements
  61916. */
  61917. numberOfArrayElements: number;
  61918. /**
  61919. * Gets the number of faces
  61920. */
  61921. numberOfFaces: number;
  61922. /**
  61923. * Gets the number of mipmap levels
  61924. */
  61925. numberOfMipmapLevels: number;
  61926. /**
  61927. * Gets the bytes of key value data
  61928. */
  61929. bytesOfKeyValueData: number;
  61930. /**
  61931. * Gets the load type
  61932. */
  61933. loadType: number;
  61934. /**
  61935. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61936. */
  61937. isInvalid: boolean;
  61938. /**
  61939. * Creates a new KhronosTextureContainer
  61940. * @param data contents of the KTX container file
  61941. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61942. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61943. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61944. */
  61945. constructor(
  61946. /** contents of the KTX container file */
  61947. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61948. /**
  61949. * Uploads KTX content to a Babylon Texture.
  61950. * It is assumed that the texture has already been created & is currently bound
  61951. * @hidden
  61952. */
  61953. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61954. private _upload2DCompressedLevels;
  61955. /**
  61956. * Checks if the given data starts with a KTX file identifier.
  61957. * @param data the data to check
  61958. * @returns true if the data is a KTX file or false otherwise
  61959. */
  61960. static IsValid(data: ArrayBufferView): boolean;
  61961. }
  61962. }
  61963. declare module "babylonjs/Misc/workerPool" {
  61964. import { IDisposable } from "babylonjs/scene";
  61965. /**
  61966. * Helper class to push actions to a pool of workers.
  61967. */
  61968. export class WorkerPool implements IDisposable {
  61969. private _workerInfos;
  61970. private _pendingActions;
  61971. /**
  61972. * Constructor
  61973. * @param workers Array of workers to use for actions
  61974. */
  61975. constructor(workers: Array<Worker>);
  61976. /**
  61977. * Terminates all workers and clears any pending actions.
  61978. */
  61979. dispose(): void;
  61980. /**
  61981. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61982. * pended until a worker has completed its action.
  61983. * @param action The action to perform. Call onComplete when the action is complete.
  61984. */
  61985. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61986. private _execute;
  61987. }
  61988. }
  61989. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61990. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61991. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61992. /**
  61993. * Class for loading KTX2 files
  61994. */
  61995. export class KhronosTextureContainer2 {
  61996. private static _WorkerPoolPromise?;
  61997. private static _Initialized;
  61998. private static _Ktx2Decoder;
  61999. /**
  62000. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62001. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62002. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62003. * Urls you can change:
  62004. * URLConfig.jsDecoderModule
  62005. * URLConfig.wasmUASTCToASTC
  62006. * URLConfig.wasmUASTCToBC7
  62007. * URLConfig.wasmUASTCToRGBA_UNORM
  62008. * URLConfig.wasmUASTCToRGBA_SRGB
  62009. * URLConfig.jsMSCTranscoder
  62010. * URLConfig.wasmMSCTranscoder
  62011. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  62012. */
  62013. static URLConfig: {
  62014. jsDecoderModule: string;
  62015. wasmUASTCToASTC: null;
  62016. wasmUASTCToBC7: null;
  62017. wasmUASTCToRGBA_UNORM: null;
  62018. wasmUASTCToRGBA_SRGB: null;
  62019. jsMSCTranscoder: null;
  62020. wasmMSCTranscoder: null;
  62021. };
  62022. /**
  62023. * Default number of workers used to handle data decoding
  62024. */
  62025. static DefaultNumWorkers: number;
  62026. private static GetDefaultNumWorkers;
  62027. private _engine;
  62028. private static _CreateWorkerPool;
  62029. /**
  62030. * Constructor
  62031. * @param engine The engine to use
  62032. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62033. */
  62034. constructor(engine: ThinEngine, numWorkers?: number);
  62035. /** @hidden */
  62036. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62037. /**
  62038. * Stop all async operations and release resources.
  62039. */
  62040. dispose(): void;
  62041. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62042. /**
  62043. * Checks if the given data starts with a KTX2 file identifier.
  62044. * @param data the data to check
  62045. * @returns true if the data is a KTX2 file or false otherwise
  62046. */
  62047. static IsValid(data: ArrayBufferView): boolean;
  62048. }
  62049. }
  62050. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  62051. import { Nullable } from "babylonjs/types";
  62052. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  62053. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  62054. /**
  62055. * Implementation of the KTX Texture Loader.
  62056. * @hidden
  62057. */
  62058. export class _KTXTextureLoader implements IInternalTextureLoader {
  62059. /**
  62060. * Defines wether the loader supports cascade loading the different faces.
  62061. */
  62062. readonly supportCascades: boolean;
  62063. /**
  62064. * This returns if the loader support the current file information.
  62065. * @param extension defines the file extension of the file being loaded
  62066. * @param mimeType defines the optional mime type of the file being loaded
  62067. * @returns true if the loader can load the specified file
  62068. */
  62069. canLoad(extension: string, mimeType?: string): boolean;
  62070. /**
  62071. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62072. * @param data contains the texture data
  62073. * @param texture defines the BabylonJS internal texture
  62074. * @param createPolynomials will be true if polynomials have been requested
  62075. * @param onLoad defines the callback to trigger once the texture is ready
  62076. * @param onError defines the callback to trigger in case of error
  62077. */
  62078. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62079. /**
  62080. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62081. * @param data contains the texture data
  62082. * @param texture defines the BabylonJS internal texture
  62083. * @param callback defines the method to call once ready to upload
  62084. */
  62085. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62086. }
  62087. }
  62088. declare module "babylonjs/Helpers/sceneHelpers" {
  62089. import { Nullable } from "babylonjs/types";
  62090. import { Mesh } from "babylonjs/Meshes/mesh";
  62091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62092. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  62093. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  62094. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  62095. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  62096. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  62097. import "babylonjs/Meshes/Builders/boxBuilder";
  62098. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  62099. /** @hidden */
  62100. export var _forceSceneHelpersToBundle: boolean;
  62101. module "babylonjs/scene" {
  62102. interface Scene {
  62103. /**
  62104. * Creates a default light for the scene.
  62105. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62106. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62107. */
  62108. createDefaultLight(replace?: boolean): void;
  62109. /**
  62110. * Creates a default camera for the scene.
  62111. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62112. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62113. * @param replace has default false, when true replaces the active camera in the scene
  62114. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62115. */
  62116. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62117. /**
  62118. * Creates a default camera and a default light.
  62119. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62120. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62121. * @param replace has the default false, when true replaces the active camera/light in the scene
  62122. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62123. */
  62124. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62125. /**
  62126. * Creates a new sky box
  62127. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62128. * @param environmentTexture defines the texture to use as environment texture
  62129. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62130. * @param scale defines the overall scale of the skybox
  62131. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62132. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62133. * @returns a new mesh holding the sky box
  62134. */
  62135. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62136. /**
  62137. * Creates a new environment
  62138. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62139. * @param options defines the options you can use to configure the environment
  62140. * @returns the new EnvironmentHelper
  62141. */
  62142. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62143. /**
  62144. * Creates a new VREXperienceHelper
  62145. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62146. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62147. * @returns a new VREXperienceHelper
  62148. */
  62149. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62150. /**
  62151. * Creates a new WebXRDefaultExperience
  62152. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62153. * @param options experience options
  62154. * @returns a promise for a new WebXRDefaultExperience
  62155. */
  62156. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62157. }
  62158. }
  62159. }
  62160. declare module "babylonjs/Helpers/videoDome" {
  62161. import { Scene } from "babylonjs/scene";
  62162. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  62163. import { TextureDome } from "babylonjs/Helpers/textureDome";
  62164. /**
  62165. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62166. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62167. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62168. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62169. */
  62170. export class VideoDome extends TextureDome<VideoTexture> {
  62171. /**
  62172. * Define the video source as a Monoscopic panoramic 360 video.
  62173. */
  62174. static readonly MODE_MONOSCOPIC: number;
  62175. /**
  62176. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62177. */
  62178. static readonly MODE_TOPBOTTOM: number;
  62179. /**
  62180. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62181. */
  62182. static readonly MODE_SIDEBYSIDE: number;
  62183. /**
  62184. * Get the video texture associated with this video dome
  62185. */
  62186. get videoTexture(): VideoTexture;
  62187. /**
  62188. * Get the video mode of this dome
  62189. */
  62190. get videoMode(): number;
  62191. /**
  62192. * Set the video mode of this dome.
  62193. * @see textureMode
  62194. */
  62195. set videoMode(value: number);
  62196. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62197. }
  62198. }
  62199. declare module "babylonjs/Helpers/index" {
  62200. export * from "babylonjs/Helpers/environmentHelper";
  62201. export * from "babylonjs/Helpers/photoDome";
  62202. export * from "babylonjs/Helpers/sceneHelpers";
  62203. export * from "babylonjs/Helpers/videoDome";
  62204. }
  62205. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  62206. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62207. import { IDisposable } from "babylonjs/scene";
  62208. import { Engine } from "babylonjs/Engines/engine";
  62209. /**
  62210. * This class can be used to get instrumentation data from a Babylon engine
  62211. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62212. */
  62213. export class EngineInstrumentation implements IDisposable {
  62214. /**
  62215. * Define the instrumented engine.
  62216. */
  62217. engine: Engine;
  62218. private _captureGPUFrameTime;
  62219. private _gpuFrameTimeToken;
  62220. private _gpuFrameTime;
  62221. private _captureShaderCompilationTime;
  62222. private _shaderCompilationTime;
  62223. private _onBeginFrameObserver;
  62224. private _onEndFrameObserver;
  62225. private _onBeforeShaderCompilationObserver;
  62226. private _onAfterShaderCompilationObserver;
  62227. /**
  62228. * Gets the perf counter used for GPU frame time
  62229. */
  62230. get gpuFrameTimeCounter(): PerfCounter;
  62231. /**
  62232. * Gets the GPU frame time capture status
  62233. */
  62234. get captureGPUFrameTime(): boolean;
  62235. /**
  62236. * Enable or disable the GPU frame time capture
  62237. */
  62238. set captureGPUFrameTime(value: boolean);
  62239. /**
  62240. * Gets the perf counter used for shader compilation time
  62241. */
  62242. get shaderCompilationTimeCounter(): PerfCounter;
  62243. /**
  62244. * Gets the shader compilation time capture status
  62245. */
  62246. get captureShaderCompilationTime(): boolean;
  62247. /**
  62248. * Enable or disable the shader compilation time capture
  62249. */
  62250. set captureShaderCompilationTime(value: boolean);
  62251. /**
  62252. * Instantiates a new engine instrumentation.
  62253. * This class can be used to get instrumentation data from a Babylon engine
  62254. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62255. * @param engine Defines the engine to instrument
  62256. */
  62257. constructor(
  62258. /**
  62259. * Define the instrumented engine.
  62260. */
  62261. engine: Engine);
  62262. /**
  62263. * Dispose and release associated resources.
  62264. */
  62265. dispose(): void;
  62266. }
  62267. }
  62268. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  62269. import { Scene, IDisposable } from "babylonjs/scene";
  62270. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  62271. /**
  62272. * This class can be used to get instrumentation data from a Babylon engine
  62273. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62274. */
  62275. export class SceneInstrumentation implements IDisposable {
  62276. /**
  62277. * Defines the scene to instrument
  62278. */
  62279. scene: Scene;
  62280. private _captureActiveMeshesEvaluationTime;
  62281. private _activeMeshesEvaluationTime;
  62282. private _captureRenderTargetsRenderTime;
  62283. private _renderTargetsRenderTime;
  62284. private _captureFrameTime;
  62285. private _frameTime;
  62286. private _captureRenderTime;
  62287. private _renderTime;
  62288. private _captureInterFrameTime;
  62289. private _interFrameTime;
  62290. private _captureParticlesRenderTime;
  62291. private _particlesRenderTime;
  62292. private _captureSpritesRenderTime;
  62293. private _spritesRenderTime;
  62294. private _capturePhysicsTime;
  62295. private _physicsTime;
  62296. private _captureAnimationsTime;
  62297. private _animationsTime;
  62298. private _captureCameraRenderTime;
  62299. private _cameraRenderTime;
  62300. private _onBeforeActiveMeshesEvaluationObserver;
  62301. private _onAfterActiveMeshesEvaluationObserver;
  62302. private _onBeforeRenderTargetsRenderObserver;
  62303. private _onAfterRenderTargetsRenderObserver;
  62304. private _onAfterRenderObserver;
  62305. private _onBeforeDrawPhaseObserver;
  62306. private _onAfterDrawPhaseObserver;
  62307. private _onBeforeAnimationsObserver;
  62308. private _onBeforeParticlesRenderingObserver;
  62309. private _onAfterParticlesRenderingObserver;
  62310. private _onBeforeSpritesRenderingObserver;
  62311. private _onAfterSpritesRenderingObserver;
  62312. private _onBeforePhysicsObserver;
  62313. private _onAfterPhysicsObserver;
  62314. private _onAfterAnimationsObserver;
  62315. private _onBeforeCameraRenderObserver;
  62316. private _onAfterCameraRenderObserver;
  62317. /**
  62318. * Gets the perf counter used for active meshes evaluation time
  62319. */
  62320. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62321. /**
  62322. * Gets the active meshes evaluation time capture status
  62323. */
  62324. get captureActiveMeshesEvaluationTime(): boolean;
  62325. /**
  62326. * Enable or disable the active meshes evaluation time capture
  62327. */
  62328. set captureActiveMeshesEvaluationTime(value: boolean);
  62329. /**
  62330. * Gets the perf counter used for render targets render time
  62331. */
  62332. get renderTargetsRenderTimeCounter(): PerfCounter;
  62333. /**
  62334. * Gets the render targets render time capture status
  62335. */
  62336. get captureRenderTargetsRenderTime(): boolean;
  62337. /**
  62338. * Enable or disable the render targets render time capture
  62339. */
  62340. set captureRenderTargetsRenderTime(value: boolean);
  62341. /**
  62342. * Gets the perf counter used for particles render time
  62343. */
  62344. get particlesRenderTimeCounter(): PerfCounter;
  62345. /**
  62346. * Gets the particles render time capture status
  62347. */
  62348. get captureParticlesRenderTime(): boolean;
  62349. /**
  62350. * Enable or disable the particles render time capture
  62351. */
  62352. set captureParticlesRenderTime(value: boolean);
  62353. /**
  62354. * Gets the perf counter used for sprites render time
  62355. */
  62356. get spritesRenderTimeCounter(): PerfCounter;
  62357. /**
  62358. * Gets the sprites render time capture status
  62359. */
  62360. get captureSpritesRenderTime(): boolean;
  62361. /**
  62362. * Enable or disable the sprites render time capture
  62363. */
  62364. set captureSpritesRenderTime(value: boolean);
  62365. /**
  62366. * Gets the perf counter used for physics time
  62367. */
  62368. get physicsTimeCounter(): PerfCounter;
  62369. /**
  62370. * Gets the physics time capture status
  62371. */
  62372. get capturePhysicsTime(): boolean;
  62373. /**
  62374. * Enable or disable the physics time capture
  62375. */
  62376. set capturePhysicsTime(value: boolean);
  62377. /**
  62378. * Gets the perf counter used for animations time
  62379. */
  62380. get animationsTimeCounter(): PerfCounter;
  62381. /**
  62382. * Gets the animations time capture status
  62383. */
  62384. get captureAnimationsTime(): boolean;
  62385. /**
  62386. * Enable or disable the animations time capture
  62387. */
  62388. set captureAnimationsTime(value: boolean);
  62389. /**
  62390. * Gets the perf counter used for frame time capture
  62391. */
  62392. get frameTimeCounter(): PerfCounter;
  62393. /**
  62394. * Gets the frame time capture status
  62395. */
  62396. get captureFrameTime(): boolean;
  62397. /**
  62398. * Enable or disable the frame time capture
  62399. */
  62400. set captureFrameTime(value: boolean);
  62401. /**
  62402. * Gets the perf counter used for inter-frames time capture
  62403. */
  62404. get interFrameTimeCounter(): PerfCounter;
  62405. /**
  62406. * Gets the inter-frames time capture status
  62407. */
  62408. get captureInterFrameTime(): boolean;
  62409. /**
  62410. * Enable or disable the inter-frames time capture
  62411. */
  62412. set captureInterFrameTime(value: boolean);
  62413. /**
  62414. * Gets the perf counter used for render time capture
  62415. */
  62416. get renderTimeCounter(): PerfCounter;
  62417. /**
  62418. * Gets the render time capture status
  62419. */
  62420. get captureRenderTime(): boolean;
  62421. /**
  62422. * Enable or disable the render time capture
  62423. */
  62424. set captureRenderTime(value: boolean);
  62425. /**
  62426. * Gets the perf counter used for camera render time capture
  62427. */
  62428. get cameraRenderTimeCounter(): PerfCounter;
  62429. /**
  62430. * Gets the camera render time capture status
  62431. */
  62432. get captureCameraRenderTime(): boolean;
  62433. /**
  62434. * Enable or disable the camera render time capture
  62435. */
  62436. set captureCameraRenderTime(value: boolean);
  62437. /**
  62438. * Gets the perf counter used for draw calls
  62439. */
  62440. get drawCallsCounter(): PerfCounter;
  62441. /**
  62442. * Instantiates a new scene instrumentation.
  62443. * This class can be used to get instrumentation data from a Babylon engine
  62444. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62445. * @param scene Defines the scene to instrument
  62446. */
  62447. constructor(
  62448. /**
  62449. * Defines the scene to instrument
  62450. */
  62451. scene: Scene);
  62452. /**
  62453. * Dispose and release associated resources.
  62454. */
  62455. dispose(): void;
  62456. }
  62457. }
  62458. declare module "babylonjs/Instrumentation/index" {
  62459. export * from "babylonjs/Instrumentation/engineInstrumentation";
  62460. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  62461. export * from "babylonjs/Instrumentation/timeToken";
  62462. }
  62463. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  62464. /** @hidden */
  62465. export var glowMapGenerationPixelShader: {
  62466. name: string;
  62467. shader: string;
  62468. };
  62469. }
  62470. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  62471. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62472. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62473. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62474. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62475. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62476. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62477. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62478. /** @hidden */
  62479. export var glowMapGenerationVertexShader: {
  62480. name: string;
  62481. shader: string;
  62482. };
  62483. }
  62484. declare module "babylonjs/Layers/effectLayer" {
  62485. import { Observable } from "babylonjs/Misc/observable";
  62486. import { Nullable } from "babylonjs/types";
  62487. import { Camera } from "babylonjs/Cameras/camera";
  62488. import { Scene } from "babylonjs/scene";
  62489. import { ISize } from "babylonjs/Maths/math.size";
  62490. import { Color4 } from "babylonjs/Maths/math.color";
  62491. import { Engine } from "babylonjs/Engines/engine";
  62492. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62494. import { Mesh } from "babylonjs/Meshes/mesh";
  62495. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62496. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62497. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62498. import { Effect } from "babylonjs/Materials/effect";
  62499. import { Material } from "babylonjs/Materials/material";
  62500. import "babylonjs/Shaders/glowMapGeneration.fragment";
  62501. import "babylonjs/Shaders/glowMapGeneration.vertex";
  62502. /**
  62503. * Effect layer options. This helps customizing the behaviour
  62504. * of the effect layer.
  62505. */
  62506. export interface IEffectLayerOptions {
  62507. /**
  62508. * Multiplication factor apply to the canvas size to compute the render target size
  62509. * used to generated the objects (the smaller the faster).
  62510. */
  62511. mainTextureRatio: number;
  62512. /**
  62513. * Enforces a fixed size texture to ensure effect stability across devices.
  62514. */
  62515. mainTextureFixedSize?: number;
  62516. /**
  62517. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62518. */
  62519. alphaBlendingMode: number;
  62520. /**
  62521. * The camera attached to the layer.
  62522. */
  62523. camera: Nullable<Camera>;
  62524. /**
  62525. * The rendering group to draw the layer in.
  62526. */
  62527. renderingGroupId: number;
  62528. }
  62529. /**
  62530. * The effect layer Helps adding post process effect blended with the main pass.
  62531. *
  62532. * This can be for instance use to generate glow or higlight effects on the scene.
  62533. *
  62534. * The effect layer class can not be used directly and is intented to inherited from to be
  62535. * customized per effects.
  62536. */
  62537. export abstract class EffectLayer {
  62538. private _vertexBuffers;
  62539. private _indexBuffer;
  62540. private _cachedDefines;
  62541. private _effectLayerMapGenerationEffect;
  62542. private _effectLayerOptions;
  62543. private _mergeEffect;
  62544. protected _scene: Scene;
  62545. protected _engine: Engine;
  62546. protected _maxSize: number;
  62547. protected _mainTextureDesiredSize: ISize;
  62548. protected _mainTexture: RenderTargetTexture;
  62549. protected _shouldRender: boolean;
  62550. protected _postProcesses: PostProcess[];
  62551. protected _textures: BaseTexture[];
  62552. protected _emissiveTextureAndColor: {
  62553. texture: Nullable<BaseTexture>;
  62554. color: Color4;
  62555. };
  62556. /**
  62557. * The name of the layer
  62558. */
  62559. name: string;
  62560. /**
  62561. * The clear color of the texture used to generate the glow map.
  62562. */
  62563. neutralColor: Color4;
  62564. /**
  62565. * Specifies whether the highlight layer is enabled or not.
  62566. */
  62567. isEnabled: boolean;
  62568. /**
  62569. * Gets the camera attached to the layer.
  62570. */
  62571. get camera(): Nullable<Camera>;
  62572. /**
  62573. * Gets the rendering group id the layer should render in.
  62574. */
  62575. get renderingGroupId(): number;
  62576. set renderingGroupId(renderingGroupId: number);
  62577. /**
  62578. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62579. */
  62580. disableBoundingBoxesFromEffectLayer: boolean;
  62581. /**
  62582. * An event triggered when the effect layer has been disposed.
  62583. */
  62584. onDisposeObservable: Observable<EffectLayer>;
  62585. /**
  62586. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62587. */
  62588. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62589. /**
  62590. * An event triggered when the generated texture is being merged in the scene.
  62591. */
  62592. onBeforeComposeObservable: Observable<EffectLayer>;
  62593. /**
  62594. * An event triggered when the mesh is rendered into the effect render target.
  62595. */
  62596. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62597. /**
  62598. * An event triggered after the mesh has been rendered into the effect render target.
  62599. */
  62600. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62601. /**
  62602. * An event triggered when the generated texture has been merged in the scene.
  62603. */
  62604. onAfterComposeObservable: Observable<EffectLayer>;
  62605. /**
  62606. * An event triggered when the efffect layer changes its size.
  62607. */
  62608. onSizeChangedObservable: Observable<EffectLayer>;
  62609. /** @hidden */
  62610. static _SceneComponentInitialization: (scene: Scene) => void;
  62611. /**
  62612. * Instantiates a new effect Layer and references it in the scene.
  62613. * @param name The name of the layer
  62614. * @param scene The scene to use the layer in
  62615. */
  62616. constructor(
  62617. /** The Friendly of the effect in the scene */
  62618. name: string, scene: Scene);
  62619. /**
  62620. * Get the effect name of the layer.
  62621. * @return The effect name
  62622. */
  62623. abstract getEffectName(): string;
  62624. /**
  62625. * Checks for the readiness of the element composing the layer.
  62626. * @param subMesh the mesh to check for
  62627. * @param useInstances specify whether or not to use instances to render the mesh
  62628. * @return true if ready otherwise, false
  62629. */
  62630. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62631. /**
  62632. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62633. * @returns true if the effect requires stencil during the main canvas render pass.
  62634. */
  62635. abstract needStencil(): boolean;
  62636. /**
  62637. * Create the merge effect. This is the shader use to blit the information back
  62638. * to the main canvas at the end of the scene rendering.
  62639. * @returns The effect containing the shader used to merge the effect on the main canvas
  62640. */
  62641. protected abstract _createMergeEffect(): Effect;
  62642. /**
  62643. * Creates the render target textures and post processes used in the effect layer.
  62644. */
  62645. protected abstract _createTextureAndPostProcesses(): void;
  62646. /**
  62647. * Implementation specific of rendering the generating effect on the main canvas.
  62648. * @param effect The effect used to render through
  62649. */
  62650. protected abstract _internalRender(effect: Effect): void;
  62651. /**
  62652. * Sets the required values for both the emissive texture and and the main color.
  62653. */
  62654. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62655. /**
  62656. * Free any resources and references associated to a mesh.
  62657. * Internal use
  62658. * @param mesh The mesh to free.
  62659. */
  62660. abstract _disposeMesh(mesh: Mesh): void;
  62661. /**
  62662. * Serializes this layer (Glow or Highlight for example)
  62663. * @returns a serialized layer object
  62664. */
  62665. abstract serialize?(): any;
  62666. /**
  62667. * Initializes the effect layer with the required options.
  62668. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62669. */
  62670. protected _init(options: Partial<IEffectLayerOptions>): void;
  62671. /**
  62672. * Generates the index buffer of the full screen quad blending to the main canvas.
  62673. */
  62674. private _generateIndexBuffer;
  62675. /**
  62676. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62677. */
  62678. private _generateVertexBuffer;
  62679. /**
  62680. * Sets the main texture desired size which is the closest power of two
  62681. * of the engine canvas size.
  62682. */
  62683. private _setMainTextureSize;
  62684. /**
  62685. * Creates the main texture for the effect layer.
  62686. */
  62687. protected _createMainTexture(): void;
  62688. /**
  62689. * Adds specific effects defines.
  62690. * @param defines The defines to add specifics to.
  62691. */
  62692. protected _addCustomEffectDefines(defines: string[]): void;
  62693. /**
  62694. * Checks for the readiness of the element composing the layer.
  62695. * @param subMesh the mesh to check for
  62696. * @param useInstances specify whether or not to use instances to render the mesh
  62697. * @param emissiveTexture the associated emissive texture used to generate the glow
  62698. * @return true if ready otherwise, false
  62699. */
  62700. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62701. /**
  62702. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62703. */
  62704. render(): void;
  62705. /**
  62706. * Determine if a given mesh will be used in the current effect.
  62707. * @param mesh mesh to test
  62708. * @returns true if the mesh will be used
  62709. */
  62710. hasMesh(mesh: AbstractMesh): boolean;
  62711. /**
  62712. * Returns true if the layer contains information to display, otherwise false.
  62713. * @returns true if the glow layer should be rendered
  62714. */
  62715. shouldRender(): boolean;
  62716. /**
  62717. * Returns true if the mesh should render, otherwise false.
  62718. * @param mesh The mesh to render
  62719. * @returns true if it should render otherwise false
  62720. */
  62721. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62722. /**
  62723. * Returns true if the mesh can be rendered, otherwise false.
  62724. * @param mesh The mesh to render
  62725. * @param material The material used on the mesh
  62726. * @returns true if it can be rendered otherwise false
  62727. */
  62728. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62729. /**
  62730. * Returns true if the mesh should render, otherwise false.
  62731. * @param mesh The mesh to render
  62732. * @returns true if it should render otherwise false
  62733. */
  62734. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62735. /**
  62736. * Renders the submesh passed in parameter to the generation map.
  62737. */
  62738. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62739. /**
  62740. * Defines whether the current material of the mesh should be use to render the effect.
  62741. * @param mesh defines the current mesh to render
  62742. */
  62743. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62744. /**
  62745. * Rebuild the required buffers.
  62746. * @hidden Internal use only.
  62747. */
  62748. _rebuild(): void;
  62749. /**
  62750. * Dispose only the render target textures and post process.
  62751. */
  62752. private _disposeTextureAndPostProcesses;
  62753. /**
  62754. * Dispose the highlight layer and free resources.
  62755. */
  62756. dispose(): void;
  62757. /**
  62758. * Gets the class name of the effect layer
  62759. * @returns the string with the class name of the effect layer
  62760. */
  62761. getClassName(): string;
  62762. /**
  62763. * Creates an effect layer from parsed effect layer data
  62764. * @param parsedEffectLayer defines effect layer data
  62765. * @param scene defines the current scene
  62766. * @param rootUrl defines the root URL containing the effect layer information
  62767. * @returns a parsed effect Layer
  62768. */
  62769. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62770. }
  62771. }
  62772. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62773. import { Scene } from "babylonjs/scene";
  62774. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62775. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62776. import { AbstractScene } from "babylonjs/abstractScene";
  62777. module "babylonjs/abstractScene" {
  62778. interface AbstractScene {
  62779. /**
  62780. * The list of effect layers (highlights/glow) added to the scene
  62781. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62782. * @see https://doc.babylonjs.com/how_to/glow_layer
  62783. */
  62784. effectLayers: Array<EffectLayer>;
  62785. /**
  62786. * Removes the given effect layer from this scene.
  62787. * @param toRemove defines the effect layer to remove
  62788. * @returns the index of the removed effect layer
  62789. */
  62790. removeEffectLayer(toRemove: EffectLayer): number;
  62791. /**
  62792. * Adds the given effect layer to this scene
  62793. * @param newEffectLayer defines the effect layer to add
  62794. */
  62795. addEffectLayer(newEffectLayer: EffectLayer): void;
  62796. }
  62797. }
  62798. /**
  62799. * Defines the layer scene component responsible to manage any effect layers
  62800. * in a given scene.
  62801. */
  62802. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62803. /**
  62804. * The component name helpfull to identify the component in the list of scene components.
  62805. */
  62806. readonly name: string;
  62807. /**
  62808. * The scene the component belongs to.
  62809. */
  62810. scene: Scene;
  62811. private _engine;
  62812. private _renderEffects;
  62813. private _needStencil;
  62814. private _previousStencilState;
  62815. /**
  62816. * Creates a new instance of the component for the given scene
  62817. * @param scene Defines the scene to register the component in
  62818. */
  62819. constructor(scene: Scene);
  62820. /**
  62821. * Registers the component in a given scene
  62822. */
  62823. register(): void;
  62824. /**
  62825. * Rebuilds the elements related to this component in case of
  62826. * context lost for instance.
  62827. */
  62828. rebuild(): void;
  62829. /**
  62830. * Serializes the component data to the specified json object
  62831. * @param serializationObject The object to serialize to
  62832. */
  62833. serialize(serializationObject: any): void;
  62834. /**
  62835. * Adds all the elements from the container to the scene
  62836. * @param container the container holding the elements
  62837. */
  62838. addFromContainer(container: AbstractScene): void;
  62839. /**
  62840. * Removes all the elements in the container from the scene
  62841. * @param container contains the elements to remove
  62842. * @param dispose if the removed element should be disposed (default: false)
  62843. */
  62844. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62845. /**
  62846. * Disposes the component and the associated ressources.
  62847. */
  62848. dispose(): void;
  62849. private _isReadyForMesh;
  62850. private _renderMainTexture;
  62851. private _setStencil;
  62852. private _setStencilBack;
  62853. private _draw;
  62854. private _drawCamera;
  62855. private _drawRenderingGroup;
  62856. }
  62857. }
  62858. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62859. /** @hidden */
  62860. export var glowMapMergePixelShader: {
  62861. name: string;
  62862. shader: string;
  62863. };
  62864. }
  62865. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62866. /** @hidden */
  62867. export var glowMapMergeVertexShader: {
  62868. name: string;
  62869. shader: string;
  62870. };
  62871. }
  62872. declare module "babylonjs/Layers/glowLayer" {
  62873. import { Nullable } from "babylonjs/types";
  62874. import { Camera } from "babylonjs/Cameras/camera";
  62875. import { Scene } from "babylonjs/scene";
  62876. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62878. import { Mesh } from "babylonjs/Meshes/mesh";
  62879. import { Texture } from "babylonjs/Materials/Textures/texture";
  62880. import { Effect } from "babylonjs/Materials/effect";
  62881. import { Material } from "babylonjs/Materials/material";
  62882. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62883. import { Color4 } from "babylonjs/Maths/math.color";
  62884. import "babylonjs/Shaders/glowMapMerge.fragment";
  62885. import "babylonjs/Shaders/glowMapMerge.vertex";
  62886. import "babylonjs/Layers/effectLayerSceneComponent";
  62887. module "babylonjs/abstractScene" {
  62888. interface AbstractScene {
  62889. /**
  62890. * Return a the first highlight layer of the scene with a given name.
  62891. * @param name The name of the highlight layer to look for.
  62892. * @return The highlight layer if found otherwise null.
  62893. */
  62894. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62895. }
  62896. }
  62897. /**
  62898. * Glow layer options. This helps customizing the behaviour
  62899. * of the glow layer.
  62900. */
  62901. export interface IGlowLayerOptions {
  62902. /**
  62903. * Multiplication factor apply to the canvas size to compute the render target size
  62904. * used to generated the glowing objects (the smaller the faster).
  62905. */
  62906. mainTextureRatio: number;
  62907. /**
  62908. * Enforces a fixed size texture to ensure resize independant blur.
  62909. */
  62910. mainTextureFixedSize?: number;
  62911. /**
  62912. * How big is the kernel of the blur texture.
  62913. */
  62914. blurKernelSize: number;
  62915. /**
  62916. * The camera attached to the layer.
  62917. */
  62918. camera: Nullable<Camera>;
  62919. /**
  62920. * Enable MSAA by chosing the number of samples.
  62921. */
  62922. mainTextureSamples?: number;
  62923. /**
  62924. * The rendering group to draw the layer in.
  62925. */
  62926. renderingGroupId: number;
  62927. }
  62928. /**
  62929. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62930. *
  62931. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62932. *
  62933. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62934. */
  62935. export class GlowLayer extends EffectLayer {
  62936. /**
  62937. * Effect Name of the layer.
  62938. */
  62939. static readonly EffectName: string;
  62940. /**
  62941. * The default blur kernel size used for the glow.
  62942. */
  62943. static DefaultBlurKernelSize: number;
  62944. /**
  62945. * The default texture size ratio used for the glow.
  62946. */
  62947. static DefaultTextureRatio: number;
  62948. /**
  62949. * Sets the kernel size of the blur.
  62950. */
  62951. set blurKernelSize(value: number);
  62952. /**
  62953. * Gets the kernel size of the blur.
  62954. */
  62955. get blurKernelSize(): number;
  62956. /**
  62957. * Sets the glow intensity.
  62958. */
  62959. set intensity(value: number);
  62960. /**
  62961. * Gets the glow intensity.
  62962. */
  62963. get intensity(): number;
  62964. private _options;
  62965. private _intensity;
  62966. private _horizontalBlurPostprocess1;
  62967. private _verticalBlurPostprocess1;
  62968. private _horizontalBlurPostprocess2;
  62969. private _verticalBlurPostprocess2;
  62970. private _blurTexture1;
  62971. private _blurTexture2;
  62972. private _postProcesses1;
  62973. private _postProcesses2;
  62974. private _includedOnlyMeshes;
  62975. private _excludedMeshes;
  62976. private _meshesUsingTheirOwnMaterials;
  62977. /**
  62978. * Callback used to let the user override the color selection on a per mesh basis
  62979. */
  62980. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62981. /**
  62982. * Callback used to let the user override the texture selection on a per mesh basis
  62983. */
  62984. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62985. /**
  62986. * Instantiates a new glow Layer and references it to the scene.
  62987. * @param name The name of the layer
  62988. * @param scene The scene to use the layer in
  62989. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62990. */
  62991. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62992. /**
  62993. * Get the effect name of the layer.
  62994. * @return The effect name
  62995. */
  62996. getEffectName(): string;
  62997. /**
  62998. * Create the merge effect. This is the shader use to blit the information back
  62999. * to the main canvas at the end of the scene rendering.
  63000. */
  63001. protected _createMergeEffect(): Effect;
  63002. /**
  63003. * Creates the render target textures and post processes used in the glow layer.
  63004. */
  63005. protected _createTextureAndPostProcesses(): void;
  63006. /**
  63007. * Checks for the readiness of the element composing the layer.
  63008. * @param subMesh the mesh to check for
  63009. * @param useInstances specify wether or not to use instances to render the mesh
  63010. * @param emissiveTexture the associated emissive texture used to generate the glow
  63011. * @return true if ready otherwise, false
  63012. */
  63013. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63014. /**
  63015. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63016. */
  63017. needStencil(): boolean;
  63018. /**
  63019. * Returns true if the mesh can be rendered, otherwise false.
  63020. * @param mesh The mesh to render
  63021. * @param material The material used on the mesh
  63022. * @returns true if it can be rendered otherwise false
  63023. */
  63024. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63025. /**
  63026. * Implementation specific of rendering the generating effect on the main canvas.
  63027. * @param effect The effect used to render through
  63028. */
  63029. protected _internalRender(effect: Effect): void;
  63030. /**
  63031. * Sets the required values for both the emissive texture and and the main color.
  63032. */
  63033. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63034. /**
  63035. * Returns true if the mesh should render, otherwise false.
  63036. * @param mesh The mesh to render
  63037. * @returns true if it should render otherwise false
  63038. */
  63039. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63040. /**
  63041. * Adds specific effects defines.
  63042. * @param defines The defines to add specifics to.
  63043. */
  63044. protected _addCustomEffectDefines(defines: string[]): void;
  63045. /**
  63046. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63047. * @param mesh The mesh to exclude from the glow layer
  63048. */
  63049. addExcludedMesh(mesh: Mesh): void;
  63050. /**
  63051. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63052. * @param mesh The mesh to remove
  63053. */
  63054. removeExcludedMesh(mesh: Mesh): void;
  63055. /**
  63056. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63057. * @param mesh The mesh to include in the glow layer
  63058. */
  63059. addIncludedOnlyMesh(mesh: Mesh): void;
  63060. /**
  63061. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63062. * @param mesh The mesh to remove
  63063. */
  63064. removeIncludedOnlyMesh(mesh: Mesh): void;
  63065. /**
  63066. * Determine if a given mesh will be used in the glow layer
  63067. * @param mesh The mesh to test
  63068. * @returns true if the mesh will be highlighted by the current glow layer
  63069. */
  63070. hasMesh(mesh: AbstractMesh): boolean;
  63071. /**
  63072. * Defines whether the current material of the mesh should be use to render the effect.
  63073. * @param mesh defines the current mesh to render
  63074. */
  63075. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63076. /**
  63077. * Add a mesh to be rendered through its own material and not with emissive only.
  63078. * @param mesh The mesh for which we need to use its material
  63079. */
  63080. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63081. /**
  63082. * Remove a mesh from being rendered through its own material and not with emissive only.
  63083. * @param mesh The mesh for which we need to not use its material
  63084. */
  63085. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63086. /**
  63087. * Free any resources and references associated to a mesh.
  63088. * Internal use
  63089. * @param mesh The mesh to free.
  63090. * @hidden
  63091. */
  63092. _disposeMesh(mesh: Mesh): void;
  63093. /**
  63094. * Gets the class name of the effect layer
  63095. * @returns the string with the class name of the effect layer
  63096. */
  63097. getClassName(): string;
  63098. /**
  63099. * Serializes this glow layer
  63100. * @returns a serialized glow layer object
  63101. */
  63102. serialize(): any;
  63103. /**
  63104. * Creates a Glow Layer from parsed glow layer data
  63105. * @param parsedGlowLayer defines glow layer data
  63106. * @param scene defines the current scene
  63107. * @param rootUrl defines the root URL containing the glow layer information
  63108. * @returns a parsed Glow Layer
  63109. */
  63110. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63111. }
  63112. }
  63113. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  63114. /** @hidden */
  63115. export var glowBlurPostProcessPixelShader: {
  63116. name: string;
  63117. shader: string;
  63118. };
  63119. }
  63120. declare module "babylonjs/Layers/highlightLayer" {
  63121. import { Observable } from "babylonjs/Misc/observable";
  63122. import { Nullable } from "babylonjs/types";
  63123. import { Camera } from "babylonjs/Cameras/camera";
  63124. import { Scene } from "babylonjs/scene";
  63125. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63127. import { Mesh } from "babylonjs/Meshes/mesh";
  63128. import { Effect } from "babylonjs/Materials/effect";
  63129. import { Material } from "babylonjs/Materials/material";
  63130. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  63131. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63132. import "babylonjs/Shaders/glowMapMerge.fragment";
  63133. import "babylonjs/Shaders/glowMapMerge.vertex";
  63134. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  63135. module "babylonjs/abstractScene" {
  63136. interface AbstractScene {
  63137. /**
  63138. * Return a the first highlight layer of the scene with a given name.
  63139. * @param name The name of the highlight layer to look for.
  63140. * @return The highlight layer if found otherwise null.
  63141. */
  63142. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63143. }
  63144. }
  63145. /**
  63146. * Highlight layer options. This helps customizing the behaviour
  63147. * of the highlight layer.
  63148. */
  63149. export interface IHighlightLayerOptions {
  63150. /**
  63151. * Multiplication factor apply to the canvas size to compute the render target size
  63152. * used to generated the glowing objects (the smaller the faster).
  63153. */
  63154. mainTextureRatio: number;
  63155. /**
  63156. * Enforces a fixed size texture to ensure resize independant blur.
  63157. */
  63158. mainTextureFixedSize?: number;
  63159. /**
  63160. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63161. * of the picture to blur (the smaller the faster).
  63162. */
  63163. blurTextureSizeRatio: number;
  63164. /**
  63165. * How big in texel of the blur texture is the vertical blur.
  63166. */
  63167. blurVerticalSize: number;
  63168. /**
  63169. * How big in texel of the blur texture is the horizontal blur.
  63170. */
  63171. blurHorizontalSize: number;
  63172. /**
  63173. * Alpha blending mode used to apply the blur. Default is combine.
  63174. */
  63175. alphaBlendingMode: number;
  63176. /**
  63177. * The camera attached to the layer.
  63178. */
  63179. camera: Nullable<Camera>;
  63180. /**
  63181. * Should we display highlight as a solid stroke?
  63182. */
  63183. isStroke?: boolean;
  63184. /**
  63185. * The rendering group to draw the layer in.
  63186. */
  63187. renderingGroupId: number;
  63188. }
  63189. /**
  63190. * The highlight layer Helps adding a glow effect around a mesh.
  63191. *
  63192. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63193. * glowy meshes to your scene.
  63194. *
  63195. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63196. */
  63197. export class HighlightLayer extends EffectLayer {
  63198. name: string;
  63199. /**
  63200. * Effect Name of the highlight layer.
  63201. */
  63202. static readonly EffectName: string;
  63203. /**
  63204. * The neutral color used during the preparation of the glow effect.
  63205. * This is black by default as the blend operation is a blend operation.
  63206. */
  63207. static NeutralColor: Color4;
  63208. /**
  63209. * Stencil value used for glowing meshes.
  63210. */
  63211. static GlowingMeshStencilReference: number;
  63212. /**
  63213. * Stencil value used for the other meshes in the scene.
  63214. */
  63215. static NormalMeshStencilReference: number;
  63216. /**
  63217. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63218. */
  63219. innerGlow: boolean;
  63220. /**
  63221. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63222. */
  63223. outerGlow: boolean;
  63224. /**
  63225. * Specifies the horizontal size of the blur.
  63226. */
  63227. set blurHorizontalSize(value: number);
  63228. /**
  63229. * Specifies the vertical size of the blur.
  63230. */
  63231. set blurVerticalSize(value: number);
  63232. /**
  63233. * Gets the horizontal size of the blur.
  63234. */
  63235. get blurHorizontalSize(): number;
  63236. /**
  63237. * Gets the vertical size of the blur.
  63238. */
  63239. get blurVerticalSize(): number;
  63240. /**
  63241. * An event triggered when the highlight layer is being blurred.
  63242. */
  63243. onBeforeBlurObservable: Observable<HighlightLayer>;
  63244. /**
  63245. * An event triggered when the highlight layer has been blurred.
  63246. */
  63247. onAfterBlurObservable: Observable<HighlightLayer>;
  63248. private _instanceGlowingMeshStencilReference;
  63249. private _options;
  63250. private _downSamplePostprocess;
  63251. private _horizontalBlurPostprocess;
  63252. private _verticalBlurPostprocess;
  63253. private _blurTexture;
  63254. private _meshes;
  63255. private _excludedMeshes;
  63256. /**
  63257. * Instantiates a new highlight Layer and references it to the scene..
  63258. * @param name The name of the layer
  63259. * @param scene The scene to use the layer in
  63260. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63261. */
  63262. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63263. /**
  63264. * Get the effect name of the layer.
  63265. * @return The effect name
  63266. */
  63267. getEffectName(): string;
  63268. /**
  63269. * Create the merge effect. This is the shader use to blit the information back
  63270. * to the main canvas at the end of the scene rendering.
  63271. */
  63272. protected _createMergeEffect(): Effect;
  63273. /**
  63274. * Creates the render target textures and post processes used in the highlight layer.
  63275. */
  63276. protected _createTextureAndPostProcesses(): void;
  63277. /**
  63278. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63279. */
  63280. needStencil(): boolean;
  63281. /**
  63282. * Checks for the readiness of the element composing the layer.
  63283. * @param subMesh the mesh to check for
  63284. * @param useInstances specify wether or not to use instances to render the mesh
  63285. * @param emissiveTexture the associated emissive texture used to generate the glow
  63286. * @return true if ready otherwise, false
  63287. */
  63288. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63289. /**
  63290. * Implementation specific of rendering the generating effect on the main canvas.
  63291. * @param effect The effect used to render through
  63292. */
  63293. protected _internalRender(effect: Effect): void;
  63294. /**
  63295. * Returns true if the layer contains information to display, otherwise false.
  63296. */
  63297. shouldRender(): boolean;
  63298. /**
  63299. * Returns true if the mesh should render, otherwise false.
  63300. * @param mesh The mesh to render
  63301. * @returns true if it should render otherwise false
  63302. */
  63303. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63304. /**
  63305. * Returns true if the mesh can be rendered, otherwise false.
  63306. * @param mesh The mesh to render
  63307. * @param material The material used on the mesh
  63308. * @returns true if it can be rendered otherwise false
  63309. */
  63310. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63311. /**
  63312. * Adds specific effects defines.
  63313. * @param defines The defines to add specifics to.
  63314. */
  63315. protected _addCustomEffectDefines(defines: string[]): void;
  63316. /**
  63317. * Sets the required values for both the emissive texture and and the main color.
  63318. */
  63319. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63320. /**
  63321. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63322. * @param mesh The mesh to exclude from the highlight layer
  63323. */
  63324. addExcludedMesh(mesh: Mesh): void;
  63325. /**
  63326. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63327. * @param mesh The mesh to highlight
  63328. */
  63329. removeExcludedMesh(mesh: Mesh): void;
  63330. /**
  63331. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63332. * @param mesh mesh to test
  63333. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63334. */
  63335. hasMesh(mesh: AbstractMesh): boolean;
  63336. /**
  63337. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63338. * @param mesh The mesh to highlight
  63339. * @param color The color of the highlight
  63340. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63341. */
  63342. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63343. /**
  63344. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63345. * @param mesh The mesh to highlight
  63346. */
  63347. removeMesh(mesh: Mesh): void;
  63348. /**
  63349. * Remove all the meshes currently referenced in the highlight layer
  63350. */
  63351. removeAllMeshes(): void;
  63352. /**
  63353. * Force the stencil to the normal expected value for none glowing parts
  63354. */
  63355. private _defaultStencilReference;
  63356. /**
  63357. * Free any resources and references associated to a mesh.
  63358. * Internal use
  63359. * @param mesh The mesh to free.
  63360. * @hidden
  63361. */
  63362. _disposeMesh(mesh: Mesh): void;
  63363. /**
  63364. * Dispose the highlight layer and free resources.
  63365. */
  63366. dispose(): void;
  63367. /**
  63368. * Gets the class name of the effect layer
  63369. * @returns the string with the class name of the effect layer
  63370. */
  63371. getClassName(): string;
  63372. /**
  63373. * Serializes this Highlight layer
  63374. * @returns a serialized Highlight layer object
  63375. */
  63376. serialize(): any;
  63377. /**
  63378. * Creates a Highlight layer from parsed Highlight layer data
  63379. * @param parsedHightlightLayer defines the Highlight layer data
  63380. * @param scene defines the current scene
  63381. * @param rootUrl defines the root URL containing the Highlight layer information
  63382. * @returns a parsed Highlight layer
  63383. */
  63384. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63385. }
  63386. }
  63387. declare module "babylonjs/Layers/layerSceneComponent" {
  63388. import { Scene } from "babylonjs/scene";
  63389. import { ISceneComponent } from "babylonjs/sceneComponent";
  63390. import { Layer } from "babylonjs/Layers/layer";
  63391. import { AbstractScene } from "babylonjs/abstractScene";
  63392. module "babylonjs/abstractScene" {
  63393. interface AbstractScene {
  63394. /**
  63395. * The list of layers (background and foreground) of the scene
  63396. */
  63397. layers: Array<Layer>;
  63398. }
  63399. }
  63400. /**
  63401. * Defines the layer scene component responsible to manage any layers
  63402. * in a given scene.
  63403. */
  63404. export class LayerSceneComponent implements ISceneComponent {
  63405. /**
  63406. * The component name helpfull to identify the component in the list of scene components.
  63407. */
  63408. readonly name: string;
  63409. /**
  63410. * The scene the component belongs to.
  63411. */
  63412. scene: Scene;
  63413. private _engine;
  63414. /**
  63415. * Creates a new instance of the component for the given scene
  63416. * @param scene Defines the scene to register the component in
  63417. */
  63418. constructor(scene: Scene);
  63419. /**
  63420. * Registers the component in a given scene
  63421. */
  63422. register(): void;
  63423. /**
  63424. * Rebuilds the elements related to this component in case of
  63425. * context lost for instance.
  63426. */
  63427. rebuild(): void;
  63428. /**
  63429. * Disposes the component and the associated ressources.
  63430. */
  63431. dispose(): void;
  63432. private _draw;
  63433. private _drawCameraPredicate;
  63434. private _drawCameraBackground;
  63435. private _drawCameraForeground;
  63436. private _drawRenderTargetPredicate;
  63437. private _drawRenderTargetBackground;
  63438. private _drawRenderTargetForeground;
  63439. /**
  63440. * Adds all the elements from the container to the scene
  63441. * @param container the container holding the elements
  63442. */
  63443. addFromContainer(container: AbstractScene): void;
  63444. /**
  63445. * Removes all the elements in the container from the scene
  63446. * @param container contains the elements to remove
  63447. * @param dispose if the removed element should be disposed (default: false)
  63448. */
  63449. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63450. }
  63451. }
  63452. declare module "babylonjs/Shaders/layer.fragment" {
  63453. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63454. /** @hidden */
  63455. export var layerPixelShader: {
  63456. name: string;
  63457. shader: string;
  63458. };
  63459. }
  63460. declare module "babylonjs/Shaders/layer.vertex" {
  63461. /** @hidden */
  63462. export var layerVertexShader: {
  63463. name: string;
  63464. shader: string;
  63465. };
  63466. }
  63467. declare module "babylonjs/Layers/layer" {
  63468. import { Observable } from "babylonjs/Misc/observable";
  63469. import { Nullable } from "babylonjs/types";
  63470. import { Scene } from "babylonjs/scene";
  63471. import { Vector2 } from "babylonjs/Maths/math.vector";
  63472. import { Color4 } from "babylonjs/Maths/math.color";
  63473. import { Texture } from "babylonjs/Materials/Textures/texture";
  63474. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63475. import "babylonjs/Shaders/layer.fragment";
  63476. import "babylonjs/Shaders/layer.vertex";
  63477. /**
  63478. * This represents a full screen 2d layer.
  63479. * This can be useful to display a picture in the background of your scene for instance.
  63480. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63481. */
  63482. export class Layer {
  63483. /**
  63484. * Define the name of the layer.
  63485. */
  63486. name: string;
  63487. /**
  63488. * Define the texture the layer should display.
  63489. */
  63490. texture: Nullable<Texture>;
  63491. /**
  63492. * Is the layer in background or foreground.
  63493. */
  63494. isBackground: boolean;
  63495. /**
  63496. * Define the color of the layer (instead of texture).
  63497. */
  63498. color: Color4;
  63499. /**
  63500. * Define the scale of the layer in order to zoom in out of the texture.
  63501. */
  63502. scale: Vector2;
  63503. /**
  63504. * Define an offset for the layer in order to shift the texture.
  63505. */
  63506. offset: Vector2;
  63507. /**
  63508. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63509. */
  63510. alphaBlendingMode: number;
  63511. /**
  63512. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63513. * Alpha test will not mix with the background color in case of transparency.
  63514. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63515. */
  63516. alphaTest: boolean;
  63517. /**
  63518. * Define a mask to restrict the layer to only some of the scene cameras.
  63519. */
  63520. layerMask: number;
  63521. /**
  63522. * Define the list of render target the layer is visible into.
  63523. */
  63524. renderTargetTextures: RenderTargetTexture[];
  63525. /**
  63526. * Define if the layer is only used in renderTarget or if it also
  63527. * renders in the main frame buffer of the canvas.
  63528. */
  63529. renderOnlyInRenderTargetTextures: boolean;
  63530. private _scene;
  63531. private _vertexBuffers;
  63532. private _indexBuffer;
  63533. private _effect;
  63534. private _previousDefines;
  63535. /**
  63536. * An event triggered when the layer is disposed.
  63537. */
  63538. onDisposeObservable: Observable<Layer>;
  63539. private _onDisposeObserver;
  63540. /**
  63541. * Back compatibility with callback before the onDisposeObservable existed.
  63542. * The set callback will be triggered when the layer has been disposed.
  63543. */
  63544. set onDispose(callback: () => void);
  63545. /**
  63546. * An event triggered before rendering the scene
  63547. */
  63548. onBeforeRenderObservable: Observable<Layer>;
  63549. private _onBeforeRenderObserver;
  63550. /**
  63551. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63552. * The set callback will be triggered just before rendering the layer.
  63553. */
  63554. set onBeforeRender(callback: () => void);
  63555. /**
  63556. * An event triggered after rendering the scene
  63557. */
  63558. onAfterRenderObservable: Observable<Layer>;
  63559. private _onAfterRenderObserver;
  63560. /**
  63561. * Back compatibility with callback before the onAfterRenderObservable existed.
  63562. * The set callback will be triggered just after rendering the layer.
  63563. */
  63564. set onAfterRender(callback: () => void);
  63565. /**
  63566. * Instantiates a new layer.
  63567. * This represents a full screen 2d layer.
  63568. * This can be useful to display a picture in the background of your scene for instance.
  63569. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63570. * @param name Define the name of the layer in the scene
  63571. * @param imgUrl Define the url of the texture to display in the layer
  63572. * @param scene Define the scene the layer belongs to
  63573. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63574. * @param color Defines a color for the layer
  63575. */
  63576. constructor(
  63577. /**
  63578. * Define the name of the layer.
  63579. */
  63580. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63581. private _createIndexBuffer;
  63582. /** @hidden */
  63583. _rebuild(): void;
  63584. /**
  63585. * Renders the layer in the scene.
  63586. */
  63587. render(): void;
  63588. /**
  63589. * Disposes and releases the associated ressources.
  63590. */
  63591. dispose(): void;
  63592. }
  63593. }
  63594. declare module "babylonjs/Layers/index" {
  63595. export * from "babylonjs/Layers/effectLayer";
  63596. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63597. export * from "babylonjs/Layers/glowLayer";
  63598. export * from "babylonjs/Layers/highlightLayer";
  63599. export * from "babylonjs/Layers/layer";
  63600. export * from "babylonjs/Layers/layerSceneComponent";
  63601. }
  63602. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63603. /** @hidden */
  63604. export var lensFlarePixelShader: {
  63605. name: string;
  63606. shader: string;
  63607. };
  63608. }
  63609. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63610. /** @hidden */
  63611. export var lensFlareVertexShader: {
  63612. name: string;
  63613. shader: string;
  63614. };
  63615. }
  63616. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63617. import { Scene } from "babylonjs/scene";
  63618. import { Vector3 } from "babylonjs/Maths/math.vector";
  63619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63620. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63621. import "babylonjs/Shaders/lensFlare.fragment";
  63622. import "babylonjs/Shaders/lensFlare.vertex";
  63623. import { Viewport } from "babylonjs/Maths/math.viewport";
  63624. /**
  63625. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63626. * It is usually composed of several `lensFlare`.
  63627. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63628. */
  63629. export class LensFlareSystem {
  63630. /**
  63631. * Define the name of the lens flare system
  63632. */
  63633. name: string;
  63634. /**
  63635. * List of lens flares used in this system.
  63636. */
  63637. lensFlares: LensFlare[];
  63638. /**
  63639. * Define a limit from the border the lens flare can be visible.
  63640. */
  63641. borderLimit: number;
  63642. /**
  63643. * Define a viewport border we do not want to see the lens flare in.
  63644. */
  63645. viewportBorder: number;
  63646. /**
  63647. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63648. */
  63649. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63650. /**
  63651. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63652. */
  63653. layerMask: number;
  63654. /**
  63655. * Define the id of the lens flare system in the scene.
  63656. * (equal to name by default)
  63657. */
  63658. id: string;
  63659. private _scene;
  63660. private _emitter;
  63661. private _vertexBuffers;
  63662. private _indexBuffer;
  63663. private _effect;
  63664. private _positionX;
  63665. private _positionY;
  63666. private _isEnabled;
  63667. /** @hidden */
  63668. static _SceneComponentInitialization: (scene: Scene) => void;
  63669. /**
  63670. * Instantiates a lens flare system.
  63671. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63672. * It is usually composed of several `lensFlare`.
  63673. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63674. * @param name Define the name of the lens flare system in the scene
  63675. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63676. * @param scene Define the scene the lens flare system belongs to
  63677. */
  63678. constructor(
  63679. /**
  63680. * Define the name of the lens flare system
  63681. */
  63682. name: string, emitter: any, scene: Scene);
  63683. /**
  63684. * Define if the lens flare system is enabled.
  63685. */
  63686. get isEnabled(): boolean;
  63687. set isEnabled(value: boolean);
  63688. /**
  63689. * Get the scene the effects belongs to.
  63690. * @returns the scene holding the lens flare system
  63691. */
  63692. getScene(): Scene;
  63693. /**
  63694. * Get the emitter of the lens flare system.
  63695. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63696. * @returns the emitter of the lens flare system
  63697. */
  63698. getEmitter(): any;
  63699. /**
  63700. * Set the emitter of the lens flare system.
  63701. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63702. * @param newEmitter Define the new emitter of the system
  63703. */
  63704. setEmitter(newEmitter: any): void;
  63705. /**
  63706. * Get the lens flare system emitter position.
  63707. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63708. * @returns the position
  63709. */
  63710. getEmitterPosition(): Vector3;
  63711. /**
  63712. * @hidden
  63713. */
  63714. computeEffectivePosition(globalViewport: Viewport): boolean;
  63715. /** @hidden */
  63716. _isVisible(): boolean;
  63717. /**
  63718. * @hidden
  63719. */
  63720. render(): boolean;
  63721. /**
  63722. * Dispose and release the lens flare with its associated resources.
  63723. */
  63724. dispose(): void;
  63725. /**
  63726. * Parse a lens flare system from a JSON repressentation
  63727. * @param parsedLensFlareSystem Define the JSON to parse
  63728. * @param scene Define the scene the parsed system should be instantiated in
  63729. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63730. * @returns the parsed system
  63731. */
  63732. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63733. /**
  63734. * Serialize the current Lens Flare System into a JSON representation.
  63735. * @returns the serialized JSON
  63736. */
  63737. serialize(): any;
  63738. }
  63739. }
  63740. declare module "babylonjs/LensFlares/lensFlare" {
  63741. import { Nullable } from "babylonjs/types";
  63742. import { Color3 } from "babylonjs/Maths/math.color";
  63743. import { Texture } from "babylonjs/Materials/Textures/texture";
  63744. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63745. /**
  63746. * This represents one of the lens effect in a `lensFlareSystem`.
  63747. * It controls one of the indiviual texture used in the effect.
  63748. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63749. */
  63750. export class LensFlare {
  63751. /**
  63752. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63753. */
  63754. size: number;
  63755. /**
  63756. * 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.
  63757. */
  63758. position: number;
  63759. /**
  63760. * Define the lens color.
  63761. */
  63762. color: Color3;
  63763. /**
  63764. * Define the lens texture.
  63765. */
  63766. texture: Nullable<Texture>;
  63767. /**
  63768. * Define the alpha mode to render this particular lens.
  63769. */
  63770. alphaMode: number;
  63771. private _system;
  63772. /**
  63773. * Creates a new Lens Flare.
  63774. * This represents one of the lens effect in a `lensFlareSystem`.
  63775. * It controls one of the indiviual texture used in the effect.
  63776. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63777. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63778. * @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.
  63779. * @param color Define the lens color
  63780. * @param imgUrl Define the lens texture url
  63781. * @param system Define the `lensFlareSystem` this flare is part of
  63782. * @returns The newly created Lens Flare
  63783. */
  63784. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63785. /**
  63786. * Instantiates a new Lens Flare.
  63787. * This represents one of the lens effect in a `lensFlareSystem`.
  63788. * It controls one of the indiviual texture used in the effect.
  63789. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63790. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63791. * @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.
  63792. * @param color Define the lens color
  63793. * @param imgUrl Define the lens texture url
  63794. * @param system Define the `lensFlareSystem` this flare is part of
  63795. */
  63796. constructor(
  63797. /**
  63798. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63799. */
  63800. size: number,
  63801. /**
  63802. * 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.
  63803. */
  63804. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63805. /**
  63806. * Dispose and release the lens flare with its associated resources.
  63807. */
  63808. dispose(): void;
  63809. }
  63810. }
  63811. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63812. import { Nullable } from "babylonjs/types";
  63813. import { Scene } from "babylonjs/scene";
  63814. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63815. import { AbstractScene } from "babylonjs/abstractScene";
  63816. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63817. module "babylonjs/abstractScene" {
  63818. interface AbstractScene {
  63819. /**
  63820. * The list of lens flare system added to the scene
  63821. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63822. */
  63823. lensFlareSystems: Array<LensFlareSystem>;
  63824. /**
  63825. * Removes the given lens flare system from this scene.
  63826. * @param toRemove The lens flare system to remove
  63827. * @returns The index of the removed lens flare system
  63828. */
  63829. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63830. /**
  63831. * Adds the given lens flare system to this scene
  63832. * @param newLensFlareSystem The lens flare system to add
  63833. */
  63834. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63835. /**
  63836. * Gets a lens flare system using its name
  63837. * @param name defines the name to look for
  63838. * @returns the lens flare system or null if not found
  63839. */
  63840. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63841. /**
  63842. * Gets a lens flare system using its id
  63843. * @param id defines the id to look for
  63844. * @returns the lens flare system or null if not found
  63845. */
  63846. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63847. }
  63848. }
  63849. /**
  63850. * Defines the lens flare scene component responsible to manage any lens flares
  63851. * in a given scene.
  63852. */
  63853. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63854. /**
  63855. * The component name helpfull to identify the component in the list of scene components.
  63856. */
  63857. readonly name: string;
  63858. /**
  63859. * The scene the component belongs to.
  63860. */
  63861. scene: Scene;
  63862. /**
  63863. * Creates a new instance of the component for the given scene
  63864. * @param scene Defines the scene to register the component in
  63865. */
  63866. constructor(scene: Scene);
  63867. /**
  63868. * Registers the component in a given scene
  63869. */
  63870. register(): void;
  63871. /**
  63872. * Rebuilds the elements related to this component in case of
  63873. * context lost for instance.
  63874. */
  63875. rebuild(): void;
  63876. /**
  63877. * Adds all the elements from the container to the scene
  63878. * @param container the container holding the elements
  63879. */
  63880. addFromContainer(container: AbstractScene): void;
  63881. /**
  63882. * Removes all the elements in the container from the scene
  63883. * @param container contains the elements to remove
  63884. * @param dispose if the removed element should be disposed (default: false)
  63885. */
  63886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63887. /**
  63888. * Serializes the component data to the specified json object
  63889. * @param serializationObject The object to serialize to
  63890. */
  63891. serialize(serializationObject: any): void;
  63892. /**
  63893. * Disposes the component and the associated ressources.
  63894. */
  63895. dispose(): void;
  63896. private _draw;
  63897. }
  63898. }
  63899. declare module "babylonjs/LensFlares/index" {
  63900. export * from "babylonjs/LensFlares/lensFlare";
  63901. export * from "babylonjs/LensFlares/lensFlareSystem";
  63902. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63903. }
  63904. declare module "babylonjs/Shaders/depth.fragment" {
  63905. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63906. /** @hidden */
  63907. export var depthPixelShader: {
  63908. name: string;
  63909. shader: string;
  63910. };
  63911. }
  63912. declare module "babylonjs/Shaders/depth.vertex" {
  63913. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63914. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63915. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63916. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63918. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63919. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63920. /** @hidden */
  63921. export var depthVertexShader: {
  63922. name: string;
  63923. shader: string;
  63924. };
  63925. }
  63926. declare module "babylonjs/Rendering/depthRenderer" {
  63927. import { Nullable } from "babylonjs/types";
  63928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63929. import { Scene } from "babylonjs/scene";
  63930. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63931. import { Camera } from "babylonjs/Cameras/camera";
  63932. import "babylonjs/Shaders/depth.fragment";
  63933. import "babylonjs/Shaders/depth.vertex";
  63934. /**
  63935. * This represents a depth renderer in Babylon.
  63936. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63937. */
  63938. export class DepthRenderer {
  63939. private _scene;
  63940. private _depthMap;
  63941. private _effect;
  63942. private readonly _storeNonLinearDepth;
  63943. private readonly _clearColor;
  63944. /** Get if the depth renderer is using packed depth or not */
  63945. readonly isPacked: boolean;
  63946. private _cachedDefines;
  63947. private _camera;
  63948. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63949. enabled: boolean;
  63950. /**
  63951. * Specifiess that the depth renderer will only be used within
  63952. * the camera it is created for.
  63953. * This can help forcing its rendering during the camera processing.
  63954. */
  63955. useOnlyInActiveCamera: boolean;
  63956. /** @hidden */
  63957. static _SceneComponentInitialization: (scene: Scene) => void;
  63958. /**
  63959. * Instantiates a depth renderer
  63960. * @param scene The scene the renderer belongs to
  63961. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63962. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63963. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63964. */
  63965. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63966. /**
  63967. * Creates the depth rendering effect and checks if the effect is ready.
  63968. * @param subMesh The submesh to be used to render the depth map of
  63969. * @param useInstances If multiple world instances should be used
  63970. * @returns if the depth renderer is ready to render the depth map
  63971. */
  63972. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63973. /**
  63974. * Gets the texture which the depth map will be written to.
  63975. * @returns The depth map texture
  63976. */
  63977. getDepthMap(): RenderTargetTexture;
  63978. /**
  63979. * Disposes of the depth renderer.
  63980. */
  63981. dispose(): void;
  63982. }
  63983. }
  63984. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63985. /** @hidden */
  63986. export var minmaxReduxPixelShader: {
  63987. name: string;
  63988. shader: string;
  63989. };
  63990. }
  63991. declare module "babylonjs/Misc/minMaxReducer" {
  63992. import { Nullable } from "babylonjs/types";
  63993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63994. import { Camera } from "babylonjs/Cameras/camera";
  63995. import { Observer } from "babylonjs/Misc/observable";
  63996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63997. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63998. import { Observable } from "babylonjs/Misc/observable";
  63999. import "babylonjs/Shaders/minmaxRedux.fragment";
  64000. /**
  64001. * This class computes a min/max reduction from a texture: it means it computes the minimum
  64002. * and maximum values from all values of the texture.
  64003. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  64004. * The source values are read from the red channel of the texture.
  64005. */
  64006. export class MinMaxReducer {
  64007. /**
  64008. * Observable triggered when the computation has been performed
  64009. */
  64010. onAfterReductionPerformed: Observable<{
  64011. min: number;
  64012. max: number;
  64013. }>;
  64014. protected _camera: Camera;
  64015. protected _sourceTexture: Nullable<RenderTargetTexture>;
  64016. protected _reductionSteps: Nullable<Array<PostProcess>>;
  64017. protected _postProcessManager: PostProcessManager;
  64018. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  64019. protected _forceFullscreenViewport: boolean;
  64020. /**
  64021. * Creates a min/max reducer
  64022. * @param camera The camera to use for the post processes
  64023. */
  64024. constructor(camera: Camera);
  64025. /**
  64026. * Gets the texture used to read the values from.
  64027. */
  64028. get sourceTexture(): Nullable<RenderTargetTexture>;
  64029. /**
  64030. * Sets the source texture to read the values from.
  64031. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  64032. * because in such textures '1' value must not be taken into account to compute the maximum
  64033. * as this value is used to clear the texture.
  64034. * Note that the computation is not activated by calling this function, you must call activate() for that!
  64035. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  64036. * @param depthRedux Indicates if the texture is a depth texture or not
  64037. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  64038. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64039. */
  64040. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64041. /**
  64042. * Defines the refresh rate of the computation.
  64043. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64044. */
  64045. get refreshRate(): number;
  64046. set refreshRate(value: number);
  64047. protected _activated: boolean;
  64048. /**
  64049. * Gets the activation status of the reducer
  64050. */
  64051. get activated(): boolean;
  64052. /**
  64053. * Activates the reduction computation.
  64054. * When activated, the observers registered in onAfterReductionPerformed are
  64055. * called after the compuation is performed
  64056. */
  64057. activate(): void;
  64058. /**
  64059. * Deactivates the reduction computation.
  64060. */
  64061. deactivate(): void;
  64062. /**
  64063. * Disposes the min/max reducer
  64064. * @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.
  64065. */
  64066. dispose(disposeAll?: boolean): void;
  64067. }
  64068. }
  64069. declare module "babylonjs/Misc/depthReducer" {
  64070. import { Nullable } from "babylonjs/types";
  64071. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64072. import { Camera } from "babylonjs/Cameras/camera";
  64073. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64074. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  64075. /**
  64076. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64077. */
  64078. export class DepthReducer extends MinMaxReducer {
  64079. private _depthRenderer;
  64080. private _depthRendererId;
  64081. /**
  64082. * Gets the depth renderer used for the computation.
  64083. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64084. */
  64085. get depthRenderer(): Nullable<DepthRenderer>;
  64086. /**
  64087. * Creates a depth reducer
  64088. * @param camera The camera used to render the depth texture
  64089. */
  64090. constructor(camera: Camera);
  64091. /**
  64092. * Sets the depth renderer to use to generate the depth map
  64093. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64094. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64095. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64096. */
  64097. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64098. /** @hidden */
  64099. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64100. /**
  64101. * Activates the reduction computation.
  64102. * When activated, the observers registered in onAfterReductionPerformed are
  64103. * called after the compuation is performed
  64104. */
  64105. activate(): void;
  64106. /**
  64107. * Deactivates the reduction computation.
  64108. */
  64109. deactivate(): void;
  64110. /**
  64111. * Disposes the depth reducer
  64112. * @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.
  64113. */
  64114. dispose(disposeAll?: boolean): void;
  64115. }
  64116. }
  64117. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  64118. import { Nullable } from "babylonjs/types";
  64119. import { Scene } from "babylonjs/scene";
  64120. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64121. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64122. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64123. import { Effect } from "babylonjs/Materials/effect";
  64124. import "babylonjs/Shaders/shadowMap.fragment";
  64125. import "babylonjs/Shaders/shadowMap.vertex";
  64126. import "babylonjs/Shaders/depthBoxBlur.fragment";
  64127. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  64128. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64129. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  64130. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64131. /**
  64132. * A CSM implementation allowing casting shadows on large scenes.
  64133. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64134. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64135. */
  64136. export class CascadedShadowGenerator extends ShadowGenerator {
  64137. private static readonly frustumCornersNDCSpace;
  64138. /**
  64139. * Name of the CSM class
  64140. */
  64141. static CLASSNAME: string;
  64142. /**
  64143. * Defines the default number of cascades used by the CSM.
  64144. */
  64145. static readonly DEFAULT_CASCADES_COUNT: number;
  64146. /**
  64147. * Defines the minimum number of cascades used by the CSM.
  64148. */
  64149. static readonly MIN_CASCADES_COUNT: number;
  64150. /**
  64151. * Defines the maximum number of cascades used by the CSM.
  64152. */
  64153. static readonly MAX_CASCADES_COUNT: number;
  64154. protected _validateFilter(filter: number): number;
  64155. /**
  64156. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64157. */
  64158. penumbraDarkness: number;
  64159. private _numCascades;
  64160. /**
  64161. * Gets or set the number of cascades used by the CSM.
  64162. */
  64163. get numCascades(): number;
  64164. set numCascades(value: number);
  64165. /**
  64166. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64167. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64168. */
  64169. stabilizeCascades: boolean;
  64170. private _freezeShadowCastersBoundingInfo;
  64171. private _freezeShadowCastersBoundingInfoObservable;
  64172. /**
  64173. * Enables or disables the shadow casters bounding info computation.
  64174. * If your shadow casters don't move, you can disable this feature.
  64175. * If it is enabled, the bounding box computation is done every frame.
  64176. */
  64177. get freezeShadowCastersBoundingInfo(): boolean;
  64178. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64179. private _scbiMin;
  64180. private _scbiMax;
  64181. protected _computeShadowCastersBoundingInfo(): void;
  64182. protected _shadowCastersBoundingInfo: BoundingInfo;
  64183. /**
  64184. * Gets or sets the shadow casters bounding info.
  64185. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64186. * so that the system won't overwrite the bounds you provide
  64187. */
  64188. get shadowCastersBoundingInfo(): BoundingInfo;
  64189. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64190. protected _breaksAreDirty: boolean;
  64191. protected _minDistance: number;
  64192. protected _maxDistance: number;
  64193. /**
  64194. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64195. *
  64196. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64197. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64198. * @param min minimal distance for the breaks (default to 0.)
  64199. * @param max maximal distance for the breaks (default to 1.)
  64200. */
  64201. setMinMaxDistance(min: number, max: number): void;
  64202. /** Gets the minimal distance used in the cascade break computation */
  64203. get minDistance(): number;
  64204. /** Gets the maximal distance used in the cascade break computation */
  64205. get maxDistance(): number;
  64206. /**
  64207. * Gets the class name of that object
  64208. * @returns "CascadedShadowGenerator"
  64209. */
  64210. getClassName(): string;
  64211. private _cascadeMinExtents;
  64212. private _cascadeMaxExtents;
  64213. /**
  64214. * Gets a cascade minimum extents
  64215. * @param cascadeIndex index of the cascade
  64216. * @returns the minimum cascade extents
  64217. */
  64218. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64219. /**
  64220. * Gets a cascade maximum extents
  64221. * @param cascadeIndex index of the cascade
  64222. * @returns the maximum cascade extents
  64223. */
  64224. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64225. private _cascades;
  64226. private _currentLayer;
  64227. private _viewSpaceFrustumsZ;
  64228. private _viewMatrices;
  64229. private _projectionMatrices;
  64230. private _transformMatrices;
  64231. private _transformMatricesAsArray;
  64232. private _frustumLengths;
  64233. private _lightSizeUVCorrection;
  64234. private _depthCorrection;
  64235. private _frustumCornersWorldSpace;
  64236. private _frustumCenter;
  64237. private _shadowCameraPos;
  64238. private _shadowMaxZ;
  64239. /**
  64240. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64241. * It defaults to camera.maxZ
  64242. */
  64243. get shadowMaxZ(): number;
  64244. /**
  64245. * Sets the shadow max z distance.
  64246. */
  64247. set shadowMaxZ(value: number);
  64248. protected _debug: boolean;
  64249. /**
  64250. * Gets or sets the debug flag.
  64251. * When enabled, the cascades are materialized by different colors on the screen.
  64252. */
  64253. get debug(): boolean;
  64254. set debug(dbg: boolean);
  64255. private _depthClamp;
  64256. /**
  64257. * Gets or sets the depth clamping value.
  64258. *
  64259. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64260. * to account for the shadow casters far away.
  64261. *
  64262. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64263. */
  64264. get depthClamp(): boolean;
  64265. set depthClamp(value: boolean);
  64266. private _cascadeBlendPercentage;
  64267. /**
  64268. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64269. * It defaults to 0.1 (10% blending).
  64270. */
  64271. get cascadeBlendPercentage(): number;
  64272. set cascadeBlendPercentage(value: number);
  64273. private _lambda;
  64274. /**
  64275. * Gets or set the lambda parameter.
  64276. * This parameter is used to split the camera frustum and create the cascades.
  64277. * 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.
  64278. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64279. */
  64280. get lambda(): number;
  64281. set lambda(value: number);
  64282. /**
  64283. * Gets the view matrix corresponding to a given cascade
  64284. * @param cascadeNum cascade to retrieve the view matrix from
  64285. * @returns the cascade view matrix
  64286. */
  64287. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64288. /**
  64289. * Gets the projection matrix corresponding to a given cascade
  64290. * @param cascadeNum cascade to retrieve the projection matrix from
  64291. * @returns the cascade projection matrix
  64292. */
  64293. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64294. /**
  64295. * Gets the transformation matrix corresponding to a given cascade
  64296. * @param cascadeNum cascade to retrieve the transformation matrix from
  64297. * @returns the cascade transformation matrix
  64298. */
  64299. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64300. private _depthRenderer;
  64301. /**
  64302. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64303. *
  64304. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64305. *
  64306. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64307. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64308. * @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
  64309. */
  64310. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64311. private _depthReducer;
  64312. private _autoCalcDepthBounds;
  64313. /**
  64314. * Gets or sets the autoCalcDepthBounds property.
  64315. *
  64316. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64317. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64318. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64319. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64320. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64321. */
  64322. get autoCalcDepthBounds(): boolean;
  64323. set autoCalcDepthBounds(value: boolean);
  64324. /**
  64325. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64326. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64327. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64328. * for setting the refresh rate on the renderer yourself!
  64329. */
  64330. get autoCalcDepthBoundsRefreshRate(): number;
  64331. set autoCalcDepthBoundsRefreshRate(value: number);
  64332. /**
  64333. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64334. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64335. * you change the camera near/far planes!
  64336. */
  64337. splitFrustum(): void;
  64338. private _splitFrustum;
  64339. private _computeMatrices;
  64340. private _computeFrustumInWorldSpace;
  64341. private _computeCascadeFrustum;
  64342. /**
  64343. * Support test.
  64344. */
  64345. static get IsSupported(): boolean;
  64346. /** @hidden */
  64347. static _SceneComponentInitialization: (scene: Scene) => void;
  64348. /**
  64349. * Creates a Cascaded Shadow Generator object.
  64350. * A ShadowGenerator is the required tool to use the shadows.
  64351. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64352. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64353. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64354. * @param light The directional light object generating the shadows.
  64355. * @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.
  64356. */
  64357. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64358. protected _initializeGenerator(): void;
  64359. protected _createTargetRenderTexture(): void;
  64360. protected _initializeShadowMap(): void;
  64361. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64362. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64363. /**
  64364. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64365. * @param defines Defines of the material we want to update
  64366. * @param lightIndex Index of the light in the enabled light list of the material
  64367. */
  64368. prepareDefines(defines: any, lightIndex: number): void;
  64369. /**
  64370. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64371. * defined in the generator but impacting the effect).
  64372. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64373. * @param effect The effect we are binfing the information for
  64374. */
  64375. bindShadowLight(lightIndex: string, effect: Effect): void;
  64376. /**
  64377. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64378. * (eq to view projection * shadow projection matrices)
  64379. * @returns The transform matrix used to create the shadow map
  64380. */
  64381. getTransformMatrix(): Matrix;
  64382. /**
  64383. * Disposes the ShadowGenerator.
  64384. * Returns nothing.
  64385. */
  64386. dispose(): void;
  64387. /**
  64388. * Serializes the shadow generator setup to a json object.
  64389. * @returns The serialized JSON object
  64390. */
  64391. serialize(): any;
  64392. /**
  64393. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64394. * @param parsedShadowGenerator The JSON object to parse
  64395. * @param scene The scene to create the shadow map for
  64396. * @returns The parsed shadow generator
  64397. */
  64398. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64399. }
  64400. }
  64401. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  64402. import { Scene } from "babylonjs/scene";
  64403. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  64404. import { AbstractScene } from "babylonjs/abstractScene";
  64405. /**
  64406. * Defines the shadow generator component responsible to manage any shadow generators
  64407. * in a given scene.
  64408. */
  64409. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64410. /**
  64411. * The component name helpfull to identify the component in the list of scene components.
  64412. */
  64413. readonly name: string;
  64414. /**
  64415. * The scene the component belongs to.
  64416. */
  64417. scene: Scene;
  64418. /**
  64419. * Creates a new instance of the component for the given scene
  64420. * @param scene Defines the scene to register the component in
  64421. */
  64422. constructor(scene: Scene);
  64423. /**
  64424. * Registers the component in a given scene
  64425. */
  64426. register(): void;
  64427. /**
  64428. * Rebuilds the elements related to this component in case of
  64429. * context lost for instance.
  64430. */
  64431. rebuild(): void;
  64432. /**
  64433. * Serializes the component data to the specified json object
  64434. * @param serializationObject The object to serialize to
  64435. */
  64436. serialize(serializationObject: any): void;
  64437. /**
  64438. * Adds all the elements from the container to the scene
  64439. * @param container the container holding the elements
  64440. */
  64441. addFromContainer(container: AbstractScene): void;
  64442. /**
  64443. * Removes all the elements in the container from the scene
  64444. * @param container contains the elements to remove
  64445. * @param dispose if the removed element should be disposed (default: false)
  64446. */
  64447. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64448. /**
  64449. * Rebuilds the elements related to this component in case of
  64450. * context lost for instance.
  64451. */
  64452. dispose(): void;
  64453. private _gatherRenderTargets;
  64454. }
  64455. }
  64456. declare module "babylonjs/Lights/Shadows/index" {
  64457. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  64458. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  64459. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  64460. }
  64461. declare module "babylonjs/Lights/pointLight" {
  64462. import { Scene } from "babylonjs/scene";
  64463. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64464. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64465. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  64466. import { Effect } from "babylonjs/Materials/effect";
  64467. /**
  64468. * A point light is a light defined by an unique point in world space.
  64469. * The light is emitted in every direction from this point.
  64470. * A good example of a point light is a standard light bulb.
  64471. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64472. */
  64473. export class PointLight extends ShadowLight {
  64474. private _shadowAngle;
  64475. /**
  64476. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64477. * This specifies what angle the shadow will use to be created.
  64478. *
  64479. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64480. */
  64481. get shadowAngle(): number;
  64482. /**
  64483. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64484. * This specifies what angle the shadow will use to be created.
  64485. *
  64486. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64487. */
  64488. set shadowAngle(value: number);
  64489. /**
  64490. * Gets the direction if it has been set.
  64491. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64492. */
  64493. get direction(): Vector3;
  64494. /**
  64495. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64496. */
  64497. set direction(value: Vector3);
  64498. /**
  64499. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64500. * A PointLight emits the light in every direction.
  64501. * It can cast shadows.
  64502. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64503. * ```javascript
  64504. * var pointLight = new PointLight("pl", camera.position, scene);
  64505. * ```
  64506. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64507. * @param name The light friendly name
  64508. * @param position The position of the point light in the scene
  64509. * @param scene The scene the lights belongs to
  64510. */
  64511. constructor(name: string, position: Vector3, scene: Scene);
  64512. /**
  64513. * Returns the string "PointLight"
  64514. * @returns the class name
  64515. */
  64516. getClassName(): string;
  64517. /**
  64518. * Returns the integer 0.
  64519. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64520. */
  64521. getTypeID(): number;
  64522. /**
  64523. * Specifies wether or not the shadowmap should be a cube texture.
  64524. * @returns true if the shadowmap needs to be a cube texture.
  64525. */
  64526. needCube(): boolean;
  64527. /**
  64528. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64529. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64530. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64531. */
  64532. getShadowDirection(faceIndex?: number): Vector3;
  64533. /**
  64534. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64535. * - fov = PI / 2
  64536. * - aspect ratio : 1.0
  64537. * - z-near and far equal to the active camera minZ and maxZ.
  64538. * Returns the PointLight.
  64539. */
  64540. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64541. protected _buildUniformLayout(): void;
  64542. /**
  64543. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64544. * @param effect The effect to update
  64545. * @param lightIndex The index of the light in the effect to update
  64546. * @returns The point light
  64547. */
  64548. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64549. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64550. /**
  64551. * Prepares the list of defines specific to the light type.
  64552. * @param defines the list of defines
  64553. * @param lightIndex defines the index of the light for the effect
  64554. */
  64555. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64556. }
  64557. }
  64558. declare module "babylonjs/Lights/index" {
  64559. export * from "babylonjs/Lights/light";
  64560. export * from "babylonjs/Lights/shadowLight";
  64561. export * from "babylonjs/Lights/Shadows/index";
  64562. export * from "babylonjs/Lights/directionalLight";
  64563. export * from "babylonjs/Lights/hemisphericLight";
  64564. export * from "babylonjs/Lights/pointLight";
  64565. export * from "babylonjs/Lights/spotLight";
  64566. }
  64567. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64568. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64569. /**
  64570. * Header information of HDR texture files.
  64571. */
  64572. export interface HDRInfo {
  64573. /**
  64574. * The height of the texture in pixels.
  64575. */
  64576. height: number;
  64577. /**
  64578. * The width of the texture in pixels.
  64579. */
  64580. width: number;
  64581. /**
  64582. * The index of the beginning of the data in the binary file.
  64583. */
  64584. dataPosition: number;
  64585. }
  64586. /**
  64587. * This groups tools to convert HDR texture to native colors array.
  64588. */
  64589. export class HDRTools {
  64590. private static Ldexp;
  64591. private static Rgbe2float;
  64592. private static readStringLine;
  64593. /**
  64594. * Reads header information from an RGBE texture stored in a native array.
  64595. * More information on this format are available here:
  64596. * https://en.wikipedia.org/wiki/RGBE_image_format
  64597. *
  64598. * @param uint8array The binary file stored in native array.
  64599. * @return The header information.
  64600. */
  64601. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64602. /**
  64603. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64604. * This RGBE texture needs to store the information as a panorama.
  64605. *
  64606. * More information on this format are available here:
  64607. * https://en.wikipedia.org/wiki/RGBE_image_format
  64608. *
  64609. * @param buffer The binary file stored in an array buffer.
  64610. * @param size The expected size of the extracted cubemap.
  64611. * @return The Cube Map information.
  64612. */
  64613. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64614. /**
  64615. * Returns the pixels data extracted from an RGBE texture.
  64616. * This pixels will be stored left to right up to down in the R G B order in one array.
  64617. *
  64618. * More information on this format are available here:
  64619. * https://en.wikipedia.org/wiki/RGBE_image_format
  64620. *
  64621. * @param uint8array The binary file stored in an array buffer.
  64622. * @param hdrInfo The header information of the file.
  64623. * @return The pixels data in RGB right to left up to down order.
  64624. */
  64625. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64626. private static RGBE_ReadPixels_RLE;
  64627. private static RGBE_ReadPixels_NOT_RLE;
  64628. }
  64629. }
  64630. declare module "babylonjs/Materials/effectRenderer" {
  64631. import { Nullable } from "babylonjs/types";
  64632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64634. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64635. import { Viewport } from "babylonjs/Maths/math.viewport";
  64636. import { Observable } from "babylonjs/Misc/observable";
  64637. import { Effect } from "babylonjs/Materials/effect";
  64638. import "babylonjs/Shaders/postprocess.vertex";
  64639. /**
  64640. * Effect Render Options
  64641. */
  64642. export interface IEffectRendererOptions {
  64643. /**
  64644. * Defines the vertices positions.
  64645. */
  64646. positions?: number[];
  64647. /**
  64648. * Defines the indices.
  64649. */
  64650. indices?: number[];
  64651. }
  64652. /**
  64653. * Helper class to render one or more effects.
  64654. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64655. */
  64656. export class EffectRenderer {
  64657. private engine;
  64658. private static _DefaultOptions;
  64659. private _vertexBuffers;
  64660. private _indexBuffer;
  64661. private _fullscreenViewport;
  64662. /**
  64663. * Creates an effect renderer
  64664. * @param engine the engine to use for rendering
  64665. * @param options defines the options of the effect renderer
  64666. */
  64667. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64668. /**
  64669. * Sets the current viewport in normalized coordinates 0-1
  64670. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64671. */
  64672. setViewport(viewport?: Viewport): void;
  64673. /**
  64674. * Binds the embedded attributes buffer to the effect.
  64675. * @param effect Defines the effect to bind the attributes for
  64676. */
  64677. bindBuffers(effect: Effect): void;
  64678. /**
  64679. * Sets the current effect wrapper to use during draw.
  64680. * The effect needs to be ready before calling this api.
  64681. * This also sets the default full screen position attribute.
  64682. * @param effectWrapper Defines the effect to draw with
  64683. */
  64684. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64685. /**
  64686. * Restores engine states
  64687. */
  64688. restoreStates(): void;
  64689. /**
  64690. * Draws a full screen quad.
  64691. */
  64692. draw(): void;
  64693. private isRenderTargetTexture;
  64694. /**
  64695. * renders one or more effects to a specified texture
  64696. * @param effectWrapper the effect to renderer
  64697. * @param outputTexture texture to draw to, if null it will render to the screen.
  64698. */
  64699. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64700. /**
  64701. * Disposes of the effect renderer
  64702. */
  64703. dispose(): void;
  64704. }
  64705. /**
  64706. * Options to create an EffectWrapper
  64707. */
  64708. interface EffectWrapperCreationOptions {
  64709. /**
  64710. * Engine to use to create the effect
  64711. */
  64712. engine: ThinEngine;
  64713. /**
  64714. * Fragment shader for the effect
  64715. */
  64716. fragmentShader: string;
  64717. /**
  64718. * Use the shader store instead of direct source code
  64719. */
  64720. useShaderStore?: boolean;
  64721. /**
  64722. * Vertex shader for the effect
  64723. */
  64724. vertexShader?: string;
  64725. /**
  64726. * Attributes to use in the shader
  64727. */
  64728. attributeNames?: Array<string>;
  64729. /**
  64730. * Uniforms to use in the shader
  64731. */
  64732. uniformNames?: Array<string>;
  64733. /**
  64734. * Texture sampler names to use in the shader
  64735. */
  64736. samplerNames?: Array<string>;
  64737. /**
  64738. * Defines to use in the shader
  64739. */
  64740. defines?: Array<string>;
  64741. /**
  64742. * Callback when effect is compiled
  64743. */
  64744. onCompiled?: Nullable<(effect: Effect) => void>;
  64745. /**
  64746. * The friendly name of the effect displayed in Spector.
  64747. */
  64748. name?: string;
  64749. }
  64750. /**
  64751. * Wraps an effect to be used for rendering
  64752. */
  64753. export class EffectWrapper {
  64754. /**
  64755. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64756. */
  64757. onApplyObservable: Observable<{}>;
  64758. /**
  64759. * The underlying effect
  64760. */
  64761. effect: Effect;
  64762. /**
  64763. * Creates an effect to be renderer
  64764. * @param creationOptions options to create the effect
  64765. */
  64766. constructor(creationOptions: EffectWrapperCreationOptions);
  64767. /**
  64768. * Disposes of the effect wrapper
  64769. */
  64770. dispose(): void;
  64771. }
  64772. }
  64773. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64774. /** @hidden */
  64775. export var hdrFilteringVertexShader: {
  64776. name: string;
  64777. shader: string;
  64778. };
  64779. }
  64780. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64781. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64782. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64783. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64784. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64785. /** @hidden */
  64786. export var hdrFilteringPixelShader: {
  64787. name: string;
  64788. shader: string;
  64789. };
  64790. }
  64791. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64792. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64793. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64794. import { Nullable } from "babylonjs/types";
  64795. import "babylonjs/Shaders/hdrFiltering.vertex";
  64796. import "babylonjs/Shaders/hdrFiltering.fragment";
  64797. /**
  64798. * Options for texture filtering
  64799. */
  64800. interface IHDRFilteringOptions {
  64801. /**
  64802. * Scales pixel intensity for the input HDR map.
  64803. */
  64804. hdrScale?: number;
  64805. /**
  64806. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64807. */
  64808. quality?: number;
  64809. }
  64810. /**
  64811. * Filters HDR maps to get correct renderings of PBR reflections
  64812. */
  64813. export class HDRFiltering {
  64814. private _engine;
  64815. private _effectRenderer;
  64816. private _effectWrapper;
  64817. private _lodGenerationOffset;
  64818. private _lodGenerationScale;
  64819. /**
  64820. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64821. * you care about baking speed.
  64822. */
  64823. quality: number;
  64824. /**
  64825. * Scales pixel intensity for the input HDR map.
  64826. */
  64827. hdrScale: number;
  64828. /**
  64829. * Instantiates HDR filter for reflection maps
  64830. *
  64831. * @param engine Thin engine
  64832. * @param options Options
  64833. */
  64834. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64835. private _createRenderTarget;
  64836. private _prefilterInternal;
  64837. private _createEffect;
  64838. /**
  64839. * Get a value indicating if the filter is ready to be used
  64840. * @param texture Texture to filter
  64841. * @returns true if the filter is ready
  64842. */
  64843. isReady(texture: BaseTexture): boolean;
  64844. /**
  64845. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64846. * Prefiltering will be invoked at the end of next rendering pass.
  64847. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64848. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64849. * @param texture Texture to filter
  64850. * @param onFinished Callback when filtering is done
  64851. * @return Promise called when prefiltering is done
  64852. */
  64853. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64854. }
  64855. }
  64856. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64857. import { Nullable } from "babylonjs/types";
  64858. import { Scene } from "babylonjs/scene";
  64859. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64860. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64861. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64862. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64863. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64864. /**
  64865. * This represents a texture coming from an HDR input.
  64866. *
  64867. * The only supported format is currently panorama picture stored in RGBE format.
  64868. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64869. */
  64870. export class HDRCubeTexture extends BaseTexture {
  64871. private static _facesMapping;
  64872. private _generateHarmonics;
  64873. private _noMipmap;
  64874. private _prefilterOnLoad;
  64875. private _textureMatrix;
  64876. private _size;
  64877. private _onLoad;
  64878. private _onError;
  64879. /**
  64880. * The texture URL.
  64881. */
  64882. url: string;
  64883. protected _isBlocking: boolean;
  64884. /**
  64885. * Sets wether or not the texture is blocking during loading.
  64886. */
  64887. set isBlocking(value: boolean);
  64888. /**
  64889. * Gets wether or not the texture is blocking during loading.
  64890. */
  64891. get isBlocking(): boolean;
  64892. protected _rotationY: number;
  64893. /**
  64894. * Sets texture matrix rotation angle around Y axis in radians.
  64895. */
  64896. set rotationY(value: number);
  64897. /**
  64898. * Gets texture matrix rotation angle around Y axis radians.
  64899. */
  64900. get rotationY(): number;
  64901. /**
  64902. * Gets or sets the center of the bounding box associated with the cube texture
  64903. * It must define where the camera used to render the texture was set
  64904. */
  64905. boundingBoxPosition: Vector3;
  64906. private _boundingBoxSize;
  64907. /**
  64908. * Gets or sets the size of the bounding box associated with the cube texture
  64909. * When defined, the cubemap will switch to local mode
  64910. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64911. * @example https://www.babylonjs-playground.com/#RNASML
  64912. */
  64913. set boundingBoxSize(value: Vector3);
  64914. get boundingBoxSize(): Vector3;
  64915. /**
  64916. * Instantiates an HDRTexture from the following parameters.
  64917. *
  64918. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64919. * @param sceneOrEngine The scene or engine the texture will be used in
  64920. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64921. * @param noMipmap Forces to not generate the mipmap if true
  64922. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64923. * @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)
  64924. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64925. */
  64926. 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>);
  64927. /**
  64928. * Get the current class name of the texture useful for serialization or dynamic coding.
  64929. * @returns "HDRCubeTexture"
  64930. */
  64931. getClassName(): string;
  64932. /**
  64933. * Occurs when the file is raw .hdr file.
  64934. */
  64935. private loadTexture;
  64936. clone(): HDRCubeTexture;
  64937. delayLoad(): void;
  64938. /**
  64939. * Get the texture reflection matrix used to rotate/transform the reflection.
  64940. * @returns the reflection matrix
  64941. */
  64942. getReflectionTextureMatrix(): Matrix;
  64943. /**
  64944. * Set the texture reflection matrix used to rotate/transform the reflection.
  64945. * @param value Define the reflection matrix to set
  64946. */
  64947. setReflectionTextureMatrix(value: Matrix): void;
  64948. /**
  64949. * Parses a JSON representation of an HDR Texture in order to create the texture
  64950. * @param parsedTexture Define the JSON representation
  64951. * @param scene Define the scene the texture should be created in
  64952. * @param rootUrl Define the root url in case we need to load relative dependencies
  64953. * @returns the newly created texture after parsing
  64954. */
  64955. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64956. serialize(): any;
  64957. }
  64958. }
  64959. declare module "babylonjs/Physics/physicsEngine" {
  64960. import { Nullable } from "babylonjs/types";
  64961. import { Vector3 } from "babylonjs/Maths/math.vector";
  64962. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64963. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64964. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64965. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64966. /**
  64967. * Class used to control physics engine
  64968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64969. */
  64970. export class PhysicsEngine implements IPhysicsEngine {
  64971. private _physicsPlugin;
  64972. /**
  64973. * Global value used to control the smallest number supported by the simulation
  64974. */
  64975. static Epsilon: number;
  64976. private _impostors;
  64977. private _joints;
  64978. private _subTimeStep;
  64979. /**
  64980. * Gets the gravity vector used by the simulation
  64981. */
  64982. gravity: Vector3;
  64983. /**
  64984. * Factory used to create the default physics plugin.
  64985. * @returns The default physics plugin
  64986. */
  64987. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64988. /**
  64989. * Creates a new Physics Engine
  64990. * @param gravity defines the gravity vector used by the simulation
  64991. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64992. */
  64993. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64994. /**
  64995. * Sets the gravity vector used by the simulation
  64996. * @param gravity defines the gravity vector to use
  64997. */
  64998. setGravity(gravity: Vector3): void;
  64999. /**
  65000. * Set the time step of the physics engine.
  65001. * Default is 1/60.
  65002. * To slow it down, enter 1/600 for example.
  65003. * To speed it up, 1/30
  65004. * @param newTimeStep defines the new timestep to apply to this world.
  65005. */
  65006. setTimeStep(newTimeStep?: number): void;
  65007. /**
  65008. * Get the time step of the physics engine.
  65009. * @returns the current time step
  65010. */
  65011. getTimeStep(): number;
  65012. /**
  65013. * Set the sub time step of the physics engine.
  65014. * Default is 0 meaning there is no sub steps
  65015. * To increase physics resolution precision, set a small value (like 1 ms)
  65016. * @param subTimeStep defines the new sub timestep used for physics resolution.
  65017. */
  65018. setSubTimeStep(subTimeStep?: number): void;
  65019. /**
  65020. * Get the sub time step of the physics engine.
  65021. * @returns the current sub time step
  65022. */
  65023. getSubTimeStep(): number;
  65024. /**
  65025. * Release all resources
  65026. */
  65027. dispose(): void;
  65028. /**
  65029. * Gets the name of the current physics plugin
  65030. * @returns the name of the plugin
  65031. */
  65032. getPhysicsPluginName(): string;
  65033. /**
  65034. * Adding a new impostor for the impostor tracking.
  65035. * This will be done by the impostor itself.
  65036. * @param impostor the impostor to add
  65037. */
  65038. addImpostor(impostor: PhysicsImpostor): void;
  65039. /**
  65040. * Remove an impostor from the engine.
  65041. * This impostor and its mesh will not longer be updated by the physics engine.
  65042. * @param impostor the impostor to remove
  65043. */
  65044. removeImpostor(impostor: PhysicsImpostor): void;
  65045. /**
  65046. * Add a joint to the physics engine
  65047. * @param mainImpostor defines the main impostor to which the joint is added.
  65048. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  65049. * @param joint defines the joint that will connect both impostors.
  65050. */
  65051. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65052. /**
  65053. * Removes a joint from the simulation
  65054. * @param mainImpostor defines the impostor used with the joint
  65055. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  65056. * @param joint defines the joint to remove
  65057. */
  65058. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  65059. /**
  65060. * Called by the scene. No need to call it.
  65061. * @param delta defines the timespam between frames
  65062. */
  65063. _step(delta: number): void;
  65064. /**
  65065. * Gets the current plugin used to run the simulation
  65066. * @returns current plugin
  65067. */
  65068. getPhysicsPlugin(): IPhysicsEnginePlugin;
  65069. /**
  65070. * Gets the list of physic impostors
  65071. * @returns an array of PhysicsImpostor
  65072. */
  65073. getImpostors(): Array<PhysicsImpostor>;
  65074. /**
  65075. * Gets the impostor for a physics enabled object
  65076. * @param object defines the object impersonated by the impostor
  65077. * @returns the PhysicsImpostor or null if not found
  65078. */
  65079. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  65080. /**
  65081. * Gets the impostor for a physics body object
  65082. * @param body defines physics body used by the impostor
  65083. * @returns the PhysicsImpostor or null if not found
  65084. */
  65085. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  65086. /**
  65087. * Does a raycast in the physics world
  65088. * @param from when should the ray start?
  65089. * @param to when should the ray end?
  65090. * @returns PhysicsRaycastResult
  65091. */
  65092. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65093. }
  65094. }
  65095. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  65096. import { Nullable } from "babylonjs/types";
  65097. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65099. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65100. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65101. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65102. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65103. /** @hidden */
  65104. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  65105. private _useDeltaForWorldStep;
  65106. world: any;
  65107. name: string;
  65108. private _physicsMaterials;
  65109. private _fixedTimeStep;
  65110. private _cannonRaycastResult;
  65111. private _raycastResult;
  65112. private _physicsBodysToRemoveAfterStep;
  65113. private _firstFrame;
  65114. BJSCANNON: any;
  65115. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  65116. setGravity(gravity: Vector3): void;
  65117. setTimeStep(timeStep: number): void;
  65118. getTimeStep(): number;
  65119. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65120. private _removeMarkedPhysicsBodiesFromWorld;
  65121. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65122. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65123. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65124. private _processChildMeshes;
  65125. removePhysicsBody(impostor: PhysicsImpostor): void;
  65126. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65127. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65128. private _addMaterial;
  65129. private _checkWithEpsilon;
  65130. private _createShape;
  65131. private _createHeightmap;
  65132. private _minus90X;
  65133. private _plus90X;
  65134. private _tmpPosition;
  65135. private _tmpDeltaPosition;
  65136. private _tmpUnityRotation;
  65137. private _updatePhysicsBodyTransformation;
  65138. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65139. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65140. isSupported(): boolean;
  65141. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65142. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65143. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65144. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65145. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65146. getBodyMass(impostor: PhysicsImpostor): number;
  65147. getBodyFriction(impostor: PhysicsImpostor): number;
  65148. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65149. getBodyRestitution(impostor: PhysicsImpostor): number;
  65150. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65151. sleepBody(impostor: PhysicsImpostor): void;
  65152. wakeUpBody(impostor: PhysicsImpostor): void;
  65153. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65154. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65155. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65156. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65157. getRadius(impostor: PhysicsImpostor): number;
  65158. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65159. dispose(): void;
  65160. private _extendNamespace;
  65161. /**
  65162. * Does a raycast in the physics world
  65163. * @param from when should the ray start?
  65164. * @param to when should the ray end?
  65165. * @returns PhysicsRaycastResult
  65166. */
  65167. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65168. }
  65169. }
  65170. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  65171. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65172. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65173. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65175. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  65176. import { Nullable } from "babylonjs/types";
  65177. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65178. /** @hidden */
  65179. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65180. private _useDeltaForWorldStep;
  65181. world: any;
  65182. name: string;
  65183. BJSOIMO: any;
  65184. private _raycastResult;
  65185. private _fixedTimeStep;
  65186. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65187. setGravity(gravity: Vector3): void;
  65188. setTimeStep(timeStep: number): void;
  65189. getTimeStep(): number;
  65190. private _tmpImpostorsArray;
  65191. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65192. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65193. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65194. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65195. private _tmpPositionVector;
  65196. removePhysicsBody(impostor: PhysicsImpostor): void;
  65197. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65198. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65199. isSupported(): boolean;
  65200. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65201. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65202. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65203. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65204. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65205. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65206. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65207. getBodyMass(impostor: PhysicsImpostor): number;
  65208. getBodyFriction(impostor: PhysicsImpostor): number;
  65209. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65210. getBodyRestitution(impostor: PhysicsImpostor): number;
  65211. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65212. sleepBody(impostor: PhysicsImpostor): void;
  65213. wakeUpBody(impostor: PhysicsImpostor): void;
  65214. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65215. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65216. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65217. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65218. getRadius(impostor: PhysicsImpostor): number;
  65219. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65220. dispose(): void;
  65221. /**
  65222. * Does a raycast in the physics world
  65223. * @param from when should the ray start?
  65224. * @param to when should the ray end?
  65225. * @returns PhysicsRaycastResult
  65226. */
  65227. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65228. }
  65229. }
  65230. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  65231. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  65232. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  65233. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65234. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  65235. import { Nullable } from "babylonjs/types";
  65236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65237. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  65238. /**
  65239. * AmmoJS Physics plugin
  65240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65241. * @see https://github.com/kripken/ammo.js/
  65242. */
  65243. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65244. private _useDeltaForWorldStep;
  65245. /**
  65246. * Reference to the Ammo library
  65247. */
  65248. bjsAMMO: any;
  65249. /**
  65250. * Created ammoJS world which physics bodies are added to
  65251. */
  65252. world: any;
  65253. /**
  65254. * Name of the plugin
  65255. */
  65256. name: string;
  65257. private _timeStep;
  65258. private _fixedTimeStep;
  65259. private _maxSteps;
  65260. private _tmpQuaternion;
  65261. private _tmpAmmoTransform;
  65262. private _tmpAmmoQuaternion;
  65263. private _tmpAmmoConcreteContactResultCallback;
  65264. private _collisionConfiguration;
  65265. private _dispatcher;
  65266. private _overlappingPairCache;
  65267. private _solver;
  65268. private _softBodySolver;
  65269. private _tmpAmmoVectorA;
  65270. private _tmpAmmoVectorB;
  65271. private _tmpAmmoVectorC;
  65272. private _tmpAmmoVectorD;
  65273. private _tmpContactCallbackResult;
  65274. private _tmpAmmoVectorRCA;
  65275. private _tmpAmmoVectorRCB;
  65276. private _raycastResult;
  65277. private _tmpContactPoint;
  65278. private static readonly DISABLE_COLLISION_FLAG;
  65279. private static readonly KINEMATIC_FLAG;
  65280. private static readonly DISABLE_DEACTIVATION_FLAG;
  65281. /**
  65282. * Initializes the ammoJS plugin
  65283. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65284. * @param ammoInjection can be used to inject your own ammo reference
  65285. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65286. */
  65287. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65288. /**
  65289. * Sets the gravity of the physics world (m/(s^2))
  65290. * @param gravity Gravity to set
  65291. */
  65292. setGravity(gravity: Vector3): void;
  65293. /**
  65294. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65295. * @param timeStep timestep to use in seconds
  65296. */
  65297. setTimeStep(timeStep: number): void;
  65298. /**
  65299. * 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)
  65300. * @param fixedTimeStep fixedTimeStep to use in seconds
  65301. */
  65302. setFixedTimeStep(fixedTimeStep: number): void;
  65303. /**
  65304. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65305. * @param maxSteps the maximum number of steps by the physics engine per frame
  65306. */
  65307. setMaxSteps(maxSteps: number): void;
  65308. /**
  65309. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65310. * @returns the current timestep in seconds
  65311. */
  65312. getTimeStep(): number;
  65313. /**
  65314. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65315. */
  65316. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65317. private _isImpostorInContact;
  65318. private _isImpostorPairInContact;
  65319. private _stepSimulation;
  65320. /**
  65321. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65322. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65323. * After the step the babylon meshes are set to the position of the physics imposters
  65324. * @param delta amount of time to step forward
  65325. * @param impostors array of imposters to update before/after the step
  65326. */
  65327. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65328. /**
  65329. * Update babylon mesh to match physics world object
  65330. * @param impostor imposter to match
  65331. */
  65332. private _afterSoftStep;
  65333. /**
  65334. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65335. * @param impostor imposter to match
  65336. */
  65337. private _ropeStep;
  65338. /**
  65339. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65340. * @param impostor imposter to match
  65341. */
  65342. private _softbodyOrClothStep;
  65343. private _tmpMatrix;
  65344. /**
  65345. * Applies an impulse on the imposter
  65346. * @param impostor imposter to apply impulse to
  65347. * @param force amount of force to be applied to the imposter
  65348. * @param contactPoint the location to apply the impulse on the imposter
  65349. */
  65350. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65351. /**
  65352. * Applies a force on the imposter
  65353. * @param impostor imposter to apply force
  65354. * @param force amount of force to be applied to the imposter
  65355. * @param contactPoint the location to apply the force on the imposter
  65356. */
  65357. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65358. /**
  65359. * Creates a physics body using the plugin
  65360. * @param impostor the imposter to create the physics body on
  65361. */
  65362. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65363. /**
  65364. * Removes the physics body from the imposter and disposes of the body's memory
  65365. * @param impostor imposter to remove the physics body from
  65366. */
  65367. removePhysicsBody(impostor: PhysicsImpostor): void;
  65368. /**
  65369. * Generates a joint
  65370. * @param impostorJoint the imposter joint to create the joint with
  65371. */
  65372. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65373. /**
  65374. * Removes a joint
  65375. * @param impostorJoint the imposter joint to remove the joint from
  65376. */
  65377. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65378. private _addMeshVerts;
  65379. /**
  65380. * Initialise the soft body vertices to match its object's (mesh) vertices
  65381. * Softbody vertices (nodes) are in world space and to match this
  65382. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65383. * @param impostor to create the softbody for
  65384. */
  65385. private _softVertexData;
  65386. /**
  65387. * Create an impostor's soft body
  65388. * @param impostor to create the softbody for
  65389. */
  65390. private _createSoftbody;
  65391. /**
  65392. * Create cloth for an impostor
  65393. * @param impostor to create the softbody for
  65394. */
  65395. private _createCloth;
  65396. /**
  65397. * Create rope for an impostor
  65398. * @param impostor to create the softbody for
  65399. */
  65400. private _createRope;
  65401. /**
  65402. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65403. * @param impostor to create the custom physics shape for
  65404. */
  65405. private _createCustom;
  65406. private _addHullVerts;
  65407. private _createShape;
  65408. /**
  65409. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65410. * @param impostor imposter containing the physics body and babylon object
  65411. */
  65412. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65413. /**
  65414. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65415. * @param impostor imposter containing the physics body and babylon object
  65416. * @param newPosition new position
  65417. * @param newRotation new rotation
  65418. */
  65419. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65420. /**
  65421. * If this plugin is supported
  65422. * @returns true if its supported
  65423. */
  65424. isSupported(): boolean;
  65425. /**
  65426. * Sets the linear velocity of the physics body
  65427. * @param impostor imposter to set the velocity on
  65428. * @param velocity velocity to set
  65429. */
  65430. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65431. /**
  65432. * Sets the angular velocity of the physics body
  65433. * @param impostor imposter to set the velocity on
  65434. * @param velocity velocity to set
  65435. */
  65436. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65437. /**
  65438. * gets the linear velocity
  65439. * @param impostor imposter to get linear velocity from
  65440. * @returns linear velocity
  65441. */
  65442. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65443. /**
  65444. * gets the angular velocity
  65445. * @param impostor imposter to get angular velocity from
  65446. * @returns angular velocity
  65447. */
  65448. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65449. /**
  65450. * Sets the mass of physics body
  65451. * @param impostor imposter to set the mass on
  65452. * @param mass mass to set
  65453. */
  65454. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65455. /**
  65456. * Gets the mass of the physics body
  65457. * @param impostor imposter to get the mass from
  65458. * @returns mass
  65459. */
  65460. getBodyMass(impostor: PhysicsImpostor): number;
  65461. /**
  65462. * Gets friction of the impostor
  65463. * @param impostor impostor to get friction from
  65464. * @returns friction value
  65465. */
  65466. getBodyFriction(impostor: PhysicsImpostor): number;
  65467. /**
  65468. * Sets friction of the impostor
  65469. * @param impostor impostor to set friction on
  65470. * @param friction friction value
  65471. */
  65472. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65473. /**
  65474. * Gets restitution of the impostor
  65475. * @param impostor impostor to get restitution from
  65476. * @returns restitution value
  65477. */
  65478. getBodyRestitution(impostor: PhysicsImpostor): number;
  65479. /**
  65480. * Sets resitution of the impostor
  65481. * @param impostor impostor to set resitution on
  65482. * @param restitution resitution value
  65483. */
  65484. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65485. /**
  65486. * Gets pressure inside the impostor
  65487. * @param impostor impostor to get pressure from
  65488. * @returns pressure value
  65489. */
  65490. getBodyPressure(impostor: PhysicsImpostor): number;
  65491. /**
  65492. * Sets pressure inside a soft body impostor
  65493. * Cloth and rope must remain 0 pressure
  65494. * @param impostor impostor to set pressure on
  65495. * @param pressure pressure value
  65496. */
  65497. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65498. /**
  65499. * Gets stiffness of the impostor
  65500. * @param impostor impostor to get stiffness from
  65501. * @returns pressure value
  65502. */
  65503. getBodyStiffness(impostor: PhysicsImpostor): number;
  65504. /**
  65505. * Sets stiffness of the impostor
  65506. * @param impostor impostor to set stiffness on
  65507. * @param stiffness stiffness value from 0 to 1
  65508. */
  65509. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65510. /**
  65511. * Gets velocityIterations of the impostor
  65512. * @param impostor impostor to get velocity iterations from
  65513. * @returns velocityIterations value
  65514. */
  65515. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65516. /**
  65517. * Sets velocityIterations of the impostor
  65518. * @param impostor impostor to set velocity iterations on
  65519. * @param velocityIterations velocityIterations value
  65520. */
  65521. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65522. /**
  65523. * Gets positionIterations of the impostor
  65524. * @param impostor impostor to get position iterations from
  65525. * @returns positionIterations value
  65526. */
  65527. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65528. /**
  65529. * Sets positionIterations of the impostor
  65530. * @param impostor impostor to set position on
  65531. * @param positionIterations positionIterations value
  65532. */
  65533. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65534. /**
  65535. * Append an anchor to a cloth object
  65536. * @param impostor is the cloth impostor to add anchor to
  65537. * @param otherImpostor is the rigid impostor to anchor to
  65538. * @param width ratio across width from 0 to 1
  65539. * @param height ratio up height from 0 to 1
  65540. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65541. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65542. */
  65543. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65544. /**
  65545. * Append an hook to a rope object
  65546. * @param impostor is the rope impostor to add hook to
  65547. * @param otherImpostor is the rigid impostor to hook to
  65548. * @param length ratio along the rope from 0 to 1
  65549. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65550. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65551. */
  65552. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65553. /**
  65554. * Sleeps the physics body and stops it from being active
  65555. * @param impostor impostor to sleep
  65556. */
  65557. sleepBody(impostor: PhysicsImpostor): void;
  65558. /**
  65559. * Activates the physics body
  65560. * @param impostor impostor to activate
  65561. */
  65562. wakeUpBody(impostor: PhysicsImpostor): void;
  65563. /**
  65564. * Updates the distance parameters of the joint
  65565. * @param joint joint to update
  65566. * @param maxDistance maximum distance of the joint
  65567. * @param minDistance minimum distance of the joint
  65568. */
  65569. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65570. /**
  65571. * Sets a motor on the joint
  65572. * @param joint joint to set motor on
  65573. * @param speed speed of the motor
  65574. * @param maxForce maximum force of the motor
  65575. * @param motorIndex index of the motor
  65576. */
  65577. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65578. /**
  65579. * Sets the motors limit
  65580. * @param joint joint to set limit on
  65581. * @param upperLimit upper limit
  65582. * @param lowerLimit lower limit
  65583. */
  65584. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65585. /**
  65586. * Syncs the position and rotation of a mesh with the impostor
  65587. * @param mesh mesh to sync
  65588. * @param impostor impostor to update the mesh with
  65589. */
  65590. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65591. /**
  65592. * Gets the radius of the impostor
  65593. * @param impostor impostor to get radius from
  65594. * @returns the radius
  65595. */
  65596. getRadius(impostor: PhysicsImpostor): number;
  65597. /**
  65598. * Gets the box size of the impostor
  65599. * @param impostor impostor to get box size from
  65600. * @param result the resulting box size
  65601. */
  65602. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65603. /**
  65604. * Disposes of the impostor
  65605. */
  65606. dispose(): void;
  65607. /**
  65608. * Does a raycast in the physics world
  65609. * @param from when should the ray start?
  65610. * @param to when should the ray end?
  65611. * @returns PhysicsRaycastResult
  65612. */
  65613. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65614. }
  65615. }
  65616. declare module "babylonjs/Probes/reflectionProbe" {
  65617. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65618. import { Vector3 } from "babylonjs/Maths/math.vector";
  65619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65620. import { Nullable } from "babylonjs/types";
  65621. import { Scene } from "babylonjs/scene";
  65622. module "babylonjs/abstractScene" {
  65623. interface AbstractScene {
  65624. /**
  65625. * The list of reflection probes added to the scene
  65626. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65627. */
  65628. reflectionProbes: Array<ReflectionProbe>;
  65629. /**
  65630. * Removes the given reflection probe from this scene.
  65631. * @param toRemove The reflection probe to remove
  65632. * @returns The index of the removed reflection probe
  65633. */
  65634. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65635. /**
  65636. * Adds the given reflection probe to this scene.
  65637. * @param newReflectionProbe The reflection probe to add
  65638. */
  65639. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65640. }
  65641. }
  65642. /**
  65643. * Class used to generate realtime reflection / refraction cube textures
  65644. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65645. */
  65646. export class ReflectionProbe {
  65647. /** defines the name of the probe */
  65648. name: string;
  65649. private _scene;
  65650. private _renderTargetTexture;
  65651. private _projectionMatrix;
  65652. private _viewMatrix;
  65653. private _target;
  65654. private _add;
  65655. private _attachedMesh;
  65656. private _invertYAxis;
  65657. /** Gets or sets probe position (center of the cube map) */
  65658. position: Vector3;
  65659. /**
  65660. * Creates a new reflection probe
  65661. * @param name defines the name of the probe
  65662. * @param size defines the texture resolution (for each face)
  65663. * @param scene defines the hosting scene
  65664. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65665. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65666. */
  65667. constructor(
  65668. /** defines the name of the probe */
  65669. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65670. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65671. get samples(): number;
  65672. set samples(value: number);
  65673. /** Gets or sets the refresh rate to use (on every frame by default) */
  65674. get refreshRate(): number;
  65675. set refreshRate(value: number);
  65676. /**
  65677. * Gets the hosting scene
  65678. * @returns a Scene
  65679. */
  65680. getScene(): Scene;
  65681. /** Gets the internal CubeTexture used to render to */
  65682. get cubeTexture(): RenderTargetTexture;
  65683. /** Gets the list of meshes to render */
  65684. get renderList(): Nullable<AbstractMesh[]>;
  65685. /**
  65686. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65687. * @param mesh defines the mesh to attach to
  65688. */
  65689. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65690. /**
  65691. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65692. * @param renderingGroupId The rendering group id corresponding to its index
  65693. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65694. */
  65695. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65696. /**
  65697. * Clean all associated resources
  65698. */
  65699. dispose(): void;
  65700. /**
  65701. * Converts the reflection probe information to a readable string for debug purpose.
  65702. * @param fullDetails Supports for multiple levels of logging within scene loading
  65703. * @returns the human readable reflection probe info
  65704. */
  65705. toString(fullDetails?: boolean): string;
  65706. /**
  65707. * Get the class name of the relfection probe.
  65708. * @returns "ReflectionProbe"
  65709. */
  65710. getClassName(): string;
  65711. /**
  65712. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65713. * @returns The JSON representation of the texture
  65714. */
  65715. serialize(): any;
  65716. /**
  65717. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65718. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65719. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65720. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65721. * @returns The parsed reflection probe if successful
  65722. */
  65723. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65724. }
  65725. }
  65726. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65727. /** @hidden */
  65728. export var _BabylonLoaderRegistered: boolean;
  65729. /**
  65730. * Helps setting up some configuration for the babylon file loader.
  65731. */
  65732. export class BabylonFileLoaderConfiguration {
  65733. /**
  65734. * The loader does not allow injecting custom physix engine into the plugins.
  65735. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65736. * So you could set this variable to your engine import to make it work.
  65737. */
  65738. static LoaderInjectedPhysicsEngine: any;
  65739. }
  65740. }
  65741. declare module "babylonjs/Loading/Plugins/index" {
  65742. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65743. }
  65744. declare module "babylonjs/Loading/index" {
  65745. export * from "babylonjs/Loading/loadingScreen";
  65746. export * from "babylonjs/Loading/Plugins/index";
  65747. export * from "babylonjs/Loading/sceneLoader";
  65748. export * from "babylonjs/Loading/sceneLoaderFlags";
  65749. }
  65750. declare module "babylonjs/Materials/Background/index" {
  65751. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65752. }
  65753. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65754. import { Scene } from "babylonjs/scene";
  65755. import { Color3 } from "babylonjs/Maths/math.color";
  65756. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65757. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65758. /**
  65759. * The Physically based simple base material of BJS.
  65760. *
  65761. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65762. * It is used as the base class for both the specGloss and metalRough conventions.
  65763. */
  65764. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65765. /**
  65766. * Number of Simultaneous lights allowed on the material.
  65767. */
  65768. maxSimultaneousLights: number;
  65769. /**
  65770. * If sets to true, disables all the lights affecting the material.
  65771. */
  65772. disableLighting: boolean;
  65773. /**
  65774. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65775. */
  65776. environmentTexture: BaseTexture;
  65777. /**
  65778. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65779. */
  65780. invertNormalMapX: boolean;
  65781. /**
  65782. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65783. */
  65784. invertNormalMapY: boolean;
  65785. /**
  65786. * Normal map used in the model.
  65787. */
  65788. normalTexture: BaseTexture;
  65789. /**
  65790. * Emissivie color used to self-illuminate the model.
  65791. */
  65792. emissiveColor: Color3;
  65793. /**
  65794. * Emissivie texture used to self-illuminate the model.
  65795. */
  65796. emissiveTexture: BaseTexture;
  65797. /**
  65798. * Occlusion Channel Strenght.
  65799. */
  65800. occlusionStrength: number;
  65801. /**
  65802. * Occlusion Texture of the material (adding extra occlusion effects).
  65803. */
  65804. occlusionTexture: BaseTexture;
  65805. /**
  65806. * Defines the alpha limits in alpha test mode.
  65807. */
  65808. alphaCutOff: number;
  65809. /**
  65810. * Gets the current double sided mode.
  65811. */
  65812. get doubleSided(): boolean;
  65813. /**
  65814. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65815. */
  65816. set doubleSided(value: boolean);
  65817. /**
  65818. * Stores the pre-calculated light information of a mesh in a texture.
  65819. */
  65820. lightmapTexture: BaseTexture;
  65821. /**
  65822. * If true, the light map contains occlusion information instead of lighting info.
  65823. */
  65824. useLightmapAsShadowmap: boolean;
  65825. /**
  65826. * Instantiates a new PBRMaterial instance.
  65827. *
  65828. * @param name The material name
  65829. * @param scene The scene the material will be use in.
  65830. */
  65831. constructor(name: string, scene: Scene);
  65832. getClassName(): string;
  65833. }
  65834. }
  65835. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65836. import { Scene } from "babylonjs/scene";
  65837. import { Color3 } from "babylonjs/Maths/math.color";
  65838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65839. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65840. /**
  65841. * The PBR material of BJS following the metal roughness convention.
  65842. *
  65843. * This fits to the PBR convention in the GLTF definition:
  65844. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65845. */
  65846. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65847. /**
  65848. * The base color has two different interpretations depending on the value of metalness.
  65849. * When the material is a metal, the base color is the specific measured reflectance value
  65850. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65851. * of the material.
  65852. */
  65853. baseColor: Color3;
  65854. /**
  65855. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65856. * well as opacity information in the alpha channel.
  65857. */
  65858. baseTexture: BaseTexture;
  65859. /**
  65860. * Specifies the metallic scalar value of the material.
  65861. * Can also be used to scale the metalness values of the metallic texture.
  65862. */
  65863. metallic: number;
  65864. /**
  65865. * Specifies the roughness scalar value of the material.
  65866. * Can also be used to scale the roughness values of the metallic texture.
  65867. */
  65868. roughness: number;
  65869. /**
  65870. * Texture containing both the metallic value in the B channel and the
  65871. * roughness value in the G channel to keep better precision.
  65872. */
  65873. metallicRoughnessTexture: BaseTexture;
  65874. /**
  65875. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65876. *
  65877. * @param name The material name
  65878. * @param scene The scene the material will be use in.
  65879. */
  65880. constructor(name: string, scene: Scene);
  65881. /**
  65882. * Return the currrent class name of the material.
  65883. */
  65884. getClassName(): string;
  65885. /**
  65886. * Makes a duplicate of the current material.
  65887. * @param name - name to use for the new material.
  65888. */
  65889. clone(name: string): PBRMetallicRoughnessMaterial;
  65890. /**
  65891. * Serialize the material to a parsable JSON object.
  65892. */
  65893. serialize(): any;
  65894. /**
  65895. * Parses a JSON object correponding to the serialize function.
  65896. */
  65897. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65898. }
  65899. }
  65900. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65901. import { Scene } from "babylonjs/scene";
  65902. import { Color3 } from "babylonjs/Maths/math.color";
  65903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65904. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65905. /**
  65906. * The PBR material of BJS following the specular glossiness convention.
  65907. *
  65908. * This fits to the PBR convention in the GLTF definition:
  65909. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65910. */
  65911. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65912. /**
  65913. * Specifies the diffuse color of the material.
  65914. */
  65915. diffuseColor: Color3;
  65916. /**
  65917. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65918. * channel.
  65919. */
  65920. diffuseTexture: BaseTexture;
  65921. /**
  65922. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65923. */
  65924. specularColor: Color3;
  65925. /**
  65926. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65927. */
  65928. glossiness: number;
  65929. /**
  65930. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65931. */
  65932. specularGlossinessTexture: BaseTexture;
  65933. /**
  65934. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65935. *
  65936. * @param name The material name
  65937. * @param scene The scene the material will be use in.
  65938. */
  65939. constructor(name: string, scene: Scene);
  65940. /**
  65941. * Return the currrent class name of the material.
  65942. */
  65943. getClassName(): string;
  65944. /**
  65945. * Makes a duplicate of the current material.
  65946. * @param name - name to use for the new material.
  65947. */
  65948. clone(name: string): PBRSpecularGlossinessMaterial;
  65949. /**
  65950. * Serialize the material to a parsable JSON object.
  65951. */
  65952. serialize(): any;
  65953. /**
  65954. * Parses a JSON object correponding to the serialize function.
  65955. */
  65956. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65957. }
  65958. }
  65959. declare module "babylonjs/Materials/PBR/index" {
  65960. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65961. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65962. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65963. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65964. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65965. }
  65966. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65967. import { Nullable } from "babylonjs/types";
  65968. import { Scene } from "babylonjs/scene";
  65969. import { Matrix } from "babylonjs/Maths/math.vector";
  65970. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65971. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65972. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65973. /**
  65974. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65975. * It can help converting any input color in a desired output one. This can then be used to create effects
  65976. * from sepia, black and white to sixties or futuristic rendering...
  65977. *
  65978. * The only supported format is currently 3dl.
  65979. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65980. */
  65981. export class ColorGradingTexture extends BaseTexture {
  65982. /**
  65983. * The texture URL.
  65984. */
  65985. url: string;
  65986. /**
  65987. * Empty line regex stored for GC.
  65988. */
  65989. private static _noneEmptyLineRegex;
  65990. private _textureMatrix;
  65991. private _onLoad;
  65992. /**
  65993. * Instantiates a ColorGradingTexture from the following parameters.
  65994. *
  65995. * @param url The location of the color gradind data (currently only supporting 3dl)
  65996. * @param sceneOrEngine The scene or engine the texture will be used in
  65997. * @param onLoad defines a callback triggered when the texture has been loaded
  65998. */
  65999. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  66000. /**
  66001. * Fires the onload event from the constructor if requested.
  66002. */
  66003. private _triggerOnLoad;
  66004. /**
  66005. * Returns the texture matrix used in most of the material.
  66006. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  66007. */
  66008. getTextureMatrix(): Matrix;
  66009. /**
  66010. * Occurs when the file being loaded is a .3dl LUT file.
  66011. */
  66012. private load3dlTexture;
  66013. /**
  66014. * Starts the loading process of the texture.
  66015. */
  66016. private loadTexture;
  66017. /**
  66018. * Clones the color gradind texture.
  66019. */
  66020. clone(): ColorGradingTexture;
  66021. /**
  66022. * Called during delayed load for textures.
  66023. */
  66024. delayLoad(): void;
  66025. /**
  66026. * Parses a color grading texture serialized by Babylon.
  66027. * @param parsedTexture The texture information being parsedTexture
  66028. * @param scene The scene to load the texture in
  66029. * @param rootUrl The root url of the data assets to load
  66030. * @return A color gradind texture
  66031. */
  66032. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  66033. /**
  66034. * Serializes the LUT texture to json format.
  66035. */
  66036. serialize(): any;
  66037. }
  66038. }
  66039. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  66040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66041. import { Scene } from "babylonjs/scene";
  66042. import { Nullable } from "babylonjs/types";
  66043. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66044. /**
  66045. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  66046. */
  66047. export class EquiRectangularCubeTexture extends BaseTexture {
  66048. /** The six faces of the cube. */
  66049. private static _FacesMapping;
  66050. private _noMipmap;
  66051. private _onLoad;
  66052. private _onError;
  66053. /** The size of the cubemap. */
  66054. private _size;
  66055. /** The buffer of the image. */
  66056. private _buffer;
  66057. /** The width of the input image. */
  66058. private _width;
  66059. /** The height of the input image. */
  66060. private _height;
  66061. /** The URL to the image. */
  66062. url: string;
  66063. /**
  66064. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  66065. * @param url The location of the image
  66066. * @param scene The scene the texture will be used in
  66067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  66068. * @param noMipmap Forces to not generate the mipmap if true
  66069. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  66070. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  66071. * @param onLoad — defines a callback called when texture is loaded
  66072. * @param onError — defines a callback called if there is an error
  66073. */
  66074. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  66075. /**
  66076. * Load the image data, by putting the image on a canvas and extracting its buffer.
  66077. */
  66078. private loadImage;
  66079. /**
  66080. * Convert the image buffer into a cubemap and create a CubeTexture.
  66081. */
  66082. private loadTexture;
  66083. /**
  66084. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  66085. * @param buffer The ArrayBuffer that should be converted.
  66086. * @returns The buffer as Float32Array.
  66087. */
  66088. private getFloat32ArrayFromArrayBuffer;
  66089. /**
  66090. * Get the current class name of the texture useful for serialization or dynamic coding.
  66091. * @returns "EquiRectangularCubeTexture"
  66092. */
  66093. getClassName(): string;
  66094. /**
  66095. * Create a clone of the current EquiRectangularCubeTexture and return it.
  66096. * @returns A clone of the current EquiRectangularCubeTexture.
  66097. */
  66098. clone(): EquiRectangularCubeTexture;
  66099. }
  66100. }
  66101. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  66102. import { Nullable } from "babylonjs/types";
  66103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66104. import { Matrix } from "babylonjs/Maths/math.vector";
  66105. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  66106. import "babylonjs/Engines/Extensions/engine.videoTexture";
  66107. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  66108. import { Scene } from "babylonjs/scene";
  66109. /**
  66110. * Defines the options related to the creation of an HtmlElementTexture
  66111. */
  66112. export interface IHtmlElementTextureOptions {
  66113. /**
  66114. * Defines wether mip maps should be created or not.
  66115. */
  66116. generateMipMaps?: boolean;
  66117. /**
  66118. * Defines the sampling mode of the texture.
  66119. */
  66120. samplingMode?: number;
  66121. /**
  66122. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  66123. */
  66124. engine: Nullable<ThinEngine>;
  66125. /**
  66126. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  66127. */
  66128. scene: Nullable<Scene>;
  66129. }
  66130. /**
  66131. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  66132. * To be as efficient as possible depending on your constraints nothing aside the first upload
  66133. * is automatically managed.
  66134. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  66135. * in your application.
  66136. *
  66137. * As the update is not automatic, you need to call them manually.
  66138. */
  66139. export class HtmlElementTexture extends BaseTexture {
  66140. /**
  66141. * The texture URL.
  66142. */
  66143. element: HTMLVideoElement | HTMLCanvasElement;
  66144. private static readonly DefaultOptions;
  66145. private _textureMatrix;
  66146. private _isVideo;
  66147. private _generateMipMaps;
  66148. private _samplingMode;
  66149. /**
  66150. * Instantiates a HtmlElementTexture from the following parameters.
  66151. *
  66152. * @param name Defines the name of the texture
  66153. * @param element Defines the video or canvas the texture is filled with
  66154. * @param options Defines the other none mandatory texture creation options
  66155. */
  66156. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  66157. private _createInternalTexture;
  66158. /**
  66159. * Returns the texture matrix used in most of the material.
  66160. */
  66161. getTextureMatrix(): Matrix;
  66162. /**
  66163. * Updates the content of the texture.
  66164. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  66165. */
  66166. update(invertY?: Nullable<boolean>): void;
  66167. }
  66168. }
  66169. declare module "babylonjs/Misc/tga" {
  66170. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66171. /**
  66172. * Based on jsTGALoader - Javascript loader for TGA file
  66173. * By Vincent Thibault
  66174. * @see http://blog.robrowser.com/javascript-tga-loader.html
  66175. */
  66176. export class TGATools {
  66177. private static _TYPE_INDEXED;
  66178. private static _TYPE_RGB;
  66179. private static _TYPE_GREY;
  66180. private static _TYPE_RLE_INDEXED;
  66181. private static _TYPE_RLE_RGB;
  66182. private static _TYPE_RLE_GREY;
  66183. private static _ORIGIN_MASK;
  66184. private static _ORIGIN_SHIFT;
  66185. private static _ORIGIN_BL;
  66186. private static _ORIGIN_BR;
  66187. private static _ORIGIN_UL;
  66188. private static _ORIGIN_UR;
  66189. /**
  66190. * Gets the header of a TGA file
  66191. * @param data defines the TGA data
  66192. * @returns the header
  66193. */
  66194. static GetTGAHeader(data: Uint8Array): any;
  66195. /**
  66196. * Uploads TGA content to a Babylon Texture
  66197. * @hidden
  66198. */
  66199. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  66200. /** @hidden */
  66201. 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;
  66202. /** @hidden */
  66203. 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;
  66204. /** @hidden */
  66205. 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;
  66206. /** @hidden */
  66207. 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;
  66208. /** @hidden */
  66209. 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;
  66210. /** @hidden */
  66211. 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;
  66212. }
  66213. }
  66214. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  66215. import { Nullable } from "babylonjs/types";
  66216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66217. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66218. /**
  66219. * Implementation of the TGA Texture Loader.
  66220. * @hidden
  66221. */
  66222. export class _TGATextureLoader implements IInternalTextureLoader {
  66223. /**
  66224. * Defines wether the loader supports cascade loading the different faces.
  66225. */
  66226. readonly supportCascades: boolean;
  66227. /**
  66228. * This returns if the loader support the current file information.
  66229. * @param extension defines the file extension of the file being loaded
  66230. * @returns true if the loader can load the specified file
  66231. */
  66232. canLoad(extension: string): boolean;
  66233. /**
  66234. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66235. * @param data contains the texture data
  66236. * @param texture defines the BabylonJS internal texture
  66237. * @param createPolynomials will be true if polynomials have been requested
  66238. * @param onLoad defines the callback to trigger once the texture is ready
  66239. * @param onError defines the callback to trigger in case of error
  66240. */
  66241. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66242. /**
  66243. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66244. * @param data contains the texture data
  66245. * @param texture defines the BabylonJS internal texture
  66246. * @param callback defines the method to call once ready to upload
  66247. */
  66248. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66249. }
  66250. }
  66251. declare module "babylonjs/Misc/basis" {
  66252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66253. /**
  66254. * Info about the .basis files
  66255. */
  66256. class BasisFileInfo {
  66257. /**
  66258. * If the file has alpha
  66259. */
  66260. hasAlpha: boolean;
  66261. /**
  66262. * Info about each image of the basis file
  66263. */
  66264. images: Array<{
  66265. levels: Array<{
  66266. width: number;
  66267. height: number;
  66268. transcodedPixels: ArrayBufferView;
  66269. }>;
  66270. }>;
  66271. }
  66272. /**
  66273. * Result of transcoding a basis file
  66274. */
  66275. class TranscodeResult {
  66276. /**
  66277. * Info about the .basis file
  66278. */
  66279. fileInfo: BasisFileInfo;
  66280. /**
  66281. * Format to use when loading the file
  66282. */
  66283. format: number;
  66284. }
  66285. /**
  66286. * Configuration options for the Basis transcoder
  66287. */
  66288. export class BasisTranscodeConfiguration {
  66289. /**
  66290. * Supported compression formats used to determine the supported output format of the transcoder
  66291. */
  66292. supportedCompressionFormats?: {
  66293. /**
  66294. * etc1 compression format
  66295. */
  66296. etc1?: boolean;
  66297. /**
  66298. * s3tc compression format
  66299. */
  66300. s3tc?: boolean;
  66301. /**
  66302. * pvrtc compression format
  66303. */
  66304. pvrtc?: boolean;
  66305. /**
  66306. * etc2 compression format
  66307. */
  66308. etc2?: boolean;
  66309. };
  66310. /**
  66311. * If mipmap levels should be loaded for transcoded images (Default: true)
  66312. */
  66313. loadMipmapLevels?: boolean;
  66314. /**
  66315. * Index of a single image to load (Default: all images)
  66316. */
  66317. loadSingleImage?: number;
  66318. }
  66319. /**
  66320. * Used to load .Basis files
  66321. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66322. */
  66323. export class BasisTools {
  66324. private static _IgnoreSupportedFormats;
  66325. /**
  66326. * URL to use when loading the basis transcoder
  66327. */
  66328. static JSModuleURL: string;
  66329. /**
  66330. * URL to use when loading the wasm module for the transcoder
  66331. */
  66332. static WasmModuleURL: string;
  66333. /**
  66334. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66335. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66336. * @returns internal format corresponding to the Basis format
  66337. */
  66338. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66339. private static _WorkerPromise;
  66340. private static _Worker;
  66341. private static _actionId;
  66342. private static _CreateWorkerAsync;
  66343. /**
  66344. * Transcodes a loaded image file to compressed pixel data
  66345. * @param data image data to transcode
  66346. * @param config configuration options for the transcoding
  66347. * @returns a promise resulting in the transcoded image
  66348. */
  66349. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66350. /**
  66351. * Loads a texture from the transcode result
  66352. * @param texture texture load to
  66353. * @param transcodeResult the result of transcoding the basis file to load from
  66354. */
  66355. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66356. }
  66357. }
  66358. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  66359. import { Nullable } from "babylonjs/types";
  66360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66361. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  66362. /**
  66363. * Loader for .basis file format
  66364. */
  66365. export class _BasisTextureLoader implements IInternalTextureLoader {
  66366. /**
  66367. * Defines whether the loader supports cascade loading the different faces.
  66368. */
  66369. readonly supportCascades: boolean;
  66370. /**
  66371. * This returns if the loader support the current file information.
  66372. * @param extension defines the file extension of the file being loaded
  66373. * @returns true if the loader can load the specified file
  66374. */
  66375. canLoad(extension: string): boolean;
  66376. /**
  66377. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66378. * @param data contains the texture data
  66379. * @param texture defines the BabylonJS internal texture
  66380. * @param createPolynomials will be true if polynomials have been requested
  66381. * @param onLoad defines the callback to trigger once the texture is ready
  66382. * @param onError defines the callback to trigger in case of error
  66383. */
  66384. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66385. /**
  66386. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66387. * @param data contains the texture data
  66388. * @param texture defines the BabylonJS internal texture
  66389. * @param callback defines the method to call once ready to upload
  66390. */
  66391. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66392. }
  66393. }
  66394. declare module "babylonjs/Materials/Textures/Loaders/index" {
  66395. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  66396. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  66397. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  66398. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  66399. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  66400. }
  66401. declare module "babylonjs/Materials/Textures/Packer/frame" {
  66402. import { Vector2 } from "babylonjs/Maths/math.vector";
  66403. /**
  66404. * Defines the basic options interface of a TexturePacker Frame
  66405. */
  66406. export interface ITexturePackerFrame {
  66407. /**
  66408. * The frame ID
  66409. */
  66410. id: number;
  66411. /**
  66412. * The frames Scale
  66413. */
  66414. scale: Vector2;
  66415. /**
  66416. * The Frames offset
  66417. */
  66418. offset: Vector2;
  66419. }
  66420. /**
  66421. * This is a support class for frame Data on texture packer sets.
  66422. */
  66423. export class TexturePackerFrame implements ITexturePackerFrame {
  66424. /**
  66425. * The frame ID
  66426. */
  66427. id: number;
  66428. /**
  66429. * The frames Scale
  66430. */
  66431. scale: Vector2;
  66432. /**
  66433. * The Frames offset
  66434. */
  66435. offset: Vector2;
  66436. /**
  66437. * Initializes a texture package frame.
  66438. * @param id The numerical frame identifier
  66439. * @param scale Scalar Vector2 for UV frame
  66440. * @param offset Vector2 for the frame position in UV units.
  66441. * @returns TexturePackerFrame
  66442. */
  66443. constructor(id: number, scale: Vector2, offset: Vector2);
  66444. }
  66445. }
  66446. declare module "babylonjs/Materials/Textures/Packer/packer" {
  66447. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66448. import { Scene } from "babylonjs/scene";
  66449. import { Nullable } from "babylonjs/types";
  66450. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  66451. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  66452. /**
  66453. * Defines the basic options interface of a TexturePacker
  66454. */
  66455. export interface ITexturePackerOptions {
  66456. /**
  66457. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66458. */
  66459. map?: string[];
  66460. /**
  66461. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66462. */
  66463. uvsIn?: string;
  66464. /**
  66465. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66466. */
  66467. uvsOut?: string;
  66468. /**
  66469. * number representing the layout style. Defaults to LAYOUT_STRIP
  66470. */
  66471. layout?: number;
  66472. /**
  66473. * number of columns if using custom column count layout(2). This defaults to 4.
  66474. */
  66475. colnum?: number;
  66476. /**
  66477. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66478. */
  66479. updateInputMeshes?: boolean;
  66480. /**
  66481. * boolean flag to dispose all the source textures. Defaults to true.
  66482. */
  66483. disposeSources?: boolean;
  66484. /**
  66485. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66486. */
  66487. fillBlanks?: boolean;
  66488. /**
  66489. * string value representing the context fill style color. Defaults to 'black'.
  66490. */
  66491. customFillColor?: string;
  66492. /**
  66493. * Width and Height Value of each Frame in the TexturePacker Sets
  66494. */
  66495. frameSize?: number;
  66496. /**
  66497. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66498. */
  66499. paddingRatio?: number;
  66500. /**
  66501. * Number that declares the fill method for the padding gutter.
  66502. */
  66503. paddingMode?: number;
  66504. /**
  66505. * If in SUBUV_COLOR padding mode what color to use.
  66506. */
  66507. paddingColor?: Color3 | Color4;
  66508. }
  66509. /**
  66510. * Defines the basic interface of a TexturePacker JSON File
  66511. */
  66512. export interface ITexturePackerJSON {
  66513. /**
  66514. * The frame ID
  66515. */
  66516. name: string;
  66517. /**
  66518. * The base64 channel data
  66519. */
  66520. sets: any;
  66521. /**
  66522. * The options of the Packer
  66523. */
  66524. options: ITexturePackerOptions;
  66525. /**
  66526. * The frame data of the Packer
  66527. */
  66528. frames: Array<number>;
  66529. }
  66530. /**
  66531. * This is a support class that generates a series of packed texture sets.
  66532. * @see https://doc.babylonjs.com/babylon101/materials
  66533. */
  66534. export class TexturePacker {
  66535. /** Packer Layout Constant 0 */
  66536. static readonly LAYOUT_STRIP: number;
  66537. /** Packer Layout Constant 1 */
  66538. static readonly LAYOUT_POWER2: number;
  66539. /** Packer Layout Constant 2 */
  66540. static readonly LAYOUT_COLNUM: number;
  66541. /** Packer Layout Constant 0 */
  66542. static readonly SUBUV_WRAP: number;
  66543. /** Packer Layout Constant 1 */
  66544. static readonly SUBUV_EXTEND: number;
  66545. /** Packer Layout Constant 2 */
  66546. static readonly SUBUV_COLOR: number;
  66547. /** The Name of the Texture Package */
  66548. name: string;
  66549. /** The scene scope of the TexturePacker */
  66550. scene: Scene;
  66551. /** The Meshes to target */
  66552. meshes: AbstractMesh[];
  66553. /** Arguments passed with the Constructor */
  66554. options: ITexturePackerOptions;
  66555. /** The promise that is started upon initialization */
  66556. promise: Nullable<Promise<TexturePacker | string>>;
  66557. /** The Container object for the channel sets that are generated */
  66558. sets: object;
  66559. /** The Container array for the frames that are generated */
  66560. frames: TexturePackerFrame[];
  66561. /** The expected number of textures the system is parsing. */
  66562. private _expecting;
  66563. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66564. private _paddingValue;
  66565. /**
  66566. * Initializes a texture package series from an array of meshes or a single mesh.
  66567. * @param name The name of the package
  66568. * @param meshes The target meshes to compose the package from
  66569. * @param options The arguments that texture packer should follow while building.
  66570. * @param scene The scene which the textures are scoped to.
  66571. * @returns TexturePacker
  66572. */
  66573. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66574. /**
  66575. * Starts the package process
  66576. * @param resolve The promises resolution function
  66577. * @returns TexturePacker
  66578. */
  66579. private _createFrames;
  66580. /**
  66581. * Calculates the Size of the Channel Sets
  66582. * @returns Vector2
  66583. */
  66584. private _calculateSize;
  66585. /**
  66586. * Calculates the UV data for the frames.
  66587. * @param baseSize the base frameSize
  66588. * @param padding the base frame padding
  66589. * @param dtSize size of the Dynamic Texture for that channel
  66590. * @param dtUnits is 1/dtSize
  66591. * @param update flag to update the input meshes
  66592. */
  66593. private _calculateMeshUVFrames;
  66594. /**
  66595. * Calculates the frames Offset.
  66596. * @param index of the frame
  66597. * @returns Vector2
  66598. */
  66599. private _getFrameOffset;
  66600. /**
  66601. * Updates a Mesh to the frame data
  66602. * @param mesh that is the target
  66603. * @param frameID or the frame index
  66604. */
  66605. private _updateMeshUV;
  66606. /**
  66607. * Updates a Meshes materials to use the texture packer channels
  66608. * @param m is the mesh to target
  66609. * @param force all channels on the packer to be set.
  66610. */
  66611. private _updateTextureReferences;
  66612. /**
  66613. * Public method to set a Mesh to a frame
  66614. * @param m that is the target
  66615. * @param frameID or the frame index
  66616. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66617. */
  66618. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66619. /**
  66620. * Starts the async promise to compile the texture packer.
  66621. * @returns Promise<void>
  66622. */
  66623. processAsync(): Promise<void>;
  66624. /**
  66625. * Disposes all textures associated with this packer
  66626. */
  66627. dispose(): void;
  66628. /**
  66629. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66630. * @param imageType is the image type to use.
  66631. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66632. */
  66633. download(imageType?: string, quality?: number): void;
  66634. /**
  66635. * Public method to load a texturePacker JSON file.
  66636. * @param data of the JSON file in string format.
  66637. */
  66638. updateFromJSON(data: string): void;
  66639. }
  66640. }
  66641. declare module "babylonjs/Materials/Textures/Packer/index" {
  66642. export * from "babylonjs/Materials/Textures/Packer/packer";
  66643. export * from "babylonjs/Materials/Textures/Packer/frame";
  66644. }
  66645. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66646. import { Scene } from "babylonjs/scene";
  66647. import { Texture } from "babylonjs/Materials/Textures/texture";
  66648. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66649. /**
  66650. * 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.
  66651. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66652. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66653. */
  66654. export class CustomProceduralTexture extends ProceduralTexture {
  66655. private _animate;
  66656. private _time;
  66657. private _config;
  66658. private _texturePath;
  66659. /**
  66660. * Instantiates a new Custom Procedural Texture.
  66661. * 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.
  66662. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66663. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66664. * @param name Define the name of the texture
  66665. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66666. * @param size Define the size of the texture to create
  66667. * @param scene Define the scene the texture belongs to
  66668. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66669. * @param generateMipMaps Define if the texture should creates mip maps or not
  66670. */
  66671. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66672. private _loadJson;
  66673. /**
  66674. * Is the texture ready to be used ? (rendered at least once)
  66675. * @returns true if ready, otherwise, false.
  66676. */
  66677. isReady(): boolean;
  66678. /**
  66679. * Render the texture to its associated render target.
  66680. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66681. */
  66682. render(useCameraPostProcess?: boolean): void;
  66683. /**
  66684. * Update the list of dependant textures samplers in the shader.
  66685. */
  66686. updateTextures(): void;
  66687. /**
  66688. * Update the uniform values of the procedural texture in the shader.
  66689. */
  66690. updateShaderUniforms(): void;
  66691. /**
  66692. * Define if the texture animates or not.
  66693. */
  66694. get animate(): boolean;
  66695. set animate(value: boolean);
  66696. }
  66697. }
  66698. declare module "babylonjs/Shaders/noise.fragment" {
  66699. /** @hidden */
  66700. export var noisePixelShader: {
  66701. name: string;
  66702. shader: string;
  66703. };
  66704. }
  66705. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66706. import { Nullable } from "babylonjs/types";
  66707. import { Scene } from "babylonjs/scene";
  66708. import { Texture } from "babylonjs/Materials/Textures/texture";
  66709. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66710. import "babylonjs/Shaders/noise.fragment";
  66711. /**
  66712. * Class used to generate noise procedural textures
  66713. */
  66714. export class NoiseProceduralTexture extends ProceduralTexture {
  66715. /** Gets or sets the start time (default is 0) */
  66716. time: number;
  66717. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66718. brightness: number;
  66719. /** Defines the number of octaves to process */
  66720. octaves: number;
  66721. /** Defines the level of persistence (0.8 by default) */
  66722. persistence: number;
  66723. /** Gets or sets animation speed factor (default is 1) */
  66724. animationSpeedFactor: number;
  66725. /**
  66726. * Creates a new NoiseProceduralTexture
  66727. * @param name defines the name fo the texture
  66728. * @param size defines the size of the texture (default is 256)
  66729. * @param scene defines the hosting scene
  66730. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66731. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66732. */
  66733. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66734. private _updateShaderUniforms;
  66735. protected _getDefines(): string;
  66736. /** Generate the current state of the procedural texture */
  66737. render(useCameraPostProcess?: boolean): void;
  66738. /**
  66739. * Serializes this noise procedural texture
  66740. * @returns a serialized noise procedural texture object
  66741. */
  66742. serialize(): any;
  66743. /**
  66744. * Clone the texture.
  66745. * @returns the cloned texture
  66746. */
  66747. clone(): NoiseProceduralTexture;
  66748. /**
  66749. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66750. * @param parsedTexture defines parsed texture data
  66751. * @param scene defines the current scene
  66752. * @param rootUrl defines the root URL containing noise procedural texture information
  66753. * @returns a parsed NoiseProceduralTexture
  66754. */
  66755. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66756. }
  66757. }
  66758. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66759. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66760. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66761. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66762. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66763. }
  66764. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66765. import { Nullable } from "babylonjs/types";
  66766. import { Scene } from "babylonjs/scene";
  66767. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66769. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66771. /**
  66772. * Raw cube texture where the raw buffers are passed in
  66773. */
  66774. export class RawCubeTexture extends CubeTexture {
  66775. /**
  66776. * Creates a cube texture where the raw buffers are passed in.
  66777. * @param scene defines the scene the texture is attached to
  66778. * @param data defines the array of data to use to create each face
  66779. * @param size defines the size of the textures
  66780. * @param format defines the format of the data
  66781. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66782. * @param generateMipMaps defines if the engine should generate the mip levels
  66783. * @param invertY defines if data must be stored with Y axis inverted
  66784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66785. * @param compression defines the compression used (null by default)
  66786. */
  66787. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66788. /**
  66789. * Updates the raw cube texture.
  66790. * @param data defines the data to store
  66791. * @param format defines the data format
  66792. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66793. * @param invertY defines if data must be stored with Y axis inverted
  66794. * @param compression defines the compression used (null by default)
  66795. * @param level defines which level of the texture to update
  66796. */
  66797. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66798. /**
  66799. * Updates a raw cube texture with RGBD encoded data.
  66800. * @param data defines the array of data [mipmap][face] to use to create each face
  66801. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66802. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66803. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66804. * @returns a promsie that resolves when the operation is complete
  66805. */
  66806. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66807. /**
  66808. * Clones the raw cube texture.
  66809. * @return a new cube texture
  66810. */
  66811. clone(): CubeTexture;
  66812. /** @hidden */
  66813. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66814. }
  66815. }
  66816. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66817. import { Scene } from "babylonjs/scene";
  66818. import { Texture } from "babylonjs/Materials/Textures/texture";
  66819. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66820. /**
  66821. * Class used to store 2D array textures containing user data
  66822. */
  66823. export class RawTexture2DArray extends Texture {
  66824. /** Gets or sets the texture format to use */
  66825. format: number;
  66826. /**
  66827. * Create a new RawTexture2DArray
  66828. * @param data defines the data of the texture
  66829. * @param width defines the width of the texture
  66830. * @param height defines the height of the texture
  66831. * @param depth defines the number of layers of the texture
  66832. * @param format defines the texture format to use
  66833. * @param scene defines the hosting scene
  66834. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66835. * @param invertY defines if texture must be stored with Y axis inverted
  66836. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66837. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66838. */
  66839. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66840. /** Gets or sets the texture format to use */
  66841. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66842. /**
  66843. * Update the texture with new data
  66844. * @param data defines the data to store in the texture
  66845. */
  66846. update(data: ArrayBufferView): void;
  66847. }
  66848. }
  66849. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66850. import { Scene } from "babylonjs/scene";
  66851. import { Texture } from "babylonjs/Materials/Textures/texture";
  66852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66853. /**
  66854. * Class used to store 3D textures containing user data
  66855. */
  66856. export class RawTexture3D extends Texture {
  66857. /** Gets or sets the texture format to use */
  66858. format: number;
  66859. /**
  66860. * Create a new RawTexture3D
  66861. * @param data defines the data of the texture
  66862. * @param width defines the width of the texture
  66863. * @param height defines the height of the texture
  66864. * @param depth defines the depth of the texture
  66865. * @param format defines the texture format to use
  66866. * @param scene defines the hosting scene
  66867. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66868. * @param invertY defines if texture must be stored with Y axis inverted
  66869. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66870. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66871. */
  66872. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66873. /** Gets or sets the texture format to use */
  66874. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66875. /**
  66876. * Update the texture with new data
  66877. * @param data defines the data to store in the texture
  66878. */
  66879. update(data: ArrayBufferView): void;
  66880. }
  66881. }
  66882. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66883. import { Scene } from "babylonjs/scene";
  66884. import { Plane } from "babylonjs/Maths/math.plane";
  66885. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66886. /**
  66887. * Creates a refraction texture used by refraction channel of the standard material.
  66888. * It is like a mirror but to see through a material.
  66889. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66890. */
  66891. export class RefractionTexture extends RenderTargetTexture {
  66892. /**
  66893. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66894. * 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.
  66895. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66896. */
  66897. refractionPlane: Plane;
  66898. /**
  66899. * Define how deep under the surface we should see.
  66900. */
  66901. depth: number;
  66902. /**
  66903. * Creates a refraction texture used by refraction channel of the standard material.
  66904. * It is like a mirror but to see through a material.
  66905. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66906. * @param name Define the texture name
  66907. * @param size Define the size of the underlying texture
  66908. * @param scene Define the scene the refraction belongs to
  66909. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66910. */
  66911. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66912. /**
  66913. * Clone the refraction texture.
  66914. * @returns the cloned texture
  66915. */
  66916. clone(): RefractionTexture;
  66917. /**
  66918. * Serialize the texture to a JSON representation you could use in Parse later on
  66919. * @returns the serialized JSON representation
  66920. */
  66921. serialize(): any;
  66922. }
  66923. }
  66924. declare module "babylonjs/Materials/Textures/index" {
  66925. export * from "babylonjs/Materials/Textures/baseTexture";
  66926. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66927. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66928. export * from "babylonjs/Materials/Textures/cubeTexture";
  66929. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66930. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66931. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66932. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66933. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66934. export * from "babylonjs/Materials/Textures/internalTexture";
  66935. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66936. export * from "babylonjs/Materials/Textures/Loaders/index";
  66937. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66938. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66939. export * from "babylonjs/Materials/Textures/Packer/index";
  66940. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66941. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66942. export * from "babylonjs/Materials/Textures/rawTexture";
  66943. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66944. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66945. export * from "babylonjs/Materials/Textures/refractionTexture";
  66946. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66947. export * from "babylonjs/Materials/Textures/texture";
  66948. export * from "babylonjs/Materials/Textures/videoTexture";
  66949. }
  66950. declare module "babylonjs/Materials/Node/Enums/index" {
  66951. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66952. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66953. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66954. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66955. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66956. }
  66957. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66961. import { Mesh } from "babylonjs/Meshes/mesh";
  66962. import { Effect } from "babylonjs/Materials/effect";
  66963. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66964. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66965. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66966. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66967. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66968. /**
  66969. * Block used to add support for vertex skinning (bones)
  66970. */
  66971. export class BonesBlock extends NodeMaterialBlock {
  66972. /**
  66973. * Creates a new BonesBlock
  66974. * @param name defines the block name
  66975. */
  66976. constructor(name: string);
  66977. /**
  66978. * Initialize the block and prepare the context for build
  66979. * @param state defines the state that will be used for the build
  66980. */
  66981. initialize(state: NodeMaterialBuildState): void;
  66982. /**
  66983. * Gets the current class name
  66984. * @returns the class name
  66985. */
  66986. getClassName(): string;
  66987. /**
  66988. * Gets the matrix indices input component
  66989. */
  66990. get matricesIndices(): NodeMaterialConnectionPoint;
  66991. /**
  66992. * Gets the matrix weights input component
  66993. */
  66994. get matricesWeights(): NodeMaterialConnectionPoint;
  66995. /**
  66996. * Gets the extra matrix indices input component
  66997. */
  66998. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66999. /**
  67000. * Gets the extra matrix weights input component
  67001. */
  67002. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Gets the world input component
  67005. */
  67006. get world(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the output component
  67009. */
  67010. get output(): NodeMaterialConnectionPoint;
  67011. autoConfigure(material: NodeMaterial): void;
  67012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  67013. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67015. protected _buildBlock(state: NodeMaterialBuildState): this;
  67016. }
  67017. }
  67018. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  67019. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67020. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67023. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67024. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67025. /**
  67026. * Block used to add support for instances
  67027. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  67028. */
  67029. export class InstancesBlock extends NodeMaterialBlock {
  67030. /**
  67031. * Creates a new InstancesBlock
  67032. * @param name defines the block name
  67033. */
  67034. constructor(name: string);
  67035. /**
  67036. * Gets the current class name
  67037. * @returns the class name
  67038. */
  67039. getClassName(): string;
  67040. /**
  67041. * Gets the first world row input component
  67042. */
  67043. get world0(): NodeMaterialConnectionPoint;
  67044. /**
  67045. * Gets the second world row input component
  67046. */
  67047. get world1(): NodeMaterialConnectionPoint;
  67048. /**
  67049. * Gets the third world row input component
  67050. */
  67051. get world2(): NodeMaterialConnectionPoint;
  67052. /**
  67053. * Gets the forth world row input component
  67054. */
  67055. get world3(): NodeMaterialConnectionPoint;
  67056. /**
  67057. * Gets the world input component
  67058. */
  67059. get world(): NodeMaterialConnectionPoint;
  67060. /**
  67061. * Gets the output component
  67062. */
  67063. get output(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the isntanceID component
  67066. */
  67067. get instanceID(): NodeMaterialConnectionPoint;
  67068. autoConfigure(material: NodeMaterial): void;
  67069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  67070. protected _buildBlock(state: NodeMaterialBuildState): this;
  67071. }
  67072. }
  67073. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  67074. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67075. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67076. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67078. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67079. import { Effect } from "babylonjs/Materials/effect";
  67080. import { Mesh } from "babylonjs/Meshes/mesh";
  67081. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67082. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67083. /**
  67084. * Block used to add morph targets support to vertex shader
  67085. */
  67086. export class MorphTargetsBlock extends NodeMaterialBlock {
  67087. private _repeatableContentAnchor;
  67088. /**
  67089. * Create a new MorphTargetsBlock
  67090. * @param name defines the block name
  67091. */
  67092. constructor(name: string);
  67093. /**
  67094. * Gets the current class name
  67095. * @returns the class name
  67096. */
  67097. getClassName(): string;
  67098. /**
  67099. * Gets the position input component
  67100. */
  67101. get position(): NodeMaterialConnectionPoint;
  67102. /**
  67103. * Gets the normal input component
  67104. */
  67105. get normal(): NodeMaterialConnectionPoint;
  67106. /**
  67107. * Gets the tangent input component
  67108. */
  67109. get tangent(): NodeMaterialConnectionPoint;
  67110. /**
  67111. * Gets the tangent input component
  67112. */
  67113. get uv(): NodeMaterialConnectionPoint;
  67114. /**
  67115. * Gets the position output component
  67116. */
  67117. get positionOutput(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the normal output component
  67120. */
  67121. get normalOutput(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the tangent output component
  67124. */
  67125. get tangentOutput(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the tangent output component
  67128. */
  67129. get uvOutput(): NodeMaterialConnectionPoint;
  67130. initialize(state: NodeMaterialBuildState): void;
  67131. autoConfigure(material: NodeMaterial): void;
  67132. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67133. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67134. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  67135. protected _buildBlock(state: NodeMaterialBuildState): this;
  67136. }
  67137. }
  67138. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  67139. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67140. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67141. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67142. import { Nullable } from "babylonjs/types";
  67143. import { Scene } from "babylonjs/scene";
  67144. import { Effect } from "babylonjs/Materials/effect";
  67145. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67146. import { Mesh } from "babylonjs/Meshes/mesh";
  67147. import { Light } from "babylonjs/Lights/light";
  67148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67149. /**
  67150. * Block used to get data information from a light
  67151. */
  67152. export class LightInformationBlock extends NodeMaterialBlock {
  67153. private _lightDataUniformName;
  67154. private _lightColorUniformName;
  67155. private _lightTypeDefineName;
  67156. /**
  67157. * Gets or sets the light associated with this block
  67158. */
  67159. light: Nullable<Light>;
  67160. /**
  67161. * Creates a new LightInformationBlock
  67162. * @param name defines the block name
  67163. */
  67164. constructor(name: string);
  67165. /**
  67166. * Gets the current class name
  67167. * @returns the class name
  67168. */
  67169. getClassName(): string;
  67170. /**
  67171. * Gets the world position input component
  67172. */
  67173. get worldPosition(): NodeMaterialConnectionPoint;
  67174. /**
  67175. * Gets the direction output component
  67176. */
  67177. get direction(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the direction output component
  67180. */
  67181. get color(): NodeMaterialConnectionPoint;
  67182. /**
  67183. * Gets the direction output component
  67184. */
  67185. get intensity(): NodeMaterialConnectionPoint;
  67186. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67187. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67188. protected _buildBlock(state: NodeMaterialBuildState): this;
  67189. serialize(): any;
  67190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67191. }
  67192. }
  67193. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  67194. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  67195. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  67196. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  67197. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  67198. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  67199. }
  67200. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  67201. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67202. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67203. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67205. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67206. import { Effect } from "babylonjs/Materials/effect";
  67207. import { Mesh } from "babylonjs/Meshes/mesh";
  67208. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67209. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  67210. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  67211. /**
  67212. * Block used to add image processing support to fragment shader
  67213. */
  67214. export class ImageProcessingBlock extends NodeMaterialBlock {
  67215. /**
  67216. * Create a new ImageProcessingBlock
  67217. * @param name defines the block name
  67218. */
  67219. constructor(name: string);
  67220. /**
  67221. * Gets the current class name
  67222. * @returns the class name
  67223. */
  67224. getClassName(): string;
  67225. /**
  67226. * Gets the color input component
  67227. */
  67228. get color(): NodeMaterialConnectionPoint;
  67229. /**
  67230. * Gets the output component
  67231. */
  67232. get output(): NodeMaterialConnectionPoint;
  67233. /**
  67234. * Initialize the block and prepare the context for build
  67235. * @param state defines the state that will be used for the build
  67236. */
  67237. initialize(state: NodeMaterialBuildState): void;
  67238. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  67239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67240. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67241. protected _buildBlock(state: NodeMaterialBuildState): this;
  67242. }
  67243. }
  67244. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  67245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67248. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67249. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67250. import { Effect } from "babylonjs/Materials/effect";
  67251. import { Mesh } from "babylonjs/Meshes/mesh";
  67252. import { Scene } from "babylonjs/scene";
  67253. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  67254. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67255. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67256. /**
  67257. * Block used to pertub normals based on a normal map
  67258. */
  67259. export class PerturbNormalBlock extends NodeMaterialBlock {
  67260. private _tangentSpaceParameterName;
  67261. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67262. invertX: boolean;
  67263. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  67264. invertY: boolean;
  67265. /**
  67266. * Create a new PerturbNormalBlock
  67267. * @param name defines the block name
  67268. */
  67269. constructor(name: string);
  67270. /**
  67271. * Gets the current class name
  67272. * @returns the class name
  67273. */
  67274. getClassName(): string;
  67275. /**
  67276. * Gets the world position input component
  67277. */
  67278. get worldPosition(): NodeMaterialConnectionPoint;
  67279. /**
  67280. * Gets the world normal input component
  67281. */
  67282. get worldNormal(): NodeMaterialConnectionPoint;
  67283. /**
  67284. * Gets the world tangent input component
  67285. */
  67286. get worldTangent(): NodeMaterialConnectionPoint;
  67287. /**
  67288. * Gets the uv input component
  67289. */
  67290. get uv(): NodeMaterialConnectionPoint;
  67291. /**
  67292. * Gets the normal map color input component
  67293. */
  67294. get normalMapColor(): NodeMaterialConnectionPoint;
  67295. /**
  67296. * Gets the strength input component
  67297. */
  67298. get strength(): NodeMaterialConnectionPoint;
  67299. /**
  67300. * Gets the output component
  67301. */
  67302. get output(): NodeMaterialConnectionPoint;
  67303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67304. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67305. autoConfigure(material: NodeMaterial): void;
  67306. protected _buildBlock(state: NodeMaterialBuildState): this;
  67307. protected _dumpPropertiesCode(): string;
  67308. serialize(): any;
  67309. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67310. }
  67311. }
  67312. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  67313. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67314. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67315. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67316. /**
  67317. * Block used to discard a pixel if a value is smaller than a cutoff
  67318. */
  67319. export class DiscardBlock extends NodeMaterialBlock {
  67320. /**
  67321. * Create a new DiscardBlock
  67322. * @param name defines the block name
  67323. */
  67324. constructor(name: string);
  67325. /**
  67326. * Gets the current class name
  67327. * @returns the class name
  67328. */
  67329. getClassName(): string;
  67330. /**
  67331. * Gets the color input component
  67332. */
  67333. get value(): NodeMaterialConnectionPoint;
  67334. /**
  67335. * Gets the cutoff input component
  67336. */
  67337. get cutoff(): NodeMaterialConnectionPoint;
  67338. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67339. }
  67340. }
  67341. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  67342. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67343. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67344. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67345. /**
  67346. * Block used to test if the fragment shader is front facing
  67347. */
  67348. export class FrontFacingBlock extends NodeMaterialBlock {
  67349. /**
  67350. * Creates a new FrontFacingBlock
  67351. * @param name defines the block name
  67352. */
  67353. constructor(name: string);
  67354. /**
  67355. * Gets the current class name
  67356. * @returns the class name
  67357. */
  67358. getClassName(): string;
  67359. /**
  67360. * Gets the output component
  67361. */
  67362. get output(): NodeMaterialConnectionPoint;
  67363. protected _buildBlock(state: NodeMaterialBuildState): this;
  67364. }
  67365. }
  67366. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  67367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67370. /**
  67371. * Block used to get the derivative value on x and y of a given input
  67372. */
  67373. export class DerivativeBlock extends NodeMaterialBlock {
  67374. /**
  67375. * Create a new DerivativeBlock
  67376. * @param name defines the block name
  67377. */
  67378. constructor(name: string);
  67379. /**
  67380. * Gets the current class name
  67381. * @returns the class name
  67382. */
  67383. getClassName(): string;
  67384. /**
  67385. * Gets the input component
  67386. */
  67387. get input(): NodeMaterialConnectionPoint;
  67388. /**
  67389. * Gets the derivative output on x
  67390. */
  67391. get dx(): NodeMaterialConnectionPoint;
  67392. /**
  67393. * Gets the derivative output on y
  67394. */
  67395. get dy(): NodeMaterialConnectionPoint;
  67396. protected _buildBlock(state: NodeMaterialBuildState): this;
  67397. }
  67398. }
  67399. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  67400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67403. /**
  67404. * Block used to make gl_FragCoord available
  67405. */
  67406. export class FragCoordBlock extends NodeMaterialBlock {
  67407. /**
  67408. * Creates a new FragCoordBlock
  67409. * @param name defines the block name
  67410. */
  67411. constructor(name: string);
  67412. /**
  67413. * Gets the current class name
  67414. * @returns the class name
  67415. */
  67416. getClassName(): string;
  67417. /**
  67418. * Gets the xy component
  67419. */
  67420. get xy(): NodeMaterialConnectionPoint;
  67421. /**
  67422. * Gets the xyz component
  67423. */
  67424. get xyz(): NodeMaterialConnectionPoint;
  67425. /**
  67426. * Gets the xyzw component
  67427. */
  67428. get xyzw(): NodeMaterialConnectionPoint;
  67429. /**
  67430. * Gets the x component
  67431. */
  67432. get x(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the y component
  67435. */
  67436. get y(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the z component
  67439. */
  67440. get z(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the w component
  67443. */
  67444. get output(): NodeMaterialConnectionPoint;
  67445. protected writeOutputs(state: NodeMaterialBuildState): string;
  67446. protected _buildBlock(state: NodeMaterialBuildState): this;
  67447. }
  67448. }
  67449. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  67450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67452. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67453. import { Effect } from "babylonjs/Materials/effect";
  67454. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67455. import { Mesh } from "babylonjs/Meshes/mesh";
  67456. /**
  67457. * Block used to get the screen sizes
  67458. */
  67459. export class ScreenSizeBlock extends NodeMaterialBlock {
  67460. private _varName;
  67461. private _scene;
  67462. /**
  67463. * Creates a new ScreenSizeBlock
  67464. * @param name defines the block name
  67465. */
  67466. constructor(name: string);
  67467. /**
  67468. * Gets the current class name
  67469. * @returns the class name
  67470. */
  67471. getClassName(): string;
  67472. /**
  67473. * Gets the xy component
  67474. */
  67475. get xy(): NodeMaterialConnectionPoint;
  67476. /**
  67477. * Gets the x component
  67478. */
  67479. get x(): NodeMaterialConnectionPoint;
  67480. /**
  67481. * Gets the y component
  67482. */
  67483. get y(): NodeMaterialConnectionPoint;
  67484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67485. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67486. protected _buildBlock(state: NodeMaterialBuildState): this;
  67487. }
  67488. }
  67489. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  67490. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  67491. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  67492. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  67493. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  67494. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  67495. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  67496. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  67497. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  67498. }
  67499. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  67500. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67501. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67502. import { Mesh } from "babylonjs/Meshes/mesh";
  67503. import { Effect } from "babylonjs/Materials/effect";
  67504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67506. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67507. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  67508. /**
  67509. * Block used to add support for scene fog
  67510. */
  67511. export class FogBlock extends NodeMaterialBlock {
  67512. private _fogDistanceName;
  67513. private _fogParameters;
  67514. /**
  67515. * Create a new FogBlock
  67516. * @param name defines the block name
  67517. */
  67518. constructor(name: string);
  67519. /**
  67520. * Gets the current class name
  67521. * @returns the class name
  67522. */
  67523. getClassName(): string;
  67524. /**
  67525. * Gets the world position input component
  67526. */
  67527. get worldPosition(): NodeMaterialConnectionPoint;
  67528. /**
  67529. * Gets the view input component
  67530. */
  67531. get view(): NodeMaterialConnectionPoint;
  67532. /**
  67533. * Gets the color input component
  67534. */
  67535. get input(): NodeMaterialConnectionPoint;
  67536. /**
  67537. * Gets the fog color input component
  67538. */
  67539. get fogColor(): NodeMaterialConnectionPoint;
  67540. /**
  67541. * Gets the output component
  67542. */
  67543. get output(): NodeMaterialConnectionPoint;
  67544. autoConfigure(material: NodeMaterial): void;
  67545. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67546. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67547. protected _buildBlock(state: NodeMaterialBuildState): this;
  67548. }
  67549. }
  67550. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67555. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67556. import { Effect } from "babylonjs/Materials/effect";
  67557. import { Mesh } from "babylonjs/Meshes/mesh";
  67558. import { Light } from "babylonjs/Lights/light";
  67559. import { Nullable } from "babylonjs/types";
  67560. import { Scene } from "babylonjs/scene";
  67561. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67562. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67563. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67564. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67565. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67566. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67567. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67568. /**
  67569. * Block used to add light in the fragment shader
  67570. */
  67571. export class LightBlock extends NodeMaterialBlock {
  67572. private _lightId;
  67573. /**
  67574. * Gets or sets the light associated with this block
  67575. */
  67576. light: Nullable<Light>;
  67577. /**
  67578. * Create a new LightBlock
  67579. * @param name defines the block name
  67580. */
  67581. constructor(name: string);
  67582. /**
  67583. * Gets the current class name
  67584. * @returns the class name
  67585. */
  67586. getClassName(): string;
  67587. /**
  67588. * Gets the world position input component
  67589. */
  67590. get worldPosition(): NodeMaterialConnectionPoint;
  67591. /**
  67592. * Gets the world normal input component
  67593. */
  67594. get worldNormal(): NodeMaterialConnectionPoint;
  67595. /**
  67596. * Gets the camera (or eye) position component
  67597. */
  67598. get cameraPosition(): NodeMaterialConnectionPoint;
  67599. /**
  67600. * Gets the glossiness component
  67601. */
  67602. get glossiness(): NodeMaterialConnectionPoint;
  67603. /**
  67604. * Gets the glossinness power component
  67605. */
  67606. get glossPower(): NodeMaterialConnectionPoint;
  67607. /**
  67608. * Gets the diffuse color component
  67609. */
  67610. get diffuseColor(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the specular color component
  67613. */
  67614. get specularColor(): NodeMaterialConnectionPoint;
  67615. /**
  67616. * Gets the view matrix component
  67617. */
  67618. get view(): NodeMaterialConnectionPoint;
  67619. /**
  67620. * Gets the diffuse output component
  67621. */
  67622. get diffuseOutput(): NodeMaterialConnectionPoint;
  67623. /**
  67624. * Gets the specular output component
  67625. */
  67626. get specularOutput(): NodeMaterialConnectionPoint;
  67627. /**
  67628. * Gets the shadow output component
  67629. */
  67630. get shadow(): NodeMaterialConnectionPoint;
  67631. autoConfigure(material: NodeMaterial): void;
  67632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67633. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67635. private _injectVertexCode;
  67636. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67637. serialize(): any;
  67638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67639. }
  67640. }
  67641. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67642. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67643. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67644. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67645. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67646. /**
  67647. * Block used to read a reflection texture from a sampler
  67648. */
  67649. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67650. /**
  67651. * Create a new ReflectionTextureBlock
  67652. * @param name defines the block name
  67653. */
  67654. constructor(name: string);
  67655. /**
  67656. * Gets the current class name
  67657. * @returns the class name
  67658. */
  67659. getClassName(): string;
  67660. /**
  67661. * Gets the world position input component
  67662. */
  67663. get position(): NodeMaterialConnectionPoint;
  67664. /**
  67665. * Gets the world position input component
  67666. */
  67667. get worldPosition(): NodeMaterialConnectionPoint;
  67668. /**
  67669. * Gets the world normal input component
  67670. */
  67671. get worldNormal(): NodeMaterialConnectionPoint;
  67672. /**
  67673. * Gets the world input component
  67674. */
  67675. get world(): NodeMaterialConnectionPoint;
  67676. /**
  67677. * Gets the camera (or eye) position component
  67678. */
  67679. get cameraPosition(): NodeMaterialConnectionPoint;
  67680. /**
  67681. * Gets the view input component
  67682. */
  67683. get view(): NodeMaterialConnectionPoint;
  67684. /**
  67685. * Gets the rgb output component
  67686. */
  67687. get rgb(): NodeMaterialConnectionPoint;
  67688. /**
  67689. * Gets the rgba output component
  67690. */
  67691. get rgba(): NodeMaterialConnectionPoint;
  67692. /**
  67693. * Gets the r output component
  67694. */
  67695. get r(): NodeMaterialConnectionPoint;
  67696. /**
  67697. * Gets the g output component
  67698. */
  67699. get g(): NodeMaterialConnectionPoint;
  67700. /**
  67701. * Gets the b output component
  67702. */
  67703. get b(): NodeMaterialConnectionPoint;
  67704. /**
  67705. * Gets the a output component
  67706. */
  67707. get a(): NodeMaterialConnectionPoint;
  67708. autoConfigure(material: NodeMaterial): void;
  67709. protected _buildBlock(state: NodeMaterialBuildState): this;
  67710. }
  67711. }
  67712. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67713. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67714. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67715. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67716. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67717. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67718. }
  67719. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67720. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67721. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67722. }
  67723. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67727. /**
  67728. * Block used to add 2 vectors
  67729. */
  67730. export class AddBlock extends NodeMaterialBlock {
  67731. /**
  67732. * Creates a new AddBlock
  67733. * @param name defines the block name
  67734. */
  67735. constructor(name: string);
  67736. /**
  67737. * Gets the current class name
  67738. * @returns the class name
  67739. */
  67740. getClassName(): string;
  67741. /**
  67742. * Gets the left operand input component
  67743. */
  67744. get left(): NodeMaterialConnectionPoint;
  67745. /**
  67746. * Gets the right operand input component
  67747. */
  67748. get right(): NodeMaterialConnectionPoint;
  67749. /**
  67750. * Gets the output component
  67751. */
  67752. get output(): NodeMaterialConnectionPoint;
  67753. protected _buildBlock(state: NodeMaterialBuildState): this;
  67754. }
  67755. }
  67756. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67760. /**
  67761. * Block used to scale a vector by a float
  67762. */
  67763. export class ScaleBlock extends NodeMaterialBlock {
  67764. /**
  67765. * Creates a new ScaleBlock
  67766. * @param name defines the block name
  67767. */
  67768. constructor(name: string);
  67769. /**
  67770. * Gets the current class name
  67771. * @returns the class name
  67772. */
  67773. getClassName(): string;
  67774. /**
  67775. * Gets the input component
  67776. */
  67777. get input(): NodeMaterialConnectionPoint;
  67778. /**
  67779. * Gets the factor input component
  67780. */
  67781. get factor(): NodeMaterialConnectionPoint;
  67782. /**
  67783. * Gets the output component
  67784. */
  67785. get output(): NodeMaterialConnectionPoint;
  67786. protected _buildBlock(state: NodeMaterialBuildState): this;
  67787. }
  67788. }
  67789. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67792. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67793. import { Scene } from "babylonjs/scene";
  67794. /**
  67795. * Block used to clamp a float
  67796. */
  67797. export class ClampBlock extends NodeMaterialBlock {
  67798. /** Gets or sets the minimum range */
  67799. minimum: number;
  67800. /** Gets or sets the maximum range */
  67801. maximum: number;
  67802. /**
  67803. * Creates a new ClampBlock
  67804. * @param name defines the block name
  67805. */
  67806. constructor(name: string);
  67807. /**
  67808. * Gets the current class name
  67809. * @returns the class name
  67810. */
  67811. getClassName(): string;
  67812. /**
  67813. * Gets the value input component
  67814. */
  67815. get value(): NodeMaterialConnectionPoint;
  67816. /**
  67817. * Gets the output component
  67818. */
  67819. get output(): NodeMaterialConnectionPoint;
  67820. protected _buildBlock(state: NodeMaterialBuildState): this;
  67821. protected _dumpPropertiesCode(): string;
  67822. serialize(): any;
  67823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67824. }
  67825. }
  67826. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67830. /**
  67831. * Block used to apply a cross product between 2 vectors
  67832. */
  67833. export class CrossBlock extends NodeMaterialBlock {
  67834. /**
  67835. * Creates a new CrossBlock
  67836. * @param name defines the block name
  67837. */
  67838. constructor(name: string);
  67839. /**
  67840. * Gets the current class name
  67841. * @returns the class name
  67842. */
  67843. getClassName(): string;
  67844. /**
  67845. * Gets the left operand input component
  67846. */
  67847. get left(): NodeMaterialConnectionPoint;
  67848. /**
  67849. * Gets the right operand input component
  67850. */
  67851. get right(): NodeMaterialConnectionPoint;
  67852. /**
  67853. * Gets the output component
  67854. */
  67855. get output(): NodeMaterialConnectionPoint;
  67856. protected _buildBlock(state: NodeMaterialBuildState): this;
  67857. }
  67858. }
  67859. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67863. /**
  67864. * Block used to apply a dot product between 2 vectors
  67865. */
  67866. export class DotBlock extends NodeMaterialBlock {
  67867. /**
  67868. * Creates a new DotBlock
  67869. * @param name defines the block name
  67870. */
  67871. constructor(name: string);
  67872. /**
  67873. * Gets the current class name
  67874. * @returns the class name
  67875. */
  67876. getClassName(): string;
  67877. /**
  67878. * Gets the left operand input component
  67879. */
  67880. get left(): NodeMaterialConnectionPoint;
  67881. /**
  67882. * Gets the right operand input component
  67883. */
  67884. get right(): NodeMaterialConnectionPoint;
  67885. /**
  67886. * Gets the output component
  67887. */
  67888. get output(): NodeMaterialConnectionPoint;
  67889. protected _buildBlock(state: NodeMaterialBuildState): this;
  67890. }
  67891. }
  67892. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67893. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67894. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67895. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67896. /**
  67897. * Block used to normalize a vector
  67898. */
  67899. export class NormalizeBlock extends NodeMaterialBlock {
  67900. /**
  67901. * Creates a new NormalizeBlock
  67902. * @param name defines the block name
  67903. */
  67904. constructor(name: string);
  67905. /**
  67906. * Gets the current class name
  67907. * @returns the class name
  67908. */
  67909. getClassName(): string;
  67910. /**
  67911. * Gets the input component
  67912. */
  67913. get input(): NodeMaterialConnectionPoint;
  67914. /**
  67915. * Gets the output component
  67916. */
  67917. get output(): NodeMaterialConnectionPoint;
  67918. protected _buildBlock(state: NodeMaterialBuildState): this;
  67919. }
  67920. }
  67921. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67924. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67925. /**
  67926. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67927. */
  67928. export class ColorMergerBlock extends NodeMaterialBlock {
  67929. /**
  67930. * Create a new ColorMergerBlock
  67931. * @param name defines the block name
  67932. */
  67933. constructor(name: string);
  67934. /**
  67935. * Gets the current class name
  67936. * @returns the class name
  67937. */
  67938. getClassName(): string;
  67939. /**
  67940. * Gets the rgb component (input)
  67941. */
  67942. get rgbIn(): NodeMaterialConnectionPoint;
  67943. /**
  67944. * Gets the r component (input)
  67945. */
  67946. get r(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the g component (input)
  67949. */
  67950. get g(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the b component (input)
  67953. */
  67954. get b(): NodeMaterialConnectionPoint;
  67955. /**
  67956. * Gets the a component (input)
  67957. */
  67958. get a(): NodeMaterialConnectionPoint;
  67959. /**
  67960. * Gets the rgba component (output)
  67961. */
  67962. get rgba(): NodeMaterialConnectionPoint;
  67963. /**
  67964. * Gets the rgb component (output)
  67965. */
  67966. get rgbOut(): NodeMaterialConnectionPoint;
  67967. /**
  67968. * Gets the rgb component (output)
  67969. * @deprecated Please use rgbOut instead.
  67970. */
  67971. get rgb(): NodeMaterialConnectionPoint;
  67972. protected _buildBlock(state: NodeMaterialBuildState): this;
  67973. }
  67974. }
  67975. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67976. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67977. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67979. /**
  67980. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67981. */
  67982. export class VectorSplitterBlock extends NodeMaterialBlock {
  67983. /**
  67984. * Create a new VectorSplitterBlock
  67985. * @param name defines the block name
  67986. */
  67987. constructor(name: string);
  67988. /**
  67989. * Gets the current class name
  67990. * @returns the class name
  67991. */
  67992. getClassName(): string;
  67993. /**
  67994. * Gets the xyzw component (input)
  67995. */
  67996. get xyzw(): NodeMaterialConnectionPoint;
  67997. /**
  67998. * Gets the xyz component (input)
  67999. */
  68000. get xyzIn(): NodeMaterialConnectionPoint;
  68001. /**
  68002. * Gets the xy component (input)
  68003. */
  68004. get xyIn(): NodeMaterialConnectionPoint;
  68005. /**
  68006. * Gets the xyz component (output)
  68007. */
  68008. get xyzOut(): NodeMaterialConnectionPoint;
  68009. /**
  68010. * Gets the xy component (output)
  68011. */
  68012. get xyOut(): NodeMaterialConnectionPoint;
  68013. /**
  68014. * Gets the x component (output)
  68015. */
  68016. get x(): NodeMaterialConnectionPoint;
  68017. /**
  68018. * Gets the y component (output)
  68019. */
  68020. get y(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the z component (output)
  68023. */
  68024. get z(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the w component (output)
  68027. */
  68028. get w(): NodeMaterialConnectionPoint;
  68029. protected _inputRename(name: string): string;
  68030. protected _outputRename(name: string): string;
  68031. protected _buildBlock(state: NodeMaterialBuildState): this;
  68032. }
  68033. }
  68034. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  68035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68038. /**
  68039. * Block used to lerp between 2 values
  68040. */
  68041. export class LerpBlock extends NodeMaterialBlock {
  68042. /**
  68043. * Creates a new LerpBlock
  68044. * @param name defines the block name
  68045. */
  68046. constructor(name: string);
  68047. /**
  68048. * Gets the current class name
  68049. * @returns the class name
  68050. */
  68051. getClassName(): string;
  68052. /**
  68053. * Gets the left operand input component
  68054. */
  68055. get left(): NodeMaterialConnectionPoint;
  68056. /**
  68057. * Gets the right operand input component
  68058. */
  68059. get right(): NodeMaterialConnectionPoint;
  68060. /**
  68061. * Gets the gradient operand input component
  68062. */
  68063. get gradient(): NodeMaterialConnectionPoint;
  68064. /**
  68065. * Gets the output component
  68066. */
  68067. get output(): NodeMaterialConnectionPoint;
  68068. protected _buildBlock(state: NodeMaterialBuildState): this;
  68069. }
  68070. }
  68071. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  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. /**
  68076. * Block used to divide 2 vectors
  68077. */
  68078. export class DivideBlock extends NodeMaterialBlock {
  68079. /**
  68080. * Creates a new DivideBlock
  68081. * @param name defines the block name
  68082. */
  68083. constructor(name: string);
  68084. /**
  68085. * Gets the current class name
  68086. * @returns the class name
  68087. */
  68088. getClassName(): string;
  68089. /**
  68090. * Gets the left operand input component
  68091. */
  68092. get left(): NodeMaterialConnectionPoint;
  68093. /**
  68094. * Gets the right operand input component
  68095. */
  68096. get right(): NodeMaterialConnectionPoint;
  68097. /**
  68098. * Gets the output component
  68099. */
  68100. get output(): NodeMaterialConnectionPoint;
  68101. protected _buildBlock(state: NodeMaterialBuildState): this;
  68102. }
  68103. }
  68104. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  68105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68108. /**
  68109. * Block used to subtract 2 vectors
  68110. */
  68111. export class SubtractBlock extends NodeMaterialBlock {
  68112. /**
  68113. * Creates a new SubtractBlock
  68114. * @param name defines the block name
  68115. */
  68116. constructor(name: string);
  68117. /**
  68118. * Gets the current class name
  68119. * @returns the class name
  68120. */
  68121. getClassName(): string;
  68122. /**
  68123. * Gets the left operand input component
  68124. */
  68125. get left(): NodeMaterialConnectionPoint;
  68126. /**
  68127. * Gets the right operand input component
  68128. */
  68129. get right(): NodeMaterialConnectionPoint;
  68130. /**
  68131. * Gets the output component
  68132. */
  68133. get output(): NodeMaterialConnectionPoint;
  68134. protected _buildBlock(state: NodeMaterialBuildState): this;
  68135. }
  68136. }
  68137. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  68138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68141. /**
  68142. * Block used to step a value
  68143. */
  68144. export class StepBlock extends NodeMaterialBlock {
  68145. /**
  68146. * Creates a new StepBlock
  68147. * @param name defines the block name
  68148. */
  68149. constructor(name: string);
  68150. /**
  68151. * Gets the current class name
  68152. * @returns the class name
  68153. */
  68154. getClassName(): string;
  68155. /**
  68156. * Gets the value operand input component
  68157. */
  68158. get value(): NodeMaterialConnectionPoint;
  68159. /**
  68160. * Gets the edge operand input component
  68161. */
  68162. get edge(): NodeMaterialConnectionPoint;
  68163. /**
  68164. * Gets the output component
  68165. */
  68166. get output(): NodeMaterialConnectionPoint;
  68167. protected _buildBlock(state: NodeMaterialBuildState): this;
  68168. }
  68169. }
  68170. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  68171. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68172. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68173. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68174. /**
  68175. * Block used to get the opposite (1 - x) of a value
  68176. */
  68177. export class OneMinusBlock extends NodeMaterialBlock {
  68178. /**
  68179. * Creates a new OneMinusBlock
  68180. * @param name defines the block name
  68181. */
  68182. constructor(name: string);
  68183. /**
  68184. * Gets the current class name
  68185. * @returns the class name
  68186. */
  68187. getClassName(): string;
  68188. /**
  68189. * Gets the input component
  68190. */
  68191. get input(): NodeMaterialConnectionPoint;
  68192. /**
  68193. * Gets the output component
  68194. */
  68195. get output(): NodeMaterialConnectionPoint;
  68196. protected _buildBlock(state: NodeMaterialBuildState): this;
  68197. }
  68198. }
  68199. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  68200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68203. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68204. /**
  68205. * Block used to get the view direction
  68206. */
  68207. export class ViewDirectionBlock extends NodeMaterialBlock {
  68208. /**
  68209. * Creates a new ViewDirectionBlock
  68210. * @param name defines the block name
  68211. */
  68212. constructor(name: string);
  68213. /**
  68214. * Gets the current class name
  68215. * @returns the class name
  68216. */
  68217. getClassName(): string;
  68218. /**
  68219. * Gets the world position component
  68220. */
  68221. get worldPosition(): NodeMaterialConnectionPoint;
  68222. /**
  68223. * Gets the camera position component
  68224. */
  68225. get cameraPosition(): NodeMaterialConnectionPoint;
  68226. /**
  68227. * Gets the output component
  68228. */
  68229. get output(): NodeMaterialConnectionPoint;
  68230. autoConfigure(material: NodeMaterial): void;
  68231. protected _buildBlock(state: NodeMaterialBuildState): this;
  68232. }
  68233. }
  68234. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  68235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68238. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68239. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  68240. /**
  68241. * Block used to compute fresnel value
  68242. */
  68243. export class FresnelBlock extends NodeMaterialBlock {
  68244. /**
  68245. * Create a new FresnelBlock
  68246. * @param name defines the block name
  68247. */
  68248. constructor(name: string);
  68249. /**
  68250. * Gets the current class name
  68251. * @returns the class name
  68252. */
  68253. getClassName(): string;
  68254. /**
  68255. * Gets the world normal input component
  68256. */
  68257. get worldNormal(): NodeMaterialConnectionPoint;
  68258. /**
  68259. * Gets the view direction input component
  68260. */
  68261. get viewDirection(): NodeMaterialConnectionPoint;
  68262. /**
  68263. * Gets the bias input component
  68264. */
  68265. get bias(): NodeMaterialConnectionPoint;
  68266. /**
  68267. * Gets the camera (or eye) position component
  68268. */
  68269. get power(): NodeMaterialConnectionPoint;
  68270. /**
  68271. * Gets the fresnel output component
  68272. */
  68273. get fresnel(): NodeMaterialConnectionPoint;
  68274. autoConfigure(material: NodeMaterial): void;
  68275. protected _buildBlock(state: NodeMaterialBuildState): this;
  68276. }
  68277. }
  68278. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  68279. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68280. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68281. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68282. /**
  68283. * Block used to get the max of 2 values
  68284. */
  68285. export class MaxBlock extends NodeMaterialBlock {
  68286. /**
  68287. * Creates a new MaxBlock
  68288. * @param name defines the block name
  68289. */
  68290. constructor(name: string);
  68291. /**
  68292. * Gets the current class name
  68293. * @returns the class name
  68294. */
  68295. getClassName(): string;
  68296. /**
  68297. * Gets the left operand input component
  68298. */
  68299. get left(): NodeMaterialConnectionPoint;
  68300. /**
  68301. * Gets the right operand input component
  68302. */
  68303. get right(): NodeMaterialConnectionPoint;
  68304. /**
  68305. * Gets the output component
  68306. */
  68307. get output(): NodeMaterialConnectionPoint;
  68308. protected _buildBlock(state: NodeMaterialBuildState): this;
  68309. }
  68310. }
  68311. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  68312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68315. /**
  68316. * Block used to get the min of 2 values
  68317. */
  68318. export class MinBlock extends NodeMaterialBlock {
  68319. /**
  68320. * Creates a new MinBlock
  68321. * @param name defines the block name
  68322. */
  68323. constructor(name: string);
  68324. /**
  68325. * Gets the current class name
  68326. * @returns the class name
  68327. */
  68328. getClassName(): string;
  68329. /**
  68330. * Gets the left operand input component
  68331. */
  68332. get left(): NodeMaterialConnectionPoint;
  68333. /**
  68334. * Gets the right operand input component
  68335. */
  68336. get right(): NodeMaterialConnectionPoint;
  68337. /**
  68338. * Gets the output component
  68339. */
  68340. get output(): NodeMaterialConnectionPoint;
  68341. protected _buildBlock(state: NodeMaterialBuildState): this;
  68342. }
  68343. }
  68344. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  68345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68348. /**
  68349. * Block used to get the distance between 2 values
  68350. */
  68351. export class DistanceBlock extends NodeMaterialBlock {
  68352. /**
  68353. * Creates a new DistanceBlock
  68354. * @param name defines the block name
  68355. */
  68356. constructor(name: string);
  68357. /**
  68358. * Gets the current class name
  68359. * @returns the class name
  68360. */
  68361. getClassName(): string;
  68362. /**
  68363. * Gets the left operand input component
  68364. */
  68365. get left(): NodeMaterialConnectionPoint;
  68366. /**
  68367. * Gets the right operand input component
  68368. */
  68369. get right(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the output component
  68372. */
  68373. get output(): NodeMaterialConnectionPoint;
  68374. protected _buildBlock(state: NodeMaterialBuildState): this;
  68375. }
  68376. }
  68377. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  68378. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68379. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68380. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68381. /**
  68382. * Block used to get the length of a vector
  68383. */
  68384. export class LengthBlock extends NodeMaterialBlock {
  68385. /**
  68386. * Creates a new LengthBlock
  68387. * @param name defines the block name
  68388. */
  68389. constructor(name: string);
  68390. /**
  68391. * Gets the current class name
  68392. * @returns the class name
  68393. */
  68394. getClassName(): string;
  68395. /**
  68396. * Gets the value input component
  68397. */
  68398. get value(): NodeMaterialConnectionPoint;
  68399. /**
  68400. * Gets the output component
  68401. */
  68402. get output(): NodeMaterialConnectionPoint;
  68403. protected _buildBlock(state: NodeMaterialBuildState): this;
  68404. }
  68405. }
  68406. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  68407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68410. /**
  68411. * Block used to get negative version of a value (i.e. x * -1)
  68412. */
  68413. export class NegateBlock extends NodeMaterialBlock {
  68414. /**
  68415. * Creates a new NegateBlock
  68416. * @param name defines the block name
  68417. */
  68418. constructor(name: string);
  68419. /**
  68420. * Gets the current class name
  68421. * @returns the class name
  68422. */
  68423. getClassName(): string;
  68424. /**
  68425. * Gets the value input component
  68426. */
  68427. get value(): NodeMaterialConnectionPoint;
  68428. /**
  68429. * Gets the output component
  68430. */
  68431. get output(): NodeMaterialConnectionPoint;
  68432. protected _buildBlock(state: NodeMaterialBuildState): this;
  68433. }
  68434. }
  68435. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  68436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68439. /**
  68440. * Block used to get the value of the first parameter raised to the power of the second
  68441. */
  68442. export class PowBlock extends NodeMaterialBlock {
  68443. /**
  68444. * Creates a new PowBlock
  68445. * @param name defines the block name
  68446. */
  68447. constructor(name: string);
  68448. /**
  68449. * Gets the current class name
  68450. * @returns the class name
  68451. */
  68452. getClassName(): string;
  68453. /**
  68454. * Gets the value operand input component
  68455. */
  68456. get value(): NodeMaterialConnectionPoint;
  68457. /**
  68458. * Gets the power operand input component
  68459. */
  68460. get power(): NodeMaterialConnectionPoint;
  68461. /**
  68462. * Gets the output component
  68463. */
  68464. get output(): NodeMaterialConnectionPoint;
  68465. protected _buildBlock(state: NodeMaterialBuildState): this;
  68466. }
  68467. }
  68468. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  68469. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68470. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68472. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68473. /**
  68474. * Block used to get a random number
  68475. */
  68476. export class RandomNumberBlock extends NodeMaterialBlock {
  68477. /**
  68478. * Creates a new RandomNumberBlock
  68479. * @param name defines the block name
  68480. */
  68481. constructor(name: string);
  68482. /**
  68483. * Gets the current class name
  68484. * @returns the class name
  68485. */
  68486. getClassName(): string;
  68487. /**
  68488. * Gets the seed input component
  68489. */
  68490. get seed(): NodeMaterialConnectionPoint;
  68491. /**
  68492. * Gets the output component
  68493. */
  68494. get output(): NodeMaterialConnectionPoint;
  68495. protected _buildBlock(state: NodeMaterialBuildState): this;
  68496. }
  68497. }
  68498. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  68499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68502. /**
  68503. * Block used to compute arc tangent of 2 values
  68504. */
  68505. export class ArcTan2Block extends NodeMaterialBlock {
  68506. /**
  68507. * Creates a new ArcTan2Block
  68508. * @param name defines the block name
  68509. */
  68510. constructor(name: string);
  68511. /**
  68512. * Gets the current class name
  68513. * @returns the class name
  68514. */
  68515. getClassName(): string;
  68516. /**
  68517. * Gets the x operand input component
  68518. */
  68519. get x(): NodeMaterialConnectionPoint;
  68520. /**
  68521. * Gets the y operand input component
  68522. */
  68523. get y(): NodeMaterialConnectionPoint;
  68524. /**
  68525. * Gets the output component
  68526. */
  68527. get output(): NodeMaterialConnectionPoint;
  68528. protected _buildBlock(state: NodeMaterialBuildState): this;
  68529. }
  68530. }
  68531. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68535. /**
  68536. * Block used to smooth step a value
  68537. */
  68538. export class SmoothStepBlock extends NodeMaterialBlock {
  68539. /**
  68540. * Creates a new SmoothStepBlock
  68541. * @param name defines the block name
  68542. */
  68543. constructor(name: string);
  68544. /**
  68545. * Gets the current class name
  68546. * @returns the class name
  68547. */
  68548. getClassName(): string;
  68549. /**
  68550. * Gets the value operand input component
  68551. */
  68552. get value(): NodeMaterialConnectionPoint;
  68553. /**
  68554. * Gets the first edge operand input component
  68555. */
  68556. get edge0(): NodeMaterialConnectionPoint;
  68557. /**
  68558. * Gets the second edge operand input component
  68559. */
  68560. get edge1(): NodeMaterialConnectionPoint;
  68561. /**
  68562. * Gets the output component
  68563. */
  68564. get output(): NodeMaterialConnectionPoint;
  68565. protected _buildBlock(state: NodeMaterialBuildState): this;
  68566. }
  68567. }
  68568. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68572. /**
  68573. * Block used to get the reciprocal (1 / x) of a value
  68574. */
  68575. export class ReciprocalBlock extends NodeMaterialBlock {
  68576. /**
  68577. * Creates a new ReciprocalBlock
  68578. * @param name defines the block name
  68579. */
  68580. constructor(name: string);
  68581. /**
  68582. * Gets the current class name
  68583. * @returns the class name
  68584. */
  68585. getClassName(): string;
  68586. /**
  68587. * Gets the input component
  68588. */
  68589. get input(): NodeMaterialConnectionPoint;
  68590. /**
  68591. * Gets the output component
  68592. */
  68593. get output(): NodeMaterialConnectionPoint;
  68594. protected _buildBlock(state: NodeMaterialBuildState): this;
  68595. }
  68596. }
  68597. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68601. /**
  68602. * Block used to replace a color by another one
  68603. */
  68604. export class ReplaceColorBlock extends NodeMaterialBlock {
  68605. /**
  68606. * Creates a new ReplaceColorBlock
  68607. * @param name defines the block name
  68608. */
  68609. constructor(name: string);
  68610. /**
  68611. * Gets the current class name
  68612. * @returns the class name
  68613. */
  68614. getClassName(): string;
  68615. /**
  68616. * Gets the value input component
  68617. */
  68618. get value(): NodeMaterialConnectionPoint;
  68619. /**
  68620. * Gets the reference input component
  68621. */
  68622. get reference(): NodeMaterialConnectionPoint;
  68623. /**
  68624. * Gets the distance input component
  68625. */
  68626. get distance(): NodeMaterialConnectionPoint;
  68627. /**
  68628. * Gets the replacement input component
  68629. */
  68630. get replacement(): NodeMaterialConnectionPoint;
  68631. /**
  68632. * Gets the output component
  68633. */
  68634. get output(): NodeMaterialConnectionPoint;
  68635. protected _buildBlock(state: NodeMaterialBuildState): this;
  68636. }
  68637. }
  68638. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68642. /**
  68643. * Block used to posterize a value
  68644. * @see https://en.wikipedia.org/wiki/Posterization
  68645. */
  68646. export class PosterizeBlock extends NodeMaterialBlock {
  68647. /**
  68648. * Creates a new PosterizeBlock
  68649. * @param name defines the block name
  68650. */
  68651. constructor(name: string);
  68652. /**
  68653. * Gets the current class name
  68654. * @returns the class name
  68655. */
  68656. getClassName(): string;
  68657. /**
  68658. * Gets the value input component
  68659. */
  68660. get value(): NodeMaterialConnectionPoint;
  68661. /**
  68662. * Gets the steps input component
  68663. */
  68664. get steps(): NodeMaterialConnectionPoint;
  68665. /**
  68666. * Gets the output component
  68667. */
  68668. get output(): NodeMaterialConnectionPoint;
  68669. protected _buildBlock(state: NodeMaterialBuildState): this;
  68670. }
  68671. }
  68672. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68673. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68674. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68675. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68676. import { Scene } from "babylonjs/scene";
  68677. /**
  68678. * Operations supported by the Wave block
  68679. */
  68680. export enum WaveBlockKind {
  68681. /** SawTooth */
  68682. SawTooth = 0,
  68683. /** Square */
  68684. Square = 1,
  68685. /** Triangle */
  68686. Triangle = 2
  68687. }
  68688. /**
  68689. * Block used to apply wave operation to floats
  68690. */
  68691. export class WaveBlock extends NodeMaterialBlock {
  68692. /**
  68693. * Gets or sets the kibnd of wave to be applied by the block
  68694. */
  68695. kind: WaveBlockKind;
  68696. /**
  68697. * Creates a new WaveBlock
  68698. * @param name defines the block name
  68699. */
  68700. constructor(name: string);
  68701. /**
  68702. * Gets the current class name
  68703. * @returns the class name
  68704. */
  68705. getClassName(): string;
  68706. /**
  68707. * Gets the input component
  68708. */
  68709. get input(): NodeMaterialConnectionPoint;
  68710. /**
  68711. * Gets the output component
  68712. */
  68713. get output(): NodeMaterialConnectionPoint;
  68714. protected _buildBlock(state: NodeMaterialBuildState): this;
  68715. serialize(): any;
  68716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68717. }
  68718. }
  68719. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68723. import { Color3 } from "babylonjs/Maths/math.color";
  68724. import { Scene } from "babylonjs/scene";
  68725. import { Observable } from "babylonjs/Misc/observable";
  68726. /**
  68727. * Class used to store a color step for the GradientBlock
  68728. */
  68729. export class GradientBlockColorStep {
  68730. private _step;
  68731. /**
  68732. * Gets value indicating which step this color is associated with (between 0 and 1)
  68733. */
  68734. get step(): number;
  68735. /**
  68736. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68737. */
  68738. set step(val: number);
  68739. private _color;
  68740. /**
  68741. * Gets the color associated with this step
  68742. */
  68743. get color(): Color3;
  68744. /**
  68745. * Sets the color associated with this step
  68746. */
  68747. set color(val: Color3);
  68748. /**
  68749. * Creates a new GradientBlockColorStep
  68750. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68751. * @param color defines the color associated with this step
  68752. */
  68753. constructor(step: number, color: Color3);
  68754. }
  68755. /**
  68756. * Block used to return a color from a gradient based on an input value between 0 and 1
  68757. */
  68758. export class GradientBlock extends NodeMaterialBlock {
  68759. /**
  68760. * Gets or sets the list of color steps
  68761. */
  68762. colorSteps: GradientBlockColorStep[];
  68763. /** Gets an observable raised when the value is changed */
  68764. onValueChangedObservable: Observable<GradientBlock>;
  68765. /** calls observable when the value is changed*/
  68766. colorStepsUpdated(): void;
  68767. /**
  68768. * Creates a new GradientBlock
  68769. * @param name defines the block name
  68770. */
  68771. constructor(name: string);
  68772. /**
  68773. * Gets the current class name
  68774. * @returns the class name
  68775. */
  68776. getClassName(): string;
  68777. /**
  68778. * Gets the gradient input component
  68779. */
  68780. get gradient(): NodeMaterialConnectionPoint;
  68781. /**
  68782. * Gets the output component
  68783. */
  68784. get output(): NodeMaterialConnectionPoint;
  68785. private _writeColorConstant;
  68786. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68787. serialize(): any;
  68788. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68789. protected _dumpPropertiesCode(): string;
  68790. }
  68791. }
  68792. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68793. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68794. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68795. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68796. /**
  68797. * Block used to normalize lerp between 2 values
  68798. */
  68799. export class NLerpBlock extends NodeMaterialBlock {
  68800. /**
  68801. * Creates a new NLerpBlock
  68802. * @param name defines the block name
  68803. */
  68804. constructor(name: string);
  68805. /**
  68806. * Gets the current class name
  68807. * @returns the class name
  68808. */
  68809. getClassName(): string;
  68810. /**
  68811. * Gets the left operand input component
  68812. */
  68813. get left(): NodeMaterialConnectionPoint;
  68814. /**
  68815. * Gets the right operand input component
  68816. */
  68817. get right(): NodeMaterialConnectionPoint;
  68818. /**
  68819. * Gets the gradient operand input component
  68820. */
  68821. get gradient(): NodeMaterialConnectionPoint;
  68822. /**
  68823. * Gets the output component
  68824. */
  68825. get output(): NodeMaterialConnectionPoint;
  68826. protected _buildBlock(state: NodeMaterialBuildState): this;
  68827. }
  68828. }
  68829. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68833. import { Scene } from "babylonjs/scene";
  68834. /**
  68835. * block used to Generate a Worley Noise 3D Noise Pattern
  68836. */
  68837. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68838. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68839. manhattanDistance: boolean;
  68840. /**
  68841. * Creates a new WorleyNoise3DBlock
  68842. * @param name defines the block name
  68843. */
  68844. constructor(name: string);
  68845. /**
  68846. * Gets the current class name
  68847. * @returns the class name
  68848. */
  68849. getClassName(): string;
  68850. /**
  68851. * Gets the seed input component
  68852. */
  68853. get seed(): NodeMaterialConnectionPoint;
  68854. /**
  68855. * Gets the jitter input component
  68856. */
  68857. get jitter(): NodeMaterialConnectionPoint;
  68858. /**
  68859. * Gets the output component
  68860. */
  68861. get output(): NodeMaterialConnectionPoint;
  68862. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68863. /**
  68864. * Exposes the properties to the UI?
  68865. */
  68866. protected _dumpPropertiesCode(): string;
  68867. /**
  68868. * Exposes the properties to the Seralize?
  68869. */
  68870. serialize(): any;
  68871. /**
  68872. * Exposes the properties to the deseralize?
  68873. */
  68874. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68875. }
  68876. }
  68877. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68878. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68879. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68880. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68881. /**
  68882. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68883. */
  68884. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68885. /**
  68886. * Creates a new SimplexPerlin3DBlock
  68887. * @param name defines the block name
  68888. */
  68889. constructor(name: string);
  68890. /**
  68891. * Gets the current class name
  68892. * @returns the class name
  68893. */
  68894. getClassName(): string;
  68895. /**
  68896. * Gets the seed operand input component
  68897. */
  68898. get seed(): NodeMaterialConnectionPoint;
  68899. /**
  68900. * Gets the output component
  68901. */
  68902. get output(): NodeMaterialConnectionPoint;
  68903. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68904. }
  68905. }
  68906. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68907. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68908. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68909. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68910. /**
  68911. * Block used to blend normals
  68912. */
  68913. export class NormalBlendBlock extends NodeMaterialBlock {
  68914. /**
  68915. * Creates a new NormalBlendBlock
  68916. * @param name defines the block name
  68917. */
  68918. constructor(name: string);
  68919. /**
  68920. * Gets the current class name
  68921. * @returns the class name
  68922. */
  68923. getClassName(): string;
  68924. /**
  68925. * Gets the first input component
  68926. */
  68927. get normalMap0(): NodeMaterialConnectionPoint;
  68928. /**
  68929. * Gets the second input component
  68930. */
  68931. get normalMap1(): NodeMaterialConnectionPoint;
  68932. /**
  68933. * Gets the output component
  68934. */
  68935. get output(): NodeMaterialConnectionPoint;
  68936. protected _buildBlock(state: NodeMaterialBuildState): this;
  68937. }
  68938. }
  68939. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68943. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68944. /**
  68945. * Block used to rotate a 2d vector by a given angle
  68946. */
  68947. export class Rotate2dBlock extends NodeMaterialBlock {
  68948. /**
  68949. * Creates a new Rotate2dBlock
  68950. * @param name defines the block name
  68951. */
  68952. constructor(name: string);
  68953. /**
  68954. * Gets the current class name
  68955. * @returns the class name
  68956. */
  68957. getClassName(): string;
  68958. /**
  68959. * Gets the input vector
  68960. */
  68961. get input(): NodeMaterialConnectionPoint;
  68962. /**
  68963. * Gets the input angle
  68964. */
  68965. get angle(): NodeMaterialConnectionPoint;
  68966. /**
  68967. * Gets the output component
  68968. */
  68969. get output(): NodeMaterialConnectionPoint;
  68970. autoConfigure(material: NodeMaterial): void;
  68971. protected _buildBlock(state: NodeMaterialBuildState): this;
  68972. }
  68973. }
  68974. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68977. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68978. /**
  68979. * Block used to get the reflected vector from a direction and a normal
  68980. */
  68981. export class ReflectBlock extends NodeMaterialBlock {
  68982. /**
  68983. * Creates a new ReflectBlock
  68984. * @param name defines the block name
  68985. */
  68986. constructor(name: string);
  68987. /**
  68988. * Gets the current class name
  68989. * @returns the class name
  68990. */
  68991. getClassName(): string;
  68992. /**
  68993. * Gets the incident component
  68994. */
  68995. get incident(): NodeMaterialConnectionPoint;
  68996. /**
  68997. * Gets the normal component
  68998. */
  68999. get normal(): NodeMaterialConnectionPoint;
  69000. /**
  69001. * Gets the output component
  69002. */
  69003. get output(): NodeMaterialConnectionPoint;
  69004. protected _buildBlock(state: NodeMaterialBuildState): this;
  69005. }
  69006. }
  69007. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  69008. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69009. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69010. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69011. /**
  69012. * Block used to get the refracted vector from a direction and a normal
  69013. */
  69014. export class RefractBlock extends NodeMaterialBlock {
  69015. /**
  69016. * Creates a new RefractBlock
  69017. * @param name defines the block name
  69018. */
  69019. constructor(name: string);
  69020. /**
  69021. * Gets the current class name
  69022. * @returns the class name
  69023. */
  69024. getClassName(): string;
  69025. /**
  69026. * Gets the incident component
  69027. */
  69028. get incident(): NodeMaterialConnectionPoint;
  69029. /**
  69030. * Gets the normal component
  69031. */
  69032. get normal(): NodeMaterialConnectionPoint;
  69033. /**
  69034. * Gets the index of refraction component
  69035. */
  69036. get ior(): NodeMaterialConnectionPoint;
  69037. /**
  69038. * Gets the output component
  69039. */
  69040. get output(): NodeMaterialConnectionPoint;
  69041. protected _buildBlock(state: NodeMaterialBuildState): this;
  69042. }
  69043. }
  69044. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  69045. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69046. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69047. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69048. /**
  69049. * Block used to desaturate a color
  69050. */
  69051. export class DesaturateBlock extends NodeMaterialBlock {
  69052. /**
  69053. * Creates a new DesaturateBlock
  69054. * @param name defines the block name
  69055. */
  69056. constructor(name: string);
  69057. /**
  69058. * Gets the current class name
  69059. * @returns the class name
  69060. */
  69061. getClassName(): string;
  69062. /**
  69063. * Gets the color operand input component
  69064. */
  69065. get color(): NodeMaterialConnectionPoint;
  69066. /**
  69067. * Gets the level operand input component
  69068. */
  69069. get level(): NodeMaterialConnectionPoint;
  69070. /**
  69071. * Gets the output component
  69072. */
  69073. get output(): NodeMaterialConnectionPoint;
  69074. protected _buildBlock(state: NodeMaterialBuildState): this;
  69075. }
  69076. }
  69077. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  69078. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69079. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69080. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69081. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  69082. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69083. import { Nullable } from "babylonjs/types";
  69084. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69085. import { Mesh } from "babylonjs/Meshes/mesh";
  69086. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69087. import { Effect } from "babylonjs/Materials/effect";
  69088. import { Scene } from "babylonjs/scene";
  69089. /**
  69090. * Block used to implement the reflection module of the PBR material
  69091. */
  69092. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  69093. /** @hidden */
  69094. _defineLODReflectionAlpha: string;
  69095. /** @hidden */
  69096. _defineLinearSpecularReflection: string;
  69097. private _vEnvironmentIrradianceName;
  69098. /** @hidden */
  69099. _vReflectionMicrosurfaceInfosName: string;
  69100. /** @hidden */
  69101. _vReflectionInfosName: string;
  69102. /** @hidden */
  69103. _vReflectionFilteringInfoName: string;
  69104. private _scene;
  69105. /**
  69106. * The properties below are set by the main PBR block prior to calling methods of this class.
  69107. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69108. * It's less burden on the user side in the editor part.
  69109. */
  69110. /** @hidden */
  69111. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69112. /** @hidden */
  69113. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69114. /** @hidden */
  69115. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  69116. /** @hidden */
  69117. viewConnectionPoint: NodeMaterialConnectionPoint;
  69118. /**
  69119. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  69120. * diffuse part of the IBL.
  69121. */
  69122. useSphericalHarmonics: boolean;
  69123. /**
  69124. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  69125. */
  69126. forceIrradianceInFragment: boolean;
  69127. /**
  69128. * Create a new ReflectionBlock
  69129. * @param name defines the block name
  69130. */
  69131. constructor(name: string);
  69132. /**
  69133. * Gets the current class name
  69134. * @returns the class name
  69135. */
  69136. getClassName(): string;
  69137. /**
  69138. * Gets the position input component
  69139. */
  69140. get position(): NodeMaterialConnectionPoint;
  69141. /**
  69142. * Gets the world position input component
  69143. */
  69144. get worldPosition(): NodeMaterialConnectionPoint;
  69145. /**
  69146. * Gets the world normal input component
  69147. */
  69148. get worldNormal(): NodeMaterialConnectionPoint;
  69149. /**
  69150. * Gets the world input component
  69151. */
  69152. get world(): NodeMaterialConnectionPoint;
  69153. /**
  69154. * Gets the camera (or eye) position component
  69155. */
  69156. get cameraPosition(): NodeMaterialConnectionPoint;
  69157. /**
  69158. * Gets the view input component
  69159. */
  69160. get view(): NodeMaterialConnectionPoint;
  69161. /**
  69162. * Gets the color input component
  69163. */
  69164. get color(): NodeMaterialConnectionPoint;
  69165. /**
  69166. * Gets the reflection object output component
  69167. */
  69168. get reflection(): NodeMaterialConnectionPoint;
  69169. /**
  69170. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  69171. */
  69172. get hasTexture(): boolean;
  69173. /**
  69174. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  69175. */
  69176. get reflectionColor(): string;
  69177. protected _getTexture(): Nullable<BaseTexture>;
  69178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69180. /**
  69181. * Gets the code to inject in the vertex shader
  69182. * @param state current state of the node material building
  69183. * @returns the shader code
  69184. */
  69185. handleVertexSide(state: NodeMaterialBuildState): string;
  69186. /**
  69187. * Gets the main code of the block (fragment side)
  69188. * @param state current state of the node material building
  69189. * @param normalVarName name of the existing variable corresponding to the normal
  69190. * @returns the shader code
  69191. */
  69192. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  69193. protected _buildBlock(state: NodeMaterialBuildState): this;
  69194. protected _dumpPropertiesCode(): string;
  69195. serialize(): any;
  69196. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69197. }
  69198. }
  69199. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  69200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69203. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69205. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69206. import { Scene } from "babylonjs/scene";
  69207. import { Nullable } from "babylonjs/types";
  69208. /**
  69209. * Block used to implement the sheen module of the PBR material
  69210. */
  69211. export class SheenBlock extends NodeMaterialBlock {
  69212. /**
  69213. * Create a new SheenBlock
  69214. * @param name defines the block name
  69215. */
  69216. constructor(name: string);
  69217. /**
  69218. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  69219. * It allows the strength of the sheen effect to not depend on the base color of the material,
  69220. * making it easier to setup and tweak the effect
  69221. */
  69222. albedoScaling: boolean;
  69223. /**
  69224. * Defines if the sheen is linked to the sheen color.
  69225. */
  69226. linkSheenWithAlbedo: boolean;
  69227. /**
  69228. * Initialize the block and prepare the context for build
  69229. * @param state defines the state that will be used for the build
  69230. */
  69231. initialize(state: NodeMaterialBuildState): void;
  69232. /**
  69233. * Gets the current class name
  69234. * @returns the class name
  69235. */
  69236. getClassName(): string;
  69237. /**
  69238. * Gets the intensity input component
  69239. */
  69240. get intensity(): NodeMaterialConnectionPoint;
  69241. /**
  69242. * Gets the color input component
  69243. */
  69244. get color(): NodeMaterialConnectionPoint;
  69245. /**
  69246. * Gets the roughness input component
  69247. */
  69248. get roughness(): NodeMaterialConnectionPoint;
  69249. /**
  69250. * Gets the sheen object output component
  69251. */
  69252. get sheen(): NodeMaterialConnectionPoint;
  69253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69254. /**
  69255. * Gets the main code of the block (fragment side)
  69256. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69257. * @returns the shader code
  69258. */
  69259. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  69260. protected _buildBlock(state: NodeMaterialBuildState): this;
  69261. protected _dumpPropertiesCode(): string;
  69262. serialize(): any;
  69263. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69264. }
  69265. }
  69266. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  69267. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69272. /**
  69273. * Block used to implement the anisotropy module of the PBR material
  69274. */
  69275. export class AnisotropyBlock extends NodeMaterialBlock {
  69276. /**
  69277. * The two properties below are set by the main PBR block prior to calling methods of this class.
  69278. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  69279. * It's less burden on the user side in the editor part.
  69280. */
  69281. /** @hidden */
  69282. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  69283. /** @hidden */
  69284. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  69285. /**
  69286. * Create a new AnisotropyBlock
  69287. * @param name defines the block name
  69288. */
  69289. constructor(name: string);
  69290. /**
  69291. * Initialize the block and prepare the context for build
  69292. * @param state defines the state that will be used for the build
  69293. */
  69294. initialize(state: NodeMaterialBuildState): void;
  69295. /**
  69296. * Gets the current class name
  69297. * @returns the class name
  69298. */
  69299. getClassName(): string;
  69300. /**
  69301. * Gets the intensity input component
  69302. */
  69303. get intensity(): NodeMaterialConnectionPoint;
  69304. /**
  69305. * Gets the direction input component
  69306. */
  69307. get direction(): NodeMaterialConnectionPoint;
  69308. /**
  69309. * Gets the uv input component
  69310. */
  69311. get uv(): NodeMaterialConnectionPoint;
  69312. /**
  69313. * Gets the worldTangent input component
  69314. */
  69315. get worldTangent(): NodeMaterialConnectionPoint;
  69316. /**
  69317. * Gets the anisotropy object output component
  69318. */
  69319. get anisotropy(): NodeMaterialConnectionPoint;
  69320. private _generateTBNSpace;
  69321. /**
  69322. * Gets the main code of the block (fragment side)
  69323. * @param state current state of the node material building
  69324. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69325. * @returns the shader code
  69326. */
  69327. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  69328. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69329. protected _buildBlock(state: NodeMaterialBuildState): this;
  69330. }
  69331. }
  69332. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  69333. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69334. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69335. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69336. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69338. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69339. import { Scene } from "babylonjs/scene";
  69340. import { Nullable } from "babylonjs/types";
  69341. import { Mesh } from "babylonjs/Meshes/mesh";
  69342. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69343. import { Effect } from "babylonjs/Materials/effect";
  69344. /**
  69345. * Block used to implement the clear coat module of the PBR material
  69346. */
  69347. export class ClearCoatBlock extends NodeMaterialBlock {
  69348. private _scene;
  69349. /**
  69350. * Create a new ClearCoatBlock
  69351. * @param name defines the block name
  69352. */
  69353. constructor(name: string);
  69354. /**
  69355. * Defines if the F0 value should be remapped to account for the interface change in the material.
  69356. */
  69357. remapF0OnInterfaceChange: boolean;
  69358. /**
  69359. * Initialize the block and prepare the context for build
  69360. * @param state defines the state that will be used for the build
  69361. */
  69362. initialize(state: NodeMaterialBuildState): void;
  69363. /**
  69364. * Gets the current class name
  69365. * @returns the class name
  69366. */
  69367. getClassName(): string;
  69368. /**
  69369. * Gets the intensity input component
  69370. */
  69371. get intensity(): NodeMaterialConnectionPoint;
  69372. /**
  69373. * Gets the roughness input component
  69374. */
  69375. get roughness(): NodeMaterialConnectionPoint;
  69376. /**
  69377. * Gets the ior input component
  69378. */
  69379. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69380. /**
  69381. * Gets the bump texture input component
  69382. */
  69383. get normalMapColor(): NodeMaterialConnectionPoint;
  69384. /**
  69385. * Gets the uv input component
  69386. */
  69387. get uv(): NodeMaterialConnectionPoint;
  69388. /**
  69389. * Gets the tint color input component
  69390. */
  69391. get tintColor(): NodeMaterialConnectionPoint;
  69392. /**
  69393. * Gets the tint "at distance" input component
  69394. */
  69395. get tintAtDistance(): NodeMaterialConnectionPoint;
  69396. /**
  69397. * Gets the tint thickness input component
  69398. */
  69399. get tintThickness(): NodeMaterialConnectionPoint;
  69400. /**
  69401. * Gets the world tangent input component
  69402. */
  69403. get worldTangent(): NodeMaterialConnectionPoint;
  69404. /**
  69405. * Gets the clear coat object output component
  69406. */
  69407. get clearcoat(): NodeMaterialConnectionPoint;
  69408. autoConfigure(material: NodeMaterial): void;
  69409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69410. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69411. private _generateTBNSpace;
  69412. /**
  69413. * Gets the main code of the block (fragment side)
  69414. * @param state current state of the node material building
  69415. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69416. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69417. * @param worldPosVarName name of the variable holding the world position
  69418. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69419. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69420. * @param worldNormalVarName name of the variable holding the world normal
  69421. * @returns the shader code
  69422. */
  69423. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69424. protected _buildBlock(state: NodeMaterialBuildState): this;
  69425. protected _dumpPropertiesCode(): string;
  69426. serialize(): any;
  69427. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69428. }
  69429. }
  69430. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69431. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69432. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69433. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69434. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69436. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69437. import { Nullable } from "babylonjs/types";
  69438. /**
  69439. * Block used to implement the sub surface module of the PBR material
  69440. */
  69441. export class SubSurfaceBlock extends NodeMaterialBlock {
  69442. /**
  69443. * Create a new SubSurfaceBlock
  69444. * @param name defines the block name
  69445. */
  69446. constructor(name: string);
  69447. /**
  69448. * Initialize the block and prepare the context for build
  69449. * @param state defines the state that will be used for the build
  69450. */
  69451. initialize(state: NodeMaterialBuildState): void;
  69452. /**
  69453. * Gets the current class name
  69454. * @returns the class name
  69455. */
  69456. getClassName(): string;
  69457. /**
  69458. * Gets the thickness component
  69459. */
  69460. get thickness(): NodeMaterialConnectionPoint;
  69461. /**
  69462. * Gets the tint color input component
  69463. */
  69464. get tintColor(): NodeMaterialConnectionPoint;
  69465. /**
  69466. * Gets the translucency intensity input component
  69467. */
  69468. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69469. /**
  69470. * Gets the translucency diffusion distance input component
  69471. */
  69472. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  69473. /**
  69474. * Gets the refraction object parameters
  69475. */
  69476. get refraction(): NodeMaterialConnectionPoint;
  69477. /**
  69478. * Gets the sub surface object output component
  69479. */
  69480. get subsurface(): NodeMaterialConnectionPoint;
  69481. autoConfigure(material: NodeMaterial): void;
  69482. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69483. /**
  69484. * Gets the main code of the block (fragment side)
  69485. * @param state current state of the node material building
  69486. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69487. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69488. * @param worldPosVarName name of the variable holding the world position
  69489. * @returns the shader code
  69490. */
  69491. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69492. protected _buildBlock(state: NodeMaterialBuildState): this;
  69493. }
  69494. }
  69495. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69499. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69500. import { Light } from "babylonjs/Lights/light";
  69501. import { Nullable } from "babylonjs/types";
  69502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69503. import { Effect } from "babylonjs/Materials/effect";
  69504. import { Mesh } from "babylonjs/Meshes/mesh";
  69505. import { Scene } from "babylonjs/scene";
  69506. /**
  69507. * Block used to implement the PBR metallic/roughness model
  69508. */
  69509. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69510. /**
  69511. * Gets or sets the light associated with this block
  69512. */
  69513. light: Nullable<Light>;
  69514. private _lightId;
  69515. private _scene;
  69516. private _environmentBRDFTexture;
  69517. private _environmentBrdfSamplerName;
  69518. private _vNormalWName;
  69519. private _invertNormalName;
  69520. private _metallicReflectanceColor;
  69521. private _metallicF0Factor;
  69522. private _vMetallicReflectanceFactorsName;
  69523. /**
  69524. * Create a new ReflectionBlock
  69525. * @param name defines the block name
  69526. */
  69527. constructor(name: string);
  69528. /**
  69529. * Intensity of the direct lights e.g. the four lights available in your scene.
  69530. * This impacts both the direct diffuse and specular highlights.
  69531. */
  69532. directIntensity: number;
  69533. /**
  69534. * Intensity of the environment e.g. how much the environment will light the object
  69535. * either through harmonics for rough material or through the refelction for shiny ones.
  69536. */
  69537. environmentIntensity: number;
  69538. /**
  69539. * This is a special control allowing the reduction of the specular highlights coming from the
  69540. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69541. */
  69542. specularIntensity: number;
  69543. /**
  69544. * Defines the falloff type used in this material.
  69545. * It by default is Physical.
  69546. */
  69547. lightFalloff: number;
  69548. /**
  69549. * Specifies that alpha test should be used
  69550. */
  69551. useAlphaTest: boolean;
  69552. /**
  69553. * Defines the alpha limits in alpha test mode.
  69554. */
  69555. alphaTestCutoff: number;
  69556. /**
  69557. * Specifies that alpha blending should be used
  69558. */
  69559. useAlphaBlending: boolean;
  69560. /**
  69561. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69562. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69563. */
  69564. useRadianceOverAlpha: boolean;
  69565. /**
  69566. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69567. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69568. */
  69569. useSpecularOverAlpha: boolean;
  69570. /**
  69571. * Enables specular anti aliasing in the PBR shader.
  69572. * It will both interacts on the Geometry for analytical and IBL lighting.
  69573. * It also prefilter the roughness map based on the bump values.
  69574. */
  69575. enableSpecularAntiAliasing: boolean;
  69576. /**
  69577. * Enables realtime filtering on the texture.
  69578. */
  69579. realTimeFiltering: boolean;
  69580. /**
  69581. * Quality switch for realtime filtering
  69582. */
  69583. realTimeFilteringQuality: number;
  69584. /**
  69585. * Defines if the material uses energy conservation.
  69586. */
  69587. useEnergyConservation: boolean;
  69588. /**
  69589. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69590. * too much the area relying on ambient texture to define their ambient occlusion.
  69591. */
  69592. useRadianceOcclusion: boolean;
  69593. /**
  69594. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69595. * makes the reflect vector face the model (under horizon).
  69596. */
  69597. useHorizonOcclusion: boolean;
  69598. /**
  69599. * If set to true, no lighting calculations will be applied.
  69600. */
  69601. unlit: boolean;
  69602. /**
  69603. * Force normal to face away from face.
  69604. */
  69605. forceNormalForward: boolean;
  69606. /**
  69607. * Defines the material debug mode.
  69608. * It helps seeing only some components of the material while troubleshooting.
  69609. */
  69610. debugMode: number;
  69611. /**
  69612. * Specify from where on screen the debug mode should start.
  69613. * The value goes from -1 (full screen) to 1 (not visible)
  69614. * It helps with side by side comparison against the final render
  69615. * This defaults to 0
  69616. */
  69617. debugLimit: number;
  69618. /**
  69619. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69620. * You can use the factor to better multiply the final value.
  69621. */
  69622. debugFactor: number;
  69623. /**
  69624. * Initialize the block and prepare the context for build
  69625. * @param state defines the state that will be used for the build
  69626. */
  69627. initialize(state: NodeMaterialBuildState): void;
  69628. /**
  69629. * Gets the current class name
  69630. * @returns the class name
  69631. */
  69632. getClassName(): string;
  69633. /**
  69634. * Gets the world position input component
  69635. */
  69636. get worldPosition(): NodeMaterialConnectionPoint;
  69637. /**
  69638. * Gets the world normal input component
  69639. */
  69640. get worldNormal(): NodeMaterialConnectionPoint;
  69641. /**
  69642. * Gets the view matrix parameter
  69643. */
  69644. get view(): NodeMaterialConnectionPoint;
  69645. /**
  69646. * Gets the camera position input component
  69647. */
  69648. get cameraPosition(): NodeMaterialConnectionPoint;
  69649. /**
  69650. * Gets the perturbed normal input component
  69651. */
  69652. get perturbedNormal(): NodeMaterialConnectionPoint;
  69653. /**
  69654. * Gets the base color input component
  69655. */
  69656. get baseColor(): NodeMaterialConnectionPoint;
  69657. /**
  69658. * Gets the metallic input component
  69659. */
  69660. get metallic(): NodeMaterialConnectionPoint;
  69661. /**
  69662. * Gets the roughness input component
  69663. */
  69664. get roughness(): NodeMaterialConnectionPoint;
  69665. /**
  69666. * Gets the ambient occlusion input component
  69667. */
  69668. get ambientOcc(): NodeMaterialConnectionPoint;
  69669. /**
  69670. * Gets the opacity input component
  69671. */
  69672. get opacity(): NodeMaterialConnectionPoint;
  69673. /**
  69674. * Gets the index of refraction input component
  69675. */
  69676. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69677. /**
  69678. * Gets the ambient color input component
  69679. */
  69680. get ambientColor(): NodeMaterialConnectionPoint;
  69681. /**
  69682. * Gets the reflection object parameters
  69683. */
  69684. get reflection(): NodeMaterialConnectionPoint;
  69685. /**
  69686. * Gets the clear coat object parameters
  69687. */
  69688. get clearcoat(): NodeMaterialConnectionPoint;
  69689. /**
  69690. * Gets the sheen object parameters
  69691. */
  69692. get sheen(): NodeMaterialConnectionPoint;
  69693. /**
  69694. * Gets the sub surface object parameters
  69695. */
  69696. get subsurface(): NodeMaterialConnectionPoint;
  69697. /**
  69698. * Gets the anisotropy object parameters
  69699. */
  69700. get anisotropy(): NodeMaterialConnectionPoint;
  69701. /**
  69702. * Gets the ambient output component
  69703. */
  69704. get ambientClr(): NodeMaterialConnectionPoint;
  69705. /**
  69706. * Gets the diffuse output component
  69707. */
  69708. get diffuseDir(): NodeMaterialConnectionPoint;
  69709. /**
  69710. * Gets the specular output component
  69711. */
  69712. get specularDir(): NodeMaterialConnectionPoint;
  69713. /**
  69714. * Gets the clear coat output component
  69715. */
  69716. get clearcoatDir(): NodeMaterialConnectionPoint;
  69717. /**
  69718. * Gets the sheen output component
  69719. */
  69720. get sheenDir(): NodeMaterialConnectionPoint;
  69721. /**
  69722. * Gets the indirect diffuse output component
  69723. */
  69724. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69725. /**
  69726. * Gets the indirect specular output component
  69727. */
  69728. get specularIndirect(): NodeMaterialConnectionPoint;
  69729. /**
  69730. * Gets the indirect clear coat output component
  69731. */
  69732. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69733. /**
  69734. * Gets the indirect sheen output component
  69735. */
  69736. get sheenIndirect(): NodeMaterialConnectionPoint;
  69737. /**
  69738. * Gets the refraction output component
  69739. */
  69740. get refraction(): NodeMaterialConnectionPoint;
  69741. /**
  69742. * Gets the global lighting output component
  69743. */
  69744. get lighting(): NodeMaterialConnectionPoint;
  69745. /**
  69746. * Gets the shadow output component
  69747. */
  69748. get shadow(): NodeMaterialConnectionPoint;
  69749. /**
  69750. * Gets the alpha output component
  69751. */
  69752. get alpha(): NodeMaterialConnectionPoint;
  69753. autoConfigure(material: NodeMaterial): void;
  69754. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69755. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69756. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69757. private _injectVertexCode;
  69758. private _getAlbedoOpacityCode;
  69759. private _getAmbientOcclusionCode;
  69760. private _getReflectivityCode;
  69761. protected _buildBlock(state: NodeMaterialBuildState): this;
  69762. protected _dumpPropertiesCode(): string;
  69763. serialize(): any;
  69764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69765. }
  69766. }
  69767. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69768. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69769. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69770. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69771. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69772. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69773. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69774. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69775. }
  69776. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69777. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69778. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69779. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69780. }
  69781. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69782. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69783. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69784. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69785. /**
  69786. * Block used to compute value of one parameter modulo another
  69787. */
  69788. export class ModBlock extends NodeMaterialBlock {
  69789. /**
  69790. * Creates a new ModBlock
  69791. * @param name defines the block name
  69792. */
  69793. constructor(name: string);
  69794. /**
  69795. * Gets the current class name
  69796. * @returns the class name
  69797. */
  69798. getClassName(): string;
  69799. /**
  69800. * Gets the left operand input component
  69801. */
  69802. get left(): NodeMaterialConnectionPoint;
  69803. /**
  69804. * Gets the right operand input component
  69805. */
  69806. get right(): NodeMaterialConnectionPoint;
  69807. /**
  69808. * Gets the output component
  69809. */
  69810. get output(): NodeMaterialConnectionPoint;
  69811. protected _buildBlock(state: NodeMaterialBuildState): this;
  69812. }
  69813. }
  69814. declare module "babylonjs/Materials/Node/Blocks/index" {
  69815. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69816. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69817. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69818. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69819. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69820. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69821. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69822. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69823. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69824. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69825. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69826. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69827. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69828. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69829. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69830. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69831. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69832. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69833. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69834. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69835. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69836. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69837. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69838. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69839. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69840. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69841. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69842. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69843. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69844. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69845. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69846. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69847. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69848. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69849. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69850. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69851. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69852. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69853. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69854. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69855. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69856. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69857. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69858. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69859. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69860. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69861. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69862. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69863. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69864. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69865. }
  69866. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69867. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69868. }
  69869. declare module "babylonjs/Materials/Node/index" {
  69870. export * from "babylonjs/Materials/Node/Enums/index";
  69871. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69872. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69873. export * from "babylonjs/Materials/Node/nodeMaterial";
  69874. export * from "babylonjs/Materials/Node/Blocks/index";
  69875. export * from "babylonjs/Materials/Node/Optimizers/index";
  69876. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69877. }
  69878. declare module "babylonjs/Materials/index" {
  69879. export * from "babylonjs/Materials/Background/index";
  69880. export * from "babylonjs/Materials/colorCurves";
  69881. export * from "babylonjs/Materials/iEffectFallbacks";
  69882. export * from "babylonjs/Materials/effectFallbacks";
  69883. export * from "babylonjs/Materials/effect";
  69884. export * from "babylonjs/Materials/fresnelParameters";
  69885. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69886. export * from "babylonjs/Materials/material";
  69887. export * from "babylonjs/Materials/materialDefines";
  69888. export * from "babylonjs/Materials/thinMaterialHelper";
  69889. export * from "babylonjs/Materials/materialHelper";
  69890. export * from "babylonjs/Materials/multiMaterial";
  69891. export * from "babylonjs/Materials/PBR/index";
  69892. export * from "babylonjs/Materials/pushMaterial";
  69893. export * from "babylonjs/Materials/shaderMaterial";
  69894. export * from "babylonjs/Materials/standardMaterial";
  69895. export * from "babylonjs/Materials/Textures/index";
  69896. export * from "babylonjs/Materials/uniformBuffer";
  69897. export * from "babylonjs/Materials/materialFlags";
  69898. export * from "babylonjs/Materials/Node/index";
  69899. export * from "babylonjs/Materials/effectRenderer";
  69900. export * from "babylonjs/Materials/shadowDepthWrapper";
  69901. }
  69902. declare module "babylonjs/Maths/index" {
  69903. export * from "babylonjs/Maths/math.scalar";
  69904. export * from "babylonjs/Maths/math.functions";
  69905. export * from "babylonjs/Maths/math";
  69906. export * from "babylonjs/Maths/sphericalPolynomial";
  69907. }
  69908. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69909. import { IDisposable } from "babylonjs/scene";
  69910. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69911. /**
  69912. * Configuration for Draco compression
  69913. */
  69914. export interface IDracoCompressionConfiguration {
  69915. /**
  69916. * Configuration for the decoder.
  69917. */
  69918. decoder: {
  69919. /**
  69920. * The url to the WebAssembly module.
  69921. */
  69922. wasmUrl?: string;
  69923. /**
  69924. * The url to the WebAssembly binary.
  69925. */
  69926. wasmBinaryUrl?: string;
  69927. /**
  69928. * The url to the fallback JavaScript module.
  69929. */
  69930. fallbackUrl?: string;
  69931. };
  69932. }
  69933. /**
  69934. * Draco compression (https://google.github.io/draco/)
  69935. *
  69936. * This class wraps the Draco module.
  69937. *
  69938. * **Encoder**
  69939. *
  69940. * The encoder is not currently implemented.
  69941. *
  69942. * **Decoder**
  69943. *
  69944. * 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.
  69945. *
  69946. * To update the configuration, use the following code:
  69947. * ```javascript
  69948. * DracoCompression.Configuration = {
  69949. * decoder: {
  69950. * wasmUrl: "<url to the WebAssembly library>",
  69951. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69952. * fallbackUrl: "<url to the fallback JavaScript library>",
  69953. * }
  69954. * };
  69955. * ```
  69956. *
  69957. * 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.
  69958. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69959. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69960. *
  69961. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69962. * ```javascript
  69963. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69964. * ```
  69965. *
  69966. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69967. */
  69968. export class DracoCompression implements IDisposable {
  69969. private _workerPoolPromise?;
  69970. private _decoderModulePromise?;
  69971. /**
  69972. * The configuration. Defaults to the following urls:
  69973. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69974. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69975. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69976. */
  69977. static Configuration: IDracoCompressionConfiguration;
  69978. /**
  69979. * Returns true if the decoder configuration is available.
  69980. */
  69981. static get DecoderAvailable(): boolean;
  69982. /**
  69983. * Default number of workers to create when creating the draco compression object.
  69984. */
  69985. static DefaultNumWorkers: number;
  69986. private static GetDefaultNumWorkers;
  69987. private static _Default;
  69988. /**
  69989. * Default instance for the draco compression object.
  69990. */
  69991. static get Default(): DracoCompression;
  69992. /**
  69993. * Constructor
  69994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69995. */
  69996. constructor(numWorkers?: number);
  69997. /**
  69998. * Stop all async operations and release resources.
  69999. */
  70000. dispose(): void;
  70001. /**
  70002. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  70003. * @returns a promise that resolves when ready
  70004. */
  70005. whenReadyAsync(): Promise<void>;
  70006. /**
  70007. * Decode Draco compressed mesh data to vertex data.
  70008. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  70009. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  70010. * @returns A promise that resolves with the decoded vertex data
  70011. */
  70012. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  70013. [kind: string]: number;
  70014. }): Promise<VertexData>;
  70015. }
  70016. }
  70017. declare module "babylonjs/Meshes/Compression/index" {
  70018. export * from "babylonjs/Meshes/Compression/dracoCompression";
  70019. }
  70020. declare module "babylonjs/Meshes/csg" {
  70021. import { Nullable } from "babylonjs/types";
  70022. import { Scene } from "babylonjs/scene";
  70023. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  70024. import { Mesh } from "babylonjs/Meshes/mesh";
  70025. import { Material } from "babylonjs/Materials/material";
  70026. /**
  70027. * Class for building Constructive Solid Geometry
  70028. */
  70029. export class CSG {
  70030. private polygons;
  70031. /**
  70032. * The world matrix
  70033. */
  70034. matrix: Matrix;
  70035. /**
  70036. * Stores the position
  70037. */
  70038. position: Vector3;
  70039. /**
  70040. * Stores the rotation
  70041. */
  70042. rotation: Vector3;
  70043. /**
  70044. * Stores the rotation quaternion
  70045. */
  70046. rotationQuaternion: Nullable<Quaternion>;
  70047. /**
  70048. * Stores the scaling vector
  70049. */
  70050. scaling: Vector3;
  70051. /**
  70052. * Convert the Mesh to CSG
  70053. * @param mesh The Mesh to convert to CSG
  70054. * @returns A new CSG from the Mesh
  70055. */
  70056. static FromMesh(mesh: Mesh): CSG;
  70057. /**
  70058. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  70059. * @param polygons Polygons used to construct a CSG solid
  70060. */
  70061. private static FromPolygons;
  70062. /**
  70063. * Clones, or makes a deep copy, of the CSG
  70064. * @returns A new CSG
  70065. */
  70066. clone(): CSG;
  70067. /**
  70068. * Unions this CSG with another CSG
  70069. * @param csg The CSG to union against this CSG
  70070. * @returns The unioned CSG
  70071. */
  70072. union(csg: CSG): CSG;
  70073. /**
  70074. * Unions this CSG with another CSG in place
  70075. * @param csg The CSG to union against this CSG
  70076. */
  70077. unionInPlace(csg: CSG): void;
  70078. /**
  70079. * Subtracts this CSG with another CSG
  70080. * @param csg The CSG to subtract against this CSG
  70081. * @returns A new CSG
  70082. */
  70083. subtract(csg: CSG): CSG;
  70084. /**
  70085. * Subtracts this CSG with another CSG in place
  70086. * @param csg The CSG to subtact against this CSG
  70087. */
  70088. subtractInPlace(csg: CSG): void;
  70089. /**
  70090. * Intersect this CSG with another CSG
  70091. * @param csg The CSG to intersect against this CSG
  70092. * @returns A new CSG
  70093. */
  70094. intersect(csg: CSG): CSG;
  70095. /**
  70096. * Intersects this CSG with another CSG in place
  70097. * @param csg The CSG to intersect against this CSG
  70098. */
  70099. intersectInPlace(csg: CSG): void;
  70100. /**
  70101. * Return a new CSG solid with solid and empty space switched. This solid is
  70102. * not modified.
  70103. * @returns A new CSG solid with solid and empty space switched
  70104. */
  70105. inverse(): CSG;
  70106. /**
  70107. * Inverses the CSG in place
  70108. */
  70109. inverseInPlace(): void;
  70110. /**
  70111. * This is used to keep meshes transformations so they can be restored
  70112. * when we build back a Babylon Mesh
  70113. * NB : All CSG operations are performed in world coordinates
  70114. * @param csg The CSG to copy the transform attributes from
  70115. * @returns This CSG
  70116. */
  70117. copyTransformAttributes(csg: CSG): CSG;
  70118. /**
  70119. * Build Raw mesh from CSG
  70120. * Coordinates here are in world space
  70121. * @param name The name of the mesh geometry
  70122. * @param scene The Scene
  70123. * @param keepSubMeshes Specifies if the submeshes should be kept
  70124. * @returns A new Mesh
  70125. */
  70126. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70127. /**
  70128. * Build Mesh from CSG taking material and transforms into account
  70129. * @param name The name of the Mesh
  70130. * @param material The material of the Mesh
  70131. * @param scene The Scene
  70132. * @param keepSubMeshes Specifies if submeshes should be kept
  70133. * @returns The new Mesh
  70134. */
  70135. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  70136. }
  70137. }
  70138. declare module "babylonjs/Meshes/trailMesh" {
  70139. import { Mesh } from "babylonjs/Meshes/mesh";
  70140. import { Scene } from "babylonjs/scene";
  70141. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70142. /**
  70143. * Class used to create a trail following a mesh
  70144. */
  70145. export class TrailMesh extends Mesh {
  70146. private _generator;
  70147. private _autoStart;
  70148. private _running;
  70149. private _diameter;
  70150. private _length;
  70151. private _sectionPolygonPointsCount;
  70152. private _sectionVectors;
  70153. private _sectionNormalVectors;
  70154. private _beforeRenderObserver;
  70155. /**
  70156. * @constructor
  70157. * @param name The value used by scene.getMeshByName() to do a lookup.
  70158. * @param generator The mesh or transform node to generate a trail.
  70159. * @param scene The scene to add this mesh to.
  70160. * @param diameter Diameter of trailing mesh. Default is 1.
  70161. * @param length Length of trailing mesh. Default is 60.
  70162. * @param autoStart Automatically start trailing mesh. Default true.
  70163. */
  70164. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  70165. /**
  70166. * "TrailMesh"
  70167. * @returns "TrailMesh"
  70168. */
  70169. getClassName(): string;
  70170. private _createMesh;
  70171. /**
  70172. * Start trailing mesh.
  70173. */
  70174. start(): void;
  70175. /**
  70176. * Stop trailing mesh.
  70177. */
  70178. stop(): void;
  70179. /**
  70180. * Update trailing mesh geometry.
  70181. */
  70182. update(): void;
  70183. /**
  70184. * Returns a new TrailMesh object.
  70185. * @param name is a string, the name given to the new mesh
  70186. * @param newGenerator use new generator object for cloned trail mesh
  70187. * @returns a new mesh
  70188. */
  70189. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  70190. /**
  70191. * Serializes this trail mesh
  70192. * @param serializationObject object to write serialization to
  70193. */
  70194. serialize(serializationObject: any): void;
  70195. /**
  70196. * Parses a serialized trail mesh
  70197. * @param parsedMesh the serialized mesh
  70198. * @param scene the scene to create the trail mesh in
  70199. * @returns the created trail mesh
  70200. */
  70201. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  70202. }
  70203. }
  70204. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  70205. import { Nullable } from "babylonjs/types";
  70206. import { Scene } from "babylonjs/scene";
  70207. import { Vector4 } from "babylonjs/Maths/math.vector";
  70208. import { Color4 } from "babylonjs/Maths/math.color";
  70209. import { Mesh } from "babylonjs/Meshes/mesh";
  70210. /**
  70211. * Class containing static functions to help procedurally build meshes
  70212. */
  70213. export class TiledBoxBuilder {
  70214. /**
  70215. * Creates a box mesh
  70216. * 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)
  70217. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70221. * @param name defines the name of the mesh
  70222. * @param options defines the options used to create the mesh
  70223. * @param scene defines the hosting scene
  70224. * @returns the box mesh
  70225. */
  70226. static CreateTiledBox(name: string, options: {
  70227. pattern?: number;
  70228. width?: number;
  70229. height?: number;
  70230. depth?: number;
  70231. tileSize?: number;
  70232. tileWidth?: number;
  70233. tileHeight?: number;
  70234. alignHorizontal?: number;
  70235. alignVertical?: number;
  70236. faceUV?: Vector4[];
  70237. faceColors?: Color4[];
  70238. sideOrientation?: number;
  70239. updatable?: boolean;
  70240. }, scene?: Nullable<Scene>): Mesh;
  70241. }
  70242. }
  70243. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  70244. import { Vector4 } from "babylonjs/Maths/math.vector";
  70245. import { Mesh } from "babylonjs/Meshes/mesh";
  70246. /**
  70247. * Class containing static functions to help procedurally build meshes
  70248. */
  70249. export class TorusKnotBuilder {
  70250. /**
  70251. * Creates a torus knot mesh
  70252. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70253. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70254. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70255. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70259. * @param name defines the name of the mesh
  70260. * @param options defines the options used to create the mesh
  70261. * @param scene defines the hosting scene
  70262. * @returns the torus knot mesh
  70263. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70264. */
  70265. static CreateTorusKnot(name: string, options: {
  70266. radius?: number;
  70267. tube?: number;
  70268. radialSegments?: number;
  70269. tubularSegments?: number;
  70270. p?: number;
  70271. q?: number;
  70272. updatable?: boolean;
  70273. sideOrientation?: number;
  70274. frontUVs?: Vector4;
  70275. backUVs?: Vector4;
  70276. }, scene: any): Mesh;
  70277. }
  70278. }
  70279. declare module "babylonjs/Meshes/polygonMesh" {
  70280. import { Scene } from "babylonjs/scene";
  70281. import { Vector2 } from "babylonjs/Maths/math.vector";
  70282. import { Mesh } from "babylonjs/Meshes/mesh";
  70283. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  70284. import { Path2 } from "babylonjs/Maths/math.path";
  70285. /**
  70286. * Polygon
  70287. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  70288. */
  70289. export class Polygon {
  70290. /**
  70291. * Creates a rectangle
  70292. * @param xmin bottom X coord
  70293. * @param ymin bottom Y coord
  70294. * @param xmax top X coord
  70295. * @param ymax top Y coord
  70296. * @returns points that make the resulting rectation
  70297. */
  70298. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  70299. /**
  70300. * Creates a circle
  70301. * @param radius radius of circle
  70302. * @param cx scale in x
  70303. * @param cy scale in y
  70304. * @param numberOfSides number of sides that make up the circle
  70305. * @returns points that make the resulting circle
  70306. */
  70307. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  70308. /**
  70309. * Creates a polygon from input string
  70310. * @param input Input polygon data
  70311. * @returns the parsed points
  70312. */
  70313. static Parse(input: string): Vector2[];
  70314. /**
  70315. * Starts building a polygon from x and y coordinates
  70316. * @param x x coordinate
  70317. * @param y y coordinate
  70318. * @returns the started path2
  70319. */
  70320. static StartingAt(x: number, y: number): Path2;
  70321. }
  70322. /**
  70323. * Builds a polygon
  70324. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  70325. */
  70326. export class PolygonMeshBuilder {
  70327. private _points;
  70328. private _outlinepoints;
  70329. private _holes;
  70330. private _name;
  70331. private _scene;
  70332. private _epoints;
  70333. private _eholes;
  70334. private _addToepoint;
  70335. /**
  70336. * Babylon reference to the earcut plugin.
  70337. */
  70338. bjsEarcut: any;
  70339. /**
  70340. * Creates a PolygonMeshBuilder
  70341. * @param name name of the builder
  70342. * @param contours Path of the polygon
  70343. * @param scene scene to add to when creating the mesh
  70344. * @param earcutInjection can be used to inject your own earcut reference
  70345. */
  70346. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  70347. /**
  70348. * Adds a whole within the polygon
  70349. * @param hole Array of points defining the hole
  70350. * @returns this
  70351. */
  70352. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70353. /**
  70354. * Creates the polygon
  70355. * @param updatable If the mesh should be updatable
  70356. * @param depth The depth of the mesh created
  70357. * @returns the created mesh
  70358. */
  70359. build(updatable?: boolean, depth?: number): Mesh;
  70360. /**
  70361. * Creates the polygon
  70362. * @param depth The depth of the mesh created
  70363. * @returns the created VertexData
  70364. */
  70365. buildVertexData(depth?: number): VertexData;
  70366. /**
  70367. * Adds a side to the polygon
  70368. * @param positions points that make the polygon
  70369. * @param normals normals of the polygon
  70370. * @param uvs uvs of the polygon
  70371. * @param indices indices of the polygon
  70372. * @param bounds bounds of the polygon
  70373. * @param points points of the polygon
  70374. * @param depth depth of the polygon
  70375. * @param flip flip of the polygon
  70376. */
  70377. private addSide;
  70378. }
  70379. }
  70380. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70381. import { Scene } from "babylonjs/scene";
  70382. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70383. import { Color4 } from "babylonjs/Maths/math.color";
  70384. import { Mesh } from "babylonjs/Meshes/mesh";
  70385. import { Nullable } from "babylonjs/types";
  70386. /**
  70387. * Class containing static functions to help procedurally build meshes
  70388. */
  70389. export class PolygonBuilder {
  70390. /**
  70391. * Creates a polygon mesh
  70392. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70393. * * 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
  70394. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70396. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70397. * * Remember you can only change the shape positions, not their number when updating a polygon
  70398. * @param name defines the name of the mesh
  70399. * @param options defines the options used to create the mesh
  70400. * @param scene defines the hosting scene
  70401. * @param earcutInjection can be used to inject your own earcut reference
  70402. * @returns the polygon mesh
  70403. */
  70404. static CreatePolygon(name: string, options: {
  70405. shape: Vector3[];
  70406. holes?: Vector3[][];
  70407. depth?: number;
  70408. faceUV?: Vector4[];
  70409. faceColors?: Color4[];
  70410. updatable?: boolean;
  70411. sideOrientation?: number;
  70412. frontUVs?: Vector4;
  70413. backUVs?: Vector4;
  70414. wrap?: boolean;
  70415. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70416. /**
  70417. * Creates an extruded polygon mesh, with depth in the Y direction.
  70418. * * 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)
  70419. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70420. * @param name defines the name of the mesh
  70421. * @param options defines the options used to create the mesh
  70422. * @param scene defines the hosting scene
  70423. * @param earcutInjection can be used to inject your own earcut reference
  70424. * @returns the polygon mesh
  70425. */
  70426. static ExtrudePolygon(name: string, options: {
  70427. shape: Vector3[];
  70428. holes?: Vector3[][];
  70429. depth?: number;
  70430. faceUV?: Vector4[];
  70431. faceColors?: Color4[];
  70432. updatable?: boolean;
  70433. sideOrientation?: number;
  70434. frontUVs?: Vector4;
  70435. backUVs?: Vector4;
  70436. wrap?: boolean;
  70437. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70438. }
  70439. }
  70440. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70441. import { Scene } from "babylonjs/scene";
  70442. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70443. import { Mesh } from "babylonjs/Meshes/mesh";
  70444. import { Nullable } from "babylonjs/types";
  70445. /**
  70446. * Class containing static functions to help procedurally build meshes
  70447. */
  70448. export class LatheBuilder {
  70449. /**
  70450. * Creates lathe mesh.
  70451. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70452. * * 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
  70453. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70454. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70455. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70456. * * 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
  70457. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70458. * * 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
  70459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70463. * @param name defines the name of the mesh
  70464. * @param options defines the options used to create the mesh
  70465. * @param scene defines the hosting scene
  70466. * @returns the lathe mesh
  70467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70468. */
  70469. static CreateLathe(name: string, options: {
  70470. shape: Vector3[];
  70471. radius?: number;
  70472. tessellation?: number;
  70473. clip?: number;
  70474. arc?: number;
  70475. closed?: boolean;
  70476. updatable?: boolean;
  70477. sideOrientation?: number;
  70478. frontUVs?: Vector4;
  70479. backUVs?: Vector4;
  70480. cap?: number;
  70481. invertUV?: boolean;
  70482. }, scene?: Nullable<Scene>): Mesh;
  70483. }
  70484. }
  70485. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70486. import { Nullable } from "babylonjs/types";
  70487. import { Scene } from "babylonjs/scene";
  70488. import { Vector4 } from "babylonjs/Maths/math.vector";
  70489. import { Mesh } from "babylonjs/Meshes/mesh";
  70490. /**
  70491. * Class containing static functions to help procedurally build meshes
  70492. */
  70493. export class TiledPlaneBuilder {
  70494. /**
  70495. * Creates a tiled plane mesh
  70496. * * The parameter `pattern` will, depending on value, do nothing or
  70497. * * * flip (reflect about central vertical) alternate tiles across and up
  70498. * * * flip every tile on alternate rows
  70499. * * * rotate (180 degs) alternate tiles across and up
  70500. * * * rotate every tile on alternate rows
  70501. * * * flip and rotate alternate tiles across and up
  70502. * * * flip and rotate every tile on alternate rows
  70503. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70504. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70507. * * 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)
  70508. * * 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)
  70509. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70510. * @param name defines the name of the mesh
  70511. * @param options defines the options used to create the mesh
  70512. * @param scene defines the hosting scene
  70513. * @returns the box mesh
  70514. */
  70515. static CreateTiledPlane(name: string, options: {
  70516. pattern?: number;
  70517. tileSize?: number;
  70518. tileWidth?: number;
  70519. tileHeight?: number;
  70520. size?: number;
  70521. width?: number;
  70522. height?: number;
  70523. alignHorizontal?: number;
  70524. alignVertical?: number;
  70525. sideOrientation?: number;
  70526. frontUVs?: Vector4;
  70527. backUVs?: Vector4;
  70528. updatable?: boolean;
  70529. }, scene?: Nullable<Scene>): Mesh;
  70530. }
  70531. }
  70532. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70533. import { Nullable } from "babylonjs/types";
  70534. import { Scene } from "babylonjs/scene";
  70535. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70536. import { Mesh } from "babylonjs/Meshes/mesh";
  70537. /**
  70538. * Class containing static functions to help procedurally build meshes
  70539. */
  70540. export class TubeBuilder {
  70541. /**
  70542. * Creates a tube mesh.
  70543. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70544. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70545. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70546. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70547. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70548. * * 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)
  70549. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70550. * * 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
  70551. * * 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
  70552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70554. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70556. * @param name defines the name of the mesh
  70557. * @param options defines the options used to create the mesh
  70558. * @param scene defines the hosting scene
  70559. * @returns the tube mesh
  70560. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70561. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70562. */
  70563. static CreateTube(name: string, options: {
  70564. path: Vector3[];
  70565. radius?: number;
  70566. tessellation?: number;
  70567. radiusFunction?: {
  70568. (i: number, distance: number): number;
  70569. };
  70570. cap?: number;
  70571. arc?: number;
  70572. updatable?: boolean;
  70573. sideOrientation?: number;
  70574. frontUVs?: Vector4;
  70575. backUVs?: Vector4;
  70576. instance?: Mesh;
  70577. invertUV?: boolean;
  70578. }, scene?: Nullable<Scene>): Mesh;
  70579. }
  70580. }
  70581. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70582. import { Scene } from "babylonjs/scene";
  70583. import { Vector4 } from "babylonjs/Maths/math.vector";
  70584. import { Mesh } from "babylonjs/Meshes/mesh";
  70585. import { Nullable } from "babylonjs/types";
  70586. /**
  70587. * Class containing static functions to help procedurally build meshes
  70588. */
  70589. export class IcoSphereBuilder {
  70590. /**
  70591. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70592. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70593. * * 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`)
  70594. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70595. * * 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
  70596. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70597. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70598. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70599. * @param name defines the name of the mesh
  70600. * @param options defines the options used to create the mesh
  70601. * @param scene defines the hosting scene
  70602. * @returns the icosahedron mesh
  70603. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70604. */
  70605. static CreateIcoSphere(name: string, options: {
  70606. radius?: number;
  70607. radiusX?: number;
  70608. radiusY?: number;
  70609. radiusZ?: number;
  70610. flat?: boolean;
  70611. subdivisions?: number;
  70612. sideOrientation?: number;
  70613. frontUVs?: Vector4;
  70614. backUVs?: Vector4;
  70615. updatable?: boolean;
  70616. }, scene?: Nullable<Scene>): Mesh;
  70617. }
  70618. }
  70619. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70620. import { Vector3 } from "babylonjs/Maths/math.vector";
  70621. import { Mesh } from "babylonjs/Meshes/mesh";
  70622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70623. /**
  70624. * Class containing static functions to help procedurally build meshes
  70625. */
  70626. export class DecalBuilder {
  70627. /**
  70628. * Creates a decal mesh.
  70629. * 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
  70630. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70631. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70632. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70633. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70634. * @param name defines the name of the mesh
  70635. * @param sourceMesh defines the mesh where the decal must be applied
  70636. * @param options defines the options used to create the mesh
  70637. * @param scene defines the hosting scene
  70638. * @returns the decal mesh
  70639. * @see https://doc.babylonjs.com/how_to/decals
  70640. */
  70641. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70642. position?: Vector3;
  70643. normal?: Vector3;
  70644. size?: Vector3;
  70645. angle?: number;
  70646. }): Mesh;
  70647. }
  70648. }
  70649. declare module "babylonjs/Meshes/meshBuilder" {
  70650. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70651. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70652. import { Nullable } from "babylonjs/types";
  70653. import { Scene } from "babylonjs/scene";
  70654. import { Mesh } from "babylonjs/Meshes/mesh";
  70655. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70656. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70658. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70659. import { Plane } from "babylonjs/Maths/math.plane";
  70660. /**
  70661. * Class containing static functions to help procedurally build meshes
  70662. */
  70663. export class MeshBuilder {
  70664. /**
  70665. * Creates a box mesh
  70666. * * The parameter `size` sets the size (float) of each box side (default 1)
  70667. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70668. * * 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)
  70669. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70673. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70674. * @param name defines the name of the mesh
  70675. * @param options defines the options used to create the mesh
  70676. * @param scene defines the hosting scene
  70677. * @returns the box mesh
  70678. */
  70679. static CreateBox(name: string, options: {
  70680. size?: number;
  70681. width?: number;
  70682. height?: number;
  70683. depth?: number;
  70684. faceUV?: Vector4[];
  70685. faceColors?: Color4[];
  70686. sideOrientation?: number;
  70687. frontUVs?: Vector4;
  70688. backUVs?: Vector4;
  70689. wrap?: boolean;
  70690. topBaseAt?: number;
  70691. bottomBaseAt?: number;
  70692. updatable?: boolean;
  70693. }, scene?: Nullable<Scene>): Mesh;
  70694. /**
  70695. * Creates a tiled box mesh
  70696. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70698. * @param name defines the name of the mesh
  70699. * @param options defines the options used to create the mesh
  70700. * @param scene defines the hosting scene
  70701. * @returns the tiled box mesh
  70702. */
  70703. static CreateTiledBox(name: string, options: {
  70704. pattern?: number;
  70705. size?: number;
  70706. width?: number;
  70707. height?: number;
  70708. depth: number;
  70709. tileSize?: number;
  70710. tileWidth?: number;
  70711. tileHeight?: number;
  70712. faceUV?: Vector4[];
  70713. faceColors?: Color4[];
  70714. alignHorizontal?: number;
  70715. alignVertical?: number;
  70716. sideOrientation?: number;
  70717. updatable?: boolean;
  70718. }, scene?: Nullable<Scene>): Mesh;
  70719. /**
  70720. * Creates a sphere mesh
  70721. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70722. * * 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`)
  70723. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70724. * * 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
  70725. * * 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)
  70726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70727. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70729. * @param name defines the name of the mesh
  70730. * @param options defines the options used to create the mesh
  70731. * @param scene defines the hosting scene
  70732. * @returns the sphere mesh
  70733. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70734. */
  70735. static CreateSphere(name: string, options: {
  70736. segments?: number;
  70737. diameter?: number;
  70738. diameterX?: number;
  70739. diameterY?: number;
  70740. diameterZ?: number;
  70741. arc?: number;
  70742. slice?: number;
  70743. sideOrientation?: number;
  70744. frontUVs?: Vector4;
  70745. backUVs?: Vector4;
  70746. updatable?: boolean;
  70747. }, scene?: Nullable<Scene>): Mesh;
  70748. /**
  70749. * Creates a plane polygonal mesh. By default, this is a disc
  70750. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70751. * * 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
  70752. * * 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
  70753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70756. * @param name defines the name of the mesh
  70757. * @param options defines the options used to create the mesh
  70758. * @param scene defines the hosting scene
  70759. * @returns the plane polygonal mesh
  70760. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70761. */
  70762. static CreateDisc(name: string, options: {
  70763. radius?: number;
  70764. tessellation?: number;
  70765. arc?: number;
  70766. updatable?: boolean;
  70767. sideOrientation?: number;
  70768. frontUVs?: Vector4;
  70769. backUVs?: Vector4;
  70770. }, scene?: Nullable<Scene>): Mesh;
  70771. /**
  70772. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70773. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70774. * * 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`)
  70775. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70776. * * 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
  70777. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70778. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70779. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70780. * @param name defines the name of the mesh
  70781. * @param options defines the options used to create the mesh
  70782. * @param scene defines the hosting scene
  70783. * @returns the icosahedron mesh
  70784. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70785. */
  70786. static CreateIcoSphere(name: string, options: {
  70787. radius?: number;
  70788. radiusX?: number;
  70789. radiusY?: number;
  70790. radiusZ?: number;
  70791. flat?: boolean;
  70792. subdivisions?: number;
  70793. sideOrientation?: number;
  70794. frontUVs?: Vector4;
  70795. backUVs?: Vector4;
  70796. updatable?: boolean;
  70797. }, scene?: Nullable<Scene>): Mesh;
  70798. /**
  70799. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70800. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70801. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70802. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70803. * * 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
  70804. * * 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
  70805. * * 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
  70806. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70807. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70808. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70809. * * 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
  70810. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70811. * * 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
  70812. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70814. * @param name defines the name of the mesh
  70815. * @param options defines the options used to create the mesh
  70816. * @param scene defines the hosting scene
  70817. * @returns the ribbon mesh
  70818. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70820. */
  70821. static CreateRibbon(name: string, options: {
  70822. pathArray: Vector3[][];
  70823. closeArray?: boolean;
  70824. closePath?: boolean;
  70825. offset?: number;
  70826. updatable?: boolean;
  70827. sideOrientation?: number;
  70828. frontUVs?: Vector4;
  70829. backUVs?: Vector4;
  70830. instance?: Mesh;
  70831. invertUV?: boolean;
  70832. uvs?: Vector2[];
  70833. colors?: Color4[];
  70834. }, scene?: Nullable<Scene>): Mesh;
  70835. /**
  70836. * Creates a cylinder or a cone mesh
  70837. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70838. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70839. * * 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.
  70840. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70841. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70842. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70843. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70844. * * 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).
  70845. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70846. * * 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).
  70847. * * 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
  70848. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70849. * * 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
  70850. * * 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.
  70851. * * If `enclose` is false, a ring surface is one element.
  70852. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70853. * * 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
  70854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70857. * @param name defines the name of the mesh
  70858. * @param options defines the options used to create the mesh
  70859. * @param scene defines the hosting scene
  70860. * @returns the cylinder mesh
  70861. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70862. */
  70863. static CreateCylinder(name: string, options: {
  70864. height?: number;
  70865. diameterTop?: number;
  70866. diameterBottom?: number;
  70867. diameter?: number;
  70868. tessellation?: number;
  70869. subdivisions?: number;
  70870. arc?: number;
  70871. faceColors?: Color4[];
  70872. faceUV?: Vector4[];
  70873. updatable?: boolean;
  70874. hasRings?: boolean;
  70875. enclose?: boolean;
  70876. cap?: number;
  70877. sideOrientation?: number;
  70878. frontUVs?: Vector4;
  70879. backUVs?: Vector4;
  70880. }, scene?: Nullable<Scene>): Mesh;
  70881. /**
  70882. * Creates a torus mesh
  70883. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70884. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70885. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70889. * @param name defines the name of the mesh
  70890. * @param options defines the options used to create the mesh
  70891. * @param scene defines the hosting scene
  70892. * @returns the torus mesh
  70893. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70894. */
  70895. static CreateTorus(name: string, options: {
  70896. diameter?: number;
  70897. thickness?: number;
  70898. tessellation?: number;
  70899. updatable?: boolean;
  70900. sideOrientation?: number;
  70901. frontUVs?: Vector4;
  70902. backUVs?: Vector4;
  70903. }, scene?: Nullable<Scene>): Mesh;
  70904. /**
  70905. * Creates a torus knot mesh
  70906. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70907. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70908. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70909. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70911. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70913. * @param name defines the name of the mesh
  70914. * @param options defines the options used to create the mesh
  70915. * @param scene defines the hosting scene
  70916. * @returns the torus knot mesh
  70917. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70918. */
  70919. static CreateTorusKnot(name: string, options: {
  70920. radius?: number;
  70921. tube?: number;
  70922. radialSegments?: number;
  70923. tubularSegments?: number;
  70924. p?: number;
  70925. q?: number;
  70926. updatable?: boolean;
  70927. sideOrientation?: number;
  70928. frontUVs?: Vector4;
  70929. backUVs?: Vector4;
  70930. }, scene?: Nullable<Scene>): Mesh;
  70931. /**
  70932. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70933. * * 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
  70934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70935. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70936. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70937. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70939. * * 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
  70940. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70943. * @param name defines the name of the new line system
  70944. * @param options defines the options used to create the line system
  70945. * @param scene defines the hosting scene
  70946. * @returns a new line system mesh
  70947. */
  70948. static CreateLineSystem(name: string, options: {
  70949. lines: Vector3[][];
  70950. updatable?: boolean;
  70951. instance?: Nullable<LinesMesh>;
  70952. colors?: Nullable<Color4[][]>;
  70953. useVertexAlpha?: boolean;
  70954. }, scene: Nullable<Scene>): LinesMesh;
  70955. /**
  70956. * Creates a line mesh
  70957. * 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
  70958. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70959. * * The parameter `points` is an array successive Vector3
  70960. * * 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
  70961. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70962. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70963. * * When updating an instance, remember that only point positions can change, not the number of points
  70964. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70965. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70966. * @param name defines the name of the new line system
  70967. * @param options defines the options used to create the line system
  70968. * @param scene defines the hosting scene
  70969. * @returns a new line mesh
  70970. */
  70971. static CreateLines(name: string, options: {
  70972. points: Vector3[];
  70973. updatable?: boolean;
  70974. instance?: Nullable<LinesMesh>;
  70975. colors?: Color4[];
  70976. useVertexAlpha?: boolean;
  70977. }, scene?: Nullable<Scene>): LinesMesh;
  70978. /**
  70979. * Creates a dashed line mesh
  70980. * * 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
  70981. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70982. * * The parameter `points` is an array successive Vector3
  70983. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70984. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70985. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70986. * * 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
  70987. * * When updating an instance, remember that only point positions can change, not the number of points
  70988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70989. * @param name defines the name of the mesh
  70990. * @param options defines the options used to create the mesh
  70991. * @param scene defines the hosting scene
  70992. * @returns the dashed line mesh
  70993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70994. */
  70995. static CreateDashedLines(name: string, options: {
  70996. points: Vector3[];
  70997. dashSize?: number;
  70998. gapSize?: number;
  70999. dashNb?: number;
  71000. updatable?: boolean;
  71001. instance?: LinesMesh;
  71002. }, scene?: Nullable<Scene>): LinesMesh;
  71003. /**
  71004. * 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.
  71005. * * 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.
  71006. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71007. * * 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.
  71008. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  71009. * * 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
  71010. * * 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
  71011. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  71012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71014. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  71015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71016. * @param name defines the name of the mesh
  71017. * @param options defines the options used to create the mesh
  71018. * @param scene defines the hosting scene
  71019. * @returns the extruded shape mesh
  71020. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71021. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71022. */
  71023. static ExtrudeShape(name: string, options: {
  71024. shape: Vector3[];
  71025. path: Vector3[];
  71026. scale?: number;
  71027. rotation?: number;
  71028. cap?: number;
  71029. updatable?: boolean;
  71030. sideOrientation?: number;
  71031. frontUVs?: Vector4;
  71032. backUVs?: Vector4;
  71033. instance?: Mesh;
  71034. invertUV?: boolean;
  71035. }, scene?: Nullable<Scene>): Mesh;
  71036. /**
  71037. * Creates an custom extruded shape mesh.
  71038. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  71039. * * 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.
  71040. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  71041. * * 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
  71042. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  71043. * * 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
  71044. * * It must returns a float value that will be the scale value applied to the shape on each path point
  71045. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  71046. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  71047. * * 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
  71048. * * 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
  71049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  71050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71051. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71054. * @param name defines the name of the mesh
  71055. * @param options defines the options used to create the mesh
  71056. * @param scene defines the hosting scene
  71057. * @returns the custom extruded shape mesh
  71058. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  71059. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71060. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  71061. */
  71062. static ExtrudeShapeCustom(name: string, options: {
  71063. shape: Vector3[];
  71064. path: Vector3[];
  71065. scaleFunction?: any;
  71066. rotationFunction?: any;
  71067. ribbonCloseArray?: boolean;
  71068. ribbonClosePath?: boolean;
  71069. cap?: number;
  71070. updatable?: boolean;
  71071. sideOrientation?: number;
  71072. frontUVs?: Vector4;
  71073. backUVs?: Vector4;
  71074. instance?: Mesh;
  71075. invertUV?: boolean;
  71076. }, scene?: Nullable<Scene>): Mesh;
  71077. /**
  71078. * Creates lathe mesh.
  71079. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  71080. * * 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
  71081. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  71082. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  71083. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  71084. * * 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
  71085. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  71086. * * 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
  71087. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71088. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71089. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71091. * @param name defines the name of the mesh
  71092. * @param options defines the options used to create the mesh
  71093. * @param scene defines the hosting scene
  71094. * @returns the lathe mesh
  71095. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  71096. */
  71097. static CreateLathe(name: string, options: {
  71098. shape: Vector3[];
  71099. radius?: number;
  71100. tessellation?: number;
  71101. clip?: number;
  71102. arc?: number;
  71103. closed?: boolean;
  71104. updatable?: boolean;
  71105. sideOrientation?: number;
  71106. frontUVs?: Vector4;
  71107. backUVs?: Vector4;
  71108. cap?: number;
  71109. invertUV?: boolean;
  71110. }, scene?: Nullable<Scene>): Mesh;
  71111. /**
  71112. * Creates a tiled plane mesh
  71113. * * You can set a limited pattern arrangement with the tiles
  71114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71117. * @param name defines the name of the mesh
  71118. * @param options defines the options used to create the mesh
  71119. * @param scene defines the hosting scene
  71120. * @returns the plane mesh
  71121. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71122. */
  71123. static CreateTiledPlane(name: string, options: {
  71124. pattern?: number;
  71125. tileSize?: number;
  71126. tileWidth?: number;
  71127. tileHeight?: number;
  71128. size?: number;
  71129. width?: number;
  71130. height?: number;
  71131. alignHorizontal?: number;
  71132. alignVertical?: number;
  71133. sideOrientation?: number;
  71134. frontUVs?: Vector4;
  71135. backUVs?: Vector4;
  71136. updatable?: boolean;
  71137. }, scene?: Nullable<Scene>): Mesh;
  71138. /**
  71139. * Creates a plane mesh
  71140. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  71141. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  71142. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  71143. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71146. * @param name defines the name of the mesh
  71147. * @param options defines the options used to create the mesh
  71148. * @param scene defines the hosting scene
  71149. * @returns the plane mesh
  71150. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  71151. */
  71152. static CreatePlane(name: string, options: {
  71153. size?: number;
  71154. width?: number;
  71155. height?: number;
  71156. sideOrientation?: number;
  71157. frontUVs?: Vector4;
  71158. backUVs?: Vector4;
  71159. updatable?: boolean;
  71160. sourcePlane?: Plane;
  71161. }, scene?: Nullable<Scene>): Mesh;
  71162. /**
  71163. * Creates a ground mesh
  71164. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  71165. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  71166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71167. * @param name defines the name of the mesh
  71168. * @param options defines the options used to create the mesh
  71169. * @param scene defines the hosting scene
  71170. * @returns the ground mesh
  71171. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  71172. */
  71173. static CreateGround(name: string, options: {
  71174. width?: number;
  71175. height?: number;
  71176. subdivisions?: number;
  71177. subdivisionsX?: number;
  71178. subdivisionsY?: number;
  71179. updatable?: boolean;
  71180. }, scene?: Nullable<Scene>): Mesh;
  71181. /**
  71182. * Creates a tiled ground mesh
  71183. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  71184. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  71185. * * 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
  71186. * * 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
  71187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71188. * @param name defines the name of the mesh
  71189. * @param options defines the options used to create the mesh
  71190. * @param scene defines the hosting scene
  71191. * @returns the tiled ground mesh
  71192. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  71193. */
  71194. static CreateTiledGround(name: string, options: {
  71195. xmin: number;
  71196. zmin: number;
  71197. xmax: number;
  71198. zmax: number;
  71199. subdivisions?: {
  71200. w: number;
  71201. h: number;
  71202. };
  71203. precision?: {
  71204. w: number;
  71205. h: number;
  71206. };
  71207. updatable?: boolean;
  71208. }, scene?: Nullable<Scene>): Mesh;
  71209. /**
  71210. * Creates a ground mesh from a height map
  71211. * * The parameter `url` sets the URL of the height map image resource.
  71212. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  71213. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  71214. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  71215. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  71216. * * 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.
  71217. * * 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).
  71218. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  71219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  71220. * @param name defines the name of the mesh
  71221. * @param url defines the url to the height map
  71222. * @param options defines the options used to create the mesh
  71223. * @param scene defines the hosting scene
  71224. * @returns the ground mesh
  71225. * @see https://doc.babylonjs.com/babylon101/height_map
  71226. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  71227. */
  71228. static CreateGroundFromHeightMap(name: string, url: string, options: {
  71229. width?: number;
  71230. height?: number;
  71231. subdivisions?: number;
  71232. minHeight?: number;
  71233. maxHeight?: number;
  71234. colorFilter?: Color3;
  71235. alphaFilter?: number;
  71236. updatable?: boolean;
  71237. onReady?: (mesh: GroundMesh) => void;
  71238. }, scene?: Nullable<Scene>): GroundMesh;
  71239. /**
  71240. * Creates a polygon mesh
  71241. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  71242. * * 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
  71243. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  71244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71245. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  71246. * * Remember you can only change the shape positions, not their number when updating a polygon
  71247. * @param name defines the name of the mesh
  71248. * @param options defines the options used to create the mesh
  71249. * @param scene defines the hosting scene
  71250. * @param earcutInjection can be used to inject your own earcut reference
  71251. * @returns the polygon mesh
  71252. */
  71253. static CreatePolygon(name: string, options: {
  71254. shape: Vector3[];
  71255. holes?: Vector3[][];
  71256. depth?: number;
  71257. faceUV?: Vector4[];
  71258. faceColors?: Color4[];
  71259. updatable?: boolean;
  71260. sideOrientation?: number;
  71261. frontUVs?: Vector4;
  71262. backUVs?: Vector4;
  71263. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71264. /**
  71265. * Creates an extruded polygon mesh, with depth in the Y direction.
  71266. * * 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)
  71267. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  71268. * @param name defines the name of the mesh
  71269. * @param options defines the options used to create the mesh
  71270. * @param scene defines the hosting scene
  71271. * @param earcutInjection can be used to inject your own earcut reference
  71272. * @returns the polygon mesh
  71273. */
  71274. static ExtrudePolygon(name: string, options: {
  71275. shape: Vector3[];
  71276. holes?: Vector3[][];
  71277. depth?: number;
  71278. faceUV?: Vector4[];
  71279. faceColors?: Color4[];
  71280. updatable?: boolean;
  71281. sideOrientation?: number;
  71282. frontUVs?: Vector4;
  71283. backUVs?: Vector4;
  71284. wrap?: boolean;
  71285. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  71286. /**
  71287. * Creates a tube mesh.
  71288. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  71289. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  71290. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  71291. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  71292. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  71293. * * 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)
  71294. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  71295. * * 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
  71296. * * 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
  71297. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71298. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71299. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  71300. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71301. * @param name defines the name of the mesh
  71302. * @param options defines the options used to create the mesh
  71303. * @param scene defines the hosting scene
  71304. * @returns the tube mesh
  71305. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  71306. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  71307. */
  71308. static CreateTube(name: string, options: {
  71309. path: Vector3[];
  71310. radius?: number;
  71311. tessellation?: number;
  71312. radiusFunction?: {
  71313. (i: number, distance: number): number;
  71314. };
  71315. cap?: number;
  71316. arc?: number;
  71317. updatable?: boolean;
  71318. sideOrientation?: number;
  71319. frontUVs?: Vector4;
  71320. backUVs?: Vector4;
  71321. instance?: Mesh;
  71322. invertUV?: boolean;
  71323. }, scene?: Nullable<Scene>): Mesh;
  71324. /**
  71325. * Creates a polyhedron mesh
  71326. * * 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
  71327. * * The parameter `size` (positive float, default 1) sets the polygon size
  71328. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  71329. * * 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`
  71330. * * 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
  71331. * * 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)`)
  71332. * * 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
  71333. * * 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
  71334. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  71335. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  71336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  71337. * @param name defines the name of the mesh
  71338. * @param options defines the options used to create the mesh
  71339. * @param scene defines the hosting scene
  71340. * @returns the polyhedron mesh
  71341. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  71342. */
  71343. static CreatePolyhedron(name: string, options: {
  71344. type?: number;
  71345. size?: number;
  71346. sizeX?: number;
  71347. sizeY?: number;
  71348. sizeZ?: number;
  71349. custom?: any;
  71350. faceUV?: Vector4[];
  71351. faceColors?: Color4[];
  71352. flat?: boolean;
  71353. updatable?: boolean;
  71354. sideOrientation?: number;
  71355. frontUVs?: Vector4;
  71356. backUVs?: Vector4;
  71357. }, scene?: Nullable<Scene>): Mesh;
  71358. /**
  71359. * Creates a decal mesh.
  71360. * 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
  71361. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71362. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71363. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71364. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71365. * @param name defines the name of the mesh
  71366. * @param sourceMesh defines the mesh where the decal must be applied
  71367. * @param options defines the options used to create the mesh
  71368. * @param scene defines the hosting scene
  71369. * @returns the decal mesh
  71370. * @see https://doc.babylonjs.com/how_to/decals
  71371. */
  71372. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71373. position?: Vector3;
  71374. normal?: Vector3;
  71375. size?: Vector3;
  71376. angle?: number;
  71377. }): Mesh;
  71378. /**
  71379. * Creates a Capsule Mesh
  71380. * @param name defines the name of the mesh.
  71381. * @param options the constructors options used to shape the mesh.
  71382. * @param scene defines the scene the mesh is scoped to.
  71383. * @returns the capsule mesh
  71384. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71385. */
  71386. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71387. }
  71388. }
  71389. declare module "babylonjs/Meshes/meshSimplification" {
  71390. import { Mesh } from "babylonjs/Meshes/mesh";
  71391. /**
  71392. * A simplifier interface for future simplification implementations
  71393. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71394. */
  71395. export interface ISimplifier {
  71396. /**
  71397. * Simplification of a given mesh according to the given settings.
  71398. * Since this requires computation, it is assumed that the function runs async.
  71399. * @param settings The settings of the simplification, including quality and distance
  71400. * @param successCallback A callback that will be called after the mesh was simplified.
  71401. * @param errorCallback in case of an error, this callback will be called. optional.
  71402. */
  71403. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71404. }
  71405. /**
  71406. * Expected simplification settings.
  71407. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71408. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71409. */
  71410. export interface ISimplificationSettings {
  71411. /**
  71412. * Gets or sets the expected quality
  71413. */
  71414. quality: number;
  71415. /**
  71416. * Gets or sets the distance when this optimized version should be used
  71417. */
  71418. distance: number;
  71419. /**
  71420. * Gets an already optimized mesh
  71421. */
  71422. optimizeMesh?: boolean;
  71423. }
  71424. /**
  71425. * Class used to specify simplification options
  71426. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71427. */
  71428. export class SimplificationSettings implements ISimplificationSettings {
  71429. /** expected quality */
  71430. quality: number;
  71431. /** distance when this optimized version should be used */
  71432. distance: number;
  71433. /** already optimized mesh */
  71434. optimizeMesh?: boolean | undefined;
  71435. /**
  71436. * Creates a SimplificationSettings
  71437. * @param quality expected quality
  71438. * @param distance distance when this optimized version should be used
  71439. * @param optimizeMesh already optimized mesh
  71440. */
  71441. constructor(
  71442. /** expected quality */
  71443. quality: number,
  71444. /** distance when this optimized version should be used */
  71445. distance: number,
  71446. /** already optimized mesh */
  71447. optimizeMesh?: boolean | undefined);
  71448. }
  71449. /**
  71450. * Interface used to define a simplification task
  71451. */
  71452. export interface ISimplificationTask {
  71453. /**
  71454. * Array of settings
  71455. */
  71456. settings: Array<ISimplificationSettings>;
  71457. /**
  71458. * Simplification type
  71459. */
  71460. simplificationType: SimplificationType;
  71461. /**
  71462. * Mesh to simplify
  71463. */
  71464. mesh: Mesh;
  71465. /**
  71466. * Callback called on success
  71467. */
  71468. successCallback?: () => void;
  71469. /**
  71470. * Defines if parallel processing can be used
  71471. */
  71472. parallelProcessing: boolean;
  71473. }
  71474. /**
  71475. * Queue used to order the simplification tasks
  71476. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71477. */
  71478. export class SimplificationQueue {
  71479. private _simplificationArray;
  71480. /**
  71481. * Gets a boolean indicating that the process is still running
  71482. */
  71483. running: boolean;
  71484. /**
  71485. * Creates a new queue
  71486. */
  71487. constructor();
  71488. /**
  71489. * Adds a new simplification task
  71490. * @param task defines a task to add
  71491. */
  71492. addTask(task: ISimplificationTask): void;
  71493. /**
  71494. * Execute next task
  71495. */
  71496. executeNext(): void;
  71497. /**
  71498. * Execute a simplification task
  71499. * @param task defines the task to run
  71500. */
  71501. runSimplification(task: ISimplificationTask): void;
  71502. private getSimplifier;
  71503. }
  71504. /**
  71505. * The implemented types of simplification
  71506. * At the moment only Quadratic Error Decimation is implemented
  71507. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71508. */
  71509. export enum SimplificationType {
  71510. /** Quadratic error decimation */
  71511. QUADRATIC = 0
  71512. }
  71513. /**
  71514. * An implementation of the Quadratic Error simplification algorithm.
  71515. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71516. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71517. * @author RaananW
  71518. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71519. */
  71520. export class QuadraticErrorSimplification implements ISimplifier {
  71521. private _mesh;
  71522. private triangles;
  71523. private vertices;
  71524. private references;
  71525. private _reconstructedMesh;
  71526. /** Gets or sets the number pf sync interations */
  71527. syncIterations: number;
  71528. /** Gets or sets the aggressiveness of the simplifier */
  71529. aggressiveness: number;
  71530. /** Gets or sets the number of allowed iterations for decimation */
  71531. decimationIterations: number;
  71532. /** Gets or sets the espilon to use for bounding box computation */
  71533. boundingBoxEpsilon: number;
  71534. /**
  71535. * Creates a new QuadraticErrorSimplification
  71536. * @param _mesh defines the target mesh
  71537. */
  71538. constructor(_mesh: Mesh);
  71539. /**
  71540. * Simplification of a given mesh according to the given settings.
  71541. * Since this requires computation, it is assumed that the function runs async.
  71542. * @param settings The settings of the simplification, including quality and distance
  71543. * @param successCallback A callback that will be called after the mesh was simplified.
  71544. */
  71545. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71546. private runDecimation;
  71547. private initWithMesh;
  71548. private init;
  71549. private reconstructMesh;
  71550. private initDecimatedMesh;
  71551. private isFlipped;
  71552. private updateTriangles;
  71553. private identifyBorder;
  71554. private updateMesh;
  71555. private vertexError;
  71556. private calculateError;
  71557. }
  71558. }
  71559. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71560. import { Scene } from "babylonjs/scene";
  71561. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71562. import { ISceneComponent } from "babylonjs/sceneComponent";
  71563. module "babylonjs/scene" {
  71564. interface Scene {
  71565. /** @hidden (Backing field) */
  71566. _simplificationQueue: SimplificationQueue;
  71567. /**
  71568. * Gets or sets the simplification queue attached to the scene
  71569. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71570. */
  71571. simplificationQueue: SimplificationQueue;
  71572. }
  71573. }
  71574. module "babylonjs/Meshes/mesh" {
  71575. interface Mesh {
  71576. /**
  71577. * Simplify the mesh according to the given array of settings.
  71578. * Function will return immediately and will simplify async
  71579. * @param settings a collection of simplification settings
  71580. * @param parallelProcessing should all levels calculate parallel or one after the other
  71581. * @param simplificationType the type of simplification to run
  71582. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71583. * @returns the current mesh
  71584. */
  71585. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71586. }
  71587. }
  71588. /**
  71589. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71590. * created in a scene
  71591. */
  71592. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71593. /**
  71594. * The component name helpfull to identify the component in the list of scene components.
  71595. */
  71596. readonly name: string;
  71597. /**
  71598. * The scene the component belongs to.
  71599. */
  71600. scene: Scene;
  71601. /**
  71602. * Creates a new instance of the component for the given scene
  71603. * @param scene Defines the scene to register the component in
  71604. */
  71605. constructor(scene: Scene);
  71606. /**
  71607. * Registers the component in a given scene
  71608. */
  71609. register(): void;
  71610. /**
  71611. * Rebuilds the elements related to this component in case of
  71612. * context lost for instance.
  71613. */
  71614. rebuild(): void;
  71615. /**
  71616. * Disposes the component and the associated ressources
  71617. */
  71618. dispose(): void;
  71619. private _beforeCameraUpdate;
  71620. }
  71621. }
  71622. declare module "babylonjs/Meshes/Builders/index" {
  71623. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71624. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71625. export * from "babylonjs/Meshes/Builders/discBuilder";
  71626. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71627. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71628. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71629. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71630. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71631. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71632. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71633. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71634. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71635. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71636. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71637. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71638. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71639. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71640. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71641. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71642. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71643. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71644. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71645. }
  71646. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71647. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71648. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71649. import { Matrix } from "babylonjs/Maths/math.vector";
  71650. module "babylonjs/Meshes/mesh" {
  71651. interface Mesh {
  71652. /**
  71653. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71654. */
  71655. thinInstanceEnablePicking: boolean;
  71656. /**
  71657. * Creates a new thin instance
  71658. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71659. * @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
  71660. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71661. */
  71662. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71663. /**
  71664. * Adds the transformation (matrix) of the current mesh as a thin instance
  71665. * @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
  71666. * @returns the thin instance index number
  71667. */
  71668. thinInstanceAddSelf(refresh: boolean): number;
  71669. /**
  71670. * Registers a custom attribute to be used with thin instances
  71671. * @param kind name of the attribute
  71672. * @param stride size in floats of the attribute
  71673. */
  71674. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71675. /**
  71676. * Sets the matrix of a thin instance
  71677. * @param index index of the thin instance
  71678. * @param matrix matrix to set
  71679. * @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
  71680. */
  71681. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71682. /**
  71683. * Sets the value of a custom attribute for a thin instance
  71684. * @param kind name of the attribute
  71685. * @param index index of the thin instance
  71686. * @param value value to set
  71687. * @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
  71688. */
  71689. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71690. /**
  71691. * 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.
  71692. */
  71693. thinInstanceCount: number;
  71694. /**
  71695. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71696. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71697. * @param buffer buffer to set
  71698. * @param stride size in floats of each value of the buffer
  71699. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71700. */
  71701. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71702. /**
  71703. * Gets the list of world matrices
  71704. * @return an array containing all the world matrices from the thin instances
  71705. */
  71706. thinInstanceGetWorldMatrices(): Matrix[];
  71707. /**
  71708. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71709. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71710. */
  71711. thinInstanceBufferUpdated(kind: string): void;
  71712. /**
  71713. * Applies a partial update to a buffer directly on the GPU
  71714. * 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
  71715. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71716. * @param data the data to set in the GPU buffer
  71717. * @param offset the offset in the GPU buffer where to update the data
  71718. */
  71719. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71720. /**
  71721. * Refreshes the bounding info, taking into account all the thin instances defined
  71722. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71723. */
  71724. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71725. /** @hidden */
  71726. _thinInstanceInitializeUserStorage(): void;
  71727. /** @hidden */
  71728. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71729. /** @hidden */
  71730. _userThinInstanceBuffersStorage: {
  71731. data: {
  71732. [key: string]: Float32Array;
  71733. };
  71734. sizes: {
  71735. [key: string]: number;
  71736. };
  71737. vertexBuffers: {
  71738. [key: string]: Nullable<VertexBuffer>;
  71739. };
  71740. strides: {
  71741. [key: string]: number;
  71742. };
  71743. };
  71744. }
  71745. }
  71746. }
  71747. declare module "babylonjs/Meshes/index" {
  71748. export * from "babylonjs/Meshes/abstractMesh";
  71749. export * from "babylonjs/Meshes/buffer";
  71750. export * from "babylonjs/Meshes/Compression/index";
  71751. export * from "babylonjs/Meshes/csg";
  71752. export * from "babylonjs/Meshes/geometry";
  71753. export * from "babylonjs/Meshes/groundMesh";
  71754. export * from "babylonjs/Meshes/trailMesh";
  71755. export * from "babylonjs/Meshes/instancedMesh";
  71756. export * from "babylonjs/Meshes/linesMesh";
  71757. export * from "babylonjs/Meshes/mesh";
  71758. export * from "babylonjs/Meshes/mesh.vertexData";
  71759. export * from "babylonjs/Meshes/meshBuilder";
  71760. export * from "babylonjs/Meshes/meshSimplification";
  71761. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71762. export * from "babylonjs/Meshes/polygonMesh";
  71763. export * from "babylonjs/Meshes/subMesh";
  71764. export * from "babylonjs/Meshes/meshLODLevel";
  71765. export * from "babylonjs/Meshes/transformNode";
  71766. export * from "babylonjs/Meshes/Builders/index";
  71767. export * from "babylonjs/Meshes/dataBuffer";
  71768. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71769. import "babylonjs/Meshes/thinInstanceMesh";
  71770. export * from "babylonjs/Meshes/thinInstanceMesh";
  71771. }
  71772. declare module "babylonjs/Morph/index" {
  71773. export * from "babylonjs/Morph/morphTarget";
  71774. export * from "babylonjs/Morph/morphTargetManager";
  71775. }
  71776. declare module "babylonjs/Navigation/INavigationEngine" {
  71777. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71778. import { Vector3 } from "babylonjs/Maths/math";
  71779. import { Mesh } from "babylonjs/Meshes/mesh";
  71780. import { Scene } from "babylonjs/scene";
  71781. /**
  71782. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71783. */
  71784. export interface INavigationEnginePlugin {
  71785. /**
  71786. * plugin name
  71787. */
  71788. name: string;
  71789. /**
  71790. * Creates a navigation mesh
  71791. * @param meshes array of all the geometry used to compute the navigatio mesh
  71792. * @param parameters bunch of parameters used to filter geometry
  71793. */
  71794. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71795. /**
  71796. * Create a navigation mesh debug mesh
  71797. * @param scene is where the mesh will be added
  71798. * @returns debug display mesh
  71799. */
  71800. createDebugNavMesh(scene: Scene): Mesh;
  71801. /**
  71802. * Get a navigation mesh constrained position, closest to the parameter position
  71803. * @param position world position
  71804. * @returns the closest point to position constrained by the navigation mesh
  71805. */
  71806. getClosestPoint(position: Vector3): Vector3;
  71807. /**
  71808. * Get a navigation mesh constrained position, closest to the parameter position
  71809. * @param position world position
  71810. * @param result output the closest point to position constrained by the navigation mesh
  71811. */
  71812. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71813. /**
  71814. * Get a navigation mesh constrained position, within a particular radius
  71815. * @param position world position
  71816. * @param maxRadius the maximum distance to the constrained world position
  71817. * @returns the closest point to position constrained by the navigation mesh
  71818. */
  71819. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71820. /**
  71821. * Get a navigation mesh constrained position, within a particular radius
  71822. * @param position world position
  71823. * @param maxRadius the maximum distance to the constrained world position
  71824. * @param result output the closest point to position constrained by the navigation mesh
  71825. */
  71826. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71827. /**
  71828. * Compute the final position from a segment made of destination-position
  71829. * @param position world position
  71830. * @param destination world position
  71831. * @returns the resulting point along the navmesh
  71832. */
  71833. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71834. /**
  71835. * Compute the final position from a segment made of destination-position
  71836. * @param position world position
  71837. * @param destination world position
  71838. * @param result output the resulting point along the navmesh
  71839. */
  71840. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71841. /**
  71842. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71843. * @param start world position
  71844. * @param end world position
  71845. * @returns array containing world position composing the path
  71846. */
  71847. computePath(start: Vector3, end: Vector3): Vector3[];
  71848. /**
  71849. * If this plugin is supported
  71850. * @returns true if plugin is supported
  71851. */
  71852. isSupported(): boolean;
  71853. /**
  71854. * Create a new Crowd so you can add agents
  71855. * @param maxAgents the maximum agent count in the crowd
  71856. * @param maxAgentRadius the maximum radius an agent can have
  71857. * @param scene to attach the crowd to
  71858. * @returns the crowd you can add agents to
  71859. */
  71860. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71861. /**
  71862. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71863. * The queries will try to find a solution within those bounds
  71864. * default is (1,1,1)
  71865. * @param extent x,y,z value that define the extent around the queries point of reference
  71866. */
  71867. setDefaultQueryExtent(extent: Vector3): void;
  71868. /**
  71869. * Get the Bounding box extent specified by setDefaultQueryExtent
  71870. * @returns the box extent values
  71871. */
  71872. getDefaultQueryExtent(): Vector3;
  71873. /**
  71874. * build the navmesh from a previously saved state using getNavmeshData
  71875. * @param data the Uint8Array returned by getNavmeshData
  71876. */
  71877. buildFromNavmeshData(data: Uint8Array): void;
  71878. /**
  71879. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71880. * @returns data the Uint8Array that can be saved and reused
  71881. */
  71882. getNavmeshData(): Uint8Array;
  71883. /**
  71884. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71885. * @param result output the box extent values
  71886. */
  71887. getDefaultQueryExtentToRef(result: Vector3): void;
  71888. /**
  71889. * Set the time step of the navigation tick update.
  71890. * Default is 1/60.
  71891. * A value of 0 will disable fixed time update
  71892. * @param newTimeStep the new timestep to apply to this world.
  71893. */
  71894. setTimeStep(newTimeStep: number): void;
  71895. /**
  71896. * Get the time step of the navigation tick update.
  71897. * @returns the current time step
  71898. */
  71899. getTimeStep(): number;
  71900. /**
  71901. * If delta time in navigation tick update is greater than the time step
  71902. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71903. * they will be discarded.
  71904. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71905. * @param newStepCount the maximum number of iterations
  71906. */
  71907. setMaximumSubStepCount(newStepCount: number): void;
  71908. /**
  71909. * Get the maximum number of iterations per navigation tick update
  71910. * @returns the maximum number of iterations
  71911. */
  71912. getMaximumSubStepCount(): number;
  71913. /**
  71914. * Release all resources
  71915. */
  71916. dispose(): void;
  71917. }
  71918. /**
  71919. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71920. */
  71921. export interface ICrowd {
  71922. /**
  71923. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71924. * You can attach anything to that node. The node position is updated in the scene update tick.
  71925. * @param pos world position that will be constrained by the navigation mesh
  71926. * @param parameters agent parameters
  71927. * @param transform hooked to the agent that will be update by the scene
  71928. * @returns agent index
  71929. */
  71930. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71931. /**
  71932. * Returns the agent position in world space
  71933. * @param index agent index returned by addAgent
  71934. * @returns world space position
  71935. */
  71936. getAgentPosition(index: number): Vector3;
  71937. /**
  71938. * Gets the agent position result in world space
  71939. * @param index agent index returned by addAgent
  71940. * @param result output world space position
  71941. */
  71942. getAgentPositionToRef(index: number, result: Vector3): void;
  71943. /**
  71944. * Gets the agent velocity in world space
  71945. * @param index agent index returned by addAgent
  71946. * @returns world space velocity
  71947. */
  71948. getAgentVelocity(index: number): Vector3;
  71949. /**
  71950. * Gets the agent velocity result in world space
  71951. * @param index agent index returned by addAgent
  71952. * @param result output world space velocity
  71953. */
  71954. getAgentVelocityToRef(index: number, result: Vector3): void;
  71955. /**
  71956. * Gets the agent next target point on the path
  71957. * @param index agent index returned by addAgent
  71958. * @returns world space position
  71959. */
  71960. getAgentNextTargetPath(index: number): Vector3;
  71961. /**
  71962. * Gets the agent state
  71963. * @param index agent index returned by addAgent
  71964. * @returns agent state
  71965. */
  71966. getAgentState(index: number): number;
  71967. /**
  71968. * returns true if the agent in over an off mesh link connection
  71969. * @param index agent index returned by addAgent
  71970. * @returns true if over an off mesh link connection
  71971. */
  71972. overOffmeshConnection(index: number): boolean;
  71973. /**
  71974. * Gets the agent next target point on the path
  71975. * @param index agent index returned by addAgent
  71976. * @param result output world space position
  71977. */
  71978. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71979. /**
  71980. * remove a particular agent previously created
  71981. * @param index agent index returned by addAgent
  71982. */
  71983. removeAgent(index: number): void;
  71984. /**
  71985. * get the list of all agents attached to this crowd
  71986. * @returns list of agent indices
  71987. */
  71988. getAgents(): number[];
  71989. /**
  71990. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71991. * @param deltaTime in seconds
  71992. */
  71993. update(deltaTime: number): void;
  71994. /**
  71995. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71996. * @param index agent index returned by addAgent
  71997. * @param destination targeted world position
  71998. */
  71999. agentGoto(index: number, destination: Vector3): void;
  72000. /**
  72001. * Teleport the agent to a new position
  72002. * @param index agent index returned by addAgent
  72003. * @param destination targeted world position
  72004. */
  72005. agentTeleport(index: number, destination: Vector3): void;
  72006. /**
  72007. * Update agent parameters
  72008. * @param index agent index returned by addAgent
  72009. * @param parameters agent parameters
  72010. */
  72011. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72012. /**
  72013. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72014. * The queries will try to find a solution within those bounds
  72015. * default is (1,1,1)
  72016. * @param extent x,y,z value that define the extent around the queries point of reference
  72017. */
  72018. setDefaultQueryExtent(extent: Vector3): void;
  72019. /**
  72020. * Get the Bounding box extent specified by setDefaultQueryExtent
  72021. * @returns the box extent values
  72022. */
  72023. getDefaultQueryExtent(): Vector3;
  72024. /**
  72025. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72026. * @param result output the box extent values
  72027. */
  72028. getDefaultQueryExtentToRef(result: Vector3): void;
  72029. /**
  72030. * Release all resources
  72031. */
  72032. dispose(): void;
  72033. }
  72034. /**
  72035. * Configures an agent
  72036. */
  72037. export interface IAgentParameters {
  72038. /**
  72039. * Agent radius. [Limit: >= 0]
  72040. */
  72041. radius: number;
  72042. /**
  72043. * Agent height. [Limit: > 0]
  72044. */
  72045. height: number;
  72046. /**
  72047. * Maximum allowed acceleration. [Limit: >= 0]
  72048. */
  72049. maxAcceleration: number;
  72050. /**
  72051. * Maximum allowed speed. [Limit: >= 0]
  72052. */
  72053. maxSpeed: number;
  72054. /**
  72055. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  72056. */
  72057. collisionQueryRange: number;
  72058. /**
  72059. * The path visibility optimization range. [Limit: > 0]
  72060. */
  72061. pathOptimizationRange: number;
  72062. /**
  72063. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  72064. */
  72065. separationWeight: number;
  72066. }
  72067. /**
  72068. * Configures the navigation mesh creation
  72069. */
  72070. export interface INavMeshParameters {
  72071. /**
  72072. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  72073. */
  72074. cs: number;
  72075. /**
  72076. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  72077. */
  72078. ch: number;
  72079. /**
  72080. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  72081. */
  72082. walkableSlopeAngle: number;
  72083. /**
  72084. * Minimum floor to 'ceiling' height that will still allow the floor area to
  72085. * be considered walkable. [Limit: >= 3] [Units: vx]
  72086. */
  72087. walkableHeight: number;
  72088. /**
  72089. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  72090. */
  72091. walkableClimb: number;
  72092. /**
  72093. * The distance to erode/shrink the walkable area of the heightfield away from
  72094. * obstructions. [Limit: >=0] [Units: vx]
  72095. */
  72096. walkableRadius: number;
  72097. /**
  72098. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  72099. */
  72100. maxEdgeLen: number;
  72101. /**
  72102. * The maximum distance a simplfied contour's border edges should deviate
  72103. * the original raw contour. [Limit: >=0] [Units: vx]
  72104. */
  72105. maxSimplificationError: number;
  72106. /**
  72107. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  72108. */
  72109. minRegionArea: number;
  72110. /**
  72111. * Any regions with a span count smaller than this value will, if possible,
  72112. * be merged with larger regions. [Limit: >=0] [Units: vx]
  72113. */
  72114. mergeRegionArea: number;
  72115. /**
  72116. * The maximum number of vertices allowed for polygons generated during the
  72117. * contour to polygon conversion process. [Limit: >= 3]
  72118. */
  72119. maxVertsPerPoly: number;
  72120. /**
  72121. * Sets the sampling distance to use when generating the detail mesh.
  72122. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  72123. */
  72124. detailSampleDist: number;
  72125. /**
  72126. * The maximum distance the detail mesh surface should deviate from heightfield
  72127. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  72128. */
  72129. detailSampleMaxError: number;
  72130. }
  72131. }
  72132. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  72133. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  72134. import { Mesh } from "babylonjs/Meshes/mesh";
  72135. import { Scene } from "babylonjs/scene";
  72136. import { Vector3 } from "babylonjs/Maths/math";
  72137. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72138. /**
  72139. * RecastJS navigation plugin
  72140. */
  72141. export class RecastJSPlugin implements INavigationEnginePlugin {
  72142. /**
  72143. * Reference to the Recast library
  72144. */
  72145. bjsRECAST: any;
  72146. /**
  72147. * plugin name
  72148. */
  72149. name: string;
  72150. /**
  72151. * the first navmesh created. We might extend this to support multiple navmeshes
  72152. */
  72153. navMesh: any;
  72154. private _maximumSubStepCount;
  72155. private _timeStep;
  72156. /**
  72157. * Initializes the recastJS plugin
  72158. * @param recastInjection can be used to inject your own recast reference
  72159. */
  72160. constructor(recastInjection?: any);
  72161. /**
  72162. * Set the time step of the navigation tick update.
  72163. * Default is 1/60.
  72164. * A value of 0 will disable fixed time update
  72165. * @param newTimeStep the new timestep to apply to this world.
  72166. */
  72167. setTimeStep(newTimeStep?: number): void;
  72168. /**
  72169. * Get the time step of the navigation tick update.
  72170. * @returns the current time step
  72171. */
  72172. getTimeStep(): number;
  72173. /**
  72174. * If delta time in navigation tick update is greater than the time step
  72175. * a number of sub iterations are done. If more iterations are need to reach deltatime
  72176. * they will be discarded.
  72177. * A value of 0 will set to no maximum and update will use as many substeps as needed
  72178. * @param newStepCount the maximum number of iterations
  72179. */
  72180. setMaximumSubStepCount(newStepCount?: number): void;
  72181. /**
  72182. * Get the maximum number of iterations per navigation tick update
  72183. * @returns the maximum number of iterations
  72184. */
  72185. getMaximumSubStepCount(): number;
  72186. /**
  72187. * Creates a navigation mesh
  72188. * @param meshes array of all the geometry used to compute the navigatio mesh
  72189. * @param parameters bunch of parameters used to filter geometry
  72190. */
  72191. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  72192. /**
  72193. * Create a navigation mesh debug mesh
  72194. * @param scene is where the mesh will be added
  72195. * @returns debug display mesh
  72196. */
  72197. createDebugNavMesh(scene: Scene): Mesh;
  72198. /**
  72199. * Get a navigation mesh constrained position, closest to the parameter position
  72200. * @param position world position
  72201. * @returns the closest point to position constrained by the navigation mesh
  72202. */
  72203. getClosestPoint(position: Vector3): Vector3;
  72204. /**
  72205. * Get a navigation mesh constrained position, closest to the parameter position
  72206. * @param position world position
  72207. * @param result output the closest point to position constrained by the navigation mesh
  72208. */
  72209. getClosestPointToRef(position: Vector3, result: Vector3): void;
  72210. /**
  72211. * Get a navigation mesh constrained position, within a particular radius
  72212. * @param position world position
  72213. * @param maxRadius the maximum distance to the constrained world position
  72214. * @returns the closest point to position constrained by the navigation mesh
  72215. */
  72216. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  72217. /**
  72218. * Get a navigation mesh constrained position, within a particular radius
  72219. * @param position world position
  72220. * @param maxRadius the maximum distance to the constrained world position
  72221. * @param result output the closest point to position constrained by the navigation mesh
  72222. */
  72223. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  72224. /**
  72225. * Compute the final position from a segment made of destination-position
  72226. * @param position world position
  72227. * @param destination world position
  72228. * @returns the resulting point along the navmesh
  72229. */
  72230. moveAlong(position: Vector3, destination: Vector3): Vector3;
  72231. /**
  72232. * Compute the final position from a segment made of destination-position
  72233. * @param position world position
  72234. * @param destination world position
  72235. * @param result output the resulting point along the navmesh
  72236. */
  72237. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  72238. /**
  72239. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  72240. * @param start world position
  72241. * @param end world position
  72242. * @returns array containing world position composing the path
  72243. */
  72244. computePath(start: Vector3, end: Vector3): Vector3[];
  72245. /**
  72246. * Create a new Crowd so you can add agents
  72247. * @param maxAgents the maximum agent count in the crowd
  72248. * @param maxAgentRadius the maximum radius an agent can have
  72249. * @param scene to attach the crowd to
  72250. * @returns the crowd you can add agents to
  72251. */
  72252. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  72253. /**
  72254. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72255. * The queries will try to find a solution within those bounds
  72256. * default is (1,1,1)
  72257. * @param extent x,y,z value that define the extent around the queries point of reference
  72258. */
  72259. setDefaultQueryExtent(extent: Vector3): void;
  72260. /**
  72261. * Get the Bounding box extent specified by setDefaultQueryExtent
  72262. * @returns the box extent values
  72263. */
  72264. getDefaultQueryExtent(): Vector3;
  72265. /**
  72266. * build the navmesh from a previously saved state using getNavmeshData
  72267. * @param data the Uint8Array returned by getNavmeshData
  72268. */
  72269. buildFromNavmeshData(data: Uint8Array): void;
  72270. /**
  72271. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  72272. * @returns data the Uint8Array that can be saved and reused
  72273. */
  72274. getNavmeshData(): Uint8Array;
  72275. /**
  72276. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72277. * @param result output the box extent values
  72278. */
  72279. getDefaultQueryExtentToRef(result: Vector3): void;
  72280. /**
  72281. * Disposes
  72282. */
  72283. dispose(): void;
  72284. /**
  72285. * If this plugin is supported
  72286. * @returns true if plugin is supported
  72287. */
  72288. isSupported(): boolean;
  72289. }
  72290. /**
  72291. * Recast detour crowd implementation
  72292. */
  72293. export class RecastJSCrowd implements ICrowd {
  72294. /**
  72295. * Recast/detour plugin
  72296. */
  72297. bjsRECASTPlugin: RecastJSPlugin;
  72298. /**
  72299. * Link to the detour crowd
  72300. */
  72301. recastCrowd: any;
  72302. /**
  72303. * One transform per agent
  72304. */
  72305. transforms: TransformNode[];
  72306. /**
  72307. * All agents created
  72308. */
  72309. agents: number[];
  72310. /**
  72311. * Link to the scene is kept to unregister the crowd from the scene
  72312. */
  72313. private _scene;
  72314. /**
  72315. * Observer for crowd updates
  72316. */
  72317. private _onBeforeAnimationsObserver;
  72318. /**
  72319. * Constructor
  72320. * @param plugin recastJS plugin
  72321. * @param maxAgents the maximum agent count in the crowd
  72322. * @param maxAgentRadius the maximum radius an agent can have
  72323. * @param scene to attach the crowd to
  72324. * @returns the crowd you can add agents to
  72325. */
  72326. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  72327. /**
  72328. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  72329. * You can attach anything to that node. The node position is updated in the scene update tick.
  72330. * @param pos world position that will be constrained by the navigation mesh
  72331. * @param parameters agent parameters
  72332. * @param transform hooked to the agent that will be update by the scene
  72333. * @returns agent index
  72334. */
  72335. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  72336. /**
  72337. * Returns the agent position in world space
  72338. * @param index agent index returned by addAgent
  72339. * @returns world space position
  72340. */
  72341. getAgentPosition(index: number): Vector3;
  72342. /**
  72343. * Returns the agent position result in world space
  72344. * @param index agent index returned by addAgent
  72345. * @param result output world space position
  72346. */
  72347. getAgentPositionToRef(index: number, result: Vector3): void;
  72348. /**
  72349. * Returns the agent velocity in world space
  72350. * @param index agent index returned by addAgent
  72351. * @returns world space velocity
  72352. */
  72353. getAgentVelocity(index: number): Vector3;
  72354. /**
  72355. * Returns the agent velocity result in world space
  72356. * @param index agent index returned by addAgent
  72357. * @param result output world space velocity
  72358. */
  72359. getAgentVelocityToRef(index: number, result: Vector3): void;
  72360. /**
  72361. * Returns the agent next target point on the path
  72362. * @param index agent index returned by addAgent
  72363. * @returns world space position
  72364. */
  72365. getAgentNextTargetPath(index: number): Vector3;
  72366. /**
  72367. * Returns the agent next target point on the path
  72368. * @param index agent index returned by addAgent
  72369. * @param result output world space position
  72370. */
  72371. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  72372. /**
  72373. * Gets the agent state
  72374. * @param index agent index returned by addAgent
  72375. * @returns agent state
  72376. */
  72377. getAgentState(index: number): number;
  72378. /**
  72379. * returns true if the agent in over an off mesh link connection
  72380. * @param index agent index returned by addAgent
  72381. * @returns true if over an off mesh link connection
  72382. */
  72383. overOffmeshConnection(index: number): boolean;
  72384. /**
  72385. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  72386. * @param index agent index returned by addAgent
  72387. * @param destination targeted world position
  72388. */
  72389. agentGoto(index: number, destination: Vector3): void;
  72390. /**
  72391. * Teleport the agent to a new position
  72392. * @param index agent index returned by addAgent
  72393. * @param destination targeted world position
  72394. */
  72395. agentTeleport(index: number, destination: Vector3): void;
  72396. /**
  72397. * Update agent parameters
  72398. * @param index agent index returned by addAgent
  72399. * @param parameters agent parameters
  72400. */
  72401. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  72402. /**
  72403. * remove a particular agent previously created
  72404. * @param index agent index returned by addAgent
  72405. */
  72406. removeAgent(index: number): void;
  72407. /**
  72408. * get the list of all agents attached to this crowd
  72409. * @returns list of agent indices
  72410. */
  72411. getAgents(): number[];
  72412. /**
  72413. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  72414. * @param deltaTime in seconds
  72415. */
  72416. update(deltaTime: number): void;
  72417. /**
  72418. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  72419. * The queries will try to find a solution within those bounds
  72420. * default is (1,1,1)
  72421. * @param extent x,y,z value that define the extent around the queries point of reference
  72422. */
  72423. setDefaultQueryExtent(extent: Vector3): void;
  72424. /**
  72425. * Get the Bounding box extent specified by setDefaultQueryExtent
  72426. * @returns the box extent values
  72427. */
  72428. getDefaultQueryExtent(): Vector3;
  72429. /**
  72430. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72431. * @param result output the box extent values
  72432. */
  72433. getDefaultQueryExtentToRef(result: Vector3): void;
  72434. /**
  72435. * Release all resources
  72436. */
  72437. dispose(): void;
  72438. }
  72439. }
  72440. declare module "babylonjs/Navigation/Plugins/index" {
  72441. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72442. }
  72443. declare module "babylonjs/Navigation/index" {
  72444. export * from "babylonjs/Navigation/INavigationEngine";
  72445. export * from "babylonjs/Navigation/Plugins/index";
  72446. }
  72447. declare module "babylonjs/Offline/database" {
  72448. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72449. /**
  72450. * Class used to enable access to IndexedDB
  72451. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72452. */
  72453. export class Database implements IOfflineProvider {
  72454. private _callbackManifestChecked;
  72455. private _currentSceneUrl;
  72456. private _db;
  72457. private _enableSceneOffline;
  72458. private _enableTexturesOffline;
  72459. private _manifestVersionFound;
  72460. private _mustUpdateRessources;
  72461. private _hasReachedQuota;
  72462. private _isSupported;
  72463. private _idbFactory;
  72464. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72465. private static IsUASupportingBlobStorage;
  72466. /**
  72467. * Gets a boolean indicating if Database storate is enabled (off by default)
  72468. */
  72469. static IDBStorageEnabled: boolean;
  72470. /**
  72471. * Gets a boolean indicating if scene must be saved in the database
  72472. */
  72473. get enableSceneOffline(): boolean;
  72474. /**
  72475. * Gets a boolean indicating if textures must be saved in the database
  72476. */
  72477. get enableTexturesOffline(): boolean;
  72478. /**
  72479. * Creates a new Database
  72480. * @param urlToScene defines the url to load the scene
  72481. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72482. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72483. */
  72484. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72485. private static _ParseURL;
  72486. private static _ReturnFullUrlLocation;
  72487. private _checkManifestFile;
  72488. /**
  72489. * Open the database and make it available
  72490. * @param successCallback defines the callback to call on success
  72491. * @param errorCallback defines the callback to call on error
  72492. */
  72493. open(successCallback: () => void, errorCallback: () => void): void;
  72494. /**
  72495. * Loads an image from the database
  72496. * @param url defines the url to load from
  72497. * @param image defines the target DOM image
  72498. */
  72499. loadImage(url: string, image: HTMLImageElement): void;
  72500. private _loadImageFromDBAsync;
  72501. private _saveImageIntoDBAsync;
  72502. private _checkVersionFromDB;
  72503. private _loadVersionFromDBAsync;
  72504. private _saveVersionIntoDBAsync;
  72505. /**
  72506. * Loads a file from database
  72507. * @param url defines the URL to load from
  72508. * @param sceneLoaded defines a callback to call on success
  72509. * @param progressCallBack defines a callback to call when progress changed
  72510. * @param errorCallback defines a callback to call on error
  72511. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72512. */
  72513. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72514. private _loadFileAsync;
  72515. private _saveFileAsync;
  72516. /**
  72517. * Validates if xhr data is correct
  72518. * @param xhr defines the request to validate
  72519. * @param dataType defines the expected data type
  72520. * @returns true if data is correct
  72521. */
  72522. private static _ValidateXHRData;
  72523. }
  72524. }
  72525. declare module "babylonjs/Offline/index" {
  72526. export * from "babylonjs/Offline/database";
  72527. export * from "babylonjs/Offline/IOfflineProvider";
  72528. }
  72529. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72530. /** @hidden */
  72531. export var gpuUpdateParticlesPixelShader: {
  72532. name: string;
  72533. shader: string;
  72534. };
  72535. }
  72536. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72537. /** @hidden */
  72538. export var gpuUpdateParticlesVertexShader: {
  72539. name: string;
  72540. shader: string;
  72541. };
  72542. }
  72543. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72544. /** @hidden */
  72545. export var clipPlaneFragmentDeclaration2: {
  72546. name: string;
  72547. shader: string;
  72548. };
  72549. }
  72550. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72551. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72552. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72553. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72554. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72555. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72556. /** @hidden */
  72557. export var gpuRenderParticlesPixelShader: {
  72558. name: string;
  72559. shader: string;
  72560. };
  72561. }
  72562. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72563. /** @hidden */
  72564. export var clipPlaneVertexDeclaration2: {
  72565. name: string;
  72566. shader: string;
  72567. };
  72568. }
  72569. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72571. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72572. /** @hidden */
  72573. export var gpuRenderParticlesVertexShader: {
  72574. name: string;
  72575. shader: string;
  72576. };
  72577. }
  72578. declare module "babylonjs/Particles/gpuParticleSystem" {
  72579. import { Nullable } from "babylonjs/types";
  72580. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72581. import { Observable } from "babylonjs/Misc/observable";
  72582. import { Matrix } from "babylonjs/Maths/math.vector";
  72583. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72584. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72585. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72586. import { IDisposable } from "babylonjs/scene";
  72587. import { Effect } from "babylonjs/Materials/effect";
  72588. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72589. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72590. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72591. import { Scene } from "babylonjs/scene";
  72592. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72593. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72594. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72595. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72596. /**
  72597. * This represents a GPU particle system in Babylon
  72598. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72599. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72600. */
  72601. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72602. /**
  72603. * The layer mask we are rendering the particles through.
  72604. */
  72605. layerMask: number;
  72606. private _capacity;
  72607. private _activeCount;
  72608. private _currentActiveCount;
  72609. private _accumulatedCount;
  72610. private _renderEffect;
  72611. private _updateEffect;
  72612. private _buffer0;
  72613. private _buffer1;
  72614. private _spriteBuffer;
  72615. private _updateVAO;
  72616. private _renderVAO;
  72617. private _targetIndex;
  72618. private _sourceBuffer;
  72619. private _targetBuffer;
  72620. private _currentRenderId;
  72621. private _started;
  72622. private _stopped;
  72623. private _timeDelta;
  72624. private _randomTexture;
  72625. private _randomTexture2;
  72626. private _attributesStrideSize;
  72627. private _updateEffectOptions;
  72628. private _randomTextureSize;
  72629. private _actualFrame;
  72630. private _customEffect;
  72631. private readonly _rawTextureWidth;
  72632. /**
  72633. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72634. */
  72635. static get IsSupported(): boolean;
  72636. /**
  72637. * An event triggered when the system is disposed.
  72638. */
  72639. onDisposeObservable: Observable<IParticleSystem>;
  72640. /**
  72641. * An event triggered when the system is stopped
  72642. */
  72643. onStoppedObservable: Observable<IParticleSystem>;
  72644. /**
  72645. * Gets the maximum number of particles active at the same time.
  72646. * @returns The max number of active particles.
  72647. */
  72648. getCapacity(): number;
  72649. /**
  72650. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72651. * to override the particles.
  72652. */
  72653. forceDepthWrite: boolean;
  72654. /**
  72655. * Gets or set the number of active particles
  72656. */
  72657. get activeParticleCount(): number;
  72658. set activeParticleCount(value: number);
  72659. private _preWarmDone;
  72660. /**
  72661. * Specifies if the particles are updated in emitter local space or world space.
  72662. */
  72663. isLocal: boolean;
  72664. /** Gets or sets a matrix to use to compute projection */
  72665. defaultProjectionMatrix: Matrix;
  72666. /**
  72667. * Is this system ready to be used/rendered
  72668. * @return true if the system is ready
  72669. */
  72670. isReady(): boolean;
  72671. /**
  72672. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72673. * @returns True if it has been started, otherwise false.
  72674. */
  72675. isStarted(): boolean;
  72676. /**
  72677. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72678. * @returns True if it has been stopped, otherwise false.
  72679. */
  72680. isStopped(): boolean;
  72681. /**
  72682. * Gets a boolean indicating that the system is stopping
  72683. * @returns true if the system is currently stopping
  72684. */
  72685. isStopping(): boolean;
  72686. /**
  72687. * Gets the number of particles active at the same time.
  72688. * @returns The number of active particles.
  72689. */
  72690. getActiveCount(): number;
  72691. /**
  72692. * Starts the particle system and begins to emit
  72693. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72694. */
  72695. start(delay?: number): void;
  72696. /**
  72697. * Stops the particle system.
  72698. */
  72699. stop(): void;
  72700. /**
  72701. * Remove all active particles
  72702. */
  72703. reset(): void;
  72704. /**
  72705. * Returns the string "GPUParticleSystem"
  72706. * @returns a string containing the class name
  72707. */
  72708. getClassName(): string;
  72709. /**
  72710. * Gets the custom effect used to render the particles
  72711. * @param blendMode Blend mode for which the effect should be retrieved
  72712. * @returns The effect
  72713. */
  72714. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72715. /**
  72716. * Sets the custom effect used to render the particles
  72717. * @param effect The effect to set
  72718. * @param blendMode Blend mode for which the effect should be set
  72719. */
  72720. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72721. /** @hidden */
  72722. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72723. /**
  72724. * Observable that will be called just before the particles are drawn
  72725. */
  72726. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72727. /**
  72728. * Gets the name of the particle vertex shader
  72729. */
  72730. get vertexShaderName(): string;
  72731. private _colorGradientsTexture;
  72732. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72733. /**
  72734. * Adds a new color gradient
  72735. * @param gradient defines the gradient to use (between 0 and 1)
  72736. * @param color1 defines the color to affect to the specified gradient
  72737. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72738. * @returns the current particle system
  72739. */
  72740. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72741. private _refreshColorGradient;
  72742. /** Force the system to rebuild all gradients that need to be resync */
  72743. forceRefreshGradients(): void;
  72744. /**
  72745. * Remove a specific color gradient
  72746. * @param gradient defines the gradient to remove
  72747. * @returns the current particle system
  72748. */
  72749. removeColorGradient(gradient: number): GPUParticleSystem;
  72750. private _angularSpeedGradientsTexture;
  72751. private _sizeGradientsTexture;
  72752. private _velocityGradientsTexture;
  72753. private _limitVelocityGradientsTexture;
  72754. private _dragGradientsTexture;
  72755. private _addFactorGradient;
  72756. /**
  72757. * Adds a new size gradient
  72758. * @param gradient defines the gradient to use (between 0 and 1)
  72759. * @param factor defines the size factor to affect to the specified gradient
  72760. * @returns the current particle system
  72761. */
  72762. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72763. /**
  72764. * Remove a specific size gradient
  72765. * @param gradient defines the gradient to remove
  72766. * @returns the current particle system
  72767. */
  72768. removeSizeGradient(gradient: number): GPUParticleSystem;
  72769. private _refreshFactorGradient;
  72770. /**
  72771. * Adds a new angular speed gradient
  72772. * @param gradient defines the gradient to use (between 0 and 1)
  72773. * @param factor defines the angular speed to affect to the specified gradient
  72774. * @returns the current particle system
  72775. */
  72776. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72777. /**
  72778. * Remove a specific angular speed gradient
  72779. * @param gradient defines the gradient to remove
  72780. * @returns the current particle system
  72781. */
  72782. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72783. /**
  72784. * Adds a new velocity gradient
  72785. * @param gradient defines the gradient to use (between 0 and 1)
  72786. * @param factor defines the velocity to affect to the specified gradient
  72787. * @returns the current particle system
  72788. */
  72789. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72790. /**
  72791. * Remove a specific velocity gradient
  72792. * @param gradient defines the gradient to remove
  72793. * @returns the current particle system
  72794. */
  72795. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72796. /**
  72797. * Adds a new limit velocity gradient
  72798. * @param gradient defines the gradient to use (between 0 and 1)
  72799. * @param factor defines the limit velocity value to affect to the specified gradient
  72800. * @returns the current particle system
  72801. */
  72802. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72803. /**
  72804. * Remove a specific limit velocity gradient
  72805. * @param gradient defines the gradient to remove
  72806. * @returns the current particle system
  72807. */
  72808. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72809. /**
  72810. * Adds a new drag gradient
  72811. * @param gradient defines the gradient to use (between 0 and 1)
  72812. * @param factor defines the drag value to affect to the specified gradient
  72813. * @returns the current particle system
  72814. */
  72815. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72816. /**
  72817. * Remove a specific drag gradient
  72818. * @param gradient defines the gradient to remove
  72819. * @returns the current particle system
  72820. */
  72821. removeDragGradient(gradient: number): GPUParticleSystem;
  72822. /**
  72823. * Not supported by GPUParticleSystem
  72824. * @param gradient defines the gradient to use (between 0 and 1)
  72825. * @param factor defines the emit rate value to affect to the specified gradient
  72826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72827. * @returns the current particle system
  72828. */
  72829. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72830. /**
  72831. * Not supported by GPUParticleSystem
  72832. * @param gradient defines the gradient to remove
  72833. * @returns the current particle system
  72834. */
  72835. removeEmitRateGradient(gradient: number): IParticleSystem;
  72836. /**
  72837. * Not supported by GPUParticleSystem
  72838. * @param gradient defines the gradient to use (between 0 and 1)
  72839. * @param factor defines the start size value to affect to the specified gradient
  72840. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72841. * @returns the current particle system
  72842. */
  72843. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72844. /**
  72845. * Not supported by GPUParticleSystem
  72846. * @param gradient defines the gradient to remove
  72847. * @returns the current particle system
  72848. */
  72849. removeStartSizeGradient(gradient: number): IParticleSystem;
  72850. /**
  72851. * Not supported by GPUParticleSystem
  72852. * @param gradient defines the gradient to use (between 0 and 1)
  72853. * @param min defines the color remap minimal range
  72854. * @param max defines the color remap maximal range
  72855. * @returns the current particle system
  72856. */
  72857. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72858. /**
  72859. * Not supported by GPUParticleSystem
  72860. * @param gradient defines the gradient to remove
  72861. * @returns the current particle system
  72862. */
  72863. removeColorRemapGradient(): IParticleSystem;
  72864. /**
  72865. * Not supported by GPUParticleSystem
  72866. * @param gradient defines the gradient to use (between 0 and 1)
  72867. * @param min defines the alpha remap minimal range
  72868. * @param max defines the alpha remap maximal range
  72869. * @returns the current particle system
  72870. */
  72871. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72872. /**
  72873. * Not supported by GPUParticleSystem
  72874. * @param gradient defines the gradient to remove
  72875. * @returns the current particle system
  72876. */
  72877. removeAlphaRemapGradient(): IParticleSystem;
  72878. /**
  72879. * Not supported by GPUParticleSystem
  72880. * @param gradient defines the gradient to use (between 0 and 1)
  72881. * @param color defines the color to affect to the specified gradient
  72882. * @returns the current particle system
  72883. */
  72884. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72885. /**
  72886. * Not supported by GPUParticleSystem
  72887. * @param gradient defines the gradient to remove
  72888. * @returns the current particle system
  72889. */
  72890. removeRampGradient(): IParticleSystem;
  72891. /**
  72892. * Not supported by GPUParticleSystem
  72893. * @returns the list of ramp gradients
  72894. */
  72895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72896. /**
  72897. * Not supported by GPUParticleSystem
  72898. * Gets or sets a boolean indicating that ramp gradients must be used
  72899. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72900. */
  72901. get useRampGradients(): boolean;
  72902. set useRampGradients(value: boolean);
  72903. /**
  72904. * Not supported by GPUParticleSystem
  72905. * @param gradient defines the gradient to use (between 0 and 1)
  72906. * @param factor defines the life time factor to affect to the specified gradient
  72907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72908. * @returns the current particle system
  72909. */
  72910. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72911. /**
  72912. * Not supported by GPUParticleSystem
  72913. * @param gradient defines the gradient to remove
  72914. * @returns the current particle system
  72915. */
  72916. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72917. /**
  72918. * Instantiates a GPU particle system.
  72919. * 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.
  72920. * @param name The name of the particle system
  72921. * @param options The options used to create the system
  72922. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72923. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72924. * @param customEffect a custom effect used to change the way particles are rendered by default
  72925. */
  72926. constructor(name: string, options: Partial<{
  72927. capacity: number;
  72928. randomTextureSize: number;
  72929. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72930. protected _reset(): void;
  72931. private _createUpdateVAO;
  72932. private _createRenderVAO;
  72933. private _initialize;
  72934. /** @hidden */
  72935. _recreateUpdateEffect(): void;
  72936. private _getEffect;
  72937. /**
  72938. * Fill the defines array according to the current settings of the particle system
  72939. * @param defines Array to be updated
  72940. * @param blendMode blend mode to take into account when updating the array
  72941. */
  72942. fillDefines(defines: Array<string>, blendMode?: number): void;
  72943. /**
  72944. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72945. * @param uniforms Uniforms array to fill
  72946. * @param attributes Attributes array to fill
  72947. * @param samplers Samplers array to fill
  72948. */
  72949. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72950. /** @hidden */
  72951. _recreateRenderEffect(): Effect;
  72952. /**
  72953. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72954. * @param preWarm defines if we are in the pre-warmimg phase
  72955. */
  72956. animate(preWarm?: boolean): void;
  72957. private _createFactorGradientTexture;
  72958. private _createSizeGradientTexture;
  72959. private _createAngularSpeedGradientTexture;
  72960. private _createVelocityGradientTexture;
  72961. private _createLimitVelocityGradientTexture;
  72962. private _createDragGradientTexture;
  72963. private _createColorGradientTexture;
  72964. /**
  72965. * Renders the particle system in its current state
  72966. * @param preWarm defines if the system should only update the particles but not render them
  72967. * @returns the current number of particles
  72968. */
  72969. render(preWarm?: boolean): number;
  72970. /**
  72971. * Rebuilds the particle system
  72972. */
  72973. rebuild(): void;
  72974. private _releaseBuffers;
  72975. private _releaseVAOs;
  72976. /**
  72977. * Disposes the particle system and free the associated resources
  72978. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72979. */
  72980. dispose(disposeTexture?: boolean): void;
  72981. /**
  72982. * Clones the particle system.
  72983. * @param name The name of the cloned object
  72984. * @param newEmitter The new emitter to use
  72985. * @returns the cloned particle system
  72986. */
  72987. clone(name: string, newEmitter: any): GPUParticleSystem;
  72988. /**
  72989. * Serializes the particle system to a JSON object
  72990. * @param serializeTexture defines if the texture must be serialized as well
  72991. * @returns the JSON object
  72992. */
  72993. serialize(serializeTexture?: boolean): any;
  72994. /**
  72995. * Parses a JSON object to create a GPU particle system.
  72996. * @param parsedParticleSystem The JSON object to parse
  72997. * @param sceneOrEngine The scene or the engine to create the particle system in
  72998. * @param rootUrl The root url to use to load external dependencies like texture
  72999. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  73000. * @returns the parsed GPU particle system
  73001. */
  73002. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  73003. }
  73004. }
  73005. declare module "babylonjs/Particles/particleSystemSet" {
  73006. import { Nullable } from "babylonjs/types";
  73007. import { Color3 } from "babylonjs/Maths/math.color";
  73008. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73010. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73011. import { Scene, IDisposable } from "babylonjs/scene";
  73012. /**
  73013. * Represents a set of particle systems working together to create a specific effect
  73014. */
  73015. export class ParticleSystemSet implements IDisposable {
  73016. /**
  73017. * Gets or sets base Assets URL
  73018. */
  73019. static BaseAssetsUrl: string;
  73020. private _emitterCreationOptions;
  73021. private _emitterNode;
  73022. /**
  73023. * Gets the particle system list
  73024. */
  73025. systems: IParticleSystem[];
  73026. /**
  73027. * Gets the emitter node used with this set
  73028. */
  73029. get emitterNode(): Nullable<TransformNode>;
  73030. /**
  73031. * Creates a new emitter mesh as a sphere
  73032. * @param options defines the options used to create the sphere
  73033. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  73034. * @param scene defines the hosting scene
  73035. */
  73036. setEmitterAsSphere(options: {
  73037. diameter: number;
  73038. segments: number;
  73039. color: Color3;
  73040. }, renderingGroupId: number, scene: Scene): void;
  73041. /**
  73042. * Starts all particle systems of the set
  73043. * @param emitter defines an optional mesh to use as emitter for the particle systems
  73044. */
  73045. start(emitter?: AbstractMesh): void;
  73046. /**
  73047. * Release all associated resources
  73048. */
  73049. dispose(): void;
  73050. /**
  73051. * Serialize the set into a JSON compatible object
  73052. * @param serializeTexture defines if the texture must be serialized as well
  73053. * @returns a JSON compatible representation of the set
  73054. */
  73055. serialize(serializeTexture?: boolean): any;
  73056. /**
  73057. * Parse a new ParticleSystemSet from a serialized source
  73058. * @param data defines a JSON compatible representation of the set
  73059. * @param scene defines the hosting scene
  73060. * @param gpu defines if we want GPU particles or CPU particles
  73061. * @returns a new ParticleSystemSet
  73062. */
  73063. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  73064. }
  73065. }
  73066. declare module "babylonjs/Particles/particleHelper" {
  73067. import { Nullable } from "babylonjs/types";
  73068. import { Scene } from "babylonjs/scene";
  73069. import { Vector3 } from "babylonjs/Maths/math.vector";
  73070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73071. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73072. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  73073. /**
  73074. * This class is made for on one-liner static method to help creating particle system set.
  73075. */
  73076. export class ParticleHelper {
  73077. /**
  73078. * Gets or sets base Assets URL
  73079. */
  73080. static BaseAssetsUrl: string;
  73081. /** Define the Url to load snippets */
  73082. static SnippetUrl: string;
  73083. /**
  73084. * Create a default particle system that you can tweak
  73085. * @param emitter defines the emitter to use
  73086. * @param capacity defines the system capacity (default is 500 particles)
  73087. * @param scene defines the hosting scene
  73088. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  73089. * @returns the new Particle system
  73090. */
  73091. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  73092. /**
  73093. * This is the main static method (one-liner) of this helper to create different particle systems
  73094. * @param type This string represents the type to the particle system to create
  73095. * @param scene The scene where the particle system should live
  73096. * @param gpu If the system will use gpu
  73097. * @returns the ParticleSystemSet created
  73098. */
  73099. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  73100. /**
  73101. * Static function used to export a particle system to a ParticleSystemSet variable.
  73102. * Please note that the emitter shape is not exported
  73103. * @param systems defines the particle systems to export
  73104. * @returns the created particle system set
  73105. */
  73106. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  73107. /**
  73108. * Creates a particle system from a snippet saved in a remote file
  73109. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  73110. * @param url defines the url to load from
  73111. * @param scene defines the hosting scene
  73112. * @param gpu If the system will use gpu
  73113. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73114. * @returns a promise that will resolve to the new particle system
  73115. */
  73116. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73117. /**
  73118. * Creates a particle system from a snippet saved by the particle system editor
  73119. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  73120. * @param scene defines the hosting scene
  73121. * @param gpu If the system will use gpu
  73122. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  73123. * @returns a promise that will resolve to the new particle system
  73124. */
  73125. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  73126. }
  73127. }
  73128. declare module "babylonjs/Particles/particleSystemComponent" {
  73129. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  73130. import { Effect } from "babylonjs/Materials/effect";
  73131. import "babylonjs/Shaders/particles.vertex";
  73132. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  73133. module "babylonjs/Engines/engine" {
  73134. interface Engine {
  73135. /**
  73136. * Create an effect to use with particle systems.
  73137. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  73138. * the particle system for which you want to create a custom effect in the last parameter
  73139. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  73140. * @param uniformsNames defines a list of attribute names
  73141. * @param samplers defines an array of string used to represent textures
  73142. * @param defines defines the string containing the defines to use to compile the shaders
  73143. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  73144. * @param onCompiled defines a function to call when the effect creation is successful
  73145. * @param onError defines a function to call when the effect creation has failed
  73146. * @param particleSystem the particle system you want to create the effect for
  73147. * @returns the new Effect
  73148. */
  73149. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  73150. }
  73151. }
  73152. module "babylonjs/Meshes/mesh" {
  73153. interface Mesh {
  73154. /**
  73155. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  73156. * @returns an array of IParticleSystem
  73157. */
  73158. getEmittedParticleSystems(): IParticleSystem[];
  73159. /**
  73160. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  73161. * @returns an array of IParticleSystem
  73162. */
  73163. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  73164. }
  73165. }
  73166. }
  73167. declare module "babylonjs/Particles/pointsCloudSystem" {
  73168. import { Color4 } from "babylonjs/Maths/math";
  73169. import { Mesh } from "babylonjs/Meshes/mesh";
  73170. import { Scene, IDisposable } from "babylonjs/scene";
  73171. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  73172. /** Defines the 4 color options */
  73173. export enum PointColor {
  73174. /** color value */
  73175. Color = 2,
  73176. /** uv value */
  73177. UV = 1,
  73178. /** random value */
  73179. Random = 0,
  73180. /** stated value */
  73181. Stated = 3
  73182. }
  73183. /**
  73184. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  73185. * 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.
  73186. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  73187. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  73188. *
  73189. * Full documentation here : TO BE ENTERED
  73190. */
  73191. export class PointsCloudSystem implements IDisposable {
  73192. /**
  73193. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  73194. * Example : var p = SPS.particles[i];
  73195. */
  73196. particles: CloudPoint[];
  73197. /**
  73198. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  73199. */
  73200. nbParticles: number;
  73201. /**
  73202. * This a counter for your own usage. It's not set by any SPS functions.
  73203. */
  73204. counter: number;
  73205. /**
  73206. * The PCS name. This name is also given to the underlying mesh.
  73207. */
  73208. name: string;
  73209. /**
  73210. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  73211. */
  73212. mesh: Mesh;
  73213. /**
  73214. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  73215. * Please read :
  73216. */
  73217. vars: any;
  73218. /**
  73219. * @hidden
  73220. */
  73221. _size: number;
  73222. private _scene;
  73223. private _promises;
  73224. private _positions;
  73225. private _indices;
  73226. private _normals;
  73227. private _colors;
  73228. private _uvs;
  73229. private _indices32;
  73230. private _positions32;
  73231. private _colors32;
  73232. private _uvs32;
  73233. private _updatable;
  73234. private _isVisibilityBoxLocked;
  73235. private _alwaysVisible;
  73236. private _groups;
  73237. private _groupCounter;
  73238. private _computeParticleColor;
  73239. private _computeParticleTexture;
  73240. private _computeParticleRotation;
  73241. private _computeBoundingBox;
  73242. private _isReady;
  73243. /**
  73244. * Creates a PCS (Points Cloud System) object
  73245. * @param name (String) is the PCS name, this will be the underlying mesh name
  73246. * @param pointSize (number) is the size for each point
  73247. * @param scene (Scene) is the scene in which the PCS is added
  73248. * @param options defines the options of the PCS e.g.
  73249. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  73250. */
  73251. constructor(name: string, pointSize: number, scene: Scene, options?: {
  73252. updatable?: boolean;
  73253. });
  73254. /**
  73255. * Builds the PCS underlying mesh. Returns a standard Mesh.
  73256. * If no points were added to the PCS, the returned mesh is just a single point.
  73257. * @returns a promise for the created mesh
  73258. */
  73259. buildMeshAsync(): Promise<Mesh>;
  73260. /**
  73261. * @hidden
  73262. */
  73263. private _buildMesh;
  73264. private _addParticle;
  73265. private _randomUnitVector;
  73266. private _getColorIndicesForCoord;
  73267. private _setPointsColorOrUV;
  73268. private _colorFromTexture;
  73269. private _calculateDensity;
  73270. /**
  73271. * Adds points to the PCS in random positions within a unit sphere
  73272. * @param nb (positive integer) the number of particles to be created from this model
  73273. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  73274. * @returns the number of groups in the system
  73275. */
  73276. addPoints(nb: number, pointFunction?: any): number;
  73277. /**
  73278. * Adds points to the PCS from the surface of the model shape
  73279. * @param mesh is any Mesh object that will be used as a surface model for the points
  73280. * @param nb (positive integer) the number of particles to be created from this model
  73281. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73282. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73283. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73284. * @returns the number of groups in the system
  73285. */
  73286. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73287. /**
  73288. * Adds points to the PCS inside the model shape
  73289. * @param mesh is any Mesh object that will be used as a surface model for the points
  73290. * @param nb (positive integer) the number of particles to be created from this model
  73291. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  73292. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  73293. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  73294. * @returns the number of groups in the system
  73295. */
  73296. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  73297. /**
  73298. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  73299. * This method calls `updateParticle()` for each particle of the SPS.
  73300. * For an animated SPS, it is usually called within the render loop.
  73301. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  73302. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  73303. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  73304. * @returns the PCS.
  73305. */
  73306. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  73307. /**
  73308. * Disposes the PCS.
  73309. */
  73310. dispose(): void;
  73311. /**
  73312. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  73313. * doc :
  73314. * @returns the PCS.
  73315. */
  73316. refreshVisibleSize(): PointsCloudSystem;
  73317. /**
  73318. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  73319. * @param size the size (float) of the visibility box
  73320. * note : this doesn't lock the PCS mesh bounding box.
  73321. * doc :
  73322. */
  73323. setVisibilityBox(size: number): void;
  73324. /**
  73325. * Gets whether the PCS is always visible or not
  73326. * doc :
  73327. */
  73328. get isAlwaysVisible(): boolean;
  73329. /**
  73330. * Sets the PCS as always visible or not
  73331. * doc :
  73332. */
  73333. set isAlwaysVisible(val: boolean);
  73334. /**
  73335. * Tells to `setParticles()` to compute the particle rotations or not
  73336. * Default value : false. The PCS is faster when it's set to false
  73337. * Note : particle rotations are only applied to parent particles
  73338. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  73339. */
  73340. set computeParticleRotation(val: boolean);
  73341. /**
  73342. * Tells to `setParticles()` to compute the particle colors or not.
  73343. * Default value : true. The PCS is faster when it's set to false.
  73344. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73345. */
  73346. set computeParticleColor(val: boolean);
  73347. set computeParticleTexture(val: boolean);
  73348. /**
  73349. * Gets if `setParticles()` computes the particle colors or not.
  73350. * Default value : false. The PCS is faster when it's set to false.
  73351. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  73352. */
  73353. get computeParticleColor(): boolean;
  73354. /**
  73355. * Gets if `setParticles()` computes the particle textures or not.
  73356. * Default value : false. The PCS is faster when it's set to false.
  73357. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  73358. */
  73359. get computeParticleTexture(): boolean;
  73360. /**
  73361. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  73362. */
  73363. set computeBoundingBox(val: boolean);
  73364. /**
  73365. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  73366. */
  73367. get computeBoundingBox(): boolean;
  73368. /**
  73369. * This function does nothing. It may be overwritten to set all the particle first values.
  73370. * The PCS doesn't call this function, you may have to call it by your own.
  73371. * doc :
  73372. */
  73373. initParticles(): void;
  73374. /**
  73375. * This function does nothing. It may be overwritten to recycle a particle
  73376. * The PCS doesn't call this function, you can to call it
  73377. * doc :
  73378. * @param particle The particle to recycle
  73379. * @returns the recycled particle
  73380. */
  73381. recycleParticle(particle: CloudPoint): CloudPoint;
  73382. /**
  73383. * Updates a particle : this function should be overwritten by the user.
  73384. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  73385. * doc :
  73386. * @example : just set a particle position or velocity and recycle conditions
  73387. * @param particle The particle to update
  73388. * @returns the updated particle
  73389. */
  73390. updateParticle(particle: CloudPoint): CloudPoint;
  73391. /**
  73392. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  73393. * This does nothing and may be overwritten by the user.
  73394. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73395. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73396. * @param update the boolean update value actually passed to setParticles()
  73397. */
  73398. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73399. /**
  73400. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  73401. * This will be passed three parameters.
  73402. * This does nothing and may be overwritten by the user.
  73403. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  73404. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  73405. * @param update the boolean update value actually passed to setParticles()
  73406. */
  73407. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  73408. }
  73409. }
  73410. declare module "babylonjs/Particles/cloudPoint" {
  73411. import { Nullable } from "babylonjs/types";
  73412. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  73413. import { Mesh } from "babylonjs/Meshes/mesh";
  73414. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  73415. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  73416. /**
  73417. * Represents one particle of a points cloud system.
  73418. */
  73419. export class CloudPoint {
  73420. /**
  73421. * particle global index
  73422. */
  73423. idx: number;
  73424. /**
  73425. * The color of the particle
  73426. */
  73427. color: Nullable<Color4>;
  73428. /**
  73429. * The world space position of the particle.
  73430. */
  73431. position: Vector3;
  73432. /**
  73433. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73434. */
  73435. rotation: Vector3;
  73436. /**
  73437. * The world space rotation quaternion of the particle.
  73438. */
  73439. rotationQuaternion: Nullable<Quaternion>;
  73440. /**
  73441. * The uv of the particle.
  73442. */
  73443. uv: Nullable<Vector2>;
  73444. /**
  73445. * The current speed of the particle.
  73446. */
  73447. velocity: Vector3;
  73448. /**
  73449. * The pivot point in the particle local space.
  73450. */
  73451. pivot: Vector3;
  73452. /**
  73453. * Must the particle be translated from its pivot point in its local space ?
  73454. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73455. * Default : false
  73456. */
  73457. translateFromPivot: boolean;
  73458. /**
  73459. * Index of this particle in the global "positions" array (Internal use)
  73460. * @hidden
  73461. */
  73462. _pos: number;
  73463. /**
  73464. * @hidden Index of this particle in the global "indices" array (Internal use)
  73465. */
  73466. _ind: number;
  73467. /**
  73468. * Group this particle belongs to
  73469. */
  73470. _group: PointsGroup;
  73471. /**
  73472. * Group id of this particle
  73473. */
  73474. groupId: number;
  73475. /**
  73476. * Index of the particle in its group id (Internal use)
  73477. */
  73478. idxInGroup: number;
  73479. /**
  73480. * @hidden Particle BoundingInfo object (Internal use)
  73481. */
  73482. _boundingInfo: BoundingInfo;
  73483. /**
  73484. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73485. */
  73486. _pcs: PointsCloudSystem;
  73487. /**
  73488. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73489. */
  73490. _stillInvisible: boolean;
  73491. /**
  73492. * @hidden Last computed particle rotation matrix
  73493. */
  73494. _rotationMatrix: number[];
  73495. /**
  73496. * Parent particle Id, if any.
  73497. * Default null.
  73498. */
  73499. parentId: Nullable<number>;
  73500. /**
  73501. * @hidden Internal global position in the PCS.
  73502. */
  73503. _globalPosition: Vector3;
  73504. /**
  73505. * Creates a Point Cloud object.
  73506. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73507. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73508. * @param group (PointsGroup) is the group the particle belongs to
  73509. * @param groupId (integer) is the group identifier in the PCS.
  73510. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73511. * @param pcs defines the PCS it is associated to
  73512. */
  73513. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73514. /**
  73515. * get point size
  73516. */
  73517. get size(): Vector3;
  73518. /**
  73519. * Set point size
  73520. */
  73521. set size(scale: Vector3);
  73522. /**
  73523. * Legacy support, changed quaternion to rotationQuaternion
  73524. */
  73525. get quaternion(): Nullable<Quaternion>;
  73526. /**
  73527. * Legacy support, changed quaternion to rotationQuaternion
  73528. */
  73529. set quaternion(q: Nullable<Quaternion>);
  73530. /**
  73531. * Returns a boolean. True if the particle intersects a mesh, else false
  73532. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73533. * @param target is the object (point or mesh) what the intersection is computed against
  73534. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73535. * @returns true if it intersects
  73536. */
  73537. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73538. /**
  73539. * get the rotation matrix of the particle
  73540. * @hidden
  73541. */
  73542. getRotationMatrix(m: Matrix): void;
  73543. }
  73544. /**
  73545. * Represents a group of points in a points cloud system
  73546. * * PCS internal tool, don't use it manually.
  73547. */
  73548. export class PointsGroup {
  73549. /**
  73550. * The group id
  73551. * @hidden
  73552. */
  73553. groupID: number;
  73554. /**
  73555. * image data for group (internal use)
  73556. * @hidden
  73557. */
  73558. _groupImageData: Nullable<ArrayBufferView>;
  73559. /**
  73560. * Image Width (internal use)
  73561. * @hidden
  73562. */
  73563. _groupImgWidth: number;
  73564. /**
  73565. * Image Height (internal use)
  73566. * @hidden
  73567. */
  73568. _groupImgHeight: number;
  73569. /**
  73570. * Custom position function (internal use)
  73571. * @hidden
  73572. */
  73573. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73574. /**
  73575. * density per facet for surface points
  73576. * @hidden
  73577. */
  73578. _groupDensity: number[];
  73579. /**
  73580. * Only when points are colored by texture carries pointer to texture list array
  73581. * @hidden
  73582. */
  73583. _textureNb: number;
  73584. /**
  73585. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73586. * PCS internal tool, don't use it manually.
  73587. * @hidden
  73588. */
  73589. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73590. }
  73591. }
  73592. declare module "babylonjs/Particles/index" {
  73593. export * from "babylonjs/Particles/baseParticleSystem";
  73594. export * from "babylonjs/Particles/EmitterTypes/index";
  73595. export * from "babylonjs/Particles/gpuParticleSystem";
  73596. export * from "babylonjs/Particles/IParticleSystem";
  73597. export * from "babylonjs/Particles/particle";
  73598. export * from "babylonjs/Particles/particleHelper";
  73599. export * from "babylonjs/Particles/particleSystem";
  73600. import "babylonjs/Particles/particleSystemComponent";
  73601. export * from "babylonjs/Particles/particleSystemComponent";
  73602. export * from "babylonjs/Particles/particleSystemSet";
  73603. export * from "babylonjs/Particles/solidParticle";
  73604. export * from "babylonjs/Particles/solidParticleSystem";
  73605. export * from "babylonjs/Particles/cloudPoint";
  73606. export * from "babylonjs/Particles/pointsCloudSystem";
  73607. export * from "babylonjs/Particles/subEmitter";
  73608. }
  73609. declare module "babylonjs/Physics/physicsEngineComponent" {
  73610. import { Nullable } from "babylonjs/types";
  73611. import { Observable, Observer } from "babylonjs/Misc/observable";
  73612. import { Vector3 } from "babylonjs/Maths/math.vector";
  73613. import { Mesh } from "babylonjs/Meshes/mesh";
  73614. import { ISceneComponent } from "babylonjs/sceneComponent";
  73615. import { Scene } from "babylonjs/scene";
  73616. import { Node } from "babylonjs/node";
  73617. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73618. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73619. module "babylonjs/scene" {
  73620. interface Scene {
  73621. /** @hidden (Backing field) */
  73622. _physicsEngine: Nullable<IPhysicsEngine>;
  73623. /** @hidden */
  73624. _physicsTimeAccumulator: number;
  73625. /**
  73626. * Gets the current physics engine
  73627. * @returns a IPhysicsEngine or null if none attached
  73628. */
  73629. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73630. /**
  73631. * Enables physics to the current scene
  73632. * @param gravity defines the scene's gravity for the physics engine
  73633. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73634. * @return a boolean indicating if the physics engine was initialized
  73635. */
  73636. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73637. /**
  73638. * Disables and disposes the physics engine associated with the scene
  73639. */
  73640. disablePhysicsEngine(): void;
  73641. /**
  73642. * Gets a boolean indicating if there is an active physics engine
  73643. * @returns a boolean indicating if there is an active physics engine
  73644. */
  73645. isPhysicsEnabled(): boolean;
  73646. /**
  73647. * Deletes a physics compound impostor
  73648. * @param compound defines the compound to delete
  73649. */
  73650. deleteCompoundImpostor(compound: any): void;
  73651. /**
  73652. * An event triggered when physic simulation is about to be run
  73653. */
  73654. onBeforePhysicsObservable: Observable<Scene>;
  73655. /**
  73656. * An event triggered when physic simulation has been done
  73657. */
  73658. onAfterPhysicsObservable: Observable<Scene>;
  73659. }
  73660. }
  73661. module "babylonjs/Meshes/abstractMesh" {
  73662. interface AbstractMesh {
  73663. /** @hidden */
  73664. _physicsImpostor: Nullable<PhysicsImpostor>;
  73665. /**
  73666. * Gets or sets impostor used for physic simulation
  73667. * @see https://doc.babylonjs.com/features/physics_engine
  73668. */
  73669. physicsImpostor: Nullable<PhysicsImpostor>;
  73670. /**
  73671. * Gets the current physics impostor
  73672. * @see https://doc.babylonjs.com/features/physics_engine
  73673. * @returns a physics impostor or null
  73674. */
  73675. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73676. /** Apply a physic impulse to the mesh
  73677. * @param force defines the force to apply
  73678. * @param contactPoint defines where to apply the force
  73679. * @returns the current mesh
  73680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73681. */
  73682. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73683. /**
  73684. * Creates a physic joint between two meshes
  73685. * @param otherMesh defines the other mesh to use
  73686. * @param pivot1 defines the pivot to use on this mesh
  73687. * @param pivot2 defines the pivot to use on the other mesh
  73688. * @param options defines additional options (can be plugin dependent)
  73689. * @returns the current mesh
  73690. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73691. */
  73692. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73693. /** @hidden */
  73694. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73695. }
  73696. }
  73697. /**
  73698. * Defines the physics engine scene component responsible to manage a physics engine
  73699. */
  73700. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73701. /**
  73702. * The component name helpful to identify the component in the list of scene components.
  73703. */
  73704. readonly name: string;
  73705. /**
  73706. * The scene the component belongs to.
  73707. */
  73708. scene: Scene;
  73709. /**
  73710. * Creates a new instance of the component for the given scene
  73711. * @param scene Defines the scene to register the component in
  73712. */
  73713. constructor(scene: Scene);
  73714. /**
  73715. * Registers the component in a given scene
  73716. */
  73717. register(): void;
  73718. /**
  73719. * Rebuilds the elements related to this component in case of
  73720. * context lost for instance.
  73721. */
  73722. rebuild(): void;
  73723. /**
  73724. * Disposes the component and the associated ressources
  73725. */
  73726. dispose(): void;
  73727. }
  73728. }
  73729. declare module "babylonjs/Physics/physicsHelper" {
  73730. import { Nullable } from "babylonjs/types";
  73731. import { Vector3 } from "babylonjs/Maths/math.vector";
  73732. import { Mesh } from "babylonjs/Meshes/mesh";
  73733. import { Scene } from "babylonjs/scene";
  73734. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73735. /**
  73736. * A helper for physics simulations
  73737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73738. */
  73739. export class PhysicsHelper {
  73740. private _scene;
  73741. private _physicsEngine;
  73742. /**
  73743. * Initializes the Physics helper
  73744. * @param scene Babylon.js scene
  73745. */
  73746. constructor(scene: Scene);
  73747. /**
  73748. * Applies a radial explosion impulse
  73749. * @param origin the origin of the explosion
  73750. * @param radiusOrEventOptions the radius or the options of radial explosion
  73751. * @param strength the explosion strength
  73752. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73753. * @returns A physics radial explosion event, or null
  73754. */
  73755. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73756. /**
  73757. * Applies a radial explosion force
  73758. * @param origin the origin of the explosion
  73759. * @param radiusOrEventOptions the radius or the options of radial explosion
  73760. * @param strength the explosion strength
  73761. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73762. * @returns A physics radial explosion event, or null
  73763. */
  73764. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73765. /**
  73766. * Creates a gravitational field
  73767. * @param origin the origin of the explosion
  73768. * @param radiusOrEventOptions the radius or the options of radial explosion
  73769. * @param strength the explosion strength
  73770. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73771. * @returns A physics gravitational field event, or null
  73772. */
  73773. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73774. /**
  73775. * Creates a physics updraft event
  73776. * @param origin the origin of the updraft
  73777. * @param radiusOrEventOptions the radius or the options of the updraft
  73778. * @param strength the strength of the updraft
  73779. * @param height the height of the updraft
  73780. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73781. * @returns A physics updraft event, or null
  73782. */
  73783. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73784. /**
  73785. * Creates a physics vortex event
  73786. * @param origin the of the vortex
  73787. * @param radiusOrEventOptions the radius or the options of the vortex
  73788. * @param strength the strength of the vortex
  73789. * @param height the height of the vortex
  73790. * @returns a Physics vortex event, or null
  73791. * A physics vortex event or null
  73792. */
  73793. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73794. }
  73795. /**
  73796. * Represents a physics radial explosion event
  73797. */
  73798. class PhysicsRadialExplosionEvent {
  73799. private _scene;
  73800. private _options;
  73801. private _sphere;
  73802. private _dataFetched;
  73803. /**
  73804. * Initializes a radial explosioin event
  73805. * @param _scene BabylonJS scene
  73806. * @param _options The options for the vortex event
  73807. */
  73808. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73809. /**
  73810. * Returns the data related to the radial explosion event (sphere).
  73811. * @returns The radial explosion event data
  73812. */
  73813. getData(): PhysicsRadialExplosionEventData;
  73814. /**
  73815. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73816. * @param impostor A physics imposter
  73817. * @param origin the origin of the explosion
  73818. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73819. */
  73820. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73821. /**
  73822. * Triggers affecterd impostors callbacks
  73823. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73824. */
  73825. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73826. /**
  73827. * Disposes the sphere.
  73828. * @param force Specifies if the sphere should be disposed by force
  73829. */
  73830. dispose(force?: boolean): void;
  73831. /*** Helpers ***/
  73832. private _prepareSphere;
  73833. private _intersectsWithSphere;
  73834. }
  73835. /**
  73836. * Represents a gravitational field event
  73837. */
  73838. class PhysicsGravitationalFieldEvent {
  73839. private _physicsHelper;
  73840. private _scene;
  73841. private _origin;
  73842. private _options;
  73843. private _tickCallback;
  73844. private _sphere;
  73845. private _dataFetched;
  73846. /**
  73847. * Initializes the physics gravitational field event
  73848. * @param _physicsHelper A physics helper
  73849. * @param _scene BabylonJS scene
  73850. * @param _origin The origin position of the gravitational field event
  73851. * @param _options The options for the vortex event
  73852. */
  73853. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73854. /**
  73855. * Returns the data related to the gravitational field event (sphere).
  73856. * @returns A gravitational field event
  73857. */
  73858. getData(): PhysicsGravitationalFieldEventData;
  73859. /**
  73860. * Enables the gravitational field.
  73861. */
  73862. enable(): void;
  73863. /**
  73864. * Disables the gravitational field.
  73865. */
  73866. disable(): void;
  73867. /**
  73868. * Disposes the sphere.
  73869. * @param force The force to dispose from the gravitational field event
  73870. */
  73871. dispose(force?: boolean): void;
  73872. private _tick;
  73873. }
  73874. /**
  73875. * Represents a physics updraft event
  73876. */
  73877. class PhysicsUpdraftEvent {
  73878. private _scene;
  73879. private _origin;
  73880. private _options;
  73881. private _physicsEngine;
  73882. private _originTop;
  73883. private _originDirection;
  73884. private _tickCallback;
  73885. private _cylinder;
  73886. private _cylinderPosition;
  73887. private _dataFetched;
  73888. /**
  73889. * Initializes the physics updraft event
  73890. * @param _scene BabylonJS scene
  73891. * @param _origin The origin position of the updraft
  73892. * @param _options The options for the updraft event
  73893. */
  73894. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73895. /**
  73896. * Returns the data related to the updraft event (cylinder).
  73897. * @returns A physics updraft event
  73898. */
  73899. getData(): PhysicsUpdraftEventData;
  73900. /**
  73901. * Enables the updraft.
  73902. */
  73903. enable(): void;
  73904. /**
  73905. * Disables the updraft.
  73906. */
  73907. disable(): void;
  73908. /**
  73909. * Disposes the cylinder.
  73910. * @param force Specifies if the updraft should be disposed by force
  73911. */
  73912. dispose(force?: boolean): void;
  73913. private getImpostorHitData;
  73914. private _tick;
  73915. /*** Helpers ***/
  73916. private _prepareCylinder;
  73917. private _intersectsWithCylinder;
  73918. }
  73919. /**
  73920. * Represents a physics vortex event
  73921. */
  73922. class PhysicsVortexEvent {
  73923. private _scene;
  73924. private _origin;
  73925. private _options;
  73926. private _physicsEngine;
  73927. private _originTop;
  73928. private _tickCallback;
  73929. private _cylinder;
  73930. private _cylinderPosition;
  73931. private _dataFetched;
  73932. /**
  73933. * Initializes the physics vortex event
  73934. * @param _scene The BabylonJS scene
  73935. * @param _origin The origin position of the vortex
  73936. * @param _options The options for the vortex event
  73937. */
  73938. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73939. /**
  73940. * Returns the data related to the vortex event (cylinder).
  73941. * @returns The physics vortex event data
  73942. */
  73943. getData(): PhysicsVortexEventData;
  73944. /**
  73945. * Enables the vortex.
  73946. */
  73947. enable(): void;
  73948. /**
  73949. * Disables the cortex.
  73950. */
  73951. disable(): void;
  73952. /**
  73953. * Disposes the sphere.
  73954. * @param force
  73955. */
  73956. dispose(force?: boolean): void;
  73957. private getImpostorHitData;
  73958. private _tick;
  73959. /*** Helpers ***/
  73960. private _prepareCylinder;
  73961. private _intersectsWithCylinder;
  73962. }
  73963. /**
  73964. * Options fot the radial explosion event
  73965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73966. */
  73967. export class PhysicsRadialExplosionEventOptions {
  73968. /**
  73969. * The radius of the sphere for the radial explosion.
  73970. */
  73971. radius: number;
  73972. /**
  73973. * The strenth of the explosion.
  73974. */
  73975. strength: number;
  73976. /**
  73977. * The strenght of the force in correspondence to the distance of the affected object
  73978. */
  73979. falloff: PhysicsRadialImpulseFalloff;
  73980. /**
  73981. * Sphere options for the radial explosion.
  73982. */
  73983. sphere: {
  73984. segments: number;
  73985. diameter: number;
  73986. };
  73987. /**
  73988. * Sphere options for the radial explosion.
  73989. */
  73990. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73991. }
  73992. /**
  73993. * Options fot the updraft event
  73994. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73995. */
  73996. export class PhysicsUpdraftEventOptions {
  73997. /**
  73998. * The radius of the cylinder for the vortex
  73999. */
  74000. radius: number;
  74001. /**
  74002. * The strenth of the updraft.
  74003. */
  74004. strength: number;
  74005. /**
  74006. * The height of the cylinder for the updraft.
  74007. */
  74008. height: number;
  74009. /**
  74010. * The mode for the the updraft.
  74011. */
  74012. updraftMode: PhysicsUpdraftMode;
  74013. }
  74014. /**
  74015. * Options fot the vortex event
  74016. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74017. */
  74018. export class PhysicsVortexEventOptions {
  74019. /**
  74020. * The radius of the cylinder for the vortex
  74021. */
  74022. radius: number;
  74023. /**
  74024. * The strenth of the vortex.
  74025. */
  74026. strength: number;
  74027. /**
  74028. * The height of the cylinder for the vortex.
  74029. */
  74030. height: number;
  74031. /**
  74032. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  74033. */
  74034. centripetalForceThreshold: number;
  74035. /**
  74036. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  74037. */
  74038. centripetalForceMultiplier: number;
  74039. /**
  74040. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  74041. */
  74042. centrifugalForceMultiplier: number;
  74043. /**
  74044. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  74045. */
  74046. updraftForceMultiplier: number;
  74047. }
  74048. /**
  74049. * The strenght of the force in correspondence to the distance of the affected object
  74050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74051. */
  74052. export enum PhysicsRadialImpulseFalloff {
  74053. /** Defines that impulse is constant in strength across it's whole radius */
  74054. Constant = 0,
  74055. /** Defines that impulse gets weaker if it's further from the origin */
  74056. Linear = 1
  74057. }
  74058. /**
  74059. * The strength of the force in correspondence to the distance of the affected object
  74060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74061. */
  74062. export enum PhysicsUpdraftMode {
  74063. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  74064. Center = 0,
  74065. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  74066. Perpendicular = 1
  74067. }
  74068. /**
  74069. * Interface for a physics hit data
  74070. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74071. */
  74072. export interface PhysicsHitData {
  74073. /**
  74074. * The force applied at the contact point
  74075. */
  74076. force: Vector3;
  74077. /**
  74078. * The contact point
  74079. */
  74080. contactPoint: Vector3;
  74081. /**
  74082. * The distance from the origin to the contact point
  74083. */
  74084. distanceFromOrigin: number;
  74085. }
  74086. /**
  74087. * Interface for radial explosion event data
  74088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74089. */
  74090. export interface PhysicsRadialExplosionEventData {
  74091. /**
  74092. * A sphere used for the radial explosion event
  74093. */
  74094. sphere: Mesh;
  74095. }
  74096. /**
  74097. * Interface for gravitational field event data
  74098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74099. */
  74100. export interface PhysicsGravitationalFieldEventData {
  74101. /**
  74102. * A sphere mesh used for the gravitational field event
  74103. */
  74104. sphere: Mesh;
  74105. }
  74106. /**
  74107. * Interface for updraft event data
  74108. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74109. */
  74110. export interface PhysicsUpdraftEventData {
  74111. /**
  74112. * A cylinder used for the updraft event
  74113. */
  74114. cylinder: Mesh;
  74115. }
  74116. /**
  74117. * Interface for vortex event data
  74118. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74119. */
  74120. export interface PhysicsVortexEventData {
  74121. /**
  74122. * A cylinder used for the vortex event
  74123. */
  74124. cylinder: Mesh;
  74125. }
  74126. /**
  74127. * Interface for an affected physics impostor
  74128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  74129. */
  74130. export interface PhysicsAffectedImpostorWithData {
  74131. /**
  74132. * The impostor affected by the effect
  74133. */
  74134. impostor: PhysicsImpostor;
  74135. /**
  74136. * The data about the hit/horce from the explosion
  74137. */
  74138. hitData: PhysicsHitData;
  74139. }
  74140. }
  74141. declare module "babylonjs/Physics/Plugins/index" {
  74142. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  74143. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  74144. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  74145. }
  74146. declare module "babylonjs/Physics/index" {
  74147. export * from "babylonjs/Physics/IPhysicsEngine";
  74148. export * from "babylonjs/Physics/physicsEngine";
  74149. export * from "babylonjs/Physics/physicsEngineComponent";
  74150. export * from "babylonjs/Physics/physicsHelper";
  74151. export * from "babylonjs/Physics/physicsImpostor";
  74152. export * from "babylonjs/Physics/physicsJoint";
  74153. export * from "babylonjs/Physics/Plugins/index";
  74154. }
  74155. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  74156. /** @hidden */
  74157. export var blackAndWhitePixelShader: {
  74158. name: string;
  74159. shader: string;
  74160. };
  74161. }
  74162. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  74163. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74164. import { Camera } from "babylonjs/Cameras/camera";
  74165. import { Engine } from "babylonjs/Engines/engine";
  74166. import "babylonjs/Shaders/blackAndWhite.fragment";
  74167. import { Nullable } from "babylonjs/types";
  74168. import { Scene } from "babylonjs/scene";
  74169. /**
  74170. * Post process used to render in black and white
  74171. */
  74172. export class BlackAndWhitePostProcess extends PostProcess {
  74173. /**
  74174. * Linear about to convert he result to black and white (default: 1)
  74175. */
  74176. degree: number;
  74177. /**
  74178. * Gets a string identifying the name of the class
  74179. * @returns "BlackAndWhitePostProcess" string
  74180. */
  74181. getClassName(): string;
  74182. /**
  74183. * Creates a black and white post process
  74184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  74185. * @param name The name of the effect.
  74186. * @param options The required width/height ratio to downsize to before computing the render pass.
  74187. * @param camera The camera to apply the render pass to.
  74188. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74189. * @param engine The engine which the post process will be applied. (default: current engine)
  74190. * @param reusable If the post process can be reused on the same frame. (default: false)
  74191. */
  74192. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74193. /** @hidden */
  74194. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  74195. }
  74196. }
  74197. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  74198. import { Nullable } from "babylonjs/types";
  74199. import { Camera } from "babylonjs/Cameras/camera";
  74200. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74201. import { Engine } from "babylonjs/Engines/engine";
  74202. /**
  74203. * This represents a set of one or more post processes in Babylon.
  74204. * A post process can be used to apply a shader to a texture after it is rendered.
  74205. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74206. */
  74207. export class PostProcessRenderEffect {
  74208. private _postProcesses;
  74209. private _getPostProcesses;
  74210. private _singleInstance;
  74211. private _cameras;
  74212. private _indicesForCamera;
  74213. /**
  74214. * Name of the effect
  74215. * @hidden
  74216. */
  74217. _name: string;
  74218. /**
  74219. * Instantiates a post process render effect.
  74220. * A post process can be used to apply a shader to a texture after it is rendered.
  74221. * @param engine The engine the effect is tied to
  74222. * @param name The name of the effect
  74223. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  74224. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  74225. */
  74226. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  74227. /**
  74228. * Checks if all the post processes in the effect are supported.
  74229. */
  74230. get isSupported(): boolean;
  74231. /**
  74232. * Updates the current state of the effect
  74233. * @hidden
  74234. */
  74235. _update(): void;
  74236. /**
  74237. * Attaches the effect on cameras
  74238. * @param cameras The camera to attach to.
  74239. * @hidden
  74240. */
  74241. _attachCameras(cameras: Camera): void;
  74242. /**
  74243. * Attaches the effect on cameras
  74244. * @param cameras The camera to attach to.
  74245. * @hidden
  74246. */
  74247. _attachCameras(cameras: Camera[]): void;
  74248. /**
  74249. * Detaches the effect on cameras
  74250. * @param cameras The camera to detatch from.
  74251. * @hidden
  74252. */
  74253. _detachCameras(cameras: Camera): void;
  74254. /**
  74255. * Detatches the effect on cameras
  74256. * @param cameras The camera to detatch from.
  74257. * @hidden
  74258. */
  74259. _detachCameras(cameras: Camera[]): void;
  74260. /**
  74261. * Enables the effect on given cameras
  74262. * @param cameras The camera to enable.
  74263. * @hidden
  74264. */
  74265. _enable(cameras: Camera): void;
  74266. /**
  74267. * Enables the effect on given cameras
  74268. * @param cameras The camera to enable.
  74269. * @hidden
  74270. */
  74271. _enable(cameras: Nullable<Camera[]>): void;
  74272. /**
  74273. * Disables the effect on the given cameras
  74274. * @param cameras The camera to disable.
  74275. * @hidden
  74276. */
  74277. _disable(cameras: Camera): void;
  74278. /**
  74279. * Disables the effect on the given cameras
  74280. * @param cameras The camera to disable.
  74281. * @hidden
  74282. */
  74283. _disable(cameras: Nullable<Camera[]>): void;
  74284. /**
  74285. * Gets a list of the post processes contained in the effect.
  74286. * @param camera The camera to get the post processes on.
  74287. * @returns The list of the post processes in the effect.
  74288. */
  74289. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  74290. }
  74291. }
  74292. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  74293. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74294. /** @hidden */
  74295. export var extractHighlightsPixelShader: {
  74296. name: string;
  74297. shader: string;
  74298. };
  74299. }
  74300. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  74301. import { Nullable } from "babylonjs/types";
  74302. import { Camera } from "babylonjs/Cameras/camera";
  74303. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74304. import { Engine } from "babylonjs/Engines/engine";
  74305. import "babylonjs/Shaders/extractHighlights.fragment";
  74306. /**
  74307. * 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.
  74308. */
  74309. export class ExtractHighlightsPostProcess extends PostProcess {
  74310. /**
  74311. * The luminance threshold, pixels below this value will be set to black.
  74312. */
  74313. threshold: number;
  74314. /** @hidden */
  74315. _exposure: number;
  74316. /**
  74317. * Post process which has the input texture to be used when performing highlight extraction
  74318. * @hidden
  74319. */
  74320. _inputPostProcess: Nullable<PostProcess>;
  74321. /**
  74322. * Gets a string identifying the name of the class
  74323. * @returns "ExtractHighlightsPostProcess" string
  74324. */
  74325. getClassName(): string;
  74326. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74327. }
  74328. }
  74329. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  74330. /** @hidden */
  74331. export var bloomMergePixelShader: {
  74332. name: string;
  74333. shader: string;
  74334. };
  74335. }
  74336. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  74337. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74338. import { Nullable } from "babylonjs/types";
  74339. import { Engine } from "babylonjs/Engines/engine";
  74340. import { Camera } from "babylonjs/Cameras/camera";
  74341. import "babylonjs/Shaders/bloomMerge.fragment";
  74342. /**
  74343. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74344. */
  74345. export class BloomMergePostProcess extends PostProcess {
  74346. /** Weight of the bloom to be added to the original input. */
  74347. weight: number;
  74348. /**
  74349. * Gets a string identifying the name of the class
  74350. * @returns "BloomMergePostProcess" string
  74351. */
  74352. getClassName(): string;
  74353. /**
  74354. * Creates a new instance of @see BloomMergePostProcess
  74355. * @param name The name of the effect.
  74356. * @param originalFromInput Post process which's input will be used for the merge.
  74357. * @param blurred Blurred highlights post process which's output will be used.
  74358. * @param weight Weight of the bloom to be added to the original input.
  74359. * @param options The required width/height ratio to downsize to before computing the render pass.
  74360. * @param camera The camera to apply the render pass to.
  74361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74362. * @param engine The engine which the post process will be applied. (default: current engine)
  74363. * @param reusable If the post process can be reused on the same frame. (default: false)
  74364. * @param textureType Type of textures used when performing the post process. (default: 0)
  74365. * @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)
  74366. */
  74367. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  74368. /** Weight of the bloom to be added to the original input. */
  74369. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74370. }
  74371. }
  74372. declare module "babylonjs/PostProcesses/bloomEffect" {
  74373. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74374. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74375. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74376. import { Camera } from "babylonjs/Cameras/camera";
  74377. import { Scene } from "babylonjs/scene";
  74378. /**
  74379. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  74380. */
  74381. export class BloomEffect extends PostProcessRenderEffect {
  74382. private bloomScale;
  74383. /**
  74384. * @hidden Internal
  74385. */
  74386. _effects: Array<PostProcess>;
  74387. /**
  74388. * @hidden Internal
  74389. */
  74390. _downscale: ExtractHighlightsPostProcess;
  74391. private _blurX;
  74392. private _blurY;
  74393. private _merge;
  74394. /**
  74395. * The luminance threshold to find bright areas of the image to bloom.
  74396. */
  74397. get threshold(): number;
  74398. set threshold(value: number);
  74399. /**
  74400. * The strength of the bloom.
  74401. */
  74402. get weight(): number;
  74403. set weight(value: number);
  74404. /**
  74405. * Specifies the size of the bloom blur kernel, relative to the final output size
  74406. */
  74407. get kernel(): number;
  74408. set kernel(value: number);
  74409. /**
  74410. * Creates a new instance of @see BloomEffect
  74411. * @param scene The scene the effect belongs to.
  74412. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  74413. * @param bloomKernel The size of the kernel to be used when applying the blur.
  74414. * @param bloomWeight The the strength of bloom.
  74415. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74416. * @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)
  74417. */
  74418. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  74419. /**
  74420. * Disposes each of the internal effects for a given camera.
  74421. * @param camera The camera to dispose the effect on.
  74422. */
  74423. disposeEffects(camera: Camera): void;
  74424. /**
  74425. * @hidden Internal
  74426. */
  74427. _updateEffects(): void;
  74428. /**
  74429. * Internal
  74430. * @returns if all the contained post processes are ready.
  74431. * @hidden
  74432. */
  74433. _isReady(): boolean;
  74434. }
  74435. }
  74436. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74437. /** @hidden */
  74438. export var chromaticAberrationPixelShader: {
  74439. name: string;
  74440. shader: string;
  74441. };
  74442. }
  74443. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74444. import { Vector2 } from "babylonjs/Maths/math.vector";
  74445. import { Nullable } from "babylonjs/types";
  74446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74447. import { Camera } from "babylonjs/Cameras/camera";
  74448. import { Engine } from "babylonjs/Engines/engine";
  74449. import "babylonjs/Shaders/chromaticAberration.fragment";
  74450. import { Scene } from "babylonjs/scene";
  74451. /**
  74452. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74453. */
  74454. export class ChromaticAberrationPostProcess extends PostProcess {
  74455. /**
  74456. * The amount of seperation of rgb channels (default: 30)
  74457. */
  74458. aberrationAmount: number;
  74459. /**
  74460. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74461. */
  74462. radialIntensity: number;
  74463. /**
  74464. * 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))
  74465. */
  74466. direction: Vector2;
  74467. /**
  74468. * 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))
  74469. */
  74470. centerPosition: Vector2;
  74471. /** The width of the screen to apply the effect on */
  74472. screenWidth: number;
  74473. /** The height of the screen to apply the effect on */
  74474. screenHeight: number;
  74475. /**
  74476. * Gets a string identifying the name of the class
  74477. * @returns "ChromaticAberrationPostProcess" string
  74478. */
  74479. getClassName(): string;
  74480. /**
  74481. * Creates a new instance ChromaticAberrationPostProcess
  74482. * @param name The name of the effect.
  74483. * @param screenWidth The width of the screen to apply the effect on.
  74484. * @param screenHeight The height of the screen to apply the effect on.
  74485. * @param options The required width/height ratio to downsize to before computing the render pass.
  74486. * @param camera The camera to apply the render pass to.
  74487. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74488. * @param engine The engine which the post process will be applied. (default: current engine)
  74489. * @param reusable If the post process can be reused on the same frame. (default: false)
  74490. * @param textureType Type of textures used when performing the post process. (default: 0)
  74491. * @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)
  74492. */
  74493. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74494. /** @hidden */
  74495. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74496. }
  74497. }
  74498. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74499. /** @hidden */
  74500. export var circleOfConfusionPixelShader: {
  74501. name: string;
  74502. shader: string;
  74503. };
  74504. }
  74505. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74506. import { Nullable } from "babylonjs/types";
  74507. import { Engine } from "babylonjs/Engines/engine";
  74508. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74509. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74510. import { Camera } from "babylonjs/Cameras/camera";
  74511. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74512. /**
  74513. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74514. */
  74515. export class CircleOfConfusionPostProcess extends PostProcess {
  74516. /**
  74517. * 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.
  74518. */
  74519. lensSize: number;
  74520. /**
  74521. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74522. */
  74523. fStop: number;
  74524. /**
  74525. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74526. */
  74527. focusDistance: number;
  74528. /**
  74529. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74530. */
  74531. focalLength: number;
  74532. /**
  74533. * Gets a string identifying the name of the class
  74534. * @returns "CircleOfConfusionPostProcess" string
  74535. */
  74536. getClassName(): string;
  74537. private _depthTexture;
  74538. /**
  74539. * Creates a new instance CircleOfConfusionPostProcess
  74540. * @param name The name of the effect.
  74541. * @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.
  74542. * @param options The required width/height ratio to downsize to before computing the render pass.
  74543. * @param camera The camera to apply the render pass to.
  74544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74545. * @param engine The engine which the post process will be applied. (default: current engine)
  74546. * @param reusable If the post process can be reused on the same frame. (default: false)
  74547. * @param textureType Type of textures used when performing the post process. (default: 0)
  74548. * @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)
  74549. */
  74550. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74551. /**
  74552. * 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.
  74553. */
  74554. set depthTexture(value: RenderTargetTexture);
  74555. }
  74556. }
  74557. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74558. /** @hidden */
  74559. export var colorCorrectionPixelShader: {
  74560. name: string;
  74561. shader: string;
  74562. };
  74563. }
  74564. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74565. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74566. import { Engine } from "babylonjs/Engines/engine";
  74567. import { Camera } from "babylonjs/Cameras/camera";
  74568. import "babylonjs/Shaders/colorCorrection.fragment";
  74569. import { Nullable } from "babylonjs/types";
  74570. import { Scene } from "babylonjs/scene";
  74571. /**
  74572. *
  74573. * This post-process allows the modification of rendered colors by using
  74574. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74575. *
  74576. * The object needs to be provided an url to a texture containing the color
  74577. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74578. * Use an image editing software to tweak the LUT to match your needs.
  74579. *
  74580. * For an example of a color LUT, see here:
  74581. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74582. * For explanations on color grading, see here:
  74583. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74584. *
  74585. */
  74586. export class ColorCorrectionPostProcess extends PostProcess {
  74587. private _colorTableTexture;
  74588. /**
  74589. * Gets the color table url used to create the LUT texture
  74590. */
  74591. colorTableUrl: string;
  74592. /**
  74593. * Gets a string identifying the name of the class
  74594. * @returns "ColorCorrectionPostProcess" string
  74595. */
  74596. getClassName(): string;
  74597. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74598. /** @hidden */
  74599. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74600. }
  74601. }
  74602. declare module "babylonjs/Shaders/convolution.fragment" {
  74603. /** @hidden */
  74604. export var convolutionPixelShader: {
  74605. name: string;
  74606. shader: string;
  74607. };
  74608. }
  74609. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74611. import { Nullable } from "babylonjs/types";
  74612. import { Camera } from "babylonjs/Cameras/camera";
  74613. import { Engine } from "babylonjs/Engines/engine";
  74614. import "babylonjs/Shaders/convolution.fragment";
  74615. import { Scene } from "babylonjs/scene";
  74616. /**
  74617. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74618. * input texture to perform effects such as edge detection or sharpening
  74619. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74620. */
  74621. export class ConvolutionPostProcess extends PostProcess {
  74622. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74623. kernel: number[];
  74624. /**
  74625. * Gets a string identifying the name of the class
  74626. * @returns "ConvolutionPostProcess" string
  74627. */
  74628. getClassName(): string;
  74629. /**
  74630. * Creates a new instance ConvolutionPostProcess
  74631. * @param name The name of the effect.
  74632. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74633. * @param options The required width/height ratio to downsize to before computing the render pass.
  74634. * @param camera The camera to apply the render pass to.
  74635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74636. * @param engine The engine which the post process will be applied. (default: current engine)
  74637. * @param reusable If the post process can be reused on the same frame. (default: false)
  74638. * @param textureType Type of textures used when performing the post process. (default: 0)
  74639. */
  74640. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74641. /** @hidden */
  74642. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74643. /**
  74644. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74645. */
  74646. static EdgeDetect0Kernel: number[];
  74647. /**
  74648. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74649. */
  74650. static EdgeDetect1Kernel: number[];
  74651. /**
  74652. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74653. */
  74654. static EdgeDetect2Kernel: number[];
  74655. /**
  74656. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74657. */
  74658. static SharpenKernel: number[];
  74659. /**
  74660. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74661. */
  74662. static EmbossKernel: number[];
  74663. /**
  74664. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74665. */
  74666. static GaussianKernel: number[];
  74667. }
  74668. }
  74669. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74670. import { Nullable } from "babylonjs/types";
  74671. import { Vector2 } from "babylonjs/Maths/math.vector";
  74672. import { Camera } from "babylonjs/Cameras/camera";
  74673. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74674. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74675. import { Engine } from "babylonjs/Engines/engine";
  74676. import { Scene } from "babylonjs/scene";
  74677. /**
  74678. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74679. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74680. * based on samples that have a large difference in distance than the center pixel.
  74681. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74682. */
  74683. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74684. /**
  74685. * The direction the blur should be applied
  74686. */
  74687. direction: Vector2;
  74688. /**
  74689. * Gets a string identifying the name of the class
  74690. * @returns "DepthOfFieldBlurPostProcess" string
  74691. */
  74692. getClassName(): string;
  74693. /**
  74694. * Creates a new instance CircleOfConfusionPostProcess
  74695. * @param name The name of the effect.
  74696. * @param scene The scene the effect belongs to.
  74697. * @param direction The direction the blur should be applied.
  74698. * @param kernel The size of the kernel used to blur.
  74699. * @param options The required width/height ratio to downsize to before computing the render pass.
  74700. * @param camera The camera to apply the render pass to.
  74701. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74702. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74704. * @param engine The engine which the post process will be applied. (default: current engine)
  74705. * @param reusable If the post process can be reused on the same frame. (default: false)
  74706. * @param textureType Type of textures used when performing the post process. (default: 0)
  74707. * @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)
  74708. */
  74709. 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);
  74710. }
  74711. }
  74712. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74713. /** @hidden */
  74714. export var depthOfFieldMergePixelShader: {
  74715. name: string;
  74716. shader: string;
  74717. };
  74718. }
  74719. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74720. import { Nullable } from "babylonjs/types";
  74721. import { Camera } from "babylonjs/Cameras/camera";
  74722. import { Effect } from "babylonjs/Materials/effect";
  74723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74724. import { Engine } from "babylonjs/Engines/engine";
  74725. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74726. /**
  74727. * Options to be set when merging outputs from the default pipeline.
  74728. */
  74729. export class DepthOfFieldMergePostProcessOptions {
  74730. /**
  74731. * The original image to merge on top of
  74732. */
  74733. originalFromInput: PostProcess;
  74734. /**
  74735. * Parameters to perform the merge of the depth of field effect
  74736. */
  74737. depthOfField?: {
  74738. circleOfConfusion: PostProcess;
  74739. blurSteps: Array<PostProcess>;
  74740. };
  74741. /**
  74742. * Parameters to perform the merge of bloom effect
  74743. */
  74744. bloom?: {
  74745. blurred: PostProcess;
  74746. weight: number;
  74747. };
  74748. }
  74749. /**
  74750. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74751. */
  74752. export class DepthOfFieldMergePostProcess extends PostProcess {
  74753. private blurSteps;
  74754. /**
  74755. * Gets a string identifying the name of the class
  74756. * @returns "DepthOfFieldMergePostProcess" string
  74757. */
  74758. getClassName(): string;
  74759. /**
  74760. * Creates a new instance of DepthOfFieldMergePostProcess
  74761. * @param name The name of the effect.
  74762. * @param originalFromInput Post process which's input will be used for the merge.
  74763. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74764. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74765. * @param options The required width/height ratio to downsize to before computing the render pass.
  74766. * @param camera The camera to apply the render pass to.
  74767. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74768. * @param engine The engine which the post process will be applied. (default: current engine)
  74769. * @param reusable If the post process can be reused on the same frame. (default: false)
  74770. * @param textureType Type of textures used when performing the post process. (default: 0)
  74771. * @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)
  74772. */
  74773. 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);
  74774. /**
  74775. * Updates the effect with the current post process compile time values and recompiles the shader.
  74776. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74777. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74778. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74779. * @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
  74780. * @param onCompiled Called when the shader has been compiled.
  74781. * @param onError Called if there is an error when compiling a shader.
  74782. */
  74783. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74784. }
  74785. }
  74786. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74787. import { Nullable } from "babylonjs/types";
  74788. import { Camera } from "babylonjs/Cameras/camera";
  74789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74790. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74791. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74792. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74793. import { Scene } from "babylonjs/scene";
  74794. /**
  74795. * Specifies the level of max blur that should be applied when using the depth of field effect
  74796. */
  74797. export enum DepthOfFieldEffectBlurLevel {
  74798. /**
  74799. * Subtle blur
  74800. */
  74801. Low = 0,
  74802. /**
  74803. * Medium blur
  74804. */
  74805. Medium = 1,
  74806. /**
  74807. * Large blur
  74808. */
  74809. High = 2
  74810. }
  74811. /**
  74812. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74813. */
  74814. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74815. private _circleOfConfusion;
  74816. /**
  74817. * @hidden Internal, blurs from high to low
  74818. */
  74819. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74820. private _depthOfFieldBlurY;
  74821. private _dofMerge;
  74822. /**
  74823. * @hidden Internal post processes in depth of field effect
  74824. */
  74825. _effects: Array<PostProcess>;
  74826. /**
  74827. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74828. */
  74829. set focalLength(value: number);
  74830. get focalLength(): number;
  74831. /**
  74832. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74833. */
  74834. set fStop(value: number);
  74835. get fStop(): number;
  74836. /**
  74837. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74838. */
  74839. set focusDistance(value: number);
  74840. get focusDistance(): number;
  74841. /**
  74842. * 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.
  74843. */
  74844. set lensSize(value: number);
  74845. get lensSize(): number;
  74846. /**
  74847. * Creates a new instance DepthOfFieldEffect
  74848. * @param scene The scene the effect belongs to.
  74849. * @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.
  74850. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74851. * @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)
  74852. */
  74853. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74854. /**
  74855. * Get the current class name of the current effet
  74856. * @returns "DepthOfFieldEffect"
  74857. */
  74858. getClassName(): string;
  74859. /**
  74860. * 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.
  74861. */
  74862. set depthTexture(value: RenderTargetTexture);
  74863. /**
  74864. * Disposes each of the internal effects for a given camera.
  74865. * @param camera The camera to dispose the effect on.
  74866. */
  74867. disposeEffects(camera: Camera): void;
  74868. /**
  74869. * @hidden Internal
  74870. */
  74871. _updateEffects(): void;
  74872. /**
  74873. * Internal
  74874. * @returns if all the contained post processes are ready.
  74875. * @hidden
  74876. */
  74877. _isReady(): boolean;
  74878. }
  74879. }
  74880. declare module "babylonjs/Shaders/displayPass.fragment" {
  74881. /** @hidden */
  74882. export var displayPassPixelShader: {
  74883. name: string;
  74884. shader: string;
  74885. };
  74886. }
  74887. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74888. import { Nullable } from "babylonjs/types";
  74889. import { Camera } from "babylonjs/Cameras/camera";
  74890. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74891. import { Engine } from "babylonjs/Engines/engine";
  74892. import "babylonjs/Shaders/displayPass.fragment";
  74893. import { Scene } from "babylonjs/scene";
  74894. /**
  74895. * DisplayPassPostProcess which produces an output the same as it's input
  74896. */
  74897. export class DisplayPassPostProcess extends PostProcess {
  74898. /**
  74899. * Gets a string identifying the name of the class
  74900. * @returns "DisplayPassPostProcess" string
  74901. */
  74902. getClassName(): string;
  74903. /**
  74904. * Creates the DisplayPassPostProcess
  74905. * @param name The name of the effect.
  74906. * @param options The required width/height ratio to downsize to before computing the render pass.
  74907. * @param camera The camera to apply the render pass to.
  74908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74909. * @param engine The engine which the post process will be applied. (default: current engine)
  74910. * @param reusable If the post process can be reused on the same frame. (default: false)
  74911. */
  74912. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74913. /** @hidden */
  74914. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74915. }
  74916. }
  74917. declare module "babylonjs/Shaders/filter.fragment" {
  74918. /** @hidden */
  74919. export var filterPixelShader: {
  74920. name: string;
  74921. shader: string;
  74922. };
  74923. }
  74924. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74925. import { Nullable } from "babylonjs/types";
  74926. import { Matrix } from "babylonjs/Maths/math.vector";
  74927. import { Camera } from "babylonjs/Cameras/camera";
  74928. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74929. import { Engine } from "babylonjs/Engines/engine";
  74930. import "babylonjs/Shaders/filter.fragment";
  74931. import { Scene } from "babylonjs/scene";
  74932. /**
  74933. * Applies a kernel filter to the image
  74934. */
  74935. export class FilterPostProcess extends PostProcess {
  74936. /** The matrix to be applied to the image */
  74937. kernelMatrix: Matrix;
  74938. /**
  74939. * Gets a string identifying the name of the class
  74940. * @returns "FilterPostProcess" string
  74941. */
  74942. getClassName(): string;
  74943. /**
  74944. *
  74945. * @param name The name of the effect.
  74946. * @param kernelMatrix The matrix to be applied to the image
  74947. * @param options The required width/height ratio to downsize to before computing the render pass.
  74948. * @param camera The camera to apply the render pass to.
  74949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74950. * @param engine The engine which the post process will be applied. (default: current engine)
  74951. * @param reusable If the post process can be reused on the same frame. (default: false)
  74952. */
  74953. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74954. /** @hidden */
  74955. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74956. }
  74957. }
  74958. declare module "babylonjs/Shaders/fxaa.fragment" {
  74959. /** @hidden */
  74960. export var fxaaPixelShader: {
  74961. name: string;
  74962. shader: string;
  74963. };
  74964. }
  74965. declare module "babylonjs/Shaders/fxaa.vertex" {
  74966. /** @hidden */
  74967. export var fxaaVertexShader: {
  74968. name: string;
  74969. shader: string;
  74970. };
  74971. }
  74972. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74973. import { Nullable } from "babylonjs/types";
  74974. import { Camera } from "babylonjs/Cameras/camera";
  74975. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74976. import { Engine } from "babylonjs/Engines/engine";
  74977. import "babylonjs/Shaders/fxaa.fragment";
  74978. import "babylonjs/Shaders/fxaa.vertex";
  74979. import { Scene } from "babylonjs/scene";
  74980. /**
  74981. * Fxaa post process
  74982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74983. */
  74984. export class FxaaPostProcess extends PostProcess {
  74985. /**
  74986. * Gets a string identifying the name of the class
  74987. * @returns "FxaaPostProcess" string
  74988. */
  74989. getClassName(): string;
  74990. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74991. private _getDefines;
  74992. /** @hidden */
  74993. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74994. }
  74995. }
  74996. declare module "babylonjs/Shaders/grain.fragment" {
  74997. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74998. /** @hidden */
  74999. export var grainPixelShader: {
  75000. name: string;
  75001. shader: string;
  75002. };
  75003. }
  75004. declare module "babylonjs/PostProcesses/grainPostProcess" {
  75005. import { Nullable } from "babylonjs/types";
  75006. import { Camera } from "babylonjs/Cameras/camera";
  75007. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75008. import { Engine } from "babylonjs/Engines/engine";
  75009. import "babylonjs/Shaders/grain.fragment";
  75010. import { Scene } from "babylonjs/scene";
  75011. /**
  75012. * The GrainPostProcess adds noise to the image at mid luminance levels
  75013. */
  75014. export class GrainPostProcess extends PostProcess {
  75015. /**
  75016. * The intensity of the grain added (default: 30)
  75017. */
  75018. intensity: number;
  75019. /**
  75020. * If the grain should be randomized on every frame
  75021. */
  75022. animated: boolean;
  75023. /**
  75024. * Gets a string identifying the name of the class
  75025. * @returns "GrainPostProcess" string
  75026. */
  75027. getClassName(): string;
  75028. /**
  75029. * Creates a new instance of @see GrainPostProcess
  75030. * @param name The name of the effect.
  75031. * @param options The required width/height ratio to downsize to before computing the render pass.
  75032. * @param camera The camera to apply the render pass to.
  75033. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75034. * @param engine The engine which the post process will be applied. (default: current engine)
  75035. * @param reusable If the post process can be reused on the same frame. (default: false)
  75036. * @param textureType Type of textures used when performing the post process. (default: 0)
  75037. * @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)
  75038. */
  75039. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75040. /** @hidden */
  75041. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  75042. }
  75043. }
  75044. declare module "babylonjs/Shaders/highlights.fragment" {
  75045. /** @hidden */
  75046. export var highlightsPixelShader: {
  75047. name: string;
  75048. shader: string;
  75049. };
  75050. }
  75051. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  75052. import { Nullable } from "babylonjs/types";
  75053. import { Camera } from "babylonjs/Cameras/camera";
  75054. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75055. import { Engine } from "babylonjs/Engines/engine";
  75056. import "babylonjs/Shaders/highlights.fragment";
  75057. /**
  75058. * Extracts highlights from the image
  75059. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75060. */
  75061. export class HighlightsPostProcess extends PostProcess {
  75062. /**
  75063. * Gets a string identifying the name of the class
  75064. * @returns "HighlightsPostProcess" string
  75065. */
  75066. getClassName(): string;
  75067. /**
  75068. * Extracts highlights from the image
  75069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75070. * @param name The name of the effect.
  75071. * @param options The required width/height ratio to downsize to before computing the render pass.
  75072. * @param camera The camera to apply the render pass to.
  75073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75074. * @param engine The engine which the post process will be applied. (default: current engine)
  75075. * @param reusable If the post process can be reused on the same frame. (default: false)
  75076. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  75077. */
  75078. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  75079. }
  75080. }
  75081. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  75082. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75083. /**
  75084. * Contains all parameters needed for the prepass to perform
  75085. * motion blur
  75086. */
  75087. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  75088. /**
  75089. * Is motion blur enabled
  75090. */
  75091. enabled: boolean;
  75092. /**
  75093. * Name of the configuration
  75094. */
  75095. name: string;
  75096. /**
  75097. * Textures that should be present in the MRT for this effect to work
  75098. */
  75099. readonly texturesRequired: number[];
  75100. }
  75101. }
  75102. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  75103. import { Nullable } from "babylonjs/types";
  75104. import { Scene } from "babylonjs/scene";
  75105. import { ISceneComponent } from "babylonjs/sceneComponent";
  75106. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  75107. module "babylonjs/scene" {
  75108. interface Scene {
  75109. /** @hidden (Backing field) */
  75110. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75111. /**
  75112. * Gets or Sets the current geometry buffer associated to the scene.
  75113. */
  75114. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  75115. /**
  75116. * Enables a GeometryBufferRender and associates it with the scene
  75117. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  75118. * @returns the GeometryBufferRenderer
  75119. */
  75120. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  75121. /**
  75122. * Disables the GeometryBufferRender associated with the scene
  75123. */
  75124. disableGeometryBufferRenderer(): void;
  75125. }
  75126. }
  75127. /**
  75128. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  75129. * in several rendering techniques.
  75130. */
  75131. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  75132. /**
  75133. * The component name helpful to identify the component in the list of scene components.
  75134. */
  75135. readonly name: string;
  75136. /**
  75137. * The scene the component belongs to.
  75138. */
  75139. scene: Scene;
  75140. /**
  75141. * Creates a new instance of the component for the given scene
  75142. * @param scene Defines the scene to register the component in
  75143. */
  75144. constructor(scene: Scene);
  75145. /**
  75146. * Registers the component in a given scene
  75147. */
  75148. register(): void;
  75149. /**
  75150. * Rebuilds the elements related to this component in case of
  75151. * context lost for instance.
  75152. */
  75153. rebuild(): void;
  75154. /**
  75155. * Disposes the component and the associated ressources
  75156. */
  75157. dispose(): void;
  75158. private _gatherRenderTargets;
  75159. }
  75160. }
  75161. declare module "babylonjs/Shaders/motionBlur.fragment" {
  75162. /** @hidden */
  75163. export var motionBlurPixelShader: {
  75164. name: string;
  75165. shader: string;
  75166. };
  75167. }
  75168. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  75169. import { Nullable } from "babylonjs/types";
  75170. import { Camera } from "babylonjs/Cameras/camera";
  75171. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75173. import "babylonjs/Animations/animatable";
  75174. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75175. import "babylonjs/Shaders/motionBlur.fragment";
  75176. import { Engine } from "babylonjs/Engines/engine";
  75177. import { Scene } from "babylonjs/scene";
  75178. /**
  75179. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  75180. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  75181. * As an example, all you have to do is to create the post-process:
  75182. * var mb = new BABYLON.MotionBlurPostProcess(
  75183. * 'mb', // The name of the effect.
  75184. * scene, // The scene containing the objects to blur according to their velocity.
  75185. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  75186. * camera // The camera to apply the render pass to.
  75187. * );
  75188. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  75189. */
  75190. export class MotionBlurPostProcess extends PostProcess {
  75191. /**
  75192. * Defines how much the image is blurred by the movement. Default value is equal to 1
  75193. */
  75194. motionStrength: number;
  75195. /**
  75196. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  75197. */
  75198. get motionBlurSamples(): number;
  75199. /**
  75200. * Sets the number of iterations to be used for motion blur quality
  75201. */
  75202. set motionBlurSamples(samples: number);
  75203. private _motionBlurSamples;
  75204. /**
  75205. * Gets wether or not the motion blur post-process is in object based mode.
  75206. */
  75207. get isObjectBased(): boolean;
  75208. /**
  75209. * Sets wether or not the motion blur post-process is in object based mode.
  75210. */
  75211. set isObjectBased(value: boolean);
  75212. private _isObjectBased;
  75213. private _forceGeometryBuffer;
  75214. private _geometryBufferRenderer;
  75215. private _prePassRenderer;
  75216. private _invViewProjection;
  75217. private _previousViewProjection;
  75218. /**
  75219. * Gets a string identifying the name of the class
  75220. * @returns "MotionBlurPostProcess" string
  75221. */
  75222. getClassName(): string;
  75223. /**
  75224. * Creates a new instance MotionBlurPostProcess
  75225. * @param name The name of the effect.
  75226. * @param scene The scene containing the objects to blur according to their velocity.
  75227. * @param options The required width/height ratio to downsize to before computing the render pass.
  75228. * @param camera The camera to apply the render pass to.
  75229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75230. * @param engine The engine which the post process will be applied. (default: current engine)
  75231. * @param reusable If the post process can be reused on the same frame. (default: false)
  75232. * @param textureType Type of textures used when performing the post process. (default: 0)
  75233. * @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: true)
  75234. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75235. */
  75236. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75237. /**
  75238. * Excludes the given skinned mesh from computing bones velocities.
  75239. * 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.
  75240. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  75241. */
  75242. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75243. /**
  75244. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  75245. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  75246. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  75247. */
  75248. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  75249. /**
  75250. * Disposes the post process.
  75251. * @param camera The camera to dispose the post process on.
  75252. */
  75253. dispose(camera?: Camera): void;
  75254. /**
  75255. * Called on the mode changed (object based or screen based).
  75256. */
  75257. private _applyMode;
  75258. /**
  75259. * Called on the effect is applied when the motion blur post-process is in object based mode.
  75260. */
  75261. private _onApplyObjectBased;
  75262. /**
  75263. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  75264. */
  75265. private _onApplyScreenBased;
  75266. /**
  75267. * Called on the effect must be updated (changed mode, samples count, etc.).
  75268. */
  75269. private _updateEffect;
  75270. /** @hidden */
  75271. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  75272. }
  75273. }
  75274. declare module "babylonjs/Shaders/refraction.fragment" {
  75275. /** @hidden */
  75276. export var refractionPixelShader: {
  75277. name: string;
  75278. shader: string;
  75279. };
  75280. }
  75281. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  75282. import { Color3 } from "babylonjs/Maths/math.color";
  75283. import { Camera } from "babylonjs/Cameras/camera";
  75284. import { Texture } from "babylonjs/Materials/Textures/texture";
  75285. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75286. import { Engine } from "babylonjs/Engines/engine";
  75287. import "babylonjs/Shaders/refraction.fragment";
  75288. import { Scene } from "babylonjs/scene";
  75289. /**
  75290. * Post process which applies a refractin texture
  75291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75292. */
  75293. export class RefractionPostProcess extends PostProcess {
  75294. private _refTexture;
  75295. private _ownRefractionTexture;
  75296. /** the base color of the refraction (used to taint the rendering) */
  75297. color: Color3;
  75298. /** simulated refraction depth */
  75299. depth: number;
  75300. /** the coefficient of the base color (0 to remove base color tainting) */
  75301. colorLevel: number;
  75302. /** Gets the url used to load the refraction texture */
  75303. refractionTextureUrl: string;
  75304. /**
  75305. * Gets or sets the refraction texture
  75306. * Please note that you are responsible for disposing the texture if you set it manually
  75307. */
  75308. get refractionTexture(): Texture;
  75309. set refractionTexture(value: Texture);
  75310. /**
  75311. * Gets a string identifying the name of the class
  75312. * @returns "RefractionPostProcess" string
  75313. */
  75314. getClassName(): string;
  75315. /**
  75316. * Initializes the RefractionPostProcess
  75317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  75318. * @param name The name of the effect.
  75319. * @param refractionTextureUrl Url of the refraction texture to use
  75320. * @param color the base color of the refraction (used to taint the rendering)
  75321. * @param depth simulated refraction depth
  75322. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  75323. * @param camera The camera to apply the render pass to.
  75324. * @param options The required width/height ratio to downsize to before computing the render pass.
  75325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75326. * @param engine The engine which the post process will be applied. (default: current engine)
  75327. * @param reusable If the post process can be reused on the same frame. (default: false)
  75328. */
  75329. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75330. /**
  75331. * Disposes of the post process
  75332. * @param camera Camera to dispose post process on
  75333. */
  75334. dispose(camera: Camera): void;
  75335. /** @hidden */
  75336. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  75337. }
  75338. }
  75339. declare module "babylonjs/Shaders/sharpen.fragment" {
  75340. /** @hidden */
  75341. export var sharpenPixelShader: {
  75342. name: string;
  75343. shader: string;
  75344. };
  75345. }
  75346. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  75347. import { Nullable } from "babylonjs/types";
  75348. import { Camera } from "babylonjs/Cameras/camera";
  75349. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75350. import "babylonjs/Shaders/sharpen.fragment";
  75351. import { Engine } from "babylonjs/Engines/engine";
  75352. import { Scene } from "babylonjs/scene";
  75353. /**
  75354. * The SharpenPostProcess applies a sharpen kernel to every pixel
  75355. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  75356. */
  75357. export class SharpenPostProcess extends PostProcess {
  75358. /**
  75359. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  75360. */
  75361. colorAmount: number;
  75362. /**
  75363. * How much sharpness should be applied (default: 0.3)
  75364. */
  75365. edgeAmount: number;
  75366. /**
  75367. * Gets a string identifying the name of the class
  75368. * @returns "SharpenPostProcess" string
  75369. */
  75370. getClassName(): string;
  75371. /**
  75372. * Creates a new instance ConvolutionPostProcess
  75373. * @param name The name of the effect.
  75374. * @param options The required width/height ratio to downsize to before computing the render pass.
  75375. * @param camera The camera to apply the render pass to.
  75376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75377. * @param engine The engine which the post process will be applied. (default: current engine)
  75378. * @param reusable If the post process can be reused on the same frame. (default: false)
  75379. * @param textureType Type of textures used when performing the post process. (default: 0)
  75380. * @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)
  75381. */
  75382. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75383. /** @hidden */
  75384. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  75385. }
  75386. }
  75387. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  75388. import { Nullable } from "babylonjs/types";
  75389. import { Camera } from "babylonjs/Cameras/camera";
  75390. import { Engine } from "babylonjs/Engines/engine";
  75391. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75392. import { IInspectable } from "babylonjs/Misc/iInspectable";
  75393. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  75394. /**
  75395. * PostProcessRenderPipeline
  75396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75397. */
  75398. export class PostProcessRenderPipeline {
  75399. private engine;
  75400. private _renderEffects;
  75401. private _renderEffectsForIsolatedPass;
  75402. /**
  75403. * List of inspectable custom properties (used by the Inspector)
  75404. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75405. */
  75406. inspectableCustomProperties: IInspectable[];
  75407. /**
  75408. * @hidden
  75409. */
  75410. protected _cameras: Camera[];
  75411. /** @hidden */
  75412. _name: string;
  75413. /**
  75414. * Gets pipeline name
  75415. */
  75416. get name(): string;
  75417. /** Gets the list of attached cameras */
  75418. get cameras(): Camera[];
  75419. /**
  75420. * Initializes a PostProcessRenderPipeline
  75421. * @param engine engine to add the pipeline to
  75422. * @param name name of the pipeline
  75423. */
  75424. constructor(engine: Engine, name: string);
  75425. /**
  75426. * Gets the class name
  75427. * @returns "PostProcessRenderPipeline"
  75428. */
  75429. getClassName(): string;
  75430. /**
  75431. * If all the render effects in the pipeline are supported
  75432. */
  75433. get isSupported(): boolean;
  75434. /**
  75435. * Adds an effect to the pipeline
  75436. * @param renderEffect the effect to add
  75437. */
  75438. addEffect(renderEffect: PostProcessRenderEffect): void;
  75439. /** @hidden */
  75440. _rebuild(): void;
  75441. /** @hidden */
  75442. _enableEffect(renderEffectName: string, cameras: Camera): void;
  75443. /** @hidden */
  75444. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  75445. /** @hidden */
  75446. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75447. /** @hidden */
  75448. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  75449. /** @hidden */
  75450. _attachCameras(cameras: Camera, unique: boolean): void;
  75451. /** @hidden */
  75452. _attachCameras(cameras: Camera[], unique: boolean): void;
  75453. /** @hidden */
  75454. _detachCameras(cameras: Camera): void;
  75455. /** @hidden */
  75456. _detachCameras(cameras: Nullable<Camera[]>): void;
  75457. /** @hidden */
  75458. _update(): void;
  75459. /** @hidden */
  75460. _reset(): void;
  75461. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75462. /**
  75463. * Sets the required values to the prepass renderer.
  75464. * @param prePassRenderer defines the prepass renderer to setup.
  75465. * @returns true if the pre pass is needed.
  75466. */
  75467. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75468. /**
  75469. * Disposes of the pipeline
  75470. */
  75471. dispose(): void;
  75472. }
  75473. }
  75474. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75475. import { Camera } from "babylonjs/Cameras/camera";
  75476. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75477. /**
  75478. * PostProcessRenderPipelineManager class
  75479. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75480. */
  75481. export class PostProcessRenderPipelineManager {
  75482. private _renderPipelines;
  75483. /**
  75484. * Initializes a PostProcessRenderPipelineManager
  75485. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75486. */
  75487. constructor();
  75488. /**
  75489. * Gets the list of supported render pipelines
  75490. */
  75491. get supportedPipelines(): PostProcessRenderPipeline[];
  75492. /**
  75493. * Adds a pipeline to the manager
  75494. * @param renderPipeline The pipeline to add
  75495. */
  75496. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75497. /**
  75498. * Attaches a camera to the pipeline
  75499. * @param renderPipelineName The name of the pipeline to attach to
  75500. * @param cameras the camera to attach
  75501. * @param unique if the camera can be attached multiple times to the pipeline
  75502. */
  75503. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75504. /**
  75505. * Detaches a camera from the pipeline
  75506. * @param renderPipelineName The name of the pipeline to detach from
  75507. * @param cameras the camera to detach
  75508. */
  75509. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75510. /**
  75511. * Enables an effect by name on a pipeline
  75512. * @param renderPipelineName the name of the pipeline to enable the effect in
  75513. * @param renderEffectName the name of the effect to enable
  75514. * @param cameras the cameras that the effect should be enabled on
  75515. */
  75516. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75517. /**
  75518. * Disables an effect by name on a pipeline
  75519. * @param renderPipelineName the name of the pipeline to disable the effect in
  75520. * @param renderEffectName the name of the effect to disable
  75521. * @param cameras the cameras that the effect should be disabled on
  75522. */
  75523. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75524. /**
  75525. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75526. */
  75527. update(): void;
  75528. /** @hidden */
  75529. _rebuild(): void;
  75530. /**
  75531. * Disposes of the manager and pipelines
  75532. */
  75533. dispose(): void;
  75534. }
  75535. }
  75536. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75537. import { ISceneComponent } from "babylonjs/sceneComponent";
  75538. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75539. import { Scene } from "babylonjs/scene";
  75540. module "babylonjs/scene" {
  75541. interface Scene {
  75542. /** @hidden (Backing field) */
  75543. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75544. /**
  75545. * Gets the postprocess render pipeline manager
  75546. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75547. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75548. */
  75549. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75550. }
  75551. }
  75552. /**
  75553. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75554. */
  75555. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75556. /**
  75557. * The component name helpfull to identify the component in the list of scene components.
  75558. */
  75559. readonly name: string;
  75560. /**
  75561. * The scene the component belongs to.
  75562. */
  75563. scene: Scene;
  75564. /**
  75565. * Creates a new instance of the component for the given scene
  75566. * @param scene Defines the scene to register the component in
  75567. */
  75568. constructor(scene: Scene);
  75569. /**
  75570. * Registers the component in a given scene
  75571. */
  75572. register(): void;
  75573. /**
  75574. * Rebuilds the elements related to this component in case of
  75575. * context lost for instance.
  75576. */
  75577. rebuild(): void;
  75578. /**
  75579. * Disposes the component and the associated ressources
  75580. */
  75581. dispose(): void;
  75582. private _gatherRenderTargets;
  75583. }
  75584. }
  75585. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75586. import { Nullable } from "babylonjs/types";
  75587. import { Observable } from "babylonjs/Misc/observable";
  75588. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75589. import { Camera } from "babylonjs/Cameras/camera";
  75590. import { IDisposable } from "babylonjs/scene";
  75591. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75592. import { Scene } from "babylonjs/scene";
  75593. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75594. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75595. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75596. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75597. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75598. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75599. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75600. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75601. import { Animation } from "babylonjs/Animations/animation";
  75602. /**
  75603. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75604. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75605. */
  75606. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75607. private _scene;
  75608. private _camerasToBeAttached;
  75609. /**
  75610. * ID of the sharpen post process,
  75611. */
  75612. private readonly SharpenPostProcessId;
  75613. /**
  75614. * @ignore
  75615. * ID of the image processing post process;
  75616. */
  75617. readonly ImageProcessingPostProcessId: string;
  75618. /**
  75619. * @ignore
  75620. * ID of the Fast Approximate Anti-Aliasing post process;
  75621. */
  75622. readonly FxaaPostProcessId: string;
  75623. /**
  75624. * ID of the chromatic aberration post process,
  75625. */
  75626. private readonly ChromaticAberrationPostProcessId;
  75627. /**
  75628. * ID of the grain post process
  75629. */
  75630. private readonly GrainPostProcessId;
  75631. /**
  75632. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75633. */
  75634. sharpen: SharpenPostProcess;
  75635. private _sharpenEffect;
  75636. private bloom;
  75637. /**
  75638. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75639. */
  75640. depthOfField: DepthOfFieldEffect;
  75641. /**
  75642. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75643. */
  75644. fxaa: FxaaPostProcess;
  75645. /**
  75646. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75647. */
  75648. imageProcessing: ImageProcessingPostProcess;
  75649. /**
  75650. * Chromatic aberration post process which will shift rgb colors in the image
  75651. */
  75652. chromaticAberration: ChromaticAberrationPostProcess;
  75653. private _chromaticAberrationEffect;
  75654. /**
  75655. * Grain post process which add noise to the image
  75656. */
  75657. grain: GrainPostProcess;
  75658. private _grainEffect;
  75659. /**
  75660. * Glow post process which adds a glow to emissive areas of the image
  75661. */
  75662. private _glowLayer;
  75663. /**
  75664. * Animations which can be used to tweak settings over a period of time
  75665. */
  75666. animations: Animation[];
  75667. private _imageProcessingConfigurationObserver;
  75668. private _sharpenEnabled;
  75669. private _bloomEnabled;
  75670. private _depthOfFieldEnabled;
  75671. private _depthOfFieldBlurLevel;
  75672. private _fxaaEnabled;
  75673. private _imageProcessingEnabled;
  75674. private _defaultPipelineTextureType;
  75675. private _bloomScale;
  75676. private _chromaticAberrationEnabled;
  75677. private _grainEnabled;
  75678. private _buildAllowed;
  75679. /**
  75680. * This is triggered each time the pipeline has been built.
  75681. */
  75682. onBuildObservable: Observable<DefaultRenderingPipeline>;
  75683. /**
  75684. * Gets active scene
  75685. */
  75686. get scene(): Scene;
  75687. /**
  75688. * Enable or disable the sharpen process from the pipeline
  75689. */
  75690. set sharpenEnabled(enabled: boolean);
  75691. get sharpenEnabled(): boolean;
  75692. private _resizeObserver;
  75693. private _hardwareScaleLevel;
  75694. private _bloomKernel;
  75695. /**
  75696. * Specifies the size of the bloom blur kernel, relative to the final output size
  75697. */
  75698. get bloomKernel(): number;
  75699. set bloomKernel(value: number);
  75700. /**
  75701. * Specifies the weight of the bloom in the final rendering
  75702. */
  75703. private _bloomWeight;
  75704. /**
  75705. * Specifies the luma threshold for the area that will be blurred by the bloom
  75706. */
  75707. private _bloomThreshold;
  75708. private _hdr;
  75709. /**
  75710. * The strength of the bloom.
  75711. */
  75712. set bloomWeight(value: number);
  75713. get bloomWeight(): number;
  75714. /**
  75715. * The strength of the bloom.
  75716. */
  75717. set bloomThreshold(value: number);
  75718. get bloomThreshold(): number;
  75719. /**
  75720. * The scale of the bloom, lower value will provide better performance.
  75721. */
  75722. set bloomScale(value: number);
  75723. get bloomScale(): number;
  75724. /**
  75725. * Enable or disable the bloom from the pipeline
  75726. */
  75727. set bloomEnabled(enabled: boolean);
  75728. get bloomEnabled(): boolean;
  75729. private _rebuildBloom;
  75730. /**
  75731. * If the depth of field is enabled.
  75732. */
  75733. get depthOfFieldEnabled(): boolean;
  75734. set depthOfFieldEnabled(enabled: boolean);
  75735. /**
  75736. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75737. */
  75738. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75739. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75740. /**
  75741. * If the anti aliasing is enabled.
  75742. */
  75743. set fxaaEnabled(enabled: boolean);
  75744. get fxaaEnabled(): boolean;
  75745. private _samples;
  75746. /**
  75747. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75748. */
  75749. set samples(sampleCount: number);
  75750. get samples(): number;
  75751. /**
  75752. * If image processing is enabled.
  75753. */
  75754. set imageProcessingEnabled(enabled: boolean);
  75755. get imageProcessingEnabled(): boolean;
  75756. /**
  75757. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75758. */
  75759. set glowLayerEnabled(enabled: boolean);
  75760. get glowLayerEnabled(): boolean;
  75761. /**
  75762. * Gets the glow layer (or null if not defined)
  75763. */
  75764. get glowLayer(): Nullable<GlowLayer>;
  75765. /**
  75766. * Enable or disable the chromaticAberration process from the pipeline
  75767. */
  75768. set chromaticAberrationEnabled(enabled: boolean);
  75769. get chromaticAberrationEnabled(): boolean;
  75770. /**
  75771. * Enable or disable the grain process from the pipeline
  75772. */
  75773. set grainEnabled(enabled: boolean);
  75774. get grainEnabled(): boolean;
  75775. /**
  75776. * @constructor
  75777. * @param name - The rendering pipeline name (default: "")
  75778. * @param hdr - If high dynamic range textures should be used (default: true)
  75779. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75780. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75781. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75782. */
  75783. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75784. /**
  75785. * Get the class name
  75786. * @returns "DefaultRenderingPipeline"
  75787. */
  75788. getClassName(): string;
  75789. /**
  75790. * Force the compilation of the entire pipeline.
  75791. */
  75792. prepare(): void;
  75793. private _hasCleared;
  75794. private _prevPostProcess;
  75795. private _prevPrevPostProcess;
  75796. private _setAutoClearAndTextureSharing;
  75797. private _depthOfFieldSceneObserver;
  75798. private _buildPipeline;
  75799. private _disposePostProcesses;
  75800. /**
  75801. * Adds a camera to the pipeline
  75802. * @param camera the camera to be added
  75803. */
  75804. addCamera(camera: Camera): void;
  75805. /**
  75806. * Removes a camera from the pipeline
  75807. * @param camera the camera to remove
  75808. */
  75809. removeCamera(camera: Camera): void;
  75810. /**
  75811. * Dispose of the pipeline and stop all post processes
  75812. */
  75813. dispose(): void;
  75814. /**
  75815. * Serialize the rendering pipeline (Used when exporting)
  75816. * @returns the serialized object
  75817. */
  75818. serialize(): any;
  75819. /**
  75820. * Parse the serialized pipeline
  75821. * @param source Source pipeline.
  75822. * @param scene The scene to load the pipeline to.
  75823. * @param rootUrl The URL of the serialized pipeline.
  75824. * @returns An instantiated pipeline from the serialized object.
  75825. */
  75826. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75827. }
  75828. }
  75829. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75830. /** @hidden */
  75831. export var lensHighlightsPixelShader: {
  75832. name: string;
  75833. shader: string;
  75834. };
  75835. }
  75836. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75837. /** @hidden */
  75838. export var depthOfFieldPixelShader: {
  75839. name: string;
  75840. shader: string;
  75841. };
  75842. }
  75843. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75844. import { Camera } from "babylonjs/Cameras/camera";
  75845. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75846. import { Scene } from "babylonjs/scene";
  75847. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75848. import "babylonjs/Shaders/chromaticAberration.fragment";
  75849. import "babylonjs/Shaders/lensHighlights.fragment";
  75850. import "babylonjs/Shaders/depthOfField.fragment";
  75851. /**
  75852. * BABYLON.JS Chromatic Aberration GLSL Shader
  75853. * Author: Olivier Guyot
  75854. * Separates very slightly R, G and B colors on the edges of the screen
  75855. * Inspired by Francois Tarlier & Martins Upitis
  75856. */
  75857. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75858. /**
  75859. * @ignore
  75860. * The chromatic aberration PostProcess id in the pipeline
  75861. */
  75862. LensChromaticAberrationEffect: string;
  75863. /**
  75864. * @ignore
  75865. * The highlights enhancing PostProcess id in the pipeline
  75866. */
  75867. HighlightsEnhancingEffect: string;
  75868. /**
  75869. * @ignore
  75870. * The depth-of-field PostProcess id in the pipeline
  75871. */
  75872. LensDepthOfFieldEffect: string;
  75873. private _scene;
  75874. private _depthTexture;
  75875. private _grainTexture;
  75876. private _chromaticAberrationPostProcess;
  75877. private _highlightsPostProcess;
  75878. private _depthOfFieldPostProcess;
  75879. private _edgeBlur;
  75880. private _grainAmount;
  75881. private _chromaticAberration;
  75882. private _distortion;
  75883. private _highlightsGain;
  75884. private _highlightsThreshold;
  75885. private _dofDistance;
  75886. private _dofAperture;
  75887. private _dofDarken;
  75888. private _dofPentagon;
  75889. private _blurNoise;
  75890. /**
  75891. * @constructor
  75892. *
  75893. * Effect parameters are as follow:
  75894. * {
  75895. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75896. * edge_blur: number; // from 0 to x (1 for realism)
  75897. * distortion: number; // from 0 to x (1 for realism)
  75898. * grain_amount: number; // from 0 to 1
  75899. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75900. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75901. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75902. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75903. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75904. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75905. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75906. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75907. * }
  75908. * Note: if an effect parameter is unset, effect is disabled
  75909. *
  75910. * @param name The rendering pipeline name
  75911. * @param parameters - An object containing all parameters (see above)
  75912. * @param scene The scene linked to this pipeline
  75913. * @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)
  75914. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75915. */
  75916. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75917. /**
  75918. * Get the class name
  75919. * @returns "LensRenderingPipeline"
  75920. */
  75921. getClassName(): string;
  75922. /**
  75923. * Gets associated scene
  75924. */
  75925. get scene(): Scene;
  75926. /**
  75927. * Gets or sets the edge blur
  75928. */
  75929. get edgeBlur(): number;
  75930. set edgeBlur(value: number);
  75931. /**
  75932. * Gets or sets the grain amount
  75933. */
  75934. get grainAmount(): number;
  75935. set grainAmount(value: number);
  75936. /**
  75937. * Gets or sets the chromatic aberration amount
  75938. */
  75939. get chromaticAberration(): number;
  75940. set chromaticAberration(value: number);
  75941. /**
  75942. * Gets or sets the depth of field aperture
  75943. */
  75944. get dofAperture(): number;
  75945. set dofAperture(value: number);
  75946. /**
  75947. * Gets or sets the edge distortion
  75948. */
  75949. get edgeDistortion(): number;
  75950. set edgeDistortion(value: number);
  75951. /**
  75952. * Gets or sets the depth of field distortion
  75953. */
  75954. get dofDistortion(): number;
  75955. set dofDistortion(value: number);
  75956. /**
  75957. * Gets or sets the darken out of focus amount
  75958. */
  75959. get darkenOutOfFocus(): number;
  75960. set darkenOutOfFocus(value: number);
  75961. /**
  75962. * Gets or sets a boolean indicating if blur noise is enabled
  75963. */
  75964. get blurNoise(): boolean;
  75965. set blurNoise(value: boolean);
  75966. /**
  75967. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75968. */
  75969. get pentagonBokeh(): boolean;
  75970. set pentagonBokeh(value: boolean);
  75971. /**
  75972. * Gets or sets the highlight grain amount
  75973. */
  75974. get highlightsGain(): number;
  75975. set highlightsGain(value: number);
  75976. /**
  75977. * Gets or sets the highlight threshold
  75978. */
  75979. get highlightsThreshold(): number;
  75980. set highlightsThreshold(value: number);
  75981. /**
  75982. * Sets the amount of blur at the edges
  75983. * @param amount blur amount
  75984. */
  75985. setEdgeBlur(amount: number): void;
  75986. /**
  75987. * Sets edge blur to 0
  75988. */
  75989. disableEdgeBlur(): void;
  75990. /**
  75991. * Sets the amout of grain
  75992. * @param amount Amount of grain
  75993. */
  75994. setGrainAmount(amount: number): void;
  75995. /**
  75996. * Set grain amount to 0
  75997. */
  75998. disableGrain(): void;
  75999. /**
  76000. * Sets the chromatic aberration amount
  76001. * @param amount amount of chromatic aberration
  76002. */
  76003. setChromaticAberration(amount: number): void;
  76004. /**
  76005. * Sets chromatic aberration amount to 0
  76006. */
  76007. disableChromaticAberration(): void;
  76008. /**
  76009. * Sets the EdgeDistortion amount
  76010. * @param amount amount of EdgeDistortion
  76011. */
  76012. setEdgeDistortion(amount: number): void;
  76013. /**
  76014. * Sets edge distortion to 0
  76015. */
  76016. disableEdgeDistortion(): void;
  76017. /**
  76018. * Sets the FocusDistance amount
  76019. * @param amount amount of FocusDistance
  76020. */
  76021. setFocusDistance(amount: number): void;
  76022. /**
  76023. * Disables depth of field
  76024. */
  76025. disableDepthOfField(): void;
  76026. /**
  76027. * Sets the Aperture amount
  76028. * @param amount amount of Aperture
  76029. */
  76030. setAperture(amount: number): void;
  76031. /**
  76032. * Sets the DarkenOutOfFocus amount
  76033. * @param amount amount of DarkenOutOfFocus
  76034. */
  76035. setDarkenOutOfFocus(amount: number): void;
  76036. private _pentagonBokehIsEnabled;
  76037. /**
  76038. * Creates a pentagon bokeh effect
  76039. */
  76040. enablePentagonBokeh(): void;
  76041. /**
  76042. * Disables the pentagon bokeh effect
  76043. */
  76044. disablePentagonBokeh(): void;
  76045. /**
  76046. * Enables noise blur
  76047. */
  76048. enableNoiseBlur(): void;
  76049. /**
  76050. * Disables noise blur
  76051. */
  76052. disableNoiseBlur(): void;
  76053. /**
  76054. * Sets the HighlightsGain amount
  76055. * @param amount amount of HighlightsGain
  76056. */
  76057. setHighlightsGain(amount: number): void;
  76058. /**
  76059. * Sets the HighlightsThreshold amount
  76060. * @param amount amount of HighlightsThreshold
  76061. */
  76062. setHighlightsThreshold(amount: number): void;
  76063. /**
  76064. * Disables highlights
  76065. */
  76066. disableHighlights(): void;
  76067. /**
  76068. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  76069. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  76070. */
  76071. dispose(disableDepthRender?: boolean): void;
  76072. private _createChromaticAberrationPostProcess;
  76073. private _createHighlightsPostProcess;
  76074. private _createDepthOfFieldPostProcess;
  76075. private _createGrainTexture;
  76076. }
  76077. }
  76078. declare module "babylonjs/Rendering/ssao2Configuration" {
  76079. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76080. /**
  76081. * Contains all parameters needed for the prepass to perform
  76082. * screen space subsurface scattering
  76083. */
  76084. export class SSAO2Configuration implements PrePassEffectConfiguration {
  76085. /**
  76086. * Is subsurface enabled
  76087. */
  76088. enabled: boolean;
  76089. /**
  76090. * Name of the configuration
  76091. */
  76092. name: string;
  76093. /**
  76094. * Textures that should be present in the MRT for this effect to work
  76095. */
  76096. readonly texturesRequired: number[];
  76097. }
  76098. }
  76099. declare module "babylonjs/Shaders/ssao2.fragment" {
  76100. /** @hidden */
  76101. export var ssao2PixelShader: {
  76102. name: string;
  76103. shader: string;
  76104. };
  76105. }
  76106. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  76107. /** @hidden */
  76108. export var ssaoCombinePixelShader: {
  76109. name: string;
  76110. shader: string;
  76111. };
  76112. }
  76113. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  76114. import { Camera } from "babylonjs/Cameras/camera";
  76115. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76116. import { Scene } from "babylonjs/scene";
  76117. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76118. import "babylonjs/Shaders/ssao2.fragment";
  76119. import "babylonjs/Shaders/ssaoCombine.fragment";
  76120. /**
  76121. * Render pipeline to produce ssao effect
  76122. */
  76123. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  76124. /**
  76125. * @ignore
  76126. * The PassPostProcess id in the pipeline that contains the original scene color
  76127. */
  76128. SSAOOriginalSceneColorEffect: string;
  76129. /**
  76130. * @ignore
  76131. * The SSAO PostProcess id in the pipeline
  76132. */
  76133. SSAORenderEffect: string;
  76134. /**
  76135. * @ignore
  76136. * The horizontal blur PostProcess id in the pipeline
  76137. */
  76138. SSAOBlurHRenderEffect: string;
  76139. /**
  76140. * @ignore
  76141. * The vertical blur PostProcess id in the pipeline
  76142. */
  76143. SSAOBlurVRenderEffect: string;
  76144. /**
  76145. * @ignore
  76146. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76147. */
  76148. SSAOCombineRenderEffect: string;
  76149. /**
  76150. * The output strength of the SSAO post-process. Default value is 1.0.
  76151. */
  76152. totalStrength: number;
  76153. /**
  76154. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  76155. */
  76156. maxZ: number;
  76157. /**
  76158. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  76159. */
  76160. minZAspect: number;
  76161. private _samples;
  76162. /**
  76163. * Number of samples used for the SSAO calculations. Default value is 8
  76164. */
  76165. set samples(n: number);
  76166. get samples(): number;
  76167. private _textureSamples;
  76168. /**
  76169. * Number of samples to use for antialiasing
  76170. */
  76171. set textureSamples(n: number);
  76172. get textureSamples(): number;
  76173. /**
  76174. * Force rendering the geometry through geometry buffer
  76175. */
  76176. private _forceGeometryBuffer;
  76177. /**
  76178. * Ratio object used for SSAO ratio and blur ratio
  76179. */
  76180. private _ratio;
  76181. /**
  76182. * Dynamically generated sphere sampler.
  76183. */
  76184. private _sampleSphere;
  76185. /**
  76186. * Blur filter offsets
  76187. */
  76188. private _samplerOffsets;
  76189. private _expensiveBlur;
  76190. /**
  76191. * If bilateral blur should be used
  76192. */
  76193. set expensiveBlur(b: boolean);
  76194. get expensiveBlur(): boolean;
  76195. /**
  76196. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  76197. */
  76198. radius: number;
  76199. /**
  76200. * The base color of the SSAO post-process
  76201. * The final result is "base + ssao" between [0, 1]
  76202. */
  76203. base: number;
  76204. /**
  76205. * Support test.
  76206. */
  76207. static get IsSupported(): boolean;
  76208. private _scene;
  76209. private _randomTexture;
  76210. private _originalColorPostProcess;
  76211. private _ssaoPostProcess;
  76212. private _blurHPostProcess;
  76213. private _blurVPostProcess;
  76214. private _ssaoCombinePostProcess;
  76215. private _prePassRenderer;
  76216. /**
  76217. * Gets active scene
  76218. */
  76219. get scene(): Scene;
  76220. /**
  76221. * @constructor
  76222. * @param name The rendering pipeline name
  76223. * @param scene The scene linked to this pipeline
  76224. * @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 }
  76225. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76226. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  76227. */
  76228. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  76229. /**
  76230. * Get the class name
  76231. * @returns "SSAO2RenderingPipeline"
  76232. */
  76233. getClassName(): string;
  76234. /**
  76235. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76236. */
  76237. dispose(disableGeometryBufferRenderer?: boolean): void;
  76238. private _createBlurPostProcess;
  76239. /** @hidden */
  76240. _rebuild(): void;
  76241. private _bits;
  76242. private _radicalInverse_VdC;
  76243. private _hammersley;
  76244. private _hemisphereSample_uniform;
  76245. private _generateHemisphere;
  76246. private _getDefinesForSSAO;
  76247. private _createSSAOPostProcess;
  76248. private _createSSAOCombinePostProcess;
  76249. private _createRandomTexture;
  76250. /**
  76251. * Serialize the rendering pipeline (Used when exporting)
  76252. * @returns the serialized object
  76253. */
  76254. serialize(): any;
  76255. /**
  76256. * Parse the serialized pipeline
  76257. * @param source Source pipeline.
  76258. * @param scene The scene to load the pipeline to.
  76259. * @param rootUrl The URL of the serialized pipeline.
  76260. * @returns An instantiated pipeline from the serialized object.
  76261. */
  76262. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  76263. }
  76264. }
  76265. declare module "babylonjs/Shaders/ssao.fragment" {
  76266. /** @hidden */
  76267. export var ssaoPixelShader: {
  76268. name: string;
  76269. shader: string;
  76270. };
  76271. }
  76272. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  76273. import { Camera } from "babylonjs/Cameras/camera";
  76274. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76275. import { Scene } from "babylonjs/scene";
  76276. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76277. import "babylonjs/Shaders/ssao.fragment";
  76278. import "babylonjs/Shaders/ssaoCombine.fragment";
  76279. /**
  76280. * Render pipeline to produce ssao effect
  76281. */
  76282. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  76283. /**
  76284. * @ignore
  76285. * The PassPostProcess id in the pipeline that contains the original scene color
  76286. */
  76287. SSAOOriginalSceneColorEffect: string;
  76288. /**
  76289. * @ignore
  76290. * The SSAO PostProcess id in the pipeline
  76291. */
  76292. SSAORenderEffect: string;
  76293. /**
  76294. * @ignore
  76295. * The horizontal blur PostProcess id in the pipeline
  76296. */
  76297. SSAOBlurHRenderEffect: string;
  76298. /**
  76299. * @ignore
  76300. * The vertical blur PostProcess id in the pipeline
  76301. */
  76302. SSAOBlurVRenderEffect: string;
  76303. /**
  76304. * @ignore
  76305. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  76306. */
  76307. SSAOCombineRenderEffect: string;
  76308. /**
  76309. * The output strength of the SSAO post-process. Default value is 1.0.
  76310. */
  76311. totalStrength: number;
  76312. /**
  76313. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  76314. */
  76315. radius: number;
  76316. /**
  76317. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  76318. * Must not be equal to fallOff and superior to fallOff.
  76319. * Default value is 0.0075
  76320. */
  76321. area: number;
  76322. /**
  76323. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  76324. * Must not be equal to area and inferior to area.
  76325. * Default value is 0.000001
  76326. */
  76327. fallOff: number;
  76328. /**
  76329. * The base color of the SSAO post-process
  76330. * The final result is "base + ssao" between [0, 1]
  76331. */
  76332. base: number;
  76333. private _scene;
  76334. private _depthTexture;
  76335. private _randomTexture;
  76336. private _originalColorPostProcess;
  76337. private _ssaoPostProcess;
  76338. private _blurHPostProcess;
  76339. private _blurVPostProcess;
  76340. private _ssaoCombinePostProcess;
  76341. private _firstUpdate;
  76342. /**
  76343. * Gets active scene
  76344. */
  76345. get scene(): Scene;
  76346. /**
  76347. * @constructor
  76348. * @param name - The rendering pipeline name
  76349. * @param scene - The scene linked to this pipeline
  76350. * @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 }
  76351. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  76352. */
  76353. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  76354. /**
  76355. * Get the class name
  76356. * @returns "SSAORenderingPipeline"
  76357. */
  76358. getClassName(): string;
  76359. /**
  76360. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  76361. */
  76362. dispose(disableDepthRender?: boolean): void;
  76363. private _createBlurPostProcess;
  76364. /** @hidden */
  76365. _rebuild(): void;
  76366. private _createSSAOPostProcess;
  76367. private _createSSAOCombinePostProcess;
  76368. private _createRandomTexture;
  76369. }
  76370. }
  76371. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  76372. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76373. /**
  76374. * Contains all parameters needed for the prepass to perform
  76375. * screen space reflections
  76376. */
  76377. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  76378. /**
  76379. * Is ssr enabled
  76380. */
  76381. enabled: boolean;
  76382. /**
  76383. * Name of the configuration
  76384. */
  76385. name: string;
  76386. /**
  76387. * Textures that should be present in the MRT for this effect to work
  76388. */
  76389. readonly texturesRequired: number[];
  76390. }
  76391. }
  76392. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  76393. /** @hidden */
  76394. export var screenSpaceReflectionPixelShader: {
  76395. name: string;
  76396. shader: string;
  76397. };
  76398. }
  76399. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  76400. import { Nullable } from "babylonjs/types";
  76401. import { Camera } from "babylonjs/Cameras/camera";
  76402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76403. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  76404. import { Engine } from "babylonjs/Engines/engine";
  76405. import { Scene } from "babylonjs/scene";
  76406. /**
  76407. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  76408. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  76409. */
  76410. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  76411. /**
  76412. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  76413. */
  76414. threshold: number;
  76415. /**
  76416. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  76417. */
  76418. strength: number;
  76419. /**
  76420. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  76421. */
  76422. reflectionSpecularFalloffExponent: number;
  76423. /**
  76424. * 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]
  76425. */
  76426. step: number;
  76427. /**
  76428. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  76429. */
  76430. roughnessFactor: number;
  76431. private _forceGeometryBuffer;
  76432. private _geometryBufferRenderer;
  76433. private _prePassRenderer;
  76434. private _enableSmoothReflections;
  76435. private _reflectionSamples;
  76436. private _smoothSteps;
  76437. /**
  76438. * Gets a string identifying the name of the class
  76439. * @returns "ScreenSpaceReflectionPostProcess" string
  76440. */
  76441. getClassName(): string;
  76442. /**
  76443. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  76444. * @param name The name of the effect.
  76445. * @param scene The scene containing the objects to calculate reflections.
  76446. * @param options The required width/height ratio to downsize to before computing the render pass.
  76447. * @param camera The camera to apply the render pass to.
  76448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76449. * @param engine The engine which the post process will be applied. (default: current engine)
  76450. * @param reusable If the post process can be reused on the same frame. (default: false)
  76451. * @param textureType Type of textures used when performing the post process. (default: 0)
  76452. * @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: true)
  76453. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  76454. */
  76455. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  76456. /**
  76457. * Gets wether or not smoothing reflections is enabled.
  76458. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76459. */
  76460. get enableSmoothReflections(): boolean;
  76461. /**
  76462. * Sets wether or not smoothing reflections is enabled.
  76463. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76464. */
  76465. set enableSmoothReflections(enabled: boolean);
  76466. /**
  76467. * Gets the number of samples taken while computing reflections. More samples count is high,
  76468. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76469. */
  76470. get reflectionSamples(): number;
  76471. /**
  76472. * Sets the number of samples taken while computing reflections. More samples count is high,
  76473. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76474. */
  76475. set reflectionSamples(samples: number);
  76476. /**
  76477. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76478. * more the post-process will require GPU power and can generate a drop in FPS.
  76479. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76480. */
  76481. get smoothSteps(): number;
  76482. set smoothSteps(steps: number);
  76483. private _updateEffectDefines;
  76484. /** @hidden */
  76485. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76486. }
  76487. }
  76488. declare module "babylonjs/Shaders/standard.fragment" {
  76489. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76490. /** @hidden */
  76491. export var standardPixelShader: {
  76492. name: string;
  76493. shader: string;
  76494. };
  76495. }
  76496. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76497. import { Nullable } from "babylonjs/types";
  76498. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76499. import { Camera } from "babylonjs/Cameras/camera";
  76500. import { Texture } from "babylonjs/Materials/Textures/texture";
  76501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76502. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76503. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76504. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76505. import { IDisposable } from "babylonjs/scene";
  76506. import { SpotLight } from "babylonjs/Lights/spotLight";
  76507. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76508. import { Scene } from "babylonjs/scene";
  76509. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76510. import { Animation } from "babylonjs/Animations/animation";
  76511. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76512. import "babylonjs/Shaders/standard.fragment";
  76513. /**
  76514. * Standard rendering pipeline
  76515. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76516. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76517. */
  76518. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76519. /**
  76520. * Public members
  76521. */
  76522. /**
  76523. * Post-process which contains the original scene color before the pipeline applies all the effects
  76524. */
  76525. originalPostProcess: Nullable<PostProcess>;
  76526. /**
  76527. * Post-process used to down scale an image x4
  76528. */
  76529. downSampleX4PostProcess: Nullable<PostProcess>;
  76530. /**
  76531. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76532. */
  76533. brightPassPostProcess: Nullable<PostProcess>;
  76534. /**
  76535. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76536. */
  76537. blurHPostProcesses: PostProcess[];
  76538. /**
  76539. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76540. */
  76541. blurVPostProcesses: PostProcess[];
  76542. /**
  76543. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76544. */
  76545. textureAdderPostProcess: Nullable<PostProcess>;
  76546. /**
  76547. * Post-process used to create volumetric lighting effect
  76548. */
  76549. volumetricLightPostProcess: Nullable<PostProcess>;
  76550. /**
  76551. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76552. */
  76553. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76554. /**
  76555. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76556. */
  76557. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76558. /**
  76559. * Post-process used to merge the volumetric light effect and the real scene color
  76560. */
  76561. volumetricLightMergePostProces: Nullable<PostProcess>;
  76562. /**
  76563. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76564. */
  76565. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76566. /**
  76567. * Base post-process used to calculate the average luminance of the final image for HDR
  76568. */
  76569. luminancePostProcess: Nullable<PostProcess>;
  76570. /**
  76571. * Post-processes used to create down sample post-processes in order to get
  76572. * the average luminance of the final image for HDR
  76573. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76574. */
  76575. luminanceDownSamplePostProcesses: PostProcess[];
  76576. /**
  76577. * Post-process used to create a HDR effect (light adaptation)
  76578. */
  76579. hdrPostProcess: Nullable<PostProcess>;
  76580. /**
  76581. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76582. */
  76583. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76584. /**
  76585. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76586. */
  76587. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76588. /**
  76589. * Post-process used to merge the final HDR post-process and the real scene color
  76590. */
  76591. hdrFinalPostProcess: Nullable<PostProcess>;
  76592. /**
  76593. * Post-process used to create a lens flare effect
  76594. */
  76595. lensFlarePostProcess: Nullable<PostProcess>;
  76596. /**
  76597. * Post-process that merges the result of the lens flare post-process and the real scene color
  76598. */
  76599. lensFlareComposePostProcess: Nullable<PostProcess>;
  76600. /**
  76601. * Post-process used to create a motion blur effect
  76602. */
  76603. motionBlurPostProcess: Nullable<PostProcess>;
  76604. /**
  76605. * Post-process used to create a depth of field effect
  76606. */
  76607. depthOfFieldPostProcess: Nullable<PostProcess>;
  76608. /**
  76609. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76610. */
  76611. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76612. /**
  76613. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76614. */
  76615. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76616. /**
  76617. * Represents the brightness threshold in order to configure the illuminated surfaces
  76618. */
  76619. brightThreshold: number;
  76620. /**
  76621. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76622. */
  76623. blurWidth: number;
  76624. /**
  76625. * Sets if the blur for highlighted surfaces must be only horizontal
  76626. */
  76627. horizontalBlur: boolean;
  76628. /**
  76629. * Gets the overall exposure used by the pipeline
  76630. */
  76631. get exposure(): number;
  76632. /**
  76633. * Sets the overall exposure used by the pipeline
  76634. */
  76635. set exposure(value: number);
  76636. /**
  76637. * Texture used typically to simulate "dirty" on camera lens
  76638. */
  76639. lensTexture: Nullable<Texture>;
  76640. /**
  76641. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76642. */
  76643. volumetricLightCoefficient: number;
  76644. /**
  76645. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76646. */
  76647. volumetricLightPower: number;
  76648. /**
  76649. * Used the set the blur intensity to smooth the volumetric lights
  76650. */
  76651. volumetricLightBlurScale: number;
  76652. /**
  76653. * Light (spot or directional) used to generate the volumetric lights rays
  76654. * The source light must have a shadow generate so the pipeline can get its
  76655. * depth map
  76656. */
  76657. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76658. /**
  76659. * For eye adaptation, represents the minimum luminance the eye can see
  76660. */
  76661. hdrMinimumLuminance: number;
  76662. /**
  76663. * For eye adaptation, represents the decrease luminance speed
  76664. */
  76665. hdrDecreaseRate: number;
  76666. /**
  76667. * For eye adaptation, represents the increase luminance speed
  76668. */
  76669. hdrIncreaseRate: number;
  76670. /**
  76671. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76672. */
  76673. get hdrAutoExposure(): boolean;
  76674. /**
  76675. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76676. */
  76677. set hdrAutoExposure(value: boolean);
  76678. /**
  76679. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76680. */
  76681. lensColorTexture: Nullable<Texture>;
  76682. /**
  76683. * The overall strengh for the lens flare effect
  76684. */
  76685. lensFlareStrength: number;
  76686. /**
  76687. * Dispersion coefficient for lens flare ghosts
  76688. */
  76689. lensFlareGhostDispersal: number;
  76690. /**
  76691. * Main lens flare halo width
  76692. */
  76693. lensFlareHaloWidth: number;
  76694. /**
  76695. * Based on the lens distortion effect, defines how much the lens flare result
  76696. * is distorted
  76697. */
  76698. lensFlareDistortionStrength: number;
  76699. /**
  76700. * Configures the blur intensity used for for lens flare (halo)
  76701. */
  76702. lensFlareBlurWidth: number;
  76703. /**
  76704. * Lens star texture must be used to simulate rays on the flares and is available
  76705. * in the documentation
  76706. */
  76707. lensStarTexture: Nullable<Texture>;
  76708. /**
  76709. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76710. * flare effect by taking account of the dirt texture
  76711. */
  76712. lensFlareDirtTexture: Nullable<Texture>;
  76713. /**
  76714. * Represents the focal length for the depth of field effect
  76715. */
  76716. depthOfFieldDistance: number;
  76717. /**
  76718. * Represents the blur intensity for the blurred part of the depth of field effect
  76719. */
  76720. depthOfFieldBlurWidth: number;
  76721. /**
  76722. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76723. */
  76724. get motionStrength(): number;
  76725. /**
  76726. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76727. */
  76728. set motionStrength(strength: number);
  76729. /**
  76730. * Gets wether or not the motion blur post-process is object based or screen based.
  76731. */
  76732. get objectBasedMotionBlur(): boolean;
  76733. /**
  76734. * Sets wether or not the motion blur post-process should be object based or screen based
  76735. */
  76736. set objectBasedMotionBlur(value: boolean);
  76737. /**
  76738. * List of animations for the pipeline (IAnimatable implementation)
  76739. */
  76740. animations: Animation[];
  76741. /**
  76742. * Private members
  76743. */
  76744. private _scene;
  76745. private _currentDepthOfFieldSource;
  76746. private _basePostProcess;
  76747. private _fixedExposure;
  76748. private _currentExposure;
  76749. private _hdrAutoExposure;
  76750. private _hdrCurrentLuminance;
  76751. private _motionStrength;
  76752. private _isObjectBasedMotionBlur;
  76753. private _floatTextureType;
  76754. private _camerasToBeAttached;
  76755. private _ratio;
  76756. private _bloomEnabled;
  76757. private _depthOfFieldEnabled;
  76758. private _vlsEnabled;
  76759. private _lensFlareEnabled;
  76760. private _hdrEnabled;
  76761. private _motionBlurEnabled;
  76762. private _fxaaEnabled;
  76763. private _screenSpaceReflectionsEnabled;
  76764. private _motionBlurSamples;
  76765. private _volumetricLightStepsCount;
  76766. private _samples;
  76767. /**
  76768. * @ignore
  76769. * Specifies if the bloom pipeline is enabled
  76770. */
  76771. get BloomEnabled(): boolean;
  76772. set BloomEnabled(enabled: boolean);
  76773. /**
  76774. * @ignore
  76775. * Specifies if the depth of field pipeline is enabed
  76776. */
  76777. get DepthOfFieldEnabled(): boolean;
  76778. set DepthOfFieldEnabled(enabled: boolean);
  76779. /**
  76780. * @ignore
  76781. * Specifies if the lens flare pipeline is enabed
  76782. */
  76783. get LensFlareEnabled(): boolean;
  76784. set LensFlareEnabled(enabled: boolean);
  76785. /**
  76786. * @ignore
  76787. * Specifies if the HDR pipeline is enabled
  76788. */
  76789. get HDREnabled(): boolean;
  76790. set HDREnabled(enabled: boolean);
  76791. /**
  76792. * @ignore
  76793. * Specifies if the volumetric lights scattering effect is enabled
  76794. */
  76795. get VLSEnabled(): boolean;
  76796. set VLSEnabled(enabled: boolean);
  76797. /**
  76798. * @ignore
  76799. * Specifies if the motion blur effect is enabled
  76800. */
  76801. get MotionBlurEnabled(): boolean;
  76802. set MotionBlurEnabled(enabled: boolean);
  76803. /**
  76804. * Specifies if anti-aliasing is enabled
  76805. */
  76806. get fxaaEnabled(): boolean;
  76807. set fxaaEnabled(enabled: boolean);
  76808. /**
  76809. * Specifies if screen space reflections are enabled.
  76810. */
  76811. get screenSpaceReflectionsEnabled(): boolean;
  76812. set screenSpaceReflectionsEnabled(enabled: boolean);
  76813. /**
  76814. * Specifies the number of steps used to calculate the volumetric lights
  76815. * Typically in interval [50, 200]
  76816. */
  76817. get volumetricLightStepsCount(): number;
  76818. set volumetricLightStepsCount(count: number);
  76819. /**
  76820. * Specifies the number of samples used for the motion blur effect
  76821. * Typically in interval [16, 64]
  76822. */
  76823. get motionBlurSamples(): number;
  76824. set motionBlurSamples(samples: number);
  76825. /**
  76826. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76827. */
  76828. get samples(): number;
  76829. set samples(sampleCount: number);
  76830. /**
  76831. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76832. * @constructor
  76833. * @param name The rendering pipeline name
  76834. * @param scene The scene linked to this pipeline
  76835. * @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)
  76836. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76837. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76838. */
  76839. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76840. private _buildPipeline;
  76841. private _createDownSampleX4PostProcess;
  76842. private _createBrightPassPostProcess;
  76843. private _createBlurPostProcesses;
  76844. private _createTextureAdderPostProcess;
  76845. private _createVolumetricLightPostProcess;
  76846. private _createLuminancePostProcesses;
  76847. private _createHdrPostProcess;
  76848. private _createLensFlarePostProcess;
  76849. private _createDepthOfFieldPostProcess;
  76850. private _createMotionBlurPostProcess;
  76851. private _getDepthTexture;
  76852. private _disposePostProcesses;
  76853. /**
  76854. * Dispose of the pipeline and stop all post processes
  76855. */
  76856. dispose(): void;
  76857. /**
  76858. * Serialize the rendering pipeline (Used when exporting)
  76859. * @returns the serialized object
  76860. */
  76861. serialize(): any;
  76862. /**
  76863. * Parse the serialized pipeline
  76864. * @param source Source pipeline.
  76865. * @param scene The scene to load the pipeline to.
  76866. * @param rootUrl The URL of the serialized pipeline.
  76867. * @returns An instantiated pipeline from the serialized object.
  76868. */
  76869. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76870. /**
  76871. * Luminance steps
  76872. */
  76873. static LuminanceSteps: number;
  76874. }
  76875. }
  76876. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76877. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76878. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76879. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76880. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76881. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76882. }
  76883. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76884. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76885. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76886. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76887. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76888. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76889. }
  76890. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76891. /** @hidden */
  76892. export var stereoscopicInterlacePixelShader: {
  76893. name: string;
  76894. shader: string;
  76895. };
  76896. }
  76897. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76898. import { Camera } from "babylonjs/Cameras/camera";
  76899. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76900. import { Engine } from "babylonjs/Engines/engine";
  76901. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76902. /**
  76903. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76904. */
  76905. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76906. private _stepSize;
  76907. private _passedProcess;
  76908. /**
  76909. * Gets a string identifying the name of the class
  76910. * @returns "StereoscopicInterlacePostProcessI" string
  76911. */
  76912. getClassName(): string;
  76913. /**
  76914. * Initializes a StereoscopicInterlacePostProcessI
  76915. * @param name The name of the effect.
  76916. * @param rigCameras The rig cameras to be appled to the post process
  76917. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76918. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76919. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76920. * @param engine The engine which the post process will be applied. (default: current engine)
  76921. * @param reusable If the post process can be reused on the same frame. (default: false)
  76922. */
  76923. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76924. }
  76925. /**
  76926. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76927. */
  76928. export class StereoscopicInterlacePostProcess extends PostProcess {
  76929. private _stepSize;
  76930. private _passedProcess;
  76931. /**
  76932. * Gets a string identifying the name of the class
  76933. * @returns "StereoscopicInterlacePostProcess" string
  76934. */
  76935. getClassName(): string;
  76936. /**
  76937. * Initializes a StereoscopicInterlacePostProcess
  76938. * @param name The name of the effect.
  76939. * @param rigCameras The rig cameras to be appled to the post process
  76940. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76942. * @param engine The engine which the post process will be applied. (default: current engine)
  76943. * @param reusable If the post process can be reused on the same frame. (default: false)
  76944. */
  76945. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76946. }
  76947. }
  76948. declare module "babylonjs/Shaders/tonemap.fragment" {
  76949. /** @hidden */
  76950. export var tonemapPixelShader: {
  76951. name: string;
  76952. shader: string;
  76953. };
  76954. }
  76955. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76956. import { Camera } from "babylonjs/Cameras/camera";
  76957. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76958. import "babylonjs/Shaders/tonemap.fragment";
  76959. import { Engine } from "babylonjs/Engines/engine";
  76960. /** Defines operator used for tonemapping */
  76961. export enum TonemappingOperator {
  76962. /** Hable */
  76963. Hable = 0,
  76964. /** Reinhard */
  76965. Reinhard = 1,
  76966. /** HejiDawson */
  76967. HejiDawson = 2,
  76968. /** Photographic */
  76969. Photographic = 3
  76970. }
  76971. /**
  76972. * Defines a post process to apply tone mapping
  76973. */
  76974. export class TonemapPostProcess extends PostProcess {
  76975. private _operator;
  76976. /** Defines the required exposure adjustement */
  76977. exposureAdjustment: number;
  76978. /**
  76979. * Gets a string identifying the name of the class
  76980. * @returns "TonemapPostProcess" string
  76981. */
  76982. getClassName(): string;
  76983. /**
  76984. * Creates a new TonemapPostProcess
  76985. * @param name defines the name of the postprocess
  76986. * @param _operator defines the operator to use
  76987. * @param exposureAdjustment defines the required exposure adjustement
  76988. * @param camera defines the camera to use (can be null)
  76989. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76990. * @param engine defines the hosting engine (can be ignore if camera is set)
  76991. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76992. */
  76993. constructor(name: string, _operator: TonemappingOperator,
  76994. /** Defines the required exposure adjustement */
  76995. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76996. }
  76997. }
  76998. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76999. /** @hidden */
  77000. export var volumetricLightScatteringPixelShader: {
  77001. name: string;
  77002. shader: string;
  77003. };
  77004. }
  77005. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  77006. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77008. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77009. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77010. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77011. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77012. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77013. /** @hidden */
  77014. export var volumetricLightScatteringPassVertexShader: {
  77015. name: string;
  77016. shader: string;
  77017. };
  77018. }
  77019. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  77020. /** @hidden */
  77021. export var volumetricLightScatteringPassPixelShader: {
  77022. name: string;
  77023. shader: string;
  77024. };
  77025. }
  77026. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  77027. import { Vector3 } from "babylonjs/Maths/math.vector";
  77028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77029. import { Mesh } from "babylonjs/Meshes/mesh";
  77030. import { Camera } from "babylonjs/Cameras/camera";
  77031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  77032. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  77033. import { Scene } from "babylonjs/scene";
  77034. import "babylonjs/Meshes/Builders/planeBuilder";
  77035. import "babylonjs/Shaders/depth.vertex";
  77036. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  77037. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  77038. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  77039. import { Engine } from "babylonjs/Engines/engine";
  77040. /**
  77041. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  77042. */
  77043. export class VolumetricLightScatteringPostProcess extends PostProcess {
  77044. private _volumetricLightScatteringPass;
  77045. private _volumetricLightScatteringRTT;
  77046. private _viewPort;
  77047. private _screenCoordinates;
  77048. private _cachedDefines;
  77049. /**
  77050. * If not undefined, the mesh position is computed from the attached node position
  77051. */
  77052. attachedNode: {
  77053. position: Vector3;
  77054. };
  77055. /**
  77056. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  77057. */
  77058. customMeshPosition: Vector3;
  77059. /**
  77060. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  77061. */
  77062. useCustomMeshPosition: boolean;
  77063. /**
  77064. * If the post-process should inverse the light scattering direction
  77065. */
  77066. invert: boolean;
  77067. /**
  77068. * The internal mesh used by the post-process
  77069. */
  77070. mesh: Mesh;
  77071. /**
  77072. * @hidden
  77073. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  77074. */
  77075. get useDiffuseColor(): boolean;
  77076. set useDiffuseColor(useDiffuseColor: boolean);
  77077. /**
  77078. * Array containing the excluded meshes not rendered in the internal pass
  77079. */
  77080. excludedMeshes: AbstractMesh[];
  77081. /**
  77082. * Controls the overall intensity of the post-process
  77083. */
  77084. exposure: number;
  77085. /**
  77086. * Dissipates each sample's contribution in range [0, 1]
  77087. */
  77088. decay: number;
  77089. /**
  77090. * Controls the overall intensity of each sample
  77091. */
  77092. weight: number;
  77093. /**
  77094. * Controls the density of each sample
  77095. */
  77096. density: number;
  77097. /**
  77098. * @constructor
  77099. * @param name The post-process name
  77100. * @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)
  77101. * @param camera The camera that the post-process will be attached to
  77102. * @param mesh The mesh used to create the light scattering
  77103. * @param samples The post-process quality, default 100
  77104. * @param samplingModeThe post-process filtering mode
  77105. * @param engine The babylon engine
  77106. * @param reusable If the post-process is reusable
  77107. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  77108. */
  77109. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  77110. /**
  77111. * Returns the string "VolumetricLightScatteringPostProcess"
  77112. * @returns "VolumetricLightScatteringPostProcess"
  77113. */
  77114. getClassName(): string;
  77115. private _isReady;
  77116. /**
  77117. * Sets the new light position for light scattering effect
  77118. * @param position The new custom light position
  77119. */
  77120. setCustomMeshPosition(position: Vector3): void;
  77121. /**
  77122. * Returns the light position for light scattering effect
  77123. * @return Vector3 The custom light position
  77124. */
  77125. getCustomMeshPosition(): Vector3;
  77126. /**
  77127. * Disposes the internal assets and detaches the post-process from the camera
  77128. */
  77129. dispose(camera: Camera): void;
  77130. /**
  77131. * Returns the render target texture used by the post-process
  77132. * @return the render target texture used by the post-process
  77133. */
  77134. getPass(): RenderTargetTexture;
  77135. private _meshExcluded;
  77136. private _createPass;
  77137. private _updateMeshScreenCoordinates;
  77138. /**
  77139. * Creates a default mesh for the Volumeric Light Scattering post-process
  77140. * @param name The mesh name
  77141. * @param scene The scene where to create the mesh
  77142. * @return the default mesh
  77143. */
  77144. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  77145. }
  77146. }
  77147. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  77148. /** @hidden */
  77149. export var screenSpaceCurvaturePixelShader: {
  77150. name: string;
  77151. shader: string;
  77152. };
  77153. }
  77154. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  77155. import { Nullable } from "babylonjs/types";
  77156. import { Camera } from "babylonjs/Cameras/camera";
  77157. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77158. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77159. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  77160. import { Engine } from "babylonjs/Engines/engine";
  77161. import { Scene } from "babylonjs/scene";
  77162. /**
  77163. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  77164. */
  77165. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  77166. /**
  77167. * Defines how much ridge the curvature effect displays.
  77168. */
  77169. ridge: number;
  77170. /**
  77171. * Defines how much valley the curvature effect displays.
  77172. */
  77173. valley: number;
  77174. private _geometryBufferRenderer;
  77175. /**
  77176. * Gets a string identifying the name of the class
  77177. * @returns "ScreenSpaceCurvaturePostProcess" string
  77178. */
  77179. getClassName(): string;
  77180. /**
  77181. * Creates a new instance ScreenSpaceCurvaturePostProcess
  77182. * @param name The name of the effect.
  77183. * @param scene The scene containing the objects to blur according to their velocity.
  77184. * @param options The required width/height ratio to downsize to before computing the render pass.
  77185. * @param camera The camera to apply the render pass to.
  77186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  77187. * @param engine The engine which the post process will be applied. (default: current engine)
  77188. * @param reusable If the post process can be reused on the same frame. (default: false)
  77189. * @param textureType Type of textures used when performing the post process. (default: 0)
  77190. * @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)
  77191. */
  77192. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  77193. /**
  77194. * Support test.
  77195. */
  77196. static get IsSupported(): boolean;
  77197. /** @hidden */
  77198. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  77199. }
  77200. }
  77201. declare module "babylonjs/PostProcesses/index" {
  77202. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  77203. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  77204. export * from "babylonjs/PostProcesses/bloomEffect";
  77205. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  77206. export * from "babylonjs/PostProcesses/blurPostProcess";
  77207. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  77208. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  77209. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  77210. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  77211. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  77212. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  77213. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  77214. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  77215. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  77216. export * from "babylonjs/PostProcesses/filterPostProcess";
  77217. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  77218. export * from "babylonjs/PostProcesses/grainPostProcess";
  77219. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  77220. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  77221. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  77222. export * from "babylonjs/PostProcesses/passPostProcess";
  77223. export * from "babylonjs/PostProcesses/postProcess";
  77224. export * from "babylonjs/PostProcesses/postProcessManager";
  77225. export * from "babylonjs/PostProcesses/refractionPostProcess";
  77226. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  77227. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  77228. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  77229. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  77230. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  77231. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  77232. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  77233. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  77234. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  77235. }
  77236. declare module "babylonjs/Probes/index" {
  77237. export * from "babylonjs/Probes/reflectionProbe";
  77238. }
  77239. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  77240. import { Scene } from "babylonjs/scene";
  77241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77242. import { SmartArray } from "babylonjs/Misc/smartArray";
  77243. import { ISceneComponent } from "babylonjs/sceneComponent";
  77244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  77245. import "babylonjs/Meshes/Builders/boxBuilder";
  77246. import "babylonjs/Shaders/color.fragment";
  77247. import "babylonjs/Shaders/color.vertex";
  77248. import { Color3 } from "babylonjs/Maths/math.color";
  77249. import { Observable } from "babylonjs/Misc/observable";
  77250. module "babylonjs/scene" {
  77251. interface Scene {
  77252. /** @hidden (Backing field) */
  77253. _boundingBoxRenderer: BoundingBoxRenderer;
  77254. /** @hidden (Backing field) */
  77255. _forceShowBoundingBoxes: boolean;
  77256. /**
  77257. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  77258. */
  77259. forceShowBoundingBoxes: boolean;
  77260. /**
  77261. * Gets the bounding box renderer associated with the scene
  77262. * @returns a BoundingBoxRenderer
  77263. */
  77264. getBoundingBoxRenderer(): BoundingBoxRenderer;
  77265. }
  77266. }
  77267. module "babylonjs/Meshes/abstractMesh" {
  77268. interface AbstractMesh {
  77269. /** @hidden (Backing field) */
  77270. _showBoundingBox: boolean;
  77271. /**
  77272. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  77273. */
  77274. showBoundingBox: boolean;
  77275. }
  77276. }
  77277. /**
  77278. * Component responsible of rendering the bounding box of the meshes in a scene.
  77279. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  77280. */
  77281. export class BoundingBoxRenderer implements ISceneComponent {
  77282. /**
  77283. * The component name helpfull to identify the component in the list of scene components.
  77284. */
  77285. readonly name: string;
  77286. /**
  77287. * The scene the component belongs to.
  77288. */
  77289. scene: Scene;
  77290. /**
  77291. * Color of the bounding box lines placed in front of an object
  77292. */
  77293. frontColor: Color3;
  77294. /**
  77295. * Color of the bounding box lines placed behind an object
  77296. */
  77297. backColor: Color3;
  77298. /**
  77299. * Defines if the renderer should show the back lines or not
  77300. */
  77301. showBackLines: boolean;
  77302. /**
  77303. * Observable raised before rendering a bounding box
  77304. */
  77305. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  77306. /**
  77307. * Observable raised after rendering a bounding box
  77308. */
  77309. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  77310. /**
  77311. * Observable raised after resources are created
  77312. */
  77313. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  77314. /**
  77315. * When false, no bounding boxes will be rendered
  77316. */
  77317. enabled: boolean;
  77318. /**
  77319. * @hidden
  77320. */
  77321. renderList: SmartArray<BoundingBox>;
  77322. private _colorShader;
  77323. private _vertexBuffers;
  77324. private _indexBuffer;
  77325. private _fillIndexBuffer;
  77326. private _fillIndexData;
  77327. /**
  77328. * Instantiates a new bounding box renderer in a scene.
  77329. * @param scene the scene the renderer renders in
  77330. */
  77331. constructor(scene: Scene);
  77332. /**
  77333. * Registers the component in a given scene
  77334. */
  77335. register(): void;
  77336. private _evaluateSubMesh;
  77337. private _preActiveMesh;
  77338. private _prepareResources;
  77339. private _createIndexBuffer;
  77340. /**
  77341. * Rebuilds the elements related to this component in case of
  77342. * context lost for instance.
  77343. */
  77344. rebuild(): void;
  77345. /**
  77346. * @hidden
  77347. */
  77348. reset(): void;
  77349. /**
  77350. * Render the bounding boxes of a specific rendering group
  77351. * @param renderingGroupId defines the rendering group to render
  77352. */
  77353. render(renderingGroupId: number): void;
  77354. /**
  77355. * In case of occlusion queries, we can render the occlusion bounding box through this method
  77356. * @param mesh Define the mesh to render the occlusion bounding box for
  77357. */
  77358. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  77359. /**
  77360. * Dispose and release the resources attached to this renderer.
  77361. */
  77362. dispose(): void;
  77363. }
  77364. }
  77365. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  77366. import { Nullable } from "babylonjs/types";
  77367. import { Scene } from "babylonjs/scene";
  77368. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  77369. import { Camera } from "babylonjs/Cameras/camera";
  77370. import { ISceneComponent } from "babylonjs/sceneComponent";
  77371. module "babylonjs/scene" {
  77372. interface Scene {
  77373. /** @hidden (Backing field) */
  77374. _depthRenderer: {
  77375. [id: string]: DepthRenderer;
  77376. };
  77377. /**
  77378. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  77379. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  77380. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  77381. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  77382. * @returns the created depth renderer
  77383. */
  77384. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  77385. /**
  77386. * Disables a depth renderer for a given camera
  77387. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  77388. */
  77389. disableDepthRenderer(camera?: Nullable<Camera>): void;
  77390. }
  77391. }
  77392. /**
  77393. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  77394. * in several rendering techniques.
  77395. */
  77396. export class DepthRendererSceneComponent implements ISceneComponent {
  77397. /**
  77398. * The component name helpfull to identify the component in the list of scene components.
  77399. */
  77400. readonly name: string;
  77401. /**
  77402. * The scene the component belongs to.
  77403. */
  77404. scene: Scene;
  77405. /**
  77406. * Creates a new instance of the component for the given scene
  77407. * @param scene Defines the scene to register the component in
  77408. */
  77409. constructor(scene: Scene);
  77410. /**
  77411. * Registers the component in a given scene
  77412. */
  77413. register(): void;
  77414. /**
  77415. * Rebuilds the elements related to this component in case of
  77416. * context lost for instance.
  77417. */
  77418. rebuild(): void;
  77419. /**
  77420. * Disposes the component and the associated ressources
  77421. */
  77422. dispose(): void;
  77423. private _gatherRenderTargets;
  77424. private _gatherActiveCameraRenderTargets;
  77425. }
  77426. }
  77427. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  77428. import { Nullable } from "babylonjs/types";
  77429. import { Scene } from "babylonjs/scene";
  77430. import { ISceneComponent } from "babylonjs/sceneComponent";
  77431. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  77432. module "babylonjs/abstractScene" {
  77433. interface AbstractScene {
  77434. /** @hidden (Backing field) */
  77435. _prePassRenderer: Nullable<PrePassRenderer>;
  77436. /**
  77437. * Gets or Sets the current prepass renderer associated to the scene.
  77438. */
  77439. prePassRenderer: Nullable<PrePassRenderer>;
  77440. /**
  77441. * Enables the prepass and associates it with the scene
  77442. * @returns the PrePassRenderer
  77443. */
  77444. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  77445. /**
  77446. * Disables the prepass associated with the scene
  77447. */
  77448. disablePrePassRenderer(): void;
  77449. }
  77450. }
  77451. /**
  77452. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77453. * in several rendering techniques.
  77454. */
  77455. export class PrePassRendererSceneComponent implements ISceneComponent {
  77456. /**
  77457. * The component name helpful to identify the component in the list of scene components.
  77458. */
  77459. readonly name: string;
  77460. /**
  77461. * The scene the component belongs to.
  77462. */
  77463. scene: Scene;
  77464. /**
  77465. * Creates a new instance of the component for the given scene
  77466. * @param scene Defines the scene to register the component in
  77467. */
  77468. constructor(scene: Scene);
  77469. /**
  77470. * Registers the component in a given scene
  77471. */
  77472. register(): void;
  77473. private _beforeCameraDraw;
  77474. private _afterCameraDraw;
  77475. private _beforeClearStage;
  77476. private _beforeRenderingMeshStage;
  77477. private _afterRenderingMeshStage;
  77478. /**
  77479. * Rebuilds the elements related to this component in case of
  77480. * context lost for instance.
  77481. */
  77482. rebuild(): void;
  77483. /**
  77484. * Disposes the component and the associated ressources
  77485. */
  77486. dispose(): void;
  77487. }
  77488. }
  77489. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77490. /** @hidden */
  77491. export var fibonacci: {
  77492. name: string;
  77493. shader: string;
  77494. };
  77495. }
  77496. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77497. /** @hidden */
  77498. export var diffusionProfile: {
  77499. name: string;
  77500. shader: string;
  77501. };
  77502. }
  77503. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77504. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77505. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77506. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77507. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77508. /** @hidden */
  77509. export var subSurfaceScatteringPixelShader: {
  77510. name: string;
  77511. shader: string;
  77512. };
  77513. }
  77514. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77515. import { Nullable } from "babylonjs/types";
  77516. import { Camera } from "babylonjs/Cameras/camera";
  77517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77518. import { Engine } from "babylonjs/Engines/engine";
  77519. import { Scene } from "babylonjs/scene";
  77520. import "babylonjs/Shaders/imageProcessing.fragment";
  77521. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77522. import "babylonjs/Shaders/postprocess.vertex";
  77523. /**
  77524. * Sub surface scattering post process
  77525. */
  77526. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77527. /**
  77528. * Gets a string identifying the name of the class
  77529. * @returns "SubSurfaceScatteringPostProcess" string
  77530. */
  77531. getClassName(): string;
  77532. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77533. }
  77534. }
  77535. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77536. import { Scene } from "babylonjs/scene";
  77537. import { Color3 } from "babylonjs/Maths/math.color";
  77538. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77539. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77540. /**
  77541. * Contains all parameters needed for the prepass to perform
  77542. * screen space subsurface scattering
  77543. */
  77544. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77545. /** @hidden */
  77546. static _SceneComponentInitialization: (scene: Scene) => void;
  77547. private _ssDiffusionS;
  77548. private _ssFilterRadii;
  77549. private _ssDiffusionD;
  77550. /**
  77551. * Post process to attach for screen space subsurface scattering
  77552. */
  77553. postProcess: SubSurfaceScatteringPostProcess;
  77554. /**
  77555. * Diffusion profile color for subsurface scattering
  77556. */
  77557. get ssDiffusionS(): number[];
  77558. /**
  77559. * Diffusion profile max color channel value for subsurface scattering
  77560. */
  77561. get ssDiffusionD(): number[];
  77562. /**
  77563. * Diffusion profile filter radius for subsurface scattering
  77564. */
  77565. get ssFilterRadii(): number[];
  77566. /**
  77567. * Is subsurface enabled
  77568. */
  77569. enabled: boolean;
  77570. /**
  77571. * Name of the configuration
  77572. */
  77573. name: string;
  77574. /**
  77575. * Diffusion profile colors for subsurface scattering
  77576. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77577. * See ...
  77578. * Note that you can only store up to 5 of them
  77579. */
  77580. ssDiffusionProfileColors: Color3[];
  77581. /**
  77582. * Defines the ratio real world => scene units.
  77583. * Used for subsurface scattering
  77584. */
  77585. metersPerUnit: number;
  77586. /**
  77587. * Textures that should be present in the MRT for this effect to work
  77588. */
  77589. readonly texturesRequired: number[];
  77590. private _scene;
  77591. /**
  77592. * Builds a subsurface configuration object
  77593. * @param scene The scene
  77594. */
  77595. constructor(scene: Scene);
  77596. /**
  77597. * Adds a new diffusion profile.
  77598. * Useful for more realistic subsurface scattering on diverse materials.
  77599. * @param color The color of the diffusion profile. Should be the average color of the material.
  77600. * @return The index of the diffusion profile for the material subsurface configuration
  77601. */
  77602. addDiffusionProfile(color: Color3): number;
  77603. /**
  77604. * Creates the sss post process
  77605. * @return The created post process
  77606. */
  77607. createPostProcess(): SubSurfaceScatteringPostProcess;
  77608. /**
  77609. * Deletes all diffusion profiles.
  77610. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77611. */
  77612. clearAllDiffusionProfiles(): void;
  77613. /**
  77614. * Disposes this object
  77615. */
  77616. dispose(): void;
  77617. /**
  77618. * @hidden
  77619. * https://zero-radiance.github.io/post/sampling-diffusion/
  77620. *
  77621. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77622. * ------------------------------------------------------------------------------------
  77623. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77624. * PDF[r, phi, s] = r * R[r, phi, s]
  77625. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77626. * ------------------------------------------------------------------------------------
  77627. * We importance sample the color channel with the widest scattering distance.
  77628. */
  77629. getDiffusionProfileParameters(color: Color3): number;
  77630. /**
  77631. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77632. * 'u' is the random number (the value of the CDF): [0, 1).
  77633. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77634. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77635. */
  77636. private _sampleBurleyDiffusionProfile;
  77637. }
  77638. }
  77639. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77640. import { Nullable } from "babylonjs/types";
  77641. import { Scene } from "babylonjs/scene";
  77642. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77643. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77644. import { AbstractScene } from "babylonjs/abstractScene";
  77645. module "babylonjs/abstractScene" {
  77646. interface AbstractScene {
  77647. /** @hidden (Backing field) */
  77648. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77649. /**
  77650. * Gets or Sets the current prepass renderer associated to the scene.
  77651. */
  77652. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77653. /**
  77654. * Enables the subsurface effect for prepass
  77655. * @returns the SubSurfaceConfiguration
  77656. */
  77657. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77658. /**
  77659. * Disables the subsurface effect for prepass
  77660. */
  77661. disableSubSurfaceForPrePass(): void;
  77662. }
  77663. }
  77664. /**
  77665. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77666. * in several rendering techniques.
  77667. */
  77668. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77669. /**
  77670. * The component name helpful to identify the component in the list of scene components.
  77671. */
  77672. readonly name: string;
  77673. /**
  77674. * The scene the component belongs to.
  77675. */
  77676. scene: Scene;
  77677. /**
  77678. * Creates a new instance of the component for the given scene
  77679. * @param scene Defines the scene to register the component in
  77680. */
  77681. constructor(scene: Scene);
  77682. /**
  77683. * Registers the component in a given scene
  77684. */
  77685. register(): void;
  77686. /**
  77687. * Serializes the component data to the specified json object
  77688. * @param serializationObject The object to serialize to
  77689. */
  77690. serialize(serializationObject: any): void;
  77691. /**
  77692. * Adds all the elements from the container to the scene
  77693. * @param container the container holding the elements
  77694. */
  77695. addFromContainer(container: AbstractScene): void;
  77696. /**
  77697. * Removes all the elements in the container from the scene
  77698. * @param container contains the elements to remove
  77699. * @param dispose if the removed element should be disposed (default: false)
  77700. */
  77701. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77702. /**
  77703. * Rebuilds the elements related to this component in case of
  77704. * context lost for instance.
  77705. */
  77706. rebuild(): void;
  77707. /**
  77708. * Disposes the component and the associated ressources
  77709. */
  77710. dispose(): void;
  77711. }
  77712. }
  77713. declare module "babylonjs/Shaders/outline.fragment" {
  77714. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77715. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77716. /** @hidden */
  77717. export var outlinePixelShader: {
  77718. name: string;
  77719. shader: string;
  77720. };
  77721. }
  77722. declare module "babylonjs/Shaders/outline.vertex" {
  77723. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77724. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77725. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77726. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77727. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77728. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77729. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77730. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77731. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77732. /** @hidden */
  77733. export var outlineVertexShader: {
  77734. name: string;
  77735. shader: string;
  77736. };
  77737. }
  77738. declare module "babylonjs/Rendering/outlineRenderer" {
  77739. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77740. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77741. import { Scene } from "babylonjs/scene";
  77742. import { ISceneComponent } from "babylonjs/sceneComponent";
  77743. import "babylonjs/Shaders/outline.fragment";
  77744. import "babylonjs/Shaders/outline.vertex";
  77745. module "babylonjs/scene" {
  77746. interface Scene {
  77747. /** @hidden */
  77748. _outlineRenderer: OutlineRenderer;
  77749. /**
  77750. * Gets the outline renderer associated with the scene
  77751. * @returns a OutlineRenderer
  77752. */
  77753. getOutlineRenderer(): OutlineRenderer;
  77754. }
  77755. }
  77756. module "babylonjs/Meshes/abstractMesh" {
  77757. interface AbstractMesh {
  77758. /** @hidden (Backing field) */
  77759. _renderOutline: boolean;
  77760. /**
  77761. * Gets or sets a boolean indicating if the outline must be rendered as well
  77762. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77763. */
  77764. renderOutline: boolean;
  77765. /** @hidden (Backing field) */
  77766. _renderOverlay: boolean;
  77767. /**
  77768. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77769. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77770. */
  77771. renderOverlay: boolean;
  77772. }
  77773. }
  77774. /**
  77775. * This class is responsible to draw bothe outline/overlay of meshes.
  77776. * It should not be used directly but through the available method on mesh.
  77777. */
  77778. export class OutlineRenderer implements ISceneComponent {
  77779. /**
  77780. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77781. */
  77782. private static _StencilReference;
  77783. /**
  77784. * The name of the component. Each component must have a unique name.
  77785. */
  77786. name: string;
  77787. /**
  77788. * The scene the component belongs to.
  77789. */
  77790. scene: Scene;
  77791. /**
  77792. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77793. */
  77794. zOffset: number;
  77795. private _engine;
  77796. private _effect;
  77797. private _cachedDefines;
  77798. private _savedDepthWrite;
  77799. /**
  77800. * Instantiates a new outline renderer. (There could be only one per scene).
  77801. * @param scene Defines the scene it belongs to
  77802. */
  77803. constructor(scene: Scene);
  77804. /**
  77805. * Register the component to one instance of a scene.
  77806. */
  77807. register(): void;
  77808. /**
  77809. * Rebuilds the elements related to this component in case of
  77810. * context lost for instance.
  77811. */
  77812. rebuild(): void;
  77813. /**
  77814. * Disposes the component and the associated ressources.
  77815. */
  77816. dispose(): void;
  77817. /**
  77818. * Renders the outline in the canvas.
  77819. * @param subMesh Defines the sumesh to render
  77820. * @param batch Defines the batch of meshes in case of instances
  77821. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77822. */
  77823. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77824. /**
  77825. * Returns whether or not the outline renderer is ready for a given submesh.
  77826. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77827. * @param subMesh Defines the submesh to check readyness for
  77828. * @param useInstances Defines wheter wee are trying to render instances or not
  77829. * @returns true if ready otherwise false
  77830. */
  77831. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77832. private _beforeRenderingMesh;
  77833. private _afterRenderingMesh;
  77834. }
  77835. }
  77836. declare module "babylonjs/Rendering/index" {
  77837. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77838. export * from "babylonjs/Rendering/depthRenderer";
  77839. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77840. export * from "babylonjs/Rendering/edgesRenderer";
  77841. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77842. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77843. export * from "babylonjs/Rendering/prePassRenderer";
  77844. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77845. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77846. export * from "babylonjs/Rendering/outlineRenderer";
  77847. export * from "babylonjs/Rendering/renderingGroup";
  77848. export * from "babylonjs/Rendering/renderingManager";
  77849. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77850. }
  77851. declare module "babylonjs/Sprites/ISprites" {
  77852. /**
  77853. * Defines the basic options interface of a Sprite Frame Source Size.
  77854. */
  77855. export interface ISpriteJSONSpriteSourceSize {
  77856. /**
  77857. * number of the original width of the Frame
  77858. */
  77859. w: number;
  77860. /**
  77861. * number of the original height of the Frame
  77862. */
  77863. h: number;
  77864. }
  77865. /**
  77866. * Defines the basic options interface of a Sprite Frame Data.
  77867. */
  77868. export interface ISpriteJSONSpriteFrameData {
  77869. /**
  77870. * number of the x offset of the Frame
  77871. */
  77872. x: number;
  77873. /**
  77874. * number of the y offset of the Frame
  77875. */
  77876. y: number;
  77877. /**
  77878. * number of the width of the Frame
  77879. */
  77880. w: number;
  77881. /**
  77882. * number of the height of the Frame
  77883. */
  77884. h: number;
  77885. }
  77886. /**
  77887. * Defines the basic options interface of a JSON Sprite.
  77888. */
  77889. export interface ISpriteJSONSprite {
  77890. /**
  77891. * string name of the Frame
  77892. */
  77893. filename: string;
  77894. /**
  77895. * ISpriteJSONSpriteFrame basic object of the frame data
  77896. */
  77897. frame: ISpriteJSONSpriteFrameData;
  77898. /**
  77899. * boolean to flag is the frame was rotated.
  77900. */
  77901. rotated: boolean;
  77902. /**
  77903. * boolean to flag is the frame was trimmed.
  77904. */
  77905. trimmed: boolean;
  77906. /**
  77907. * ISpriteJSONSpriteFrame basic object of the source data
  77908. */
  77909. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77910. /**
  77911. * ISpriteJSONSpriteFrame basic object of the source data
  77912. */
  77913. sourceSize: ISpriteJSONSpriteSourceSize;
  77914. }
  77915. /**
  77916. * Defines the basic options interface of a JSON atlas.
  77917. */
  77918. export interface ISpriteJSONAtlas {
  77919. /**
  77920. * Array of objects that contain the frame data.
  77921. */
  77922. frames: Array<ISpriteJSONSprite>;
  77923. /**
  77924. * object basic object containing the sprite meta data.
  77925. */
  77926. meta?: object;
  77927. }
  77928. }
  77929. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77930. /** @hidden */
  77931. export var spriteMapPixelShader: {
  77932. name: string;
  77933. shader: string;
  77934. };
  77935. }
  77936. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77937. /** @hidden */
  77938. export var spriteMapVertexShader: {
  77939. name: string;
  77940. shader: string;
  77941. };
  77942. }
  77943. declare module "babylonjs/Sprites/spriteMap" {
  77944. import { IDisposable, Scene } from "babylonjs/scene";
  77945. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77946. import { Texture } from "babylonjs/Materials/Textures/texture";
  77947. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77948. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77949. import "babylonjs/Meshes/Builders/planeBuilder";
  77950. import "babylonjs/Shaders/spriteMap.fragment";
  77951. import "babylonjs/Shaders/spriteMap.vertex";
  77952. /**
  77953. * Defines the basic options interface of a SpriteMap
  77954. */
  77955. export interface ISpriteMapOptions {
  77956. /**
  77957. * Vector2 of the number of cells in the grid.
  77958. */
  77959. stageSize?: Vector2;
  77960. /**
  77961. * Vector2 of the size of the output plane in World Units.
  77962. */
  77963. outputSize?: Vector2;
  77964. /**
  77965. * Vector3 of the position of the output plane in World Units.
  77966. */
  77967. outputPosition?: Vector3;
  77968. /**
  77969. * Vector3 of the rotation of the output plane.
  77970. */
  77971. outputRotation?: Vector3;
  77972. /**
  77973. * number of layers that the system will reserve in resources.
  77974. */
  77975. layerCount?: number;
  77976. /**
  77977. * number of max animation frames a single cell will reserve in resources.
  77978. */
  77979. maxAnimationFrames?: number;
  77980. /**
  77981. * number cell index of the base tile when the system compiles.
  77982. */
  77983. baseTile?: number;
  77984. /**
  77985. * boolean flip the sprite after its been repositioned by the framing data.
  77986. */
  77987. flipU?: boolean;
  77988. /**
  77989. * Vector3 scalar of the global RGB values of the SpriteMap.
  77990. */
  77991. colorMultiply?: Vector3;
  77992. }
  77993. /**
  77994. * Defines the IDisposable interface in order to be cleanable from resources.
  77995. */
  77996. export interface ISpriteMap extends IDisposable {
  77997. /**
  77998. * String name of the SpriteMap.
  77999. */
  78000. name: string;
  78001. /**
  78002. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  78003. */
  78004. atlasJSON: ISpriteJSONAtlas;
  78005. /**
  78006. * Texture of the SpriteMap.
  78007. */
  78008. spriteSheet: Texture;
  78009. /**
  78010. * The parameters to initialize the SpriteMap with.
  78011. */
  78012. options: ISpriteMapOptions;
  78013. }
  78014. /**
  78015. * Class used to manage a grid restricted sprite deployment on an Output plane.
  78016. */
  78017. export class SpriteMap implements ISpriteMap {
  78018. /** The Name of the spriteMap */
  78019. name: string;
  78020. /** The JSON file with the frame and meta data */
  78021. atlasJSON: ISpriteJSONAtlas;
  78022. /** The systems Sprite Sheet Texture */
  78023. spriteSheet: Texture;
  78024. /** Arguments passed with the Constructor */
  78025. options: ISpriteMapOptions;
  78026. /** Public Sprite Storage array, parsed from atlasJSON */
  78027. sprites: Array<ISpriteJSONSprite>;
  78028. /** Returns the Number of Sprites in the System */
  78029. get spriteCount(): number;
  78030. /** Returns the Position of Output Plane*/
  78031. get position(): Vector3;
  78032. /** Returns the Position of Output Plane*/
  78033. set position(v: Vector3);
  78034. /** Returns the Rotation of Output Plane*/
  78035. get rotation(): Vector3;
  78036. /** Returns the Rotation of Output Plane*/
  78037. set rotation(v: Vector3);
  78038. /** Sets the AnimationMap*/
  78039. get animationMap(): RawTexture;
  78040. /** Sets the AnimationMap*/
  78041. set animationMap(v: RawTexture);
  78042. /** Scene that the SpriteMap was created in */
  78043. private _scene;
  78044. /** Texture Buffer of Float32 that holds tile frame data*/
  78045. private _frameMap;
  78046. /** Texture Buffers of Float32 that holds tileMap data*/
  78047. private _tileMaps;
  78048. /** Texture Buffer of Float32 that holds Animation Data*/
  78049. private _animationMap;
  78050. /** Custom ShaderMaterial Central to the System*/
  78051. private _material;
  78052. /** Custom ShaderMaterial Central to the System*/
  78053. private _output;
  78054. /** Systems Time Ticker*/
  78055. private _time;
  78056. /**
  78057. * Creates a new SpriteMap
  78058. * @param name defines the SpriteMaps Name
  78059. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  78060. * @param spriteSheet is the Texture that the Sprites are on.
  78061. * @param options a basic deployment configuration
  78062. * @param scene The Scene that the map is deployed on
  78063. */
  78064. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  78065. /**
  78066. * Returns tileID location
  78067. * @returns Vector2 the cell position ID
  78068. */
  78069. getTileID(): Vector2;
  78070. /**
  78071. * Gets the UV location of the mouse over the SpriteMap.
  78072. * @returns Vector2 the UV position of the mouse interaction
  78073. */
  78074. getMousePosition(): Vector2;
  78075. /**
  78076. * Creates the "frame" texture Buffer
  78077. * -------------------------------------
  78078. * Structure of frames
  78079. * "filename": "Falling-Water-2.png",
  78080. * "frame": {"x":69,"y":103,"w":24,"h":32},
  78081. * "rotated": true,
  78082. * "trimmed": true,
  78083. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  78084. * "sourceSize": {"w":32,"h":32}
  78085. * @returns RawTexture of the frameMap
  78086. */
  78087. private _createFrameBuffer;
  78088. /**
  78089. * Creates the tileMap texture Buffer
  78090. * @param buffer normally and array of numbers, or a false to generate from scratch
  78091. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  78092. * @returns RawTexture of the tileMap
  78093. */
  78094. private _createTileBuffer;
  78095. /**
  78096. * Modifies the data of the tileMaps
  78097. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  78098. * @param pos is the iVector2 Coordinates of the Tile
  78099. * @param tile The SpriteIndex of the new Tile
  78100. */
  78101. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  78102. /**
  78103. * Creates the animationMap texture Buffer
  78104. * @param buffer normally and array of numbers, or a false to generate from scratch
  78105. * @returns RawTexture of the animationMap
  78106. */
  78107. private _createTileAnimationBuffer;
  78108. /**
  78109. * Modifies the data of the animationMap
  78110. * @param cellID is the Index of the Sprite
  78111. * @param _frame is the target Animation frame
  78112. * @param toCell is the Target Index of the next frame of the animation
  78113. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  78114. * @param speed is a global scalar of the time variable on the map.
  78115. */
  78116. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  78117. /**
  78118. * Exports the .tilemaps file
  78119. */
  78120. saveTileMaps(): void;
  78121. /**
  78122. * Imports the .tilemaps file
  78123. * @param url of the .tilemaps file
  78124. */
  78125. loadTileMaps(url: string): void;
  78126. /**
  78127. * Release associated resources
  78128. */
  78129. dispose(): void;
  78130. }
  78131. }
  78132. declare module "babylonjs/Sprites/spritePackedManager" {
  78133. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  78134. import { Scene } from "babylonjs/scene";
  78135. /**
  78136. * Class used to manage multiple sprites of different sizes on the same spritesheet
  78137. * @see https://doc.babylonjs.com/babylon101/sprites
  78138. */
  78139. export class SpritePackedManager extends SpriteManager {
  78140. /** defines the packed manager's name */
  78141. name: string;
  78142. /**
  78143. * Creates a new sprite manager from a packed sprite sheet
  78144. * @param name defines the manager's name
  78145. * @param imgUrl defines the sprite sheet url
  78146. * @param capacity defines the maximum allowed number of sprites
  78147. * @param scene defines the hosting scene
  78148. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  78149. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78150. * @param samplingMode defines the smapling mode to use with spritesheet
  78151. * @param fromPacked set to true; do not alter
  78152. */
  78153. constructor(
  78154. /** defines the packed manager's name */
  78155. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  78156. }
  78157. }
  78158. declare module "babylonjs/Sprites/index" {
  78159. export * from "babylonjs/Sprites/sprite";
  78160. export * from "babylonjs/Sprites/ISprites";
  78161. export * from "babylonjs/Sprites/spriteManager";
  78162. export * from "babylonjs/Sprites/spriteMap";
  78163. export * from "babylonjs/Sprites/spritePackedManager";
  78164. export * from "babylonjs/Sprites/spriteSceneComponent";
  78165. }
  78166. declare module "babylonjs/States/index" {
  78167. export * from "babylonjs/States/alphaCullingState";
  78168. export * from "babylonjs/States/depthCullingState";
  78169. export * from "babylonjs/States/stencilState";
  78170. }
  78171. declare module "babylonjs/Misc/assetsManager" {
  78172. import { Scene } from "babylonjs/scene";
  78173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  78175. import { Skeleton } from "babylonjs/Bones/skeleton";
  78176. import { Observable } from "babylonjs/Misc/observable";
  78177. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  78178. import { Texture } from "babylonjs/Materials/Textures/texture";
  78179. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  78180. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  78181. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  78182. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  78183. import { AssetContainer } from "babylonjs/assetContainer";
  78184. /**
  78185. * Defines the list of states available for a task inside a AssetsManager
  78186. */
  78187. export enum AssetTaskState {
  78188. /**
  78189. * Initialization
  78190. */
  78191. INIT = 0,
  78192. /**
  78193. * Running
  78194. */
  78195. RUNNING = 1,
  78196. /**
  78197. * Done
  78198. */
  78199. DONE = 2,
  78200. /**
  78201. * Error
  78202. */
  78203. ERROR = 3
  78204. }
  78205. /**
  78206. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  78207. */
  78208. export abstract class AbstractAssetTask {
  78209. /**
  78210. * Task name
  78211. */ name: string;
  78212. /**
  78213. * Callback called when the task is successful
  78214. */
  78215. onSuccess: (task: any) => void;
  78216. /**
  78217. * Callback called when the task is not successful
  78218. */
  78219. onError: (task: any, message?: string, exception?: any) => void;
  78220. /**
  78221. * Creates a new AssetsManager
  78222. * @param name defines the name of the task
  78223. */
  78224. constructor(
  78225. /**
  78226. * Task name
  78227. */ name: string);
  78228. private _isCompleted;
  78229. private _taskState;
  78230. private _errorObject;
  78231. /**
  78232. * Get if the task is completed
  78233. */
  78234. get isCompleted(): boolean;
  78235. /**
  78236. * Gets the current state of the task
  78237. */
  78238. get taskState(): AssetTaskState;
  78239. /**
  78240. * Gets the current error object (if task is in error)
  78241. */
  78242. get errorObject(): {
  78243. message?: string;
  78244. exception?: any;
  78245. };
  78246. /**
  78247. * Internal only
  78248. * @hidden
  78249. */
  78250. _setErrorObject(message?: string, exception?: any): void;
  78251. /**
  78252. * Execute the current task
  78253. * @param scene defines the scene where you want your assets to be loaded
  78254. * @param onSuccess is a callback called when the task is successfully executed
  78255. * @param onError is a callback called if an error occurs
  78256. */
  78257. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78258. /**
  78259. * Execute the current task
  78260. * @param scene defines the scene where you want your assets to be loaded
  78261. * @param onSuccess is a callback called when the task is successfully executed
  78262. * @param onError is a callback called if an error occurs
  78263. */
  78264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78265. /**
  78266. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  78267. * This can be used with failed tasks that have the reason for failure fixed.
  78268. */
  78269. reset(): void;
  78270. private onErrorCallback;
  78271. private onDoneCallback;
  78272. }
  78273. /**
  78274. * Define the interface used by progress events raised during assets loading
  78275. */
  78276. export interface IAssetsProgressEvent {
  78277. /**
  78278. * Defines the number of remaining tasks to process
  78279. */
  78280. remainingCount: number;
  78281. /**
  78282. * Defines the total number of tasks
  78283. */
  78284. totalCount: number;
  78285. /**
  78286. * Defines the task that was just processed
  78287. */
  78288. task: AbstractAssetTask;
  78289. }
  78290. /**
  78291. * Class used to share progress information about assets loading
  78292. */
  78293. export class AssetsProgressEvent implements IAssetsProgressEvent {
  78294. /**
  78295. * Defines the number of remaining tasks to process
  78296. */
  78297. remainingCount: number;
  78298. /**
  78299. * Defines the total number of tasks
  78300. */
  78301. totalCount: number;
  78302. /**
  78303. * Defines the task that was just processed
  78304. */
  78305. task: AbstractAssetTask;
  78306. /**
  78307. * Creates a AssetsProgressEvent
  78308. * @param remainingCount defines the number of remaining tasks to process
  78309. * @param totalCount defines the total number of tasks
  78310. * @param task defines the task that was just processed
  78311. */
  78312. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  78313. }
  78314. /**
  78315. * Define a task used by AssetsManager to load assets into a container
  78316. */
  78317. export class ContainerAssetTask extends AbstractAssetTask {
  78318. /**
  78319. * Defines the name of the task
  78320. */
  78321. name: string;
  78322. /**
  78323. * Defines the list of mesh's names you want to load
  78324. */
  78325. meshesNames: any;
  78326. /**
  78327. * Defines the root url to use as a base to load your meshes and associated resources
  78328. */
  78329. rootUrl: string;
  78330. /**
  78331. * Defines the filename or File of the scene to load from
  78332. */
  78333. sceneFilename: string | File;
  78334. /**
  78335. * Get the loaded asset container
  78336. */
  78337. loadedContainer: AssetContainer;
  78338. /**
  78339. * Gets the list of loaded meshes
  78340. */
  78341. loadedMeshes: Array<AbstractMesh>;
  78342. /**
  78343. * Gets the list of loaded particle systems
  78344. */
  78345. loadedParticleSystems: Array<IParticleSystem>;
  78346. /**
  78347. * Gets the list of loaded skeletons
  78348. */
  78349. loadedSkeletons: Array<Skeleton>;
  78350. /**
  78351. * Gets the list of loaded animation groups
  78352. */
  78353. loadedAnimationGroups: Array<AnimationGroup>;
  78354. /**
  78355. * Callback called when the task is successful
  78356. */
  78357. onSuccess: (task: ContainerAssetTask) => void;
  78358. /**
  78359. * Callback called when the task is successful
  78360. */
  78361. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  78362. /**
  78363. * Creates a new ContainerAssetTask
  78364. * @param name defines the name of the task
  78365. * @param meshesNames defines the list of mesh's names you want to load
  78366. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78367. * @param sceneFilename defines the filename or File of the scene to load from
  78368. */
  78369. constructor(
  78370. /**
  78371. * Defines the name of the task
  78372. */
  78373. name: string,
  78374. /**
  78375. * Defines the list of mesh's names you want to load
  78376. */
  78377. meshesNames: any,
  78378. /**
  78379. * Defines the root url to use as a base to load your meshes and associated resources
  78380. */
  78381. rootUrl: string,
  78382. /**
  78383. * Defines the filename or File of the scene to load from
  78384. */
  78385. sceneFilename: string | File);
  78386. /**
  78387. * Execute the current task
  78388. * @param scene defines the scene where you want your assets to be loaded
  78389. * @param onSuccess is a callback called when the task is successfully executed
  78390. * @param onError is a callback called if an error occurs
  78391. */
  78392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78393. }
  78394. /**
  78395. * Define a task used by AssetsManager to load meshes
  78396. */
  78397. export class MeshAssetTask extends AbstractAssetTask {
  78398. /**
  78399. * Defines the name of the task
  78400. */
  78401. name: string;
  78402. /**
  78403. * Defines the list of mesh's names you want to load
  78404. */
  78405. meshesNames: any;
  78406. /**
  78407. * Defines the root url to use as a base to load your meshes and associated resources
  78408. */
  78409. rootUrl: string;
  78410. /**
  78411. * Defines the filename or File of the scene to load from
  78412. */
  78413. sceneFilename: string | File;
  78414. /**
  78415. * Gets the list of loaded meshes
  78416. */
  78417. loadedMeshes: Array<AbstractMesh>;
  78418. /**
  78419. * Gets the list of loaded particle systems
  78420. */
  78421. loadedParticleSystems: Array<IParticleSystem>;
  78422. /**
  78423. * Gets the list of loaded skeletons
  78424. */
  78425. loadedSkeletons: Array<Skeleton>;
  78426. /**
  78427. * Gets the list of loaded animation groups
  78428. */
  78429. loadedAnimationGroups: Array<AnimationGroup>;
  78430. /**
  78431. * Callback called when the task is successful
  78432. */
  78433. onSuccess: (task: MeshAssetTask) => void;
  78434. /**
  78435. * Callback called when the task is successful
  78436. */
  78437. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  78438. /**
  78439. * Creates a new MeshAssetTask
  78440. * @param name defines the name of the task
  78441. * @param meshesNames defines the list of mesh's names you want to load
  78442. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  78443. * @param sceneFilename defines the filename or File of the scene to load from
  78444. */
  78445. constructor(
  78446. /**
  78447. * Defines the name of the task
  78448. */
  78449. name: string,
  78450. /**
  78451. * Defines the list of mesh's names you want to load
  78452. */
  78453. meshesNames: any,
  78454. /**
  78455. * Defines the root url to use as a base to load your meshes and associated resources
  78456. */
  78457. rootUrl: string,
  78458. /**
  78459. * Defines the filename or File of the scene to load from
  78460. */
  78461. sceneFilename: string | File);
  78462. /**
  78463. * Execute the current task
  78464. * @param scene defines the scene where you want your assets to be loaded
  78465. * @param onSuccess is a callback called when the task is successfully executed
  78466. * @param onError is a callback called if an error occurs
  78467. */
  78468. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78469. }
  78470. /**
  78471. * Define a task used by AssetsManager to load text content
  78472. */
  78473. export class TextFileAssetTask extends AbstractAssetTask {
  78474. /**
  78475. * Defines the name of the task
  78476. */
  78477. name: string;
  78478. /**
  78479. * Defines the location of the file to load
  78480. */
  78481. url: string;
  78482. /**
  78483. * Gets the loaded text string
  78484. */
  78485. text: string;
  78486. /**
  78487. * Callback called when the task is successful
  78488. */
  78489. onSuccess: (task: TextFileAssetTask) => void;
  78490. /**
  78491. * Callback called when the task is successful
  78492. */
  78493. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78494. /**
  78495. * Creates a new TextFileAssetTask object
  78496. * @param name defines the name of the task
  78497. * @param url defines the location of the file to load
  78498. */
  78499. constructor(
  78500. /**
  78501. * Defines the name of the task
  78502. */
  78503. name: string,
  78504. /**
  78505. * Defines the location of the file to load
  78506. */
  78507. url: string);
  78508. /**
  78509. * Execute the current task
  78510. * @param scene defines the scene where you want your assets to be loaded
  78511. * @param onSuccess is a callback called when the task is successfully executed
  78512. * @param onError is a callback called if an error occurs
  78513. */
  78514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78515. }
  78516. /**
  78517. * Define a task used by AssetsManager to load binary data
  78518. */
  78519. export class BinaryFileAssetTask extends AbstractAssetTask {
  78520. /**
  78521. * Defines the name of the task
  78522. */
  78523. name: string;
  78524. /**
  78525. * Defines the location of the file to load
  78526. */
  78527. url: string;
  78528. /**
  78529. * Gets the lodaded data (as an array buffer)
  78530. */
  78531. data: ArrayBuffer;
  78532. /**
  78533. * Callback called when the task is successful
  78534. */
  78535. onSuccess: (task: BinaryFileAssetTask) => void;
  78536. /**
  78537. * Callback called when the task is successful
  78538. */
  78539. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78540. /**
  78541. * Creates a new BinaryFileAssetTask object
  78542. * @param name defines the name of the new task
  78543. * @param url defines the location of the file to load
  78544. */
  78545. constructor(
  78546. /**
  78547. * Defines the name of the task
  78548. */
  78549. name: string,
  78550. /**
  78551. * Defines the location of the file to load
  78552. */
  78553. url: string);
  78554. /**
  78555. * Execute the current task
  78556. * @param scene defines the scene where you want your assets to be loaded
  78557. * @param onSuccess is a callback called when the task is successfully executed
  78558. * @param onError is a callback called if an error occurs
  78559. */
  78560. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78561. }
  78562. /**
  78563. * Define a task used by AssetsManager to load images
  78564. */
  78565. export class ImageAssetTask extends AbstractAssetTask {
  78566. /**
  78567. * Defines the name of the task
  78568. */
  78569. name: string;
  78570. /**
  78571. * Defines the location of the image to load
  78572. */
  78573. url: string;
  78574. /**
  78575. * Gets the loaded images
  78576. */
  78577. image: HTMLImageElement;
  78578. /**
  78579. * Callback called when the task is successful
  78580. */
  78581. onSuccess: (task: ImageAssetTask) => void;
  78582. /**
  78583. * Callback called when the task is successful
  78584. */
  78585. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78586. /**
  78587. * Creates a new ImageAssetTask
  78588. * @param name defines the name of the task
  78589. * @param url defines the location of the image to load
  78590. */
  78591. constructor(
  78592. /**
  78593. * Defines the name of the task
  78594. */
  78595. name: string,
  78596. /**
  78597. * Defines the location of the image to load
  78598. */
  78599. url: string);
  78600. /**
  78601. * Execute the current task
  78602. * @param scene defines the scene where you want your assets to be loaded
  78603. * @param onSuccess is a callback called when the task is successfully executed
  78604. * @param onError is a callback called if an error occurs
  78605. */
  78606. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78607. }
  78608. /**
  78609. * Defines the interface used by texture loading tasks
  78610. */
  78611. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78612. /**
  78613. * Gets the loaded texture
  78614. */
  78615. texture: TEX;
  78616. }
  78617. /**
  78618. * Define a task used by AssetsManager to load 2D textures
  78619. */
  78620. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78621. /**
  78622. * Defines the name of the task
  78623. */
  78624. name: string;
  78625. /**
  78626. * Defines the location of the file to load
  78627. */
  78628. url: string;
  78629. /**
  78630. * Defines if mipmap should not be generated (default is false)
  78631. */
  78632. noMipmap?: boolean | undefined;
  78633. /**
  78634. * Defines if texture must be inverted on Y axis (default is true)
  78635. */
  78636. invertY: boolean;
  78637. /**
  78638. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78639. */
  78640. samplingMode: number;
  78641. /**
  78642. * Gets the loaded texture
  78643. */
  78644. texture: Texture;
  78645. /**
  78646. * Callback called when the task is successful
  78647. */
  78648. onSuccess: (task: TextureAssetTask) => void;
  78649. /**
  78650. * Callback called when the task is successful
  78651. */
  78652. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78653. /**
  78654. * Creates a new TextureAssetTask object
  78655. * @param name defines the name of the task
  78656. * @param url defines the location of the file to load
  78657. * @param noMipmap defines if mipmap should not be generated (default is false)
  78658. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78659. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78660. */
  78661. constructor(
  78662. /**
  78663. * Defines the name of the task
  78664. */
  78665. name: string,
  78666. /**
  78667. * Defines the location of the file to load
  78668. */
  78669. url: string,
  78670. /**
  78671. * Defines if mipmap should not be generated (default is false)
  78672. */
  78673. noMipmap?: boolean | undefined,
  78674. /**
  78675. * Defines if texture must be inverted on Y axis (default is true)
  78676. */
  78677. invertY?: boolean,
  78678. /**
  78679. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78680. */
  78681. samplingMode?: number);
  78682. /**
  78683. * Execute the current task
  78684. * @param scene defines the scene where you want your assets to be loaded
  78685. * @param onSuccess is a callback called when the task is successfully executed
  78686. * @param onError is a callback called if an error occurs
  78687. */
  78688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78689. }
  78690. /**
  78691. * Define a task used by AssetsManager to load cube textures
  78692. */
  78693. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78694. /**
  78695. * Defines the name of the task
  78696. */
  78697. name: string;
  78698. /**
  78699. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78700. */
  78701. url: string;
  78702. /**
  78703. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78704. */
  78705. extensions?: string[] | undefined;
  78706. /**
  78707. * Defines if mipmaps should not be generated (default is false)
  78708. */
  78709. noMipmap?: boolean | undefined;
  78710. /**
  78711. * Defines the explicit list of files (undefined by default)
  78712. */
  78713. files?: string[] | undefined;
  78714. /**
  78715. * Gets the loaded texture
  78716. */
  78717. texture: CubeTexture;
  78718. /**
  78719. * Callback called when the task is successful
  78720. */
  78721. onSuccess: (task: CubeTextureAssetTask) => void;
  78722. /**
  78723. * Callback called when the task is successful
  78724. */
  78725. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78726. /**
  78727. * Creates a new CubeTextureAssetTask
  78728. * @param name defines the name of the task
  78729. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78730. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78731. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78732. * @param files defines the explicit list of files (undefined by default)
  78733. */
  78734. constructor(
  78735. /**
  78736. * Defines the name of the task
  78737. */
  78738. name: string,
  78739. /**
  78740. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78741. */
  78742. url: string,
  78743. /**
  78744. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78745. */
  78746. extensions?: string[] | undefined,
  78747. /**
  78748. * Defines if mipmaps should not be generated (default is false)
  78749. */
  78750. noMipmap?: boolean | undefined,
  78751. /**
  78752. * Defines the explicit list of files (undefined by default)
  78753. */
  78754. files?: string[] | undefined);
  78755. /**
  78756. * Execute the current task
  78757. * @param scene defines the scene where you want your assets to be loaded
  78758. * @param onSuccess is a callback called when the task is successfully executed
  78759. * @param onError is a callback called if an error occurs
  78760. */
  78761. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78762. }
  78763. /**
  78764. * Define a task used by AssetsManager to load HDR cube textures
  78765. */
  78766. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78767. /**
  78768. * Defines the name of the task
  78769. */
  78770. name: string;
  78771. /**
  78772. * Defines the location of the file to load
  78773. */
  78774. url: string;
  78775. /**
  78776. * Defines the desired size (the more it increases the longer the generation will be)
  78777. */
  78778. size: number;
  78779. /**
  78780. * Defines if mipmaps should not be generated (default is false)
  78781. */
  78782. noMipmap: boolean;
  78783. /**
  78784. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78785. */
  78786. generateHarmonics: boolean;
  78787. /**
  78788. * 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)
  78789. */
  78790. gammaSpace: boolean;
  78791. /**
  78792. * Internal Use Only
  78793. */
  78794. reserved: boolean;
  78795. /**
  78796. * Gets the loaded texture
  78797. */
  78798. texture: HDRCubeTexture;
  78799. /**
  78800. * Callback called when the task is successful
  78801. */
  78802. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78803. /**
  78804. * Callback called when the task is successful
  78805. */
  78806. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78807. /**
  78808. * Creates a new HDRCubeTextureAssetTask object
  78809. * @param name defines the name of the task
  78810. * @param url defines the location of the file to load
  78811. * @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.
  78812. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78813. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78814. * @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)
  78815. * @param reserved Internal use only
  78816. */
  78817. constructor(
  78818. /**
  78819. * Defines the name of the task
  78820. */
  78821. name: string,
  78822. /**
  78823. * Defines the location of the file to load
  78824. */
  78825. url: string,
  78826. /**
  78827. * Defines the desired size (the more it increases the longer the generation will be)
  78828. */
  78829. size: number,
  78830. /**
  78831. * Defines if mipmaps should not be generated (default is false)
  78832. */
  78833. noMipmap?: boolean,
  78834. /**
  78835. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78836. */
  78837. generateHarmonics?: boolean,
  78838. /**
  78839. * 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)
  78840. */
  78841. gammaSpace?: boolean,
  78842. /**
  78843. * Internal Use Only
  78844. */
  78845. reserved?: boolean);
  78846. /**
  78847. * Execute the current task
  78848. * @param scene defines the scene where you want your assets to be loaded
  78849. * @param onSuccess is a callback called when the task is successfully executed
  78850. * @param onError is a callback called if an error occurs
  78851. */
  78852. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78853. }
  78854. /**
  78855. * Define a task used by AssetsManager to load Equirectangular cube textures
  78856. */
  78857. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78858. /**
  78859. * Defines the name of the task
  78860. */
  78861. name: string;
  78862. /**
  78863. * Defines the location of the file to load
  78864. */
  78865. url: string;
  78866. /**
  78867. * Defines the desired size (the more it increases the longer the generation will be)
  78868. */
  78869. size: number;
  78870. /**
  78871. * Defines if mipmaps should not be generated (default is false)
  78872. */
  78873. noMipmap: boolean;
  78874. /**
  78875. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78876. * but the standard material would require them in Gamma space) (default is true)
  78877. */
  78878. gammaSpace: boolean;
  78879. /**
  78880. * Gets the loaded texture
  78881. */
  78882. texture: EquiRectangularCubeTexture;
  78883. /**
  78884. * Callback called when the task is successful
  78885. */
  78886. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78887. /**
  78888. * Callback called when the task is successful
  78889. */
  78890. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78891. /**
  78892. * Creates a new EquiRectangularCubeTextureAssetTask object
  78893. * @param name defines the name of the task
  78894. * @param url defines the location of the file to load
  78895. * @param size defines the desired size (the more it increases the longer the generation will be)
  78896. * If the size is omitted this implies you are using a preprocessed cubemap.
  78897. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78898. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78899. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78900. * (default is true)
  78901. */
  78902. constructor(
  78903. /**
  78904. * Defines the name of the task
  78905. */
  78906. name: string,
  78907. /**
  78908. * Defines the location of the file to load
  78909. */
  78910. url: string,
  78911. /**
  78912. * Defines the desired size (the more it increases the longer the generation will be)
  78913. */
  78914. size: number,
  78915. /**
  78916. * Defines if mipmaps should not be generated (default is false)
  78917. */
  78918. noMipmap?: boolean,
  78919. /**
  78920. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78921. * but the standard material would require them in Gamma space) (default is true)
  78922. */
  78923. gammaSpace?: boolean);
  78924. /**
  78925. * Execute the current task
  78926. * @param scene defines the scene where you want your assets to be loaded
  78927. * @param onSuccess is a callback called when the task is successfully executed
  78928. * @param onError is a callback called if an error occurs
  78929. */
  78930. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78931. }
  78932. /**
  78933. * This class can be used to easily import assets into a scene
  78934. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78935. */
  78936. export class AssetsManager {
  78937. private _scene;
  78938. private _isLoading;
  78939. protected _tasks: AbstractAssetTask[];
  78940. protected _waitingTasksCount: number;
  78941. protected _totalTasksCount: number;
  78942. /**
  78943. * Callback called when all tasks are processed
  78944. */
  78945. onFinish: (tasks: AbstractAssetTask[]) => void;
  78946. /**
  78947. * Callback called when a task is successful
  78948. */
  78949. onTaskSuccess: (task: AbstractAssetTask) => void;
  78950. /**
  78951. * Callback called when a task had an error
  78952. */
  78953. onTaskError: (task: AbstractAssetTask) => void;
  78954. /**
  78955. * Callback called when a task is done (whatever the result is)
  78956. */
  78957. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78958. /**
  78959. * Observable called when all tasks are processed
  78960. */
  78961. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78962. /**
  78963. * Observable called when a task had an error
  78964. */
  78965. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78966. /**
  78967. * Observable called when all tasks were executed
  78968. */
  78969. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78970. /**
  78971. * Observable called when a task is done (whatever the result is)
  78972. */
  78973. onProgressObservable: Observable<IAssetsProgressEvent>;
  78974. /**
  78975. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78976. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78977. */
  78978. useDefaultLoadingScreen: boolean;
  78979. /**
  78980. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78981. * when all assets have been downloaded.
  78982. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78983. */
  78984. autoHideLoadingUI: boolean;
  78985. /**
  78986. * Creates a new AssetsManager
  78987. * @param scene defines the scene to work on
  78988. */
  78989. constructor(scene: Scene);
  78990. /**
  78991. * Add a ContainerAssetTask to the list of active tasks
  78992. * @param taskName defines the name of the new task
  78993. * @param meshesNames defines the name of meshes to load
  78994. * @param rootUrl defines the root url to use to locate files
  78995. * @param sceneFilename defines the filename of the scene file
  78996. * @returns a new ContainerAssetTask object
  78997. */
  78998. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78999. /**
  79000. * Add a MeshAssetTask to the list of active tasks
  79001. * @param taskName defines the name of the new task
  79002. * @param meshesNames defines the name of meshes to load
  79003. * @param rootUrl defines the root url to use to locate files
  79004. * @param sceneFilename defines the filename of the scene file
  79005. * @returns a new MeshAssetTask object
  79006. */
  79007. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  79008. /**
  79009. * Add a TextFileAssetTask to the list of active tasks
  79010. * @param taskName defines the name of the new task
  79011. * @param url defines the url of the file to load
  79012. * @returns a new TextFileAssetTask object
  79013. */
  79014. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  79015. /**
  79016. * Add a BinaryFileAssetTask to the list of active tasks
  79017. * @param taskName defines the name of the new task
  79018. * @param url defines the url of the file to load
  79019. * @returns a new BinaryFileAssetTask object
  79020. */
  79021. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  79022. /**
  79023. * Add a ImageAssetTask to the list of active tasks
  79024. * @param taskName defines the name of the new task
  79025. * @param url defines the url of the file to load
  79026. * @returns a new ImageAssetTask object
  79027. */
  79028. addImageTask(taskName: string, url: string): ImageAssetTask;
  79029. /**
  79030. * Add a TextureAssetTask to the list of active tasks
  79031. * @param taskName defines the name of the new task
  79032. * @param url defines the url of the file to load
  79033. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79034. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  79035. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  79036. * @returns a new TextureAssetTask object
  79037. */
  79038. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  79039. /**
  79040. * Add a CubeTextureAssetTask to the list of active tasks
  79041. * @param taskName defines the name of the new task
  79042. * @param url defines the url of the file to load
  79043. * @param extensions defines the extension to use to load the cube map (can be null)
  79044. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79045. * @param files defines the list of files to load (can be null)
  79046. * @returns a new CubeTextureAssetTask object
  79047. */
  79048. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  79049. /**
  79050. *
  79051. * Add a HDRCubeTextureAssetTask to the list of active tasks
  79052. * @param taskName defines the name of the new task
  79053. * @param url defines the url of the file to load
  79054. * @param size defines the size you want for the cubemap (can be null)
  79055. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79056. * @param generateHarmonics defines if you want to automatically generate (true by default)
  79057. * @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)
  79058. * @param reserved Internal use only
  79059. * @returns a new HDRCubeTextureAssetTask object
  79060. */
  79061. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  79062. /**
  79063. *
  79064. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  79065. * @param taskName defines the name of the new task
  79066. * @param url defines the url of the file to load
  79067. * @param size defines the size you want for the cubemap (can be null)
  79068. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  79069. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  79070. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  79071. * @returns a new EquiRectangularCubeTextureAssetTask object
  79072. */
  79073. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  79074. /**
  79075. * Remove a task from the assets manager.
  79076. * @param task the task to remove
  79077. */
  79078. removeTask(task: AbstractAssetTask): void;
  79079. private _decreaseWaitingTasksCount;
  79080. private _runTask;
  79081. /**
  79082. * Reset the AssetsManager and remove all tasks
  79083. * @return the current instance of the AssetsManager
  79084. */
  79085. reset(): AssetsManager;
  79086. /**
  79087. * Start the loading process
  79088. * @return the current instance of the AssetsManager
  79089. */
  79090. load(): AssetsManager;
  79091. /**
  79092. * Start the loading process as an async operation
  79093. * @return a promise returning the list of failed tasks
  79094. */
  79095. loadAsync(): Promise<void>;
  79096. }
  79097. }
  79098. declare module "babylonjs/Misc/deferred" {
  79099. /**
  79100. * Wrapper class for promise with external resolve and reject.
  79101. */
  79102. export class Deferred<T> {
  79103. /**
  79104. * The promise associated with this deferred object.
  79105. */
  79106. readonly promise: Promise<T>;
  79107. private _resolve;
  79108. private _reject;
  79109. /**
  79110. * The resolve method of the promise associated with this deferred object.
  79111. */
  79112. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  79113. /**
  79114. * The reject method of the promise associated with this deferred object.
  79115. */
  79116. get reject(): (reason?: any) => void;
  79117. /**
  79118. * Constructor for this deferred object.
  79119. */
  79120. constructor();
  79121. }
  79122. }
  79123. declare module "babylonjs/Misc/meshExploder" {
  79124. import { Mesh } from "babylonjs/Meshes/mesh";
  79125. /**
  79126. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  79127. */
  79128. export class MeshExploder {
  79129. private _centerMesh;
  79130. private _meshes;
  79131. private _meshesOrigins;
  79132. private _toCenterVectors;
  79133. private _scaledDirection;
  79134. private _newPosition;
  79135. private _centerPosition;
  79136. /**
  79137. * Explodes meshes from a center mesh.
  79138. * @param meshes The meshes to explode.
  79139. * @param centerMesh The mesh to be center of explosion.
  79140. */
  79141. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  79142. private _setCenterMesh;
  79143. /**
  79144. * Get class name
  79145. * @returns "MeshExploder"
  79146. */
  79147. getClassName(): string;
  79148. /**
  79149. * "Exploded meshes"
  79150. * @returns Array of meshes with the centerMesh at index 0.
  79151. */
  79152. getMeshes(): Array<Mesh>;
  79153. /**
  79154. * Explodes meshes giving a specific direction
  79155. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  79156. */
  79157. explode(direction?: number): void;
  79158. }
  79159. }
  79160. declare module "babylonjs/Misc/filesInput" {
  79161. import { Engine } from "babylonjs/Engines/engine";
  79162. import { Scene } from "babylonjs/scene";
  79163. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  79164. import { Nullable } from "babylonjs/types";
  79165. /**
  79166. * Class used to help managing file picking and drag'n'drop
  79167. */
  79168. export class FilesInput {
  79169. /**
  79170. * List of files ready to be loaded
  79171. */
  79172. static get FilesToLoad(): {
  79173. [key: string]: File;
  79174. };
  79175. /**
  79176. * Callback called when a file is processed
  79177. */
  79178. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  79179. private _engine;
  79180. private _currentScene;
  79181. private _sceneLoadedCallback;
  79182. private _progressCallback;
  79183. private _additionalRenderLoopLogicCallback;
  79184. private _textureLoadingCallback;
  79185. private _startingProcessingFilesCallback;
  79186. private _onReloadCallback;
  79187. private _errorCallback;
  79188. private _elementToMonitor;
  79189. private _sceneFileToLoad;
  79190. private _filesToLoad;
  79191. /**
  79192. * Creates a new FilesInput
  79193. * @param engine defines the rendering engine
  79194. * @param scene defines the hosting scene
  79195. * @param sceneLoadedCallback callback called when scene is loaded
  79196. * @param progressCallback callback called to track progress
  79197. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  79198. * @param textureLoadingCallback callback called when a texture is loading
  79199. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  79200. * @param onReloadCallback callback called when a reload is requested
  79201. * @param errorCallback callback call if an error occurs
  79202. */
  79203. 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>);
  79204. private _dragEnterHandler;
  79205. private _dragOverHandler;
  79206. private _dropHandler;
  79207. /**
  79208. * Calls this function to listen to drag'n'drop events on a specific DOM element
  79209. * @param elementToMonitor defines the DOM element to track
  79210. */
  79211. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  79212. /** Gets the current list of files to load */
  79213. get filesToLoad(): File[];
  79214. /**
  79215. * Release all associated resources
  79216. */
  79217. dispose(): void;
  79218. private renderFunction;
  79219. private drag;
  79220. private drop;
  79221. private _traverseFolder;
  79222. private _processFiles;
  79223. /**
  79224. * Load files from a drop event
  79225. * @param event defines the drop event to use as source
  79226. */
  79227. loadFiles(event: any): void;
  79228. private _processReload;
  79229. /**
  79230. * Reload the current scene from the loaded files
  79231. */
  79232. reload(): void;
  79233. }
  79234. }
  79235. declare module "babylonjs/Misc/HighDynamicRange/index" {
  79236. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  79237. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  79238. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  79239. }
  79240. declare module "babylonjs/Misc/sceneOptimizer" {
  79241. import { Scene, IDisposable } from "babylonjs/scene";
  79242. import { Observable } from "babylonjs/Misc/observable";
  79243. /**
  79244. * Defines the root class used to create scene optimization to use with SceneOptimizer
  79245. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79246. */
  79247. export class SceneOptimization {
  79248. /**
  79249. * Defines the priority of this optimization (0 by default which means first in the list)
  79250. */
  79251. priority: number;
  79252. /**
  79253. * Gets a string describing the action executed by the current optimization
  79254. * @returns description string
  79255. */
  79256. getDescription(): string;
  79257. /**
  79258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79259. * @param scene defines the current scene where to apply this optimization
  79260. * @param optimizer defines the current optimizer
  79261. * @returns true if everything that can be done was applied
  79262. */
  79263. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79264. /**
  79265. * Creates the SceneOptimization object
  79266. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79267. * @param desc defines the description associated with the optimization
  79268. */
  79269. constructor(
  79270. /**
  79271. * Defines the priority of this optimization (0 by default which means first in the list)
  79272. */
  79273. priority?: number);
  79274. }
  79275. /**
  79276. * Defines an optimization used to reduce the size of render target textures
  79277. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79278. */
  79279. export class TextureOptimization extends SceneOptimization {
  79280. /**
  79281. * Defines the priority of this optimization (0 by default which means first in the list)
  79282. */
  79283. priority: number;
  79284. /**
  79285. * 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
  79286. */
  79287. maximumSize: number;
  79288. /**
  79289. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79290. */
  79291. step: number;
  79292. /**
  79293. * Gets a string describing the action executed by the current optimization
  79294. * @returns description string
  79295. */
  79296. getDescription(): string;
  79297. /**
  79298. * Creates the TextureOptimization object
  79299. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79300. * @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
  79301. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79302. */
  79303. constructor(
  79304. /**
  79305. * Defines the priority of this optimization (0 by default which means first in the list)
  79306. */
  79307. priority?: number,
  79308. /**
  79309. * 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
  79310. */
  79311. maximumSize?: number,
  79312. /**
  79313. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  79314. */
  79315. step?: number);
  79316. /**
  79317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79318. * @param scene defines the current scene where to apply this optimization
  79319. * @param optimizer defines the current optimizer
  79320. * @returns true if everything that can be done was applied
  79321. */
  79322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79323. }
  79324. /**
  79325. * Defines an optimization used to increase or decrease the rendering resolution
  79326. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79327. */
  79328. export class HardwareScalingOptimization extends SceneOptimization {
  79329. /**
  79330. * Defines the priority of this optimization (0 by default which means first in the list)
  79331. */
  79332. priority: number;
  79333. /**
  79334. * Defines the maximum scale to use (2 by default)
  79335. */
  79336. maximumScale: number;
  79337. /**
  79338. * Defines the step to use between two passes (0.5 by default)
  79339. */
  79340. step: number;
  79341. private _currentScale;
  79342. private _directionOffset;
  79343. /**
  79344. * Gets a string describing the action executed by the current optimization
  79345. * @return description string
  79346. */
  79347. getDescription(): string;
  79348. /**
  79349. * Creates the HardwareScalingOptimization object
  79350. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79351. * @param maximumScale defines the maximum scale to use (2 by default)
  79352. * @param step defines the step to use between two passes (0.5 by default)
  79353. */
  79354. constructor(
  79355. /**
  79356. * Defines the priority of this optimization (0 by default which means first in the list)
  79357. */
  79358. priority?: number,
  79359. /**
  79360. * Defines the maximum scale to use (2 by default)
  79361. */
  79362. maximumScale?: number,
  79363. /**
  79364. * Defines the step to use between two passes (0.5 by default)
  79365. */
  79366. step?: number);
  79367. /**
  79368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79369. * @param scene defines the current scene where to apply this optimization
  79370. * @param optimizer defines the current optimizer
  79371. * @returns true if everything that can be done was applied
  79372. */
  79373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79374. }
  79375. /**
  79376. * Defines an optimization used to remove shadows
  79377. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79378. */
  79379. export class ShadowsOptimization extends SceneOptimization {
  79380. /**
  79381. * Gets a string describing the action executed by the current optimization
  79382. * @return description string
  79383. */
  79384. getDescription(): string;
  79385. /**
  79386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79387. * @param scene defines the current scene where to apply this optimization
  79388. * @param optimizer defines the current optimizer
  79389. * @returns true if everything that can be done was applied
  79390. */
  79391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79392. }
  79393. /**
  79394. * Defines an optimization used to turn post-processes off
  79395. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79396. */
  79397. export class PostProcessesOptimization extends SceneOptimization {
  79398. /**
  79399. * Gets a string describing the action executed by the current optimization
  79400. * @return description string
  79401. */
  79402. getDescription(): string;
  79403. /**
  79404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79405. * @param scene defines the current scene where to apply this optimization
  79406. * @param optimizer defines the current optimizer
  79407. * @returns true if everything that can be done was applied
  79408. */
  79409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79410. }
  79411. /**
  79412. * Defines an optimization used to turn lens flares off
  79413. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79414. */
  79415. export class LensFlaresOptimization extends SceneOptimization {
  79416. /**
  79417. * Gets a string describing the action executed by the current optimization
  79418. * @return description string
  79419. */
  79420. getDescription(): string;
  79421. /**
  79422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79423. * @param scene defines the current scene where to apply this optimization
  79424. * @param optimizer defines the current optimizer
  79425. * @returns true if everything that can be done was applied
  79426. */
  79427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79428. }
  79429. /**
  79430. * Defines an optimization based on user defined callback.
  79431. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79432. */
  79433. export class CustomOptimization extends SceneOptimization {
  79434. /**
  79435. * Callback called to apply the custom optimization.
  79436. */
  79437. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  79438. /**
  79439. * Callback called to get custom description
  79440. */
  79441. onGetDescription: () => string;
  79442. /**
  79443. * Gets a string describing the action executed by the current optimization
  79444. * @returns description string
  79445. */
  79446. getDescription(): string;
  79447. /**
  79448. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79449. * @param scene defines the current scene where to apply this optimization
  79450. * @param optimizer defines the current optimizer
  79451. * @returns true if everything that can be done was applied
  79452. */
  79453. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79454. }
  79455. /**
  79456. * Defines an optimization used to turn particles off
  79457. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79458. */
  79459. export class ParticlesOptimization extends SceneOptimization {
  79460. /**
  79461. * Gets a string describing the action executed by the current optimization
  79462. * @return description string
  79463. */
  79464. getDescription(): string;
  79465. /**
  79466. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79467. * @param scene defines the current scene where to apply this optimization
  79468. * @param optimizer defines the current optimizer
  79469. * @returns true if everything that can be done was applied
  79470. */
  79471. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79472. }
  79473. /**
  79474. * Defines an optimization used to turn render targets off
  79475. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79476. */
  79477. export class RenderTargetsOptimization extends SceneOptimization {
  79478. /**
  79479. * Gets a string describing the action executed by the current optimization
  79480. * @return description string
  79481. */
  79482. getDescription(): string;
  79483. /**
  79484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79485. * @param scene defines the current scene where to apply this optimization
  79486. * @param optimizer defines the current optimizer
  79487. * @returns true if everything that can be done was applied
  79488. */
  79489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79490. }
  79491. /**
  79492. * Defines an optimization used to merge meshes with compatible materials
  79493. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79494. */
  79495. export class MergeMeshesOptimization extends SceneOptimization {
  79496. private static _UpdateSelectionTree;
  79497. /**
  79498. * Gets or sets a boolean which defines if optimization octree has to be updated
  79499. */
  79500. static get UpdateSelectionTree(): boolean;
  79501. /**
  79502. * Gets or sets a boolean which defines if optimization octree has to be updated
  79503. */
  79504. static set UpdateSelectionTree(value: boolean);
  79505. /**
  79506. * Gets a string describing the action executed by the current optimization
  79507. * @return description string
  79508. */
  79509. getDescription(): string;
  79510. private _canBeMerged;
  79511. /**
  79512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79513. * @param scene defines the current scene where to apply this optimization
  79514. * @param optimizer defines the current optimizer
  79515. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79516. * @returns true if everything that can be done was applied
  79517. */
  79518. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79519. }
  79520. /**
  79521. * Defines a list of options used by SceneOptimizer
  79522. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79523. */
  79524. export class SceneOptimizerOptions {
  79525. /**
  79526. * Defines the target frame rate to reach (60 by default)
  79527. */
  79528. targetFrameRate: number;
  79529. /**
  79530. * Defines the interval between two checkes (2000ms by default)
  79531. */
  79532. trackerDuration: number;
  79533. /**
  79534. * Gets the list of optimizations to apply
  79535. */
  79536. optimizations: SceneOptimization[];
  79537. /**
  79538. * Creates a new list of options used by SceneOptimizer
  79539. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79540. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79541. */
  79542. constructor(
  79543. /**
  79544. * Defines the target frame rate to reach (60 by default)
  79545. */
  79546. targetFrameRate?: number,
  79547. /**
  79548. * Defines the interval between two checkes (2000ms by default)
  79549. */
  79550. trackerDuration?: number);
  79551. /**
  79552. * Add a new optimization
  79553. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79554. * @returns the current SceneOptimizerOptions
  79555. */
  79556. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79557. /**
  79558. * Add a new custom optimization
  79559. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79560. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79561. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79562. * @returns the current SceneOptimizerOptions
  79563. */
  79564. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79565. /**
  79566. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79567. * @param targetFrameRate defines the target frame rate (60 by default)
  79568. * @returns a SceneOptimizerOptions object
  79569. */
  79570. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79571. /**
  79572. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79573. * @param targetFrameRate defines the target frame rate (60 by default)
  79574. * @returns a SceneOptimizerOptions object
  79575. */
  79576. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79577. /**
  79578. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79579. * @param targetFrameRate defines the target frame rate (60 by default)
  79580. * @returns a SceneOptimizerOptions object
  79581. */
  79582. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79583. }
  79584. /**
  79585. * Class used to run optimizations in order to reach a target frame rate
  79586. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79587. */
  79588. export class SceneOptimizer implements IDisposable {
  79589. private _isRunning;
  79590. private _options;
  79591. private _scene;
  79592. private _currentPriorityLevel;
  79593. private _targetFrameRate;
  79594. private _trackerDuration;
  79595. private _currentFrameRate;
  79596. private _sceneDisposeObserver;
  79597. private _improvementMode;
  79598. /**
  79599. * Defines an observable called when the optimizer reaches the target frame rate
  79600. */
  79601. onSuccessObservable: Observable<SceneOptimizer>;
  79602. /**
  79603. * Defines an observable called when the optimizer enables an optimization
  79604. */
  79605. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79606. /**
  79607. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79608. */
  79609. onFailureObservable: Observable<SceneOptimizer>;
  79610. /**
  79611. * Gets a boolean indicating if the optimizer is in improvement mode
  79612. */
  79613. get isInImprovementMode(): boolean;
  79614. /**
  79615. * Gets the current priority level (0 at start)
  79616. */
  79617. get currentPriorityLevel(): number;
  79618. /**
  79619. * Gets the current frame rate checked by the SceneOptimizer
  79620. */
  79621. get currentFrameRate(): number;
  79622. /**
  79623. * Gets or sets the current target frame rate (60 by default)
  79624. */
  79625. get targetFrameRate(): number;
  79626. /**
  79627. * Gets or sets the current target frame rate (60 by default)
  79628. */
  79629. set targetFrameRate(value: number);
  79630. /**
  79631. * Gets or sets the current interval between two checks (every 2000ms by default)
  79632. */
  79633. get trackerDuration(): number;
  79634. /**
  79635. * Gets or sets the current interval between two checks (every 2000ms by default)
  79636. */
  79637. set trackerDuration(value: number);
  79638. /**
  79639. * Gets the list of active optimizations
  79640. */
  79641. get optimizations(): SceneOptimization[];
  79642. /**
  79643. * Creates a new SceneOptimizer
  79644. * @param scene defines the scene to work on
  79645. * @param options defines the options to use with the SceneOptimizer
  79646. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79647. * @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)
  79648. */
  79649. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79650. /**
  79651. * Stops the current optimizer
  79652. */
  79653. stop(): void;
  79654. /**
  79655. * Reset the optimizer to initial step (current priority level = 0)
  79656. */
  79657. reset(): void;
  79658. /**
  79659. * Start the optimizer. By default it will try to reach a specific framerate
  79660. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79661. */
  79662. start(): void;
  79663. private _checkCurrentState;
  79664. /**
  79665. * Release all resources
  79666. */
  79667. dispose(): void;
  79668. /**
  79669. * Helper function to create a SceneOptimizer with one single line of code
  79670. * @param scene defines the scene to work on
  79671. * @param options defines the options to use with the SceneOptimizer
  79672. * @param onSuccess defines a callback to call on success
  79673. * @param onFailure defines a callback to call on failure
  79674. * @returns the new SceneOptimizer object
  79675. */
  79676. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79677. }
  79678. }
  79679. declare module "babylonjs/Misc/sceneSerializer" {
  79680. import { Scene } from "babylonjs/scene";
  79681. /**
  79682. * Class used to serialize a scene into a string
  79683. */
  79684. export class SceneSerializer {
  79685. /**
  79686. * Clear cache used by a previous serialization
  79687. */
  79688. static ClearCache(): void;
  79689. /**
  79690. * Serialize a scene into a JSON compatible object
  79691. * @param scene defines the scene to serialize
  79692. * @returns a JSON compatible object
  79693. */
  79694. static Serialize(scene: Scene): any;
  79695. /**
  79696. * Serialize a mesh into a JSON compatible object
  79697. * @param toSerialize defines the mesh to serialize
  79698. * @param withParents defines if parents must be serialized as well
  79699. * @param withChildren defines if children must be serialized as well
  79700. * @returns a JSON compatible object
  79701. */
  79702. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79703. }
  79704. }
  79705. declare module "babylonjs/Misc/textureTools" {
  79706. import { Texture } from "babylonjs/Materials/Textures/texture";
  79707. /**
  79708. * Class used to host texture specific utilities
  79709. */
  79710. export class TextureTools {
  79711. /**
  79712. * Uses the GPU to create a copy texture rescaled at a given size
  79713. * @param texture Texture to copy from
  79714. * @param width defines the desired width
  79715. * @param height defines the desired height
  79716. * @param useBilinearMode defines if bilinear mode has to be used
  79717. * @return the generated texture
  79718. */
  79719. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79720. }
  79721. }
  79722. declare module "babylonjs/Misc/videoRecorder" {
  79723. import { Nullable } from "babylonjs/types";
  79724. import { Engine } from "babylonjs/Engines/engine";
  79725. /**
  79726. * This represents the different options available for the video capture.
  79727. */
  79728. export interface VideoRecorderOptions {
  79729. /** Defines the mime type of the video. */
  79730. mimeType: string;
  79731. /** Defines the FPS the video should be recorded at. */
  79732. fps: number;
  79733. /** Defines the chunk size for the recording data. */
  79734. recordChunckSize: number;
  79735. /** The audio tracks to attach to the recording. */
  79736. audioTracks?: MediaStreamTrack[];
  79737. }
  79738. /**
  79739. * This can help with recording videos from BabylonJS.
  79740. * This is based on the available WebRTC functionalities of the browser.
  79741. *
  79742. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79743. */
  79744. export class VideoRecorder {
  79745. private static readonly _defaultOptions;
  79746. /**
  79747. * Returns whether or not the VideoRecorder is available in your browser.
  79748. * @param engine Defines the Babylon Engine.
  79749. * @returns true if supported otherwise false.
  79750. */
  79751. static IsSupported(engine: Engine): boolean;
  79752. private readonly _options;
  79753. private _canvas;
  79754. private _mediaRecorder;
  79755. private _recordedChunks;
  79756. private _fileName;
  79757. private _resolve;
  79758. private _reject;
  79759. /**
  79760. * True when a recording is already in progress.
  79761. */
  79762. get isRecording(): boolean;
  79763. /**
  79764. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79765. * @param engine Defines the BabylonJS Engine you wish to record.
  79766. * @param options Defines options that can be used to customize the capture.
  79767. */
  79768. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79769. /**
  79770. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79771. */
  79772. stopRecording(): void;
  79773. /**
  79774. * Starts recording the canvas for a max duration specified in parameters.
  79775. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79776. * If null no automatic download will start and you can rely on the promise to get the data back.
  79777. * @param maxDuration Defines the maximum recording time in seconds.
  79778. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79779. * @return A promise callback at the end of the recording with the video data in Blob.
  79780. */
  79781. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79782. /**
  79783. * Releases internal resources used during the recording.
  79784. */
  79785. dispose(): void;
  79786. private _handleDataAvailable;
  79787. private _handleError;
  79788. private _handleStop;
  79789. }
  79790. }
  79791. declare module "babylonjs/Misc/screenshotTools" {
  79792. import { Camera } from "babylonjs/Cameras/camera";
  79793. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79794. import { Engine } from "babylonjs/Engines/engine";
  79795. /**
  79796. * Class containing a set of static utilities functions for screenshots
  79797. */
  79798. export class ScreenshotTools {
  79799. /**
  79800. * Captures a screenshot of the current rendering
  79801. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79802. * @param engine defines the rendering engine
  79803. * @param camera defines the source camera
  79804. * @param size This parameter can be set to a single number or to an object with the
  79805. * following (optional) properties: precision, width, height. If a single number is passed,
  79806. * it will be used for both width and height. If an object is passed, the screenshot size
  79807. * will be derived from the parameters. The precision property is a multiplier allowing
  79808. * rendering at a higher or lower resolution
  79809. * @param successCallback defines the callback receives a single parameter which contains the
  79810. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79811. * src parameter of an <img> to display it
  79812. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79813. * Check your browser for supported MIME types
  79814. */
  79815. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79816. /**
  79817. * Captures a screenshot of the current rendering
  79818. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79819. * @param engine defines the rendering engine
  79820. * @param camera defines the source camera
  79821. * @param size This parameter can be set to a single number or to an object with the
  79822. * following (optional) properties: precision, width, height. If a single number is passed,
  79823. * it will be used for both width and height. If an object is passed, the screenshot size
  79824. * will be derived from the parameters. The precision property is a multiplier allowing
  79825. * rendering at a higher or lower resolution
  79826. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79827. * Check your browser for supported MIME types
  79828. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79829. * to the src parameter of an <img> to display it
  79830. */
  79831. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79832. /**
  79833. * Generates an image screenshot from the specified camera.
  79834. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79835. * @param engine The engine to use for rendering
  79836. * @param camera The camera to use for rendering
  79837. * @param size This parameter can be set to a single number or to an object with the
  79838. * following (optional) properties: precision, width, height. If a single number is passed,
  79839. * it will be used for both width and height. If an object is passed, the screenshot size
  79840. * will be derived from the parameters. The precision property is a multiplier allowing
  79841. * rendering at a higher or lower resolution
  79842. * @param successCallback The callback receives a single parameter which contains the
  79843. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79844. * src parameter of an <img> to display it
  79845. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79846. * Check your browser for supported MIME types
  79847. * @param samples Texture samples (default: 1)
  79848. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79849. * @param fileName A name for for the downloaded file.
  79850. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79851. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79852. */
  79853. 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;
  79854. /**
  79855. * Generates an image screenshot from the specified camera.
  79856. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79857. * @param engine The engine to use for rendering
  79858. * @param camera The camera to use for rendering
  79859. * @param size This parameter can be set to a single number or to an object with the
  79860. * following (optional) properties: precision, width, height. If a single number is passed,
  79861. * it will be used for both width and height. If an object is passed, the screenshot size
  79862. * will be derived from the parameters. The precision property is a multiplier allowing
  79863. * rendering at a higher or lower resolution
  79864. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79865. * Check your browser for supported MIME types
  79866. * @param samples Texture samples (default: 1)
  79867. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79868. * @param fileName A name for for the downloaded file.
  79869. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79870. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79871. * to the src parameter of an <img> to display it
  79872. */
  79873. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79874. /**
  79875. * Gets height and width for screenshot size
  79876. * @private
  79877. */
  79878. private static _getScreenshotSize;
  79879. }
  79880. }
  79881. declare module "babylonjs/Misc/dataReader" {
  79882. /**
  79883. * Interface for a data buffer
  79884. */
  79885. export interface IDataBuffer {
  79886. /**
  79887. * Reads bytes from the data buffer.
  79888. * @param byteOffset The byte offset to read
  79889. * @param byteLength The byte length to read
  79890. * @returns A promise that resolves when the bytes are read
  79891. */
  79892. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79893. /**
  79894. * The byte length of the buffer.
  79895. */
  79896. readonly byteLength: number;
  79897. }
  79898. /**
  79899. * Utility class for reading from a data buffer
  79900. */
  79901. export class DataReader {
  79902. /**
  79903. * The data buffer associated with this data reader.
  79904. */
  79905. readonly buffer: IDataBuffer;
  79906. /**
  79907. * The current byte offset from the beginning of the data buffer.
  79908. */
  79909. byteOffset: number;
  79910. private _dataView;
  79911. private _dataByteOffset;
  79912. /**
  79913. * Constructor
  79914. * @param buffer The buffer to read
  79915. */
  79916. constructor(buffer: IDataBuffer);
  79917. /**
  79918. * Loads the given byte length.
  79919. * @param byteLength The byte length to load
  79920. * @returns A promise that resolves when the load is complete
  79921. */
  79922. loadAsync(byteLength: number): Promise<void>;
  79923. /**
  79924. * Read a unsigned 32-bit integer from the currently loaded data range.
  79925. * @returns The 32-bit integer read
  79926. */
  79927. readUint32(): number;
  79928. /**
  79929. * Read a byte array from the currently loaded data range.
  79930. * @param byteLength The byte length to read
  79931. * @returns The byte array read
  79932. */
  79933. readUint8Array(byteLength: number): Uint8Array;
  79934. /**
  79935. * Read a string from the currently loaded data range.
  79936. * @param byteLength The byte length to read
  79937. * @returns The string read
  79938. */
  79939. readString(byteLength: number): string;
  79940. /**
  79941. * Skips the given byte length the currently loaded data range.
  79942. * @param byteLength The byte length to skip
  79943. */
  79944. skipBytes(byteLength: number): void;
  79945. }
  79946. }
  79947. declare module "babylonjs/Misc/dataStorage" {
  79948. /**
  79949. * Class for storing data to local storage if available or in-memory storage otherwise
  79950. */
  79951. export class DataStorage {
  79952. private static _Storage;
  79953. private static _GetStorage;
  79954. /**
  79955. * Reads a string from the data storage
  79956. * @param key The key to read
  79957. * @param defaultValue The value if the key doesn't exist
  79958. * @returns The string value
  79959. */
  79960. static ReadString(key: string, defaultValue: string): string;
  79961. /**
  79962. * Writes a string to the data storage
  79963. * @param key The key to write
  79964. * @param value The value to write
  79965. */
  79966. static WriteString(key: string, value: string): void;
  79967. /**
  79968. * Reads a boolean from the data storage
  79969. * @param key The key to read
  79970. * @param defaultValue The value if the key doesn't exist
  79971. * @returns The boolean value
  79972. */
  79973. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79974. /**
  79975. * Writes a boolean to the data storage
  79976. * @param key The key to write
  79977. * @param value The value to write
  79978. */
  79979. static WriteBoolean(key: string, value: boolean): void;
  79980. /**
  79981. * Reads a number from the data storage
  79982. * @param key The key to read
  79983. * @param defaultValue The value if the key doesn't exist
  79984. * @returns The number value
  79985. */
  79986. static ReadNumber(key: string, defaultValue: number): number;
  79987. /**
  79988. * Writes a number to the data storage
  79989. * @param key The key to write
  79990. * @param value The value to write
  79991. */
  79992. static WriteNumber(key: string, value: number): void;
  79993. }
  79994. }
  79995. declare module "babylonjs/Misc/sceneRecorder" {
  79996. import { Scene } from "babylonjs/scene";
  79997. /**
  79998. * Class used to record delta files between 2 scene states
  79999. */
  80000. export class SceneRecorder {
  80001. private _trackedScene;
  80002. private _savedJSON;
  80003. /**
  80004. * Track a given scene. This means the current scene state will be considered the original state
  80005. * @param scene defines the scene to track
  80006. */
  80007. track(scene: Scene): void;
  80008. /**
  80009. * Get the delta between current state and original state
  80010. * @returns a string containing the delta
  80011. */
  80012. getDelta(): any;
  80013. private _compareArray;
  80014. private _compareObjects;
  80015. private _compareCollections;
  80016. private static GetShadowGeneratorById;
  80017. /**
  80018. * Apply a given delta to a given scene
  80019. * @param deltaJSON defines the JSON containing the delta
  80020. * @param scene defines the scene to apply the delta to
  80021. */
  80022. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  80023. private static _ApplyPropertiesToEntity;
  80024. private static _ApplyDeltaForEntity;
  80025. }
  80026. }
  80027. declare module "babylonjs/Misc/trajectoryClassifier" {
  80028. import { DeepImmutable, Nullable } from "babylonjs/types";
  80029. import { Vector3 } from "babylonjs/Maths/math.vector";
  80030. /**
  80031. * A 3D trajectory consisting of an order list of vectors describing a
  80032. * path of motion through 3D space.
  80033. */
  80034. export class Trajectory {
  80035. private _points;
  80036. private readonly _segmentLength;
  80037. /**
  80038. * Serialize to JSON.
  80039. * @returns serialized JSON string
  80040. */
  80041. serialize(): string;
  80042. /**
  80043. * Deserialize from JSON.
  80044. * @param json serialized JSON string
  80045. * @returns deserialized Trajectory
  80046. */
  80047. static Deserialize(json: string): Trajectory;
  80048. /**
  80049. * Create a new empty Trajectory.
  80050. * @param segmentLength radius of discretization for Trajectory points
  80051. */
  80052. constructor(segmentLength?: number);
  80053. /**
  80054. * Get the length of the Trajectory.
  80055. * @returns length of the Trajectory
  80056. */
  80057. getLength(): number;
  80058. /**
  80059. * Append a new point to the Trajectory.
  80060. * NOTE: This implementation has many allocations.
  80061. * @param point point to append to the Trajectory
  80062. */
  80063. add(point: DeepImmutable<Vector3>): void;
  80064. /**
  80065. * Create a new Trajectory with a segment length chosen to make it
  80066. * probable that the new Trajectory will have a specified number of
  80067. * segments. This operation is imprecise.
  80068. * @param targetResolution number of segments desired
  80069. * @returns new Trajectory with approximately the requested number of segments
  80070. */
  80071. resampleAtTargetResolution(targetResolution: number): Trajectory;
  80072. /**
  80073. * Convert Trajectory segments into tokenized representation. This
  80074. * representation is an array of numbers where each nth number is the
  80075. * index of the token which is most similar to the nth segment of the
  80076. * Trajectory.
  80077. * @param tokens list of vectors which serve as discrete tokens
  80078. * @returns list of indices of most similar token per segment
  80079. */
  80080. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  80081. private static _forwardDir;
  80082. private static _inverseFromVec;
  80083. private static _upDir;
  80084. private static _fromToVec;
  80085. private static _lookMatrix;
  80086. /**
  80087. * Transform the rotation (i.e., direction) of a segment to isolate
  80088. * the relative transformation represented by the segment. This operation
  80089. * may or may not succeed due to singularities in the equations that define
  80090. * motion relativity in this context.
  80091. * @param priorVec the origin of the prior segment
  80092. * @param fromVec the origin of the current segment
  80093. * @param toVec the destination of the current segment
  80094. * @param result reference to output variable
  80095. * @returns whether or not transformation was successful
  80096. */
  80097. private static _transformSegmentDirToRef;
  80098. private static _bestMatch;
  80099. private static _score;
  80100. private static _bestScore;
  80101. /**
  80102. * Determine which token vector is most similar to the
  80103. * segment vector.
  80104. * @param segment segment vector
  80105. * @param tokens token vector list
  80106. * @returns index of the most similar token to the segment
  80107. */
  80108. private static _tokenizeSegment;
  80109. }
  80110. /**
  80111. * Class representing a set of known, named trajectories to which Trajectories can be
  80112. * added and using which Trajectories can be recognized.
  80113. */
  80114. export class TrajectoryClassifier {
  80115. private _maximumAllowableMatchCost;
  80116. private _vector3Alphabet;
  80117. private _levenshteinAlphabet;
  80118. private _nameToDescribedTrajectory;
  80119. /**
  80120. * Serialize to JSON.
  80121. * @returns JSON serialization
  80122. */
  80123. serialize(): string;
  80124. /**
  80125. * Deserialize from JSON.
  80126. * @param json JSON serialization
  80127. * @returns deserialized TrajectorySet
  80128. */
  80129. static Deserialize(json: string): TrajectoryClassifier;
  80130. /**
  80131. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  80132. * VERY naive, need to be generating these things from known
  80133. * sets. Better version later, probably eliminating this one.
  80134. * @returns auto-generated TrajectorySet
  80135. */
  80136. static Generate(): TrajectoryClassifier;
  80137. private constructor();
  80138. /**
  80139. * Add a new Trajectory to the set with a given name.
  80140. * @param trajectory new Trajectory to be added
  80141. * @param classification name to which to add the Trajectory
  80142. */
  80143. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  80144. /**
  80145. * Remove a known named trajectory and all Trajectories associated with it.
  80146. * @param classification name to remove
  80147. * @returns whether anything was removed
  80148. */
  80149. deleteClassification(classification: string): boolean;
  80150. /**
  80151. * Attempt to recognize a Trajectory from among all the classifications
  80152. * already known to the classifier.
  80153. * @param trajectory Trajectory to be recognized
  80154. * @returns classification of Trajectory if recognized, null otherwise
  80155. */
  80156. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  80157. }
  80158. }
  80159. declare module "babylonjs/Misc/index" {
  80160. export * from "babylonjs/Misc/andOrNotEvaluator";
  80161. export * from "babylonjs/Misc/assetsManager";
  80162. export * from "babylonjs/Misc/basis";
  80163. export * from "babylonjs/Misc/dds";
  80164. export * from "babylonjs/Misc/decorators";
  80165. export * from "babylonjs/Misc/deferred";
  80166. export * from "babylonjs/Misc/environmentTextureTools";
  80167. export * from "babylonjs/Misc/meshExploder";
  80168. export * from "babylonjs/Misc/filesInput";
  80169. export * from "babylonjs/Misc/HighDynamicRange/index";
  80170. export * from "babylonjs/Misc/khronosTextureContainer";
  80171. export * from "babylonjs/Misc/observable";
  80172. export * from "babylonjs/Misc/performanceMonitor";
  80173. export * from "babylonjs/Misc/promise";
  80174. export * from "babylonjs/Misc/sceneOptimizer";
  80175. export * from "babylonjs/Misc/sceneSerializer";
  80176. export * from "babylonjs/Misc/smartArray";
  80177. export * from "babylonjs/Misc/stringDictionary";
  80178. export * from "babylonjs/Misc/tags";
  80179. export * from "babylonjs/Misc/textureTools";
  80180. export * from "babylonjs/Misc/tga";
  80181. export * from "babylonjs/Misc/tools";
  80182. export * from "babylonjs/Misc/videoRecorder";
  80183. export * from "babylonjs/Misc/virtualJoystick";
  80184. export * from "babylonjs/Misc/workerPool";
  80185. export * from "babylonjs/Misc/logger";
  80186. export * from "babylonjs/Misc/typeStore";
  80187. export * from "babylonjs/Misc/filesInputStore";
  80188. export * from "babylonjs/Misc/deepCopier";
  80189. export * from "babylonjs/Misc/pivotTools";
  80190. export * from "babylonjs/Misc/precisionDate";
  80191. export * from "babylonjs/Misc/screenshotTools";
  80192. export * from "babylonjs/Misc/typeStore";
  80193. export * from "babylonjs/Misc/webRequest";
  80194. export * from "babylonjs/Misc/iInspectable";
  80195. export * from "babylonjs/Misc/brdfTextureTools";
  80196. export * from "babylonjs/Misc/rgbdTextureTools";
  80197. export * from "babylonjs/Misc/gradients";
  80198. export * from "babylonjs/Misc/perfCounter";
  80199. export * from "babylonjs/Misc/fileRequest";
  80200. export * from "babylonjs/Misc/customAnimationFrameRequester";
  80201. export * from "babylonjs/Misc/retryStrategy";
  80202. export * from "babylonjs/Misc/interfaces/screenshotSize";
  80203. export * from "babylonjs/Misc/canvasGenerator";
  80204. export * from "babylonjs/Misc/fileTools";
  80205. export * from "babylonjs/Misc/stringTools";
  80206. export * from "babylonjs/Misc/dataReader";
  80207. export * from "babylonjs/Misc/minMaxReducer";
  80208. export * from "babylonjs/Misc/depthReducer";
  80209. export * from "babylonjs/Misc/dataStorage";
  80210. export * from "babylonjs/Misc/sceneRecorder";
  80211. export * from "babylonjs/Misc/khronosTextureContainer2";
  80212. export * from "babylonjs/Misc/trajectoryClassifier";
  80213. export * from "babylonjs/Misc/timer";
  80214. export * from "babylonjs/Misc/copyTools";
  80215. }
  80216. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  80217. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  80218. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80219. import { Observable } from "babylonjs/Misc/observable";
  80220. import { Matrix } from "babylonjs/Maths/math.vector";
  80221. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80222. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80223. /**
  80224. * An interface for all Hit test features
  80225. */
  80226. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  80227. /**
  80228. * Triggered when new babylon (transformed) hit test results are available
  80229. */
  80230. onHitTestResultObservable: Observable<T[]>;
  80231. }
  80232. /**
  80233. * Options used for hit testing
  80234. */
  80235. export interface IWebXRLegacyHitTestOptions {
  80236. /**
  80237. * Only test when user interacted with the scene. Default - hit test every frame
  80238. */
  80239. testOnPointerDownOnly?: boolean;
  80240. /**
  80241. * The node to use to transform the local results to world coordinates
  80242. */
  80243. worldParentNode?: TransformNode;
  80244. }
  80245. /**
  80246. * Interface defining the babylon result of raycasting/hit-test
  80247. */
  80248. export interface IWebXRLegacyHitResult {
  80249. /**
  80250. * Transformation matrix that can be applied to a node that will put it in the hit point location
  80251. */
  80252. transformationMatrix: Matrix;
  80253. /**
  80254. * The native hit test result
  80255. */
  80256. xrHitResult: XRHitResult | XRHitTestResult;
  80257. }
  80258. /**
  80259. * The currently-working hit-test module.
  80260. * Hit test (or Ray-casting) is used to interact with the real world.
  80261. * For further information read here - https://github.com/immersive-web/hit-test
  80262. */
  80263. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  80264. /**
  80265. * options to use when constructing this feature
  80266. */
  80267. readonly options: IWebXRLegacyHitTestOptions;
  80268. private _direction;
  80269. private _mat;
  80270. private _onSelectEnabled;
  80271. private _origin;
  80272. /**
  80273. * The module's name
  80274. */
  80275. static readonly Name: string;
  80276. /**
  80277. * The (Babylon) version of this module.
  80278. * This is an integer representing the implementation version.
  80279. * This number does not correspond to the WebXR specs version
  80280. */
  80281. static readonly Version: number;
  80282. /**
  80283. * Populated with the last native XR Hit Results
  80284. */
  80285. lastNativeXRHitResults: XRHitResult[];
  80286. /**
  80287. * Triggered when new babylon (transformed) hit test results are available
  80288. */
  80289. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  80290. /**
  80291. * Creates a new instance of the (legacy version) hit test feature
  80292. * @param _xrSessionManager an instance of WebXRSessionManager
  80293. * @param options options to use when constructing this feature
  80294. */
  80295. constructor(_xrSessionManager: WebXRSessionManager,
  80296. /**
  80297. * options to use when constructing this feature
  80298. */
  80299. options?: IWebXRLegacyHitTestOptions);
  80300. /**
  80301. * execute a hit test with an XR Ray
  80302. *
  80303. * @param xrSession a native xrSession that will execute this hit test
  80304. * @param xrRay the ray (position and direction) to use for ray-casting
  80305. * @param referenceSpace native XR reference space to use for the hit-test
  80306. * @param filter filter function that will filter the results
  80307. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80308. */
  80309. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  80310. /**
  80311. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  80312. * @param event the (select) event to use to select with
  80313. * @param referenceSpace the reference space to use for this hit test
  80314. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  80315. */
  80316. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  80317. /**
  80318. * attach this feature
  80319. * Will usually be called by the features manager
  80320. *
  80321. * @returns true if successful.
  80322. */
  80323. attach(): boolean;
  80324. /**
  80325. * detach this feature.
  80326. * Will usually be called by the features manager
  80327. *
  80328. * @returns true if successful.
  80329. */
  80330. detach(): boolean;
  80331. /**
  80332. * Dispose this feature and all of the resources attached
  80333. */
  80334. dispose(): void;
  80335. protected _onXRFrame(frame: XRFrame): void;
  80336. private _onHitTestResults;
  80337. private _onSelect;
  80338. }
  80339. }
  80340. declare module "babylonjs/XR/features/WebXRHitTest" {
  80341. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80342. import { Observable } from "babylonjs/Misc/observable";
  80343. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80344. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80345. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  80346. /**
  80347. * Options used for hit testing (version 2)
  80348. */
  80349. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  80350. /**
  80351. * Do not create a permanent hit test. Will usually be used when only
  80352. * transient inputs are needed.
  80353. */
  80354. disablePermanentHitTest?: boolean;
  80355. /**
  80356. * Enable transient (for example touch-based) hit test inspections
  80357. */
  80358. enableTransientHitTest?: boolean;
  80359. /**
  80360. * Offset ray for the permanent hit test
  80361. */
  80362. offsetRay?: Vector3;
  80363. /**
  80364. * Offset ray for the transient hit test
  80365. */
  80366. transientOffsetRay?: Vector3;
  80367. /**
  80368. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  80369. */
  80370. useReferenceSpace?: boolean;
  80371. /**
  80372. * Override the default entity type(s) of the hit-test result
  80373. */
  80374. entityTypes?: XRHitTestTrackableType[];
  80375. }
  80376. /**
  80377. * Interface defining the babylon result of hit-test
  80378. */
  80379. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  80380. /**
  80381. * The input source that generated this hit test (if transient)
  80382. */
  80383. inputSource?: XRInputSource;
  80384. /**
  80385. * Is this a transient hit test
  80386. */
  80387. isTransient?: boolean;
  80388. /**
  80389. * Position of the hit test result
  80390. */
  80391. position: Vector3;
  80392. /**
  80393. * Rotation of the hit test result
  80394. */
  80395. rotationQuaternion: Quaternion;
  80396. /**
  80397. * The native hit test result
  80398. */
  80399. xrHitResult: XRHitTestResult;
  80400. }
  80401. /**
  80402. * The currently-working hit-test module.
  80403. * Hit test (or Ray-casting) is used to interact with the real world.
  80404. * For further information read here - https://github.com/immersive-web/hit-test
  80405. *
  80406. * Tested on chrome (mobile) 80.
  80407. */
  80408. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  80409. /**
  80410. * options to use when constructing this feature
  80411. */
  80412. readonly options: IWebXRHitTestOptions;
  80413. private _tmpMat;
  80414. private _tmpPos;
  80415. private _tmpQuat;
  80416. private _transientXrHitTestSource;
  80417. private _xrHitTestSource;
  80418. private initHitTestSource;
  80419. /**
  80420. * The module's name
  80421. */
  80422. static readonly Name: string;
  80423. /**
  80424. * The (Babylon) version of this module.
  80425. * This is an integer representing the implementation version.
  80426. * This number does not correspond to the WebXR specs version
  80427. */
  80428. static readonly Version: number;
  80429. /**
  80430. * When set to true, each hit test will have its own position/rotation objects
  80431. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  80432. * the developers will clone them or copy them as they see fit.
  80433. */
  80434. autoCloneTransformation: boolean;
  80435. /**
  80436. * Triggered when new babylon (transformed) hit test results are available
  80437. * Note - this will be called when results come back from the device. It can be an empty array!!
  80438. */
  80439. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  80440. /**
  80441. * Use this to temporarily pause hit test checks.
  80442. */
  80443. paused: boolean;
  80444. /**
  80445. * Creates a new instance of the hit test feature
  80446. * @param _xrSessionManager an instance of WebXRSessionManager
  80447. * @param options options to use when constructing this feature
  80448. */
  80449. constructor(_xrSessionManager: WebXRSessionManager,
  80450. /**
  80451. * options to use when constructing this feature
  80452. */
  80453. options?: IWebXRHitTestOptions);
  80454. /**
  80455. * attach this feature
  80456. * Will usually be called by the features manager
  80457. *
  80458. * @returns true if successful.
  80459. */
  80460. attach(): boolean;
  80461. /**
  80462. * detach this feature.
  80463. * Will usually be called by the features manager
  80464. *
  80465. * @returns true if successful.
  80466. */
  80467. detach(): boolean;
  80468. /**
  80469. * Dispose this feature and all of the resources attached
  80470. */
  80471. dispose(): void;
  80472. protected _onXRFrame(frame: XRFrame): void;
  80473. private _processWebXRHitTestResult;
  80474. }
  80475. }
  80476. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80477. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80478. import { Observable } from "babylonjs/Misc/observable";
  80479. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80480. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80481. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80482. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80483. /**
  80484. * Configuration options of the anchor system
  80485. */
  80486. export interface IWebXRAnchorSystemOptions {
  80487. /**
  80488. * a node that will be used to convert local to world coordinates
  80489. */
  80490. worldParentNode?: TransformNode;
  80491. /**
  80492. * If set to true a reference of the created anchors will be kept until the next session starts
  80493. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80494. */
  80495. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80496. }
  80497. /**
  80498. * A babylon container for an XR Anchor
  80499. */
  80500. export interface IWebXRAnchor {
  80501. /**
  80502. * A babylon-assigned ID for this anchor
  80503. */
  80504. id: number;
  80505. /**
  80506. * Transformation matrix to apply to an object attached to this anchor
  80507. */
  80508. transformationMatrix: Matrix;
  80509. /**
  80510. * The native anchor object
  80511. */
  80512. xrAnchor: XRAnchor;
  80513. /**
  80514. * if defined, this object will be constantly updated by the anchor's position and rotation
  80515. */
  80516. attachedNode?: TransformNode;
  80517. /**
  80518. * Remove this anchor from the scene
  80519. */
  80520. remove(): void;
  80521. }
  80522. /**
  80523. * An implementation of the anchor system for WebXR.
  80524. * For further information see https://github.com/immersive-web/anchors/
  80525. */
  80526. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80527. private _options;
  80528. private _lastFrameDetected;
  80529. private _trackedAnchors;
  80530. private _referenceSpaceForFrameAnchors;
  80531. private _futureAnchors;
  80532. /**
  80533. * The module's name
  80534. */
  80535. static readonly Name: string;
  80536. /**
  80537. * The (Babylon) version of this module.
  80538. * This is an integer representing the implementation version.
  80539. * This number does not correspond to the WebXR specs version
  80540. */
  80541. static readonly Version: number;
  80542. /**
  80543. * Observers registered here will be executed when a new anchor was added to the session
  80544. */
  80545. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80546. /**
  80547. * Observers registered here will be executed when an anchor was removed from the session
  80548. */
  80549. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80550. /**
  80551. * Observers registered here will be executed when an existing anchor updates
  80552. * This can execute N times every frame
  80553. */
  80554. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80555. /**
  80556. * Set the reference space to use for anchor creation, when not using a hit test.
  80557. * Will default to the session's reference space if not defined
  80558. */
  80559. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80560. /**
  80561. * constructs a new anchor system
  80562. * @param _xrSessionManager an instance of WebXRSessionManager
  80563. * @param _options configuration object for this feature
  80564. */
  80565. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80566. private _tmpVector;
  80567. private _tmpQuaternion;
  80568. private _populateTmpTransformation;
  80569. /**
  80570. * Create a new anchor point using a hit test result at a specific point in the scene
  80571. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80572. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80573. *
  80574. * @param hitTestResult The hit test result to use for this anchor creation
  80575. * @param position an optional position offset for this anchor
  80576. * @param rotationQuaternion an optional rotation offset for this anchor
  80577. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80578. */
  80579. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  80580. /**
  80581. * Add a new anchor at a specific position and rotation
  80582. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80583. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80584. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80585. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80586. *
  80587. * @param position the position in which to add an anchor
  80588. * @param rotationQuaternion an optional rotation for the anchor transformation
  80589. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80590. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  80591. */
  80592. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  80593. /**
  80594. * Get the list of anchors currently being tracked by the system
  80595. */
  80596. get anchors(): IWebXRAnchor[];
  80597. /**
  80598. * detach this feature.
  80599. * Will usually be called by the features manager
  80600. *
  80601. * @returns true if successful.
  80602. */
  80603. detach(): boolean;
  80604. /**
  80605. * Dispose this feature and all of the resources attached
  80606. */
  80607. dispose(): void;
  80608. protected _onXRFrame(frame: XRFrame): void;
  80609. /**
  80610. * avoiding using Array.find for global support.
  80611. * @param xrAnchor the plane to find in the array
  80612. */
  80613. private _findIndexInAnchorArray;
  80614. private _updateAnchorWithXRFrame;
  80615. private _createAnchorAtTransformation;
  80616. }
  80617. }
  80618. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80619. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80620. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80621. import { Observable } from "babylonjs/Misc/observable";
  80622. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80623. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80624. /**
  80625. * Options used in the plane detector module
  80626. */
  80627. export interface IWebXRPlaneDetectorOptions {
  80628. /**
  80629. * The node to use to transform the local results to world coordinates
  80630. */
  80631. worldParentNode?: TransformNode;
  80632. /**
  80633. * If set to true a reference of the created planes will be kept until the next session starts
  80634. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80635. */
  80636. doNotRemovePlanesOnSessionEnded?: boolean;
  80637. }
  80638. /**
  80639. * A babylon interface for a WebXR plane.
  80640. * A Plane is actually a polygon, built from N points in space
  80641. *
  80642. * Supported in chrome 79, not supported in canary 81 ATM
  80643. */
  80644. export interface IWebXRPlane {
  80645. /**
  80646. * a babylon-assigned ID for this polygon
  80647. */
  80648. id: number;
  80649. /**
  80650. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80651. */
  80652. polygonDefinition: Array<Vector3>;
  80653. /**
  80654. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80655. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80656. */
  80657. transformationMatrix: Matrix;
  80658. /**
  80659. * the native xr-plane object
  80660. */
  80661. xrPlane: XRPlane;
  80662. }
  80663. /**
  80664. * The plane detector is used to detect planes in the real world when in AR
  80665. * For more information see https://github.com/immersive-web/real-world-geometry/
  80666. */
  80667. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80668. private _options;
  80669. private _detectedPlanes;
  80670. private _enabled;
  80671. private _lastFrameDetected;
  80672. /**
  80673. * The module's name
  80674. */
  80675. static readonly Name: string;
  80676. /**
  80677. * The (Babylon) version of this module.
  80678. * This is an integer representing the implementation version.
  80679. * This number does not correspond to the WebXR specs version
  80680. */
  80681. static readonly Version: number;
  80682. /**
  80683. * Observers registered here will be executed when a new plane was added to the session
  80684. */
  80685. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80686. /**
  80687. * Observers registered here will be executed when a plane is no longer detected in the session
  80688. */
  80689. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80690. /**
  80691. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80692. * This can execute N times every frame
  80693. */
  80694. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80695. /**
  80696. * construct a new Plane Detector
  80697. * @param _xrSessionManager an instance of xr Session manager
  80698. * @param _options configuration to use when constructing this feature
  80699. */
  80700. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80701. /**
  80702. * detach this feature.
  80703. * Will usually be called by the features manager
  80704. *
  80705. * @returns true if successful.
  80706. */
  80707. detach(): boolean;
  80708. /**
  80709. * Dispose this feature and all of the resources attached
  80710. */
  80711. dispose(): void;
  80712. /**
  80713. * Check if the needed objects are defined.
  80714. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80715. */
  80716. isCompatible(): boolean;
  80717. protected _onXRFrame(frame: XRFrame): void;
  80718. private _init;
  80719. private _updatePlaneWithXRPlane;
  80720. /**
  80721. * avoiding using Array.find for global support.
  80722. * @param xrPlane the plane to find in the array
  80723. */
  80724. private findIndexInPlaneArray;
  80725. }
  80726. }
  80727. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80728. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80730. import { Observable } from "babylonjs/Misc/observable";
  80731. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80732. /**
  80733. * Options interface for the background remover plugin
  80734. */
  80735. export interface IWebXRBackgroundRemoverOptions {
  80736. /**
  80737. * Further background meshes to disable when entering AR
  80738. */
  80739. backgroundMeshes?: AbstractMesh[];
  80740. /**
  80741. * flags to configure the removal of the environment helper.
  80742. * If not set, the entire background will be removed. If set, flags should be set as well.
  80743. */
  80744. environmentHelperRemovalFlags?: {
  80745. /**
  80746. * Should the skybox be removed (default false)
  80747. */
  80748. skyBox?: boolean;
  80749. /**
  80750. * Should the ground be removed (default false)
  80751. */
  80752. ground?: boolean;
  80753. };
  80754. /**
  80755. * don't disable the environment helper
  80756. */
  80757. ignoreEnvironmentHelper?: boolean;
  80758. }
  80759. /**
  80760. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80761. */
  80762. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80763. /**
  80764. * read-only options to be used in this module
  80765. */
  80766. readonly options: IWebXRBackgroundRemoverOptions;
  80767. /**
  80768. * The module's name
  80769. */
  80770. static readonly Name: string;
  80771. /**
  80772. * The (Babylon) version of this module.
  80773. * This is an integer representing the implementation version.
  80774. * This number does not correspond to the WebXR specs version
  80775. */
  80776. static readonly Version: number;
  80777. /**
  80778. * registered observers will be triggered when the background state changes
  80779. */
  80780. onBackgroundStateChangedObservable: Observable<boolean>;
  80781. /**
  80782. * constructs a new background remover module
  80783. * @param _xrSessionManager the session manager for this module
  80784. * @param options read-only options to be used in this module
  80785. */
  80786. constructor(_xrSessionManager: WebXRSessionManager,
  80787. /**
  80788. * read-only options to be used in this module
  80789. */
  80790. options?: IWebXRBackgroundRemoverOptions);
  80791. /**
  80792. * attach this feature
  80793. * Will usually be called by the features manager
  80794. *
  80795. * @returns true if successful.
  80796. */
  80797. attach(): boolean;
  80798. /**
  80799. * detach this feature.
  80800. * Will usually be called by the features manager
  80801. *
  80802. * @returns true if successful.
  80803. */
  80804. detach(): boolean;
  80805. /**
  80806. * Dispose this feature and all of the resources attached
  80807. */
  80808. dispose(): void;
  80809. protected _onXRFrame(_xrFrame: XRFrame): void;
  80810. private _setBackgroundState;
  80811. }
  80812. }
  80813. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80814. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80815. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80816. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80817. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80818. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80819. import { Nullable } from "babylonjs/types";
  80820. /**
  80821. * Options for the controller physics feature
  80822. */
  80823. export class IWebXRControllerPhysicsOptions {
  80824. /**
  80825. * Should the headset get its own impostor
  80826. */
  80827. enableHeadsetImpostor?: boolean;
  80828. /**
  80829. * Optional parameters for the headset impostor
  80830. */
  80831. headsetImpostorParams?: {
  80832. /**
  80833. * The type of impostor to create. Default is sphere
  80834. */
  80835. impostorType: number;
  80836. /**
  80837. * the size of the impostor. Defaults to 10cm
  80838. */
  80839. impostorSize?: number | {
  80840. width: number;
  80841. height: number;
  80842. depth: number;
  80843. };
  80844. /**
  80845. * Friction definitions
  80846. */
  80847. friction?: number;
  80848. /**
  80849. * Restitution
  80850. */
  80851. restitution?: number;
  80852. };
  80853. /**
  80854. * The physics properties of the future impostors
  80855. */
  80856. physicsProperties?: {
  80857. /**
  80858. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80859. * Note that this requires a physics engine that supports mesh impostors!
  80860. */
  80861. useControllerMesh?: boolean;
  80862. /**
  80863. * The type of impostor to create. Default is sphere
  80864. */
  80865. impostorType?: number;
  80866. /**
  80867. * the size of the impostor. Defaults to 10cm
  80868. */
  80869. impostorSize?: number | {
  80870. width: number;
  80871. height: number;
  80872. depth: number;
  80873. };
  80874. /**
  80875. * Friction definitions
  80876. */
  80877. friction?: number;
  80878. /**
  80879. * Restitution
  80880. */
  80881. restitution?: number;
  80882. };
  80883. /**
  80884. * the xr input to use with this pointer selection
  80885. */
  80886. xrInput: WebXRInput;
  80887. }
  80888. /**
  80889. * Add physics impostor to your webxr controllers,
  80890. * including naive calculation of their linear and angular velocity
  80891. */
  80892. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80893. private readonly _options;
  80894. private _attachController;
  80895. private _controllers;
  80896. private _debugMode;
  80897. private _delta;
  80898. private _headsetImpostor?;
  80899. private _headsetMesh?;
  80900. private _lastTimestamp;
  80901. private _tmpQuaternion;
  80902. private _tmpVector;
  80903. /**
  80904. * The module's name
  80905. */
  80906. static readonly Name: string;
  80907. /**
  80908. * The (Babylon) version of this module.
  80909. * This is an integer representing the implementation version.
  80910. * This number does not correspond to the webxr specs version
  80911. */
  80912. static readonly Version: number;
  80913. /**
  80914. * Construct a new Controller Physics Feature
  80915. * @param _xrSessionManager the corresponding xr session manager
  80916. * @param _options options to create this feature with
  80917. */
  80918. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80919. /**
  80920. * @hidden
  80921. * enable debugging - will show console outputs and the impostor mesh
  80922. */
  80923. _enablePhysicsDebug(): void;
  80924. /**
  80925. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80926. * @param xrController the controller to add
  80927. */
  80928. addController(xrController: WebXRInputSource): void;
  80929. /**
  80930. * attach this feature
  80931. * Will usually be called by the features manager
  80932. *
  80933. * @returns true if successful.
  80934. */
  80935. attach(): boolean;
  80936. /**
  80937. * detach this feature.
  80938. * Will usually be called by the features manager
  80939. *
  80940. * @returns true if successful.
  80941. */
  80942. detach(): boolean;
  80943. /**
  80944. * Get the headset impostor, if enabled
  80945. * @returns the impostor
  80946. */
  80947. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80948. /**
  80949. * Get the physics impostor of a specific controller.
  80950. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80951. * @param controller the controller or the controller id of which to get the impostor
  80952. * @returns the impostor or null
  80953. */
  80954. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80955. /**
  80956. * Update the physics properties provided in the constructor
  80957. * @param newProperties the new properties object
  80958. */
  80959. setPhysicsProperties(newProperties: {
  80960. impostorType?: number;
  80961. impostorSize?: number | {
  80962. width: number;
  80963. height: number;
  80964. depth: number;
  80965. };
  80966. friction?: number;
  80967. restitution?: number;
  80968. }): void;
  80969. protected _onXRFrame(_xrFrame: any): void;
  80970. private _detachController;
  80971. }
  80972. }
  80973. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80974. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80975. import { Observable } from "babylonjs/Misc/observable";
  80976. import { Vector3 } from "babylonjs/Maths/math.vector";
  80977. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80978. /**
  80979. * A babylon interface for a "WebXR" feature point.
  80980. * Represents the position and confidence value of a given feature point.
  80981. */
  80982. export interface IWebXRFeaturePoint {
  80983. /**
  80984. * Represents the position of the feature point in world space.
  80985. */
  80986. position: Vector3;
  80987. /**
  80988. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80989. */
  80990. confidenceValue: number;
  80991. }
  80992. /**
  80993. * The feature point system is used to detect feature points from real world geometry.
  80994. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80995. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80996. */
  80997. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80998. private _enabled;
  80999. private _featurePointCloud;
  81000. /**
  81001. * The module's name
  81002. */
  81003. static readonly Name: string;
  81004. /**
  81005. * The (Babylon) version of this module.
  81006. * This is an integer representing the implementation version.
  81007. * This number does not correspond to the WebXR specs version
  81008. */
  81009. static readonly Version: number;
  81010. /**
  81011. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  81012. * Will notify the observers about which feature points have been added.
  81013. */
  81014. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  81015. /**
  81016. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  81017. * Will notify the observers about which feature points have been updated.
  81018. */
  81019. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  81020. /**
  81021. * The current feature point cloud maintained across frames.
  81022. */
  81023. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  81024. /**
  81025. * construct the feature point system
  81026. * @param _xrSessionManager an instance of xr Session manager
  81027. */
  81028. constructor(_xrSessionManager: WebXRSessionManager);
  81029. /**
  81030. * Detach this feature.
  81031. * Will usually be called by the features manager
  81032. *
  81033. * @returns true if successful.
  81034. */
  81035. detach(): boolean;
  81036. /**
  81037. * Dispose this feature and all of the resources attached
  81038. */
  81039. dispose(): void;
  81040. /**
  81041. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  81042. */
  81043. protected _onXRFrame(frame: XRFrame): void;
  81044. /**
  81045. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  81046. */
  81047. private _init;
  81048. }
  81049. }
  81050. declare module "babylonjs/XR/features/WebXRHandTracking" {
  81051. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  81052. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  81053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81054. import { Mesh } from "babylonjs/Meshes/mesh";
  81055. import { WebXRInput } from "babylonjs/XR/webXRInput";
  81056. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  81057. import { Nullable } from "babylonjs/types";
  81058. import { IDisposable } from "babylonjs/scene";
  81059. import { Observable } from "babylonjs/Misc/observable";
  81060. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  81061. /**
  81062. * Configuration interface for the hand tracking feature
  81063. */
  81064. export interface IWebXRHandTrackingOptions {
  81065. /**
  81066. * The xrInput that will be used as source for new hands
  81067. */
  81068. xrInput: WebXRInput;
  81069. /**
  81070. * Configuration object for the joint meshes
  81071. */
  81072. jointMeshes?: {
  81073. /**
  81074. * Should the meshes created be invisible (defaults to false)
  81075. */
  81076. invisible?: boolean;
  81077. /**
  81078. * A source mesh to be used to create instances. Defaults to a sphere.
  81079. * This mesh will be the source for all other (25) meshes.
  81080. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  81081. */
  81082. sourceMesh?: Mesh;
  81083. /**
  81084. * This function will be called after a mesh was created for a specific joint.
  81085. * Using this function you can either manipulate the instance or return a new mesh.
  81086. * When returning a new mesh the instance created before will be disposed
  81087. */
  81088. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  81089. /**
  81090. * Should the source mesh stay visible. Defaults to false
  81091. */
  81092. keepOriginalVisible?: boolean;
  81093. /**
  81094. * Scale factor for all instances (defaults to 2)
  81095. */
  81096. scaleFactor?: number;
  81097. /**
  81098. * Should each instance have its own physics impostor
  81099. */
  81100. enablePhysics?: boolean;
  81101. /**
  81102. * If enabled, override default physics properties
  81103. */
  81104. physicsProps?: {
  81105. friction?: number;
  81106. restitution?: number;
  81107. impostorType?: number;
  81108. };
  81109. /**
  81110. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  81111. */
  81112. handMesh?: AbstractMesh;
  81113. };
  81114. }
  81115. /**
  81116. * Parts of the hands divided to writs and finger names
  81117. */
  81118. export const enum HandPart {
  81119. /**
  81120. * HandPart - Wrist
  81121. */
  81122. WRIST = "wrist",
  81123. /**
  81124. * HandPart - The THumb
  81125. */
  81126. THUMB = "thumb",
  81127. /**
  81128. * HandPart - Index finger
  81129. */
  81130. INDEX = "index",
  81131. /**
  81132. * HandPart - Middle finger
  81133. */
  81134. MIDDLE = "middle",
  81135. /**
  81136. * HandPart - Ring finger
  81137. */
  81138. RING = "ring",
  81139. /**
  81140. * HandPart - Little finger
  81141. */
  81142. LITTLE = "little"
  81143. }
  81144. /**
  81145. * Representing a single hand (with its corresponding native XRHand object)
  81146. */
  81147. export class WebXRHand implements IDisposable {
  81148. /** the controller to which the hand correlates */
  81149. readonly xrController: WebXRInputSource;
  81150. /** the meshes to be used to track the hand joints */
  81151. readonly trackedMeshes: AbstractMesh[];
  81152. /**
  81153. * Hand-parts definition (key is HandPart)
  81154. */
  81155. handPartsDefinition: {
  81156. [key: string]: number[];
  81157. };
  81158. /**
  81159. * Populate the HandPartsDefinition object.
  81160. * This is called as a side effect since certain browsers don't have XRHand defined.
  81161. */
  81162. private generateHandPartsDefinition;
  81163. /**
  81164. * Construct a new hand object
  81165. * @param xrController the controller to which the hand correlates
  81166. * @param trackedMeshes the meshes to be used to track the hand joints
  81167. */
  81168. constructor(
  81169. /** the controller to which the hand correlates */
  81170. xrController: WebXRInputSource,
  81171. /** the meshes to be used to track the hand joints */
  81172. trackedMeshes: AbstractMesh[]);
  81173. /**
  81174. * Update this hand from the latest xr frame
  81175. * @param xrFrame xrFrame to update from
  81176. * @param referenceSpace The current viewer reference space
  81177. * @param scaleFactor optional scale factor for the meshes
  81178. */
  81179. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  81180. /**
  81181. * Get meshes of part of the hand
  81182. * @param part the part of hand to get
  81183. * @returns An array of meshes that correlate to the hand part requested
  81184. */
  81185. getHandPartMeshes(part: HandPart): AbstractMesh[];
  81186. /**
  81187. * Dispose this Hand object
  81188. */
  81189. dispose(): void;
  81190. }
  81191. /**
  81192. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  81193. */
  81194. export class WebXRHandTracking extends WebXRAbstractFeature {
  81195. /**
  81196. * options to use when constructing this feature
  81197. */
  81198. readonly options: IWebXRHandTrackingOptions;
  81199. private static _idCounter;
  81200. /**
  81201. * The module's name
  81202. */
  81203. static readonly Name: string;
  81204. /**
  81205. * The (Babylon) version of this module.
  81206. * This is an integer representing the implementation version.
  81207. * This number does not correspond to the WebXR specs version
  81208. */
  81209. static readonly Version: number;
  81210. /**
  81211. * This observable will notify registered observers when a new hand object was added and initialized
  81212. */
  81213. onHandAddedObservable: Observable<WebXRHand>;
  81214. /**
  81215. * This observable will notify its observers right before the hand object is disposed
  81216. */
  81217. onHandRemovedObservable: Observable<WebXRHand>;
  81218. private _hands;
  81219. /**
  81220. * Creates a new instance of the hit test feature
  81221. * @param _xrSessionManager an instance of WebXRSessionManager
  81222. * @param options options to use when constructing this feature
  81223. */
  81224. constructor(_xrSessionManager: WebXRSessionManager,
  81225. /**
  81226. * options to use when constructing this feature
  81227. */
  81228. options: IWebXRHandTrackingOptions);
  81229. /**
  81230. * Check if the needed objects are defined.
  81231. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  81232. */
  81233. isCompatible(): boolean;
  81234. /**
  81235. * attach this feature
  81236. * Will usually be called by the features manager
  81237. *
  81238. * @returns true if successful.
  81239. */
  81240. attach(): boolean;
  81241. /**
  81242. * detach this feature.
  81243. * Will usually be called by the features manager
  81244. *
  81245. * @returns true if successful.
  81246. */
  81247. detach(): boolean;
  81248. /**
  81249. * Dispose this feature and all of the resources attached
  81250. */
  81251. dispose(): void;
  81252. /**
  81253. * Get the hand object according to the controller id
  81254. * @param controllerId the controller id to which we want to get the hand
  81255. * @returns null if not found or the WebXRHand object if found
  81256. */
  81257. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  81258. /**
  81259. * Get a hand object according to the requested handedness
  81260. * @param handedness the handedness to request
  81261. * @returns null if not found or the WebXRHand object if found
  81262. */
  81263. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  81264. protected _onXRFrame(_xrFrame: XRFrame): void;
  81265. private _attachHand;
  81266. private _detachHand;
  81267. }
  81268. }
  81269. declare module "babylonjs/XR/features/index" {
  81270. export * from "babylonjs/XR/features/WebXRAbstractFeature";
  81271. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  81272. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  81273. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  81274. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  81275. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  81276. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  81277. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  81278. export * from "babylonjs/XR/features/WebXRHitTest";
  81279. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  81280. export * from "babylonjs/XR/features/WebXRHandTracking";
  81281. }
  81282. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  81283. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81285. import { Scene } from "babylonjs/scene";
  81286. /**
  81287. * The motion controller class for all microsoft mixed reality controllers
  81288. */
  81289. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  81290. protected readonly _mapping: {
  81291. defaultButton: {
  81292. valueNodeName: string;
  81293. unpressedNodeName: string;
  81294. pressedNodeName: string;
  81295. };
  81296. defaultAxis: {
  81297. valueNodeName: string;
  81298. minNodeName: string;
  81299. maxNodeName: string;
  81300. };
  81301. buttons: {
  81302. "xr-standard-trigger": {
  81303. rootNodeName: string;
  81304. componentProperty: string;
  81305. states: string[];
  81306. };
  81307. "xr-standard-squeeze": {
  81308. rootNodeName: string;
  81309. componentProperty: string;
  81310. states: string[];
  81311. };
  81312. "xr-standard-touchpad": {
  81313. rootNodeName: string;
  81314. labelAnchorNodeName: string;
  81315. touchPointNodeName: string;
  81316. };
  81317. "xr-standard-thumbstick": {
  81318. rootNodeName: string;
  81319. componentProperty: string;
  81320. states: string[];
  81321. };
  81322. };
  81323. axes: {
  81324. "xr-standard-touchpad": {
  81325. "x-axis": {
  81326. rootNodeName: string;
  81327. };
  81328. "y-axis": {
  81329. rootNodeName: string;
  81330. };
  81331. };
  81332. "xr-standard-thumbstick": {
  81333. "x-axis": {
  81334. rootNodeName: string;
  81335. };
  81336. "y-axis": {
  81337. rootNodeName: string;
  81338. };
  81339. };
  81340. };
  81341. };
  81342. /**
  81343. * The base url used to load the left and right controller models
  81344. */
  81345. static MODEL_BASE_URL: string;
  81346. /**
  81347. * The name of the left controller model file
  81348. */
  81349. static MODEL_LEFT_FILENAME: string;
  81350. /**
  81351. * The name of the right controller model file
  81352. */
  81353. static MODEL_RIGHT_FILENAME: string;
  81354. profileId: string;
  81355. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81356. protected _getFilenameAndPath(): {
  81357. filename: string;
  81358. path: string;
  81359. };
  81360. protected _getModelLoadingConstraints(): boolean;
  81361. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81362. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81363. protected _updateModel(): void;
  81364. }
  81365. }
  81366. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  81367. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81369. import { Scene } from "babylonjs/scene";
  81370. /**
  81371. * The motion controller class for oculus touch (quest, rift).
  81372. * This class supports legacy mapping as well the standard xr mapping
  81373. */
  81374. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  81375. private _forceLegacyControllers;
  81376. private _modelRootNode;
  81377. /**
  81378. * The base url used to load the left and right controller models
  81379. */
  81380. static MODEL_BASE_URL: string;
  81381. /**
  81382. * The name of the left controller model file
  81383. */
  81384. static MODEL_LEFT_FILENAME: string;
  81385. /**
  81386. * The name of the right controller model file
  81387. */
  81388. static MODEL_RIGHT_FILENAME: string;
  81389. /**
  81390. * Base Url for the Quest controller model.
  81391. */
  81392. static QUEST_MODEL_BASE_URL: string;
  81393. profileId: string;
  81394. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  81395. protected _getFilenameAndPath(): {
  81396. filename: string;
  81397. path: string;
  81398. };
  81399. protected _getModelLoadingConstraints(): boolean;
  81400. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81401. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81402. protected _updateModel(): void;
  81403. /**
  81404. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  81405. * between the touch and touch 2.
  81406. */
  81407. private _isQuest;
  81408. }
  81409. }
  81410. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  81411. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81412. import { Scene } from "babylonjs/scene";
  81413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  81414. /**
  81415. * The motion controller class for the standard HTC-Vive controllers
  81416. */
  81417. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  81418. private _modelRootNode;
  81419. /**
  81420. * The base url used to load the left and right controller models
  81421. */
  81422. static MODEL_BASE_URL: string;
  81423. /**
  81424. * File name for the controller model.
  81425. */
  81426. static MODEL_FILENAME: string;
  81427. profileId: string;
  81428. /**
  81429. * Create a new Vive motion controller object
  81430. * @param scene the scene to use to create this controller
  81431. * @param gamepadObject the corresponding gamepad object
  81432. * @param handedness the handedness of the controller
  81433. */
  81434. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  81435. protected _getFilenameAndPath(): {
  81436. filename: string;
  81437. path: string;
  81438. };
  81439. protected _getModelLoadingConstraints(): boolean;
  81440. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  81441. protected _setRootMesh(meshes: AbstractMesh[]): void;
  81442. protected _updateModel(): void;
  81443. }
  81444. }
  81445. declare module "babylonjs/XR/motionController/index" {
  81446. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  81447. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  81448. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  81449. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  81450. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  81451. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  81452. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  81453. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  81454. }
  81455. declare module "babylonjs/XR/index" {
  81456. export * from "babylonjs/XR/webXRCamera";
  81457. export * from "babylonjs/XR/webXREnterExitUI";
  81458. export * from "babylonjs/XR/webXRExperienceHelper";
  81459. export * from "babylonjs/XR/webXRInput";
  81460. export * from "babylonjs/XR/webXRInputSource";
  81461. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  81462. export * from "babylonjs/XR/webXRTypes";
  81463. export * from "babylonjs/XR/webXRSessionManager";
  81464. export * from "babylonjs/XR/webXRDefaultExperience";
  81465. export * from "babylonjs/XR/webXRFeaturesManager";
  81466. export * from "babylonjs/XR/features/index";
  81467. export * from "babylonjs/XR/motionController/index";
  81468. }
  81469. declare module "babylonjs/index" {
  81470. export * from "babylonjs/abstractScene";
  81471. export * from "babylonjs/Actions/index";
  81472. export * from "babylonjs/Animations/index";
  81473. export * from "babylonjs/assetContainer";
  81474. export * from "babylonjs/Audio/index";
  81475. export * from "babylonjs/Behaviors/index";
  81476. export * from "babylonjs/Bones/index";
  81477. export * from "babylonjs/Cameras/index";
  81478. export * from "babylonjs/Collisions/index";
  81479. export * from "babylonjs/Culling/index";
  81480. export * from "babylonjs/Debug/index";
  81481. export * from "babylonjs/DeviceInput/index";
  81482. export * from "babylonjs/Engines/index";
  81483. export * from "babylonjs/Events/index";
  81484. export * from "babylonjs/Gamepads/index";
  81485. export * from "babylonjs/Gizmos/index";
  81486. export * from "babylonjs/Helpers/index";
  81487. export * from "babylonjs/Instrumentation/index";
  81488. export * from "babylonjs/Layers/index";
  81489. export * from "babylonjs/LensFlares/index";
  81490. export * from "babylonjs/Lights/index";
  81491. export * from "babylonjs/Loading/index";
  81492. export * from "babylonjs/Materials/index";
  81493. export * from "babylonjs/Maths/index";
  81494. export * from "babylonjs/Meshes/index";
  81495. export * from "babylonjs/Morph/index";
  81496. export * from "babylonjs/Navigation/index";
  81497. export * from "babylonjs/node";
  81498. export * from "babylonjs/Offline/index";
  81499. export * from "babylonjs/Particles/index";
  81500. export * from "babylonjs/Physics/index";
  81501. export * from "babylonjs/PostProcesses/index";
  81502. export * from "babylonjs/Probes/index";
  81503. export * from "babylonjs/Rendering/index";
  81504. export * from "babylonjs/scene";
  81505. export * from "babylonjs/sceneComponent";
  81506. export * from "babylonjs/Sprites/index";
  81507. export * from "babylonjs/States/index";
  81508. export * from "babylonjs/Misc/index";
  81509. export * from "babylonjs/XR/index";
  81510. export * from "babylonjs/types";
  81511. }
  81512. declare module "babylonjs/Animations/pathCursor" {
  81513. import { Vector3 } from "babylonjs/Maths/math.vector";
  81514. import { Path2 } from "babylonjs/Maths/math.path";
  81515. /**
  81516. * A cursor which tracks a point on a path
  81517. */
  81518. export class PathCursor {
  81519. private path;
  81520. /**
  81521. * Stores path cursor callbacks for when an onchange event is triggered
  81522. */
  81523. private _onchange;
  81524. /**
  81525. * The value of the path cursor
  81526. */
  81527. value: number;
  81528. /**
  81529. * The animation array of the path cursor
  81530. */
  81531. animations: Animation[];
  81532. /**
  81533. * Initializes the path cursor
  81534. * @param path The path to track
  81535. */
  81536. constructor(path: Path2);
  81537. /**
  81538. * Gets the cursor point on the path
  81539. * @returns A point on the path cursor at the cursor location
  81540. */
  81541. getPoint(): Vector3;
  81542. /**
  81543. * Moves the cursor ahead by the step amount
  81544. * @param step The amount to move the cursor forward
  81545. * @returns This path cursor
  81546. */
  81547. moveAhead(step?: number): PathCursor;
  81548. /**
  81549. * Moves the cursor behind by the step amount
  81550. * @param step The amount to move the cursor back
  81551. * @returns This path cursor
  81552. */
  81553. moveBack(step?: number): PathCursor;
  81554. /**
  81555. * Moves the cursor by the step amount
  81556. * If the step amount is greater than one, an exception is thrown
  81557. * @param step The amount to move the cursor
  81558. * @returns This path cursor
  81559. */
  81560. move(step: number): PathCursor;
  81561. /**
  81562. * Ensures that the value is limited between zero and one
  81563. * @returns This path cursor
  81564. */
  81565. private ensureLimits;
  81566. /**
  81567. * Runs onchange callbacks on change (used by the animation engine)
  81568. * @returns This path cursor
  81569. */
  81570. private raiseOnChange;
  81571. /**
  81572. * Executes a function on change
  81573. * @param f A path cursor onchange callback
  81574. * @returns This path cursor
  81575. */
  81576. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81577. }
  81578. }
  81579. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81580. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81581. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81582. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81583. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81584. }
  81585. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81586. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81587. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81588. }
  81589. declare module "babylonjs/Engines/Processors/index" {
  81590. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81591. export * from "babylonjs/Engines/Processors/Expressions/index";
  81592. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81593. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81594. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81595. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81596. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81597. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81598. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81599. }
  81600. declare module "babylonjs/Legacy/legacy" {
  81601. import * as Babylon from "babylonjs/index";
  81602. export * from "babylonjs/index";
  81603. }
  81604. declare module "babylonjs/Shaders/blur.fragment" {
  81605. /** @hidden */
  81606. export var blurPixelShader: {
  81607. name: string;
  81608. shader: string;
  81609. };
  81610. }
  81611. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81612. /** @hidden */
  81613. export var pointCloudVertexDeclaration: {
  81614. name: string;
  81615. shader: string;
  81616. };
  81617. }
  81618. declare module "babylonjs" {
  81619. export * from "babylonjs/Legacy/legacy";
  81620. }
  81621. declare module BABYLON {
  81622. /** Alias type for value that can be null */
  81623. export type Nullable<T> = T | null;
  81624. /**
  81625. * Alias type for number that are floats
  81626. * @ignorenaming
  81627. */
  81628. export type float = number;
  81629. /**
  81630. * Alias type for number that are doubles.
  81631. * @ignorenaming
  81632. */
  81633. export type double = number;
  81634. /**
  81635. * Alias type for number that are integer
  81636. * @ignorenaming
  81637. */
  81638. export type int = number;
  81639. /** Alias type for number array or Float32Array */
  81640. export type FloatArray = number[] | Float32Array;
  81641. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81642. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81643. /**
  81644. * Alias for types that can be used by a Buffer or VertexBuffer.
  81645. */
  81646. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81647. /**
  81648. * Alias type for primitive types
  81649. * @ignorenaming
  81650. */
  81651. type Primitive = undefined | null | boolean | string | number | Function;
  81652. /**
  81653. * Type modifier to make all the properties of an object Readonly
  81654. */
  81655. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81656. /**
  81657. * Type modifier to make all the properties of an object Readonly recursively
  81658. */
  81659. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81660. /**
  81661. * Type modifier to make object properties readonly.
  81662. */
  81663. export type DeepImmutableObject<T> = {
  81664. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81665. };
  81666. /** @hidden */
  81667. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81668. }
  81669. }
  81670. declare module BABYLON {
  81671. /**
  81672. * A class serves as a medium between the observable and its observers
  81673. */
  81674. export class EventState {
  81675. /**
  81676. * Create a new EventState
  81677. * @param mask defines the mask associated with this state
  81678. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81679. * @param target defines the original target of the state
  81680. * @param currentTarget defines the current target of the state
  81681. */
  81682. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81683. /**
  81684. * Initialize the current event state
  81685. * @param mask defines the mask associated with this state
  81686. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81687. * @param target defines the original target of the state
  81688. * @param currentTarget defines the current target of the state
  81689. * @returns the current event state
  81690. */
  81691. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81692. /**
  81693. * An Observer can set this property to true to prevent subsequent observers of being notified
  81694. */
  81695. skipNextObservers: boolean;
  81696. /**
  81697. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81698. */
  81699. mask: number;
  81700. /**
  81701. * The object that originally notified the event
  81702. */
  81703. target?: any;
  81704. /**
  81705. * The current object in the bubbling phase
  81706. */
  81707. currentTarget?: any;
  81708. /**
  81709. * This will be populated with the return value of the last function that was executed.
  81710. * If it is the first function in the callback chain it will be the event data.
  81711. */
  81712. lastReturnValue?: any;
  81713. /**
  81714. * User defined information that will be sent to observers
  81715. */
  81716. userInfo?: any;
  81717. }
  81718. /**
  81719. * Represent an Observer registered to a given Observable object.
  81720. */
  81721. export class Observer<T> {
  81722. /**
  81723. * Defines the callback to call when the observer is notified
  81724. */
  81725. callback: (eventData: T, eventState: EventState) => void;
  81726. /**
  81727. * Defines the mask of the observer (used to filter notifications)
  81728. */
  81729. mask: number;
  81730. /**
  81731. * Defines the current scope used to restore the JS context
  81732. */
  81733. scope: any;
  81734. /** @hidden */
  81735. _willBeUnregistered: boolean;
  81736. /**
  81737. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81738. */
  81739. unregisterOnNextCall: boolean;
  81740. /**
  81741. * Creates a new observer
  81742. * @param callback defines the callback to call when the observer is notified
  81743. * @param mask defines the mask of the observer (used to filter notifications)
  81744. * @param scope defines the current scope used to restore the JS context
  81745. */
  81746. constructor(
  81747. /**
  81748. * Defines the callback to call when the observer is notified
  81749. */
  81750. callback: (eventData: T, eventState: EventState) => void,
  81751. /**
  81752. * Defines the mask of the observer (used to filter notifications)
  81753. */
  81754. mask: number,
  81755. /**
  81756. * Defines the current scope used to restore the JS context
  81757. */
  81758. scope?: any);
  81759. }
  81760. /**
  81761. * Represent a list of observers registered to multiple Observables object.
  81762. */
  81763. export class MultiObserver<T> {
  81764. private _observers;
  81765. private _observables;
  81766. /**
  81767. * Release associated resources
  81768. */
  81769. dispose(): void;
  81770. /**
  81771. * Raise a callback when one of the observable will notify
  81772. * @param observables defines a list of observables to watch
  81773. * @param callback defines the callback to call on notification
  81774. * @param mask defines the mask used to filter notifications
  81775. * @param scope defines the current scope used to restore the JS context
  81776. * @returns the new MultiObserver
  81777. */
  81778. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81779. }
  81780. /**
  81781. * The Observable class is a simple implementation of the Observable pattern.
  81782. *
  81783. * 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.
  81784. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81785. * 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).
  81786. * 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.
  81787. */
  81788. export class Observable<T> {
  81789. private _observers;
  81790. private _eventState;
  81791. private _onObserverAdded;
  81792. /**
  81793. * Gets the list of observers
  81794. */
  81795. get observers(): Array<Observer<T>>;
  81796. /**
  81797. * Creates a new observable
  81798. * @param onObserverAdded defines a callback to call when a new observer is added
  81799. */
  81800. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81801. /**
  81802. * Create a new Observer with the specified callback
  81803. * @param callback the callback that will be executed for that Observer
  81804. * @param mask the mask used to filter observers
  81805. * @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.
  81806. * @param scope optional scope for the callback to be called from
  81807. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81808. * @returns the new observer created for the callback
  81809. */
  81810. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81811. /**
  81812. * Create a new Observer with the specified callback and unregisters after the next notification
  81813. * @param callback the callback that will be executed for that Observer
  81814. * @returns the new observer created for the callback
  81815. */
  81816. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81817. /**
  81818. * Remove an Observer from the Observable object
  81819. * @param observer the instance of the Observer to remove
  81820. * @returns false if it doesn't belong to this Observable
  81821. */
  81822. remove(observer: Nullable<Observer<T>>): boolean;
  81823. /**
  81824. * Remove a callback from the Observable object
  81825. * @param callback the callback to remove
  81826. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81827. * @returns false if it doesn't belong to this Observable
  81828. */
  81829. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81830. private _deferUnregister;
  81831. private _remove;
  81832. /**
  81833. * Moves the observable to the top of the observer list making it get called first when notified
  81834. * @param observer the observer to move
  81835. */
  81836. makeObserverTopPriority(observer: Observer<T>): void;
  81837. /**
  81838. * Moves the observable to the bottom of the observer list making it get called last when notified
  81839. * @param observer the observer to move
  81840. */
  81841. makeObserverBottomPriority(observer: Observer<T>): void;
  81842. /**
  81843. * Notify all Observers by calling their respective callback with the given data
  81844. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81845. * @param eventData defines the data to send to all observers
  81846. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81847. * @param target defines the original target of the state
  81848. * @param currentTarget defines the current target of the state
  81849. * @param userInfo defines any user info to send to observers
  81850. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81851. */
  81852. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81853. /**
  81854. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81855. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81856. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81857. * and it is crucial that all callbacks will be executed.
  81858. * The order of the callbacks is kept, callbacks are not executed parallel.
  81859. *
  81860. * @param eventData The data to be sent to each callback
  81861. * @param mask is used to filter observers defaults to -1
  81862. * @param target defines the callback target (see EventState)
  81863. * @param currentTarget defines he current object in the bubbling phase
  81864. * @param userInfo defines any user info to send to observers
  81865. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81866. */
  81867. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81868. /**
  81869. * Notify a specific observer
  81870. * @param observer defines the observer to notify
  81871. * @param eventData defines the data to be sent to each callback
  81872. * @param mask is used to filter observers defaults to -1
  81873. */
  81874. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81875. /**
  81876. * Gets a boolean indicating if the observable has at least one observer
  81877. * @returns true is the Observable has at least one Observer registered
  81878. */
  81879. hasObservers(): boolean;
  81880. /**
  81881. * Clear the list of observers
  81882. */
  81883. clear(): void;
  81884. /**
  81885. * Clone the current observable
  81886. * @returns a new observable
  81887. */
  81888. clone(): Observable<T>;
  81889. /**
  81890. * Does this observable handles observer registered with a given mask
  81891. * @param mask defines the mask to be tested
  81892. * @return whether or not one observer registered with the given mask is handeled
  81893. **/
  81894. hasSpecificMask(mask?: number): boolean;
  81895. }
  81896. }
  81897. declare module BABYLON {
  81898. /**
  81899. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81900. * Babylon.js
  81901. */
  81902. export class DomManagement {
  81903. /**
  81904. * Checks if the window object exists
  81905. * @returns true if the window object exists
  81906. */
  81907. static IsWindowObjectExist(): boolean;
  81908. /**
  81909. * Checks if the navigator object exists
  81910. * @returns true if the navigator object exists
  81911. */
  81912. static IsNavigatorAvailable(): boolean;
  81913. /**
  81914. * Check if the document object exists
  81915. * @returns true if the document object exists
  81916. */
  81917. static IsDocumentAvailable(): boolean;
  81918. /**
  81919. * Extracts text content from a DOM element hierarchy
  81920. * @param element defines the root element
  81921. * @returns a string
  81922. */
  81923. static GetDOMTextContent(element: HTMLElement): string;
  81924. }
  81925. }
  81926. declare module BABYLON {
  81927. /**
  81928. * Logger used througouht the application to allow configuration of
  81929. * the log level required for the messages.
  81930. */
  81931. export class Logger {
  81932. /**
  81933. * No log
  81934. */
  81935. static readonly NoneLogLevel: number;
  81936. /**
  81937. * Only message logs
  81938. */
  81939. static readonly MessageLogLevel: number;
  81940. /**
  81941. * Only warning logs
  81942. */
  81943. static readonly WarningLogLevel: number;
  81944. /**
  81945. * Only error logs
  81946. */
  81947. static readonly ErrorLogLevel: number;
  81948. /**
  81949. * All logs
  81950. */
  81951. static readonly AllLogLevel: number;
  81952. private static _LogCache;
  81953. /**
  81954. * Gets a value indicating the number of loading errors
  81955. * @ignorenaming
  81956. */
  81957. static errorsCount: number;
  81958. /**
  81959. * Callback called when a new log is added
  81960. */
  81961. static OnNewCacheEntry: (entry: string) => void;
  81962. private static _AddLogEntry;
  81963. private static _FormatMessage;
  81964. private static _LogDisabled;
  81965. private static _LogEnabled;
  81966. private static _WarnDisabled;
  81967. private static _WarnEnabled;
  81968. private static _ErrorDisabled;
  81969. private static _ErrorEnabled;
  81970. /**
  81971. * Log a message to the console
  81972. */
  81973. static Log: (message: string) => void;
  81974. /**
  81975. * Write a warning message to the console
  81976. */
  81977. static Warn: (message: string) => void;
  81978. /**
  81979. * Write an error message to the console
  81980. */
  81981. static Error: (message: string) => void;
  81982. /**
  81983. * Gets current log cache (list of logs)
  81984. */
  81985. static get LogCache(): string;
  81986. /**
  81987. * Clears the log cache
  81988. */
  81989. static ClearLogCache(): void;
  81990. /**
  81991. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81992. */
  81993. static set LogLevels(level: number);
  81994. }
  81995. }
  81996. declare module BABYLON {
  81997. /** @hidden */
  81998. export class _TypeStore {
  81999. /** @hidden */
  82000. static RegisteredTypes: {
  82001. [key: string]: Object;
  82002. };
  82003. /** @hidden */
  82004. static GetClass(fqdn: string): any;
  82005. }
  82006. }
  82007. declare module BABYLON {
  82008. /**
  82009. * Helper to manipulate strings
  82010. */
  82011. export class StringTools {
  82012. /**
  82013. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  82014. * @param str Source string
  82015. * @param suffix Suffix to search for in the source string
  82016. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  82017. */
  82018. static EndsWith(str: string, suffix: string): boolean;
  82019. /**
  82020. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  82021. * @param str Source string
  82022. * @param suffix Suffix to search for in the source string
  82023. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  82024. */
  82025. static StartsWith(str: string, suffix: string): boolean;
  82026. /**
  82027. * Decodes a buffer into a string
  82028. * @param buffer The buffer to decode
  82029. * @returns The decoded string
  82030. */
  82031. static Decode(buffer: Uint8Array | Uint16Array): string;
  82032. /**
  82033. * Encode a buffer to a base64 string
  82034. * @param buffer defines the buffer to encode
  82035. * @returns the encoded string
  82036. */
  82037. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  82038. /**
  82039. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  82040. * @param num the number to convert and pad
  82041. * @param length the expected length of the string
  82042. * @returns the padded string
  82043. */
  82044. static PadNumber(num: number, length: number): string;
  82045. }
  82046. }
  82047. declare module BABYLON {
  82048. /**
  82049. * Class containing a set of static utilities functions for deep copy.
  82050. */
  82051. export class DeepCopier {
  82052. /**
  82053. * Tries to copy an object by duplicating every property
  82054. * @param source defines the source object
  82055. * @param destination defines the target object
  82056. * @param doNotCopyList defines a list of properties to avoid
  82057. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  82058. */
  82059. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  82060. }
  82061. }
  82062. declare module BABYLON {
  82063. /**
  82064. * Class containing a set of static utilities functions for precision date
  82065. */
  82066. export class PrecisionDate {
  82067. /**
  82068. * Gets either window.performance.now() if supported or Date.now() else
  82069. */
  82070. static get Now(): number;
  82071. }
  82072. }
  82073. declare module BABYLON {
  82074. /** @hidden */
  82075. export class _DevTools {
  82076. static WarnImport(name: string): string;
  82077. }
  82078. }
  82079. declare module BABYLON {
  82080. /**
  82081. * Interface used to define the mechanism to get data from the network
  82082. */
  82083. export interface IWebRequest {
  82084. /**
  82085. * Returns client's response url
  82086. */
  82087. responseURL: string;
  82088. /**
  82089. * Returns client's status
  82090. */
  82091. status: number;
  82092. /**
  82093. * Returns client's status as a text
  82094. */
  82095. statusText: string;
  82096. }
  82097. }
  82098. declare module BABYLON {
  82099. /**
  82100. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  82101. */
  82102. export class WebRequest implements IWebRequest {
  82103. private readonly _xhr;
  82104. /**
  82105. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  82106. * i.e. when loading files, where the server/service expects an Authorization header
  82107. */
  82108. static CustomRequestHeaders: {
  82109. [key: string]: string;
  82110. };
  82111. /**
  82112. * Add callback functions in this array to update all the requests before they get sent to the network
  82113. */
  82114. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  82115. private _injectCustomRequestHeaders;
  82116. /**
  82117. * Gets or sets a function to be called when loading progress changes
  82118. */
  82119. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  82120. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  82121. /**
  82122. * Returns client's state
  82123. */
  82124. get readyState(): number;
  82125. /**
  82126. * Returns client's status
  82127. */
  82128. get status(): number;
  82129. /**
  82130. * Returns client's status as a text
  82131. */
  82132. get statusText(): string;
  82133. /**
  82134. * Returns client's response
  82135. */
  82136. get response(): any;
  82137. /**
  82138. * Returns client's response url
  82139. */
  82140. get responseURL(): string;
  82141. /**
  82142. * Returns client's response as text
  82143. */
  82144. get responseText(): string;
  82145. /**
  82146. * Gets or sets the expected response type
  82147. */
  82148. get responseType(): XMLHttpRequestResponseType;
  82149. set responseType(value: XMLHttpRequestResponseType);
  82150. /** @hidden */
  82151. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  82152. /** @hidden */
  82153. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  82154. /**
  82155. * Cancels any network activity
  82156. */
  82157. abort(): void;
  82158. /**
  82159. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  82160. * @param body defines an optional request body
  82161. */
  82162. send(body?: Document | BodyInit | null): void;
  82163. /**
  82164. * Sets the request method, request URL
  82165. * @param method defines the method to use (GET, POST, etc..)
  82166. * @param url defines the url to connect with
  82167. */
  82168. open(method: string, url: string): void;
  82169. /**
  82170. * Sets the value of a request header.
  82171. * @param name The name of the header whose value is to be set
  82172. * @param value The value to set as the body of the header
  82173. */
  82174. setRequestHeader(name: string, value: string): void;
  82175. /**
  82176. * Get the string containing the text of a particular header's value.
  82177. * @param name The name of the header
  82178. * @returns The string containing the text of the given header name
  82179. */
  82180. getResponseHeader(name: string): Nullable<string>;
  82181. }
  82182. }
  82183. declare module BABYLON {
  82184. /**
  82185. * File request interface
  82186. */
  82187. export interface IFileRequest {
  82188. /**
  82189. * Raised when the request is complete (success or error).
  82190. */
  82191. onCompleteObservable: Observable<IFileRequest>;
  82192. /**
  82193. * Aborts the request for a file.
  82194. */
  82195. abort: () => void;
  82196. }
  82197. }
  82198. declare module BABYLON {
  82199. /**
  82200. * Define options used to create a render target texture
  82201. */
  82202. export class RenderTargetCreationOptions {
  82203. /**
  82204. * Specifies is mipmaps must be generated
  82205. */
  82206. generateMipMaps?: boolean;
  82207. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  82208. generateDepthBuffer?: boolean;
  82209. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  82210. generateStencilBuffer?: boolean;
  82211. /** Defines texture type (int by default) */
  82212. type?: number;
  82213. /** Defines sampling mode (trilinear by default) */
  82214. samplingMode?: number;
  82215. /** Defines format (RGBA by default) */
  82216. format?: number;
  82217. }
  82218. }
  82219. declare module BABYLON {
  82220. /** Defines the cross module used constants to avoid circular dependncies */
  82221. export class Constants {
  82222. /** Defines that alpha blending is disabled */
  82223. static readonly ALPHA_DISABLE: number;
  82224. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  82225. static readonly ALPHA_ADD: number;
  82226. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82227. static readonly ALPHA_COMBINE: number;
  82228. /** Defines that alpha blending is DEST - SRC * DEST */
  82229. static readonly ALPHA_SUBTRACT: number;
  82230. /** Defines that alpha blending is SRC * DEST */
  82231. static readonly ALPHA_MULTIPLY: number;
  82232. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  82233. static readonly ALPHA_MAXIMIZED: number;
  82234. /** Defines that alpha blending is SRC + DEST */
  82235. static readonly ALPHA_ONEONE: number;
  82236. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  82237. static readonly ALPHA_PREMULTIPLIED: number;
  82238. /**
  82239. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  82240. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82241. */
  82242. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82243. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  82244. static readonly ALPHA_INTERPOLATE: number;
  82245. /**
  82246. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  82247. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82248. */
  82249. static readonly ALPHA_SCREENMODE: number;
  82250. /**
  82251. * Defines that alpha blending is SRC + DST
  82252. * Alpha will be set to SRC ALPHA + DST ALPHA
  82253. */
  82254. static readonly ALPHA_ONEONE_ONEONE: number;
  82255. /**
  82256. * Defines that alpha blending is SRC * DST ALPHA + DST
  82257. * Alpha will be set to 0
  82258. */
  82259. static readonly ALPHA_ALPHATOCOLOR: number;
  82260. /**
  82261. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82262. */
  82263. static readonly ALPHA_REVERSEONEMINUS: number;
  82264. /**
  82265. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  82266. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  82267. */
  82268. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  82269. /**
  82270. * Defines that alpha blending is SRC + DST
  82271. * Alpha will be set to SRC ALPHA
  82272. */
  82273. static readonly ALPHA_ONEONE_ONEZERO: number;
  82274. /**
  82275. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  82276. * Alpha will be set to DST ALPHA
  82277. */
  82278. static readonly ALPHA_EXCLUSION: number;
  82279. /** Defines that alpha blending equation a SUM */
  82280. static readonly ALPHA_EQUATION_ADD: number;
  82281. /** Defines that alpha blending equation a SUBSTRACTION */
  82282. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  82283. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  82284. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  82285. /** Defines that alpha blending equation a MAX operation */
  82286. static readonly ALPHA_EQUATION_MAX: number;
  82287. /** Defines that alpha blending equation a MIN operation */
  82288. static readonly ALPHA_EQUATION_MIN: number;
  82289. /**
  82290. * Defines that alpha blending equation a DARKEN operation:
  82291. * It takes the min of the src and sums the alpha channels.
  82292. */
  82293. static readonly ALPHA_EQUATION_DARKEN: number;
  82294. /** Defines that the ressource is not delayed*/
  82295. static readonly DELAYLOADSTATE_NONE: number;
  82296. /** Defines that the ressource was successfully delay loaded */
  82297. static readonly DELAYLOADSTATE_LOADED: number;
  82298. /** Defines that the ressource is currently delay loading */
  82299. static readonly DELAYLOADSTATE_LOADING: number;
  82300. /** Defines that the ressource is delayed and has not started loading */
  82301. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82302. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82303. static readonly NEVER: number;
  82304. /** 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 */
  82305. static readonly ALWAYS: number;
  82306. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82307. static readonly LESS: number;
  82308. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82309. static readonly EQUAL: number;
  82310. /** 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 */
  82311. static readonly LEQUAL: number;
  82312. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82313. static readonly GREATER: number;
  82314. /** 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 */
  82315. static readonly GEQUAL: number;
  82316. /** 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 */
  82317. static readonly NOTEQUAL: number;
  82318. /** Passed to stencilOperation to specify that stencil value must be kept */
  82319. static readonly KEEP: number;
  82320. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82321. static readonly REPLACE: number;
  82322. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82323. static readonly INCR: number;
  82324. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82325. static readonly DECR: number;
  82326. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82327. static readonly INVERT: number;
  82328. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82329. static readonly INCR_WRAP: number;
  82330. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82331. static readonly DECR_WRAP: number;
  82332. /** Texture is not repeating outside of 0..1 UVs */
  82333. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82334. /** Texture is repeating outside of 0..1 UVs */
  82335. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82336. /** Texture is repeating and mirrored */
  82337. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82338. /** ALPHA */
  82339. static readonly TEXTUREFORMAT_ALPHA: number;
  82340. /** LUMINANCE */
  82341. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82342. /** LUMINANCE_ALPHA */
  82343. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82344. /** RGB */
  82345. static readonly TEXTUREFORMAT_RGB: number;
  82346. /** RGBA */
  82347. static readonly TEXTUREFORMAT_RGBA: number;
  82348. /** RED */
  82349. static readonly TEXTUREFORMAT_RED: number;
  82350. /** RED (2nd reference) */
  82351. static readonly TEXTUREFORMAT_R: number;
  82352. /** RG */
  82353. static readonly TEXTUREFORMAT_RG: number;
  82354. /** RED_INTEGER */
  82355. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82356. /** RED_INTEGER (2nd reference) */
  82357. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82358. /** RG_INTEGER */
  82359. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82360. /** RGB_INTEGER */
  82361. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82362. /** RGBA_INTEGER */
  82363. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82364. /** UNSIGNED_BYTE */
  82365. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82366. /** UNSIGNED_BYTE (2nd reference) */
  82367. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82368. /** FLOAT */
  82369. static readonly TEXTURETYPE_FLOAT: number;
  82370. /** HALF_FLOAT */
  82371. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82372. /** BYTE */
  82373. static readonly TEXTURETYPE_BYTE: number;
  82374. /** SHORT */
  82375. static readonly TEXTURETYPE_SHORT: number;
  82376. /** UNSIGNED_SHORT */
  82377. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82378. /** INT */
  82379. static readonly TEXTURETYPE_INT: number;
  82380. /** UNSIGNED_INT */
  82381. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82382. /** UNSIGNED_SHORT_4_4_4_4 */
  82383. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82384. /** UNSIGNED_SHORT_5_5_5_1 */
  82385. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82386. /** UNSIGNED_SHORT_5_6_5 */
  82387. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82388. /** UNSIGNED_INT_2_10_10_10_REV */
  82389. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82390. /** UNSIGNED_INT_24_8 */
  82391. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82392. /** UNSIGNED_INT_10F_11F_11F_REV */
  82393. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82394. /** UNSIGNED_INT_5_9_9_9_REV */
  82395. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82396. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82397. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82398. /** nearest is mag = nearest and min = nearest and no mip */
  82399. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82400. /** mag = nearest and min = nearest and mip = none */
  82401. static readonly TEXTURE_NEAREST_NEAREST: number;
  82402. /** Bilinear is mag = linear and min = linear and no mip */
  82403. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82404. /** mag = linear and min = linear and mip = none */
  82405. static readonly TEXTURE_LINEAR_LINEAR: number;
  82406. /** Trilinear is mag = linear and min = linear and mip = linear */
  82407. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82408. /** Trilinear is mag = linear and min = linear and mip = linear */
  82409. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82410. /** mag = nearest and min = nearest and mip = nearest */
  82411. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82412. /** mag = nearest and min = linear and mip = nearest */
  82413. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82414. /** mag = nearest and min = linear and mip = linear */
  82415. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82416. /** mag = nearest and min = linear and mip = none */
  82417. static readonly TEXTURE_NEAREST_LINEAR: number;
  82418. /** nearest is mag = nearest and min = nearest and mip = linear */
  82419. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82420. /** mag = linear and min = nearest and mip = nearest */
  82421. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82422. /** mag = linear and min = nearest and mip = linear */
  82423. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82424. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82425. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82426. /** mag = linear and min = nearest and mip = none */
  82427. static readonly TEXTURE_LINEAR_NEAREST: number;
  82428. /** Explicit coordinates mode */
  82429. static readonly TEXTURE_EXPLICIT_MODE: number;
  82430. /** Spherical coordinates mode */
  82431. static readonly TEXTURE_SPHERICAL_MODE: number;
  82432. /** Planar coordinates mode */
  82433. static readonly TEXTURE_PLANAR_MODE: number;
  82434. /** Cubic coordinates mode */
  82435. static readonly TEXTURE_CUBIC_MODE: number;
  82436. /** Projection coordinates mode */
  82437. static readonly TEXTURE_PROJECTION_MODE: number;
  82438. /** Skybox coordinates mode */
  82439. static readonly TEXTURE_SKYBOX_MODE: number;
  82440. /** Inverse Cubic coordinates mode */
  82441. static readonly TEXTURE_INVCUBIC_MODE: number;
  82442. /** Equirectangular coordinates mode */
  82443. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82444. /** Equirectangular Fixed coordinates mode */
  82445. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82446. /** Equirectangular Fixed Mirrored coordinates mode */
  82447. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82448. /** Offline (baking) quality for texture filtering */
  82449. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  82450. /** High quality for texture filtering */
  82451. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  82452. /** Medium quality for texture filtering */
  82453. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  82454. /** Low quality for texture filtering */
  82455. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  82456. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82457. static readonly SCALEMODE_FLOOR: number;
  82458. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82459. static readonly SCALEMODE_NEAREST: number;
  82460. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82461. static readonly SCALEMODE_CEILING: number;
  82462. /**
  82463. * The dirty texture flag value
  82464. */
  82465. static readonly MATERIAL_TextureDirtyFlag: number;
  82466. /**
  82467. * The dirty light flag value
  82468. */
  82469. static readonly MATERIAL_LightDirtyFlag: number;
  82470. /**
  82471. * The dirty fresnel flag value
  82472. */
  82473. static readonly MATERIAL_FresnelDirtyFlag: number;
  82474. /**
  82475. * The dirty attribute flag value
  82476. */
  82477. static readonly MATERIAL_AttributesDirtyFlag: number;
  82478. /**
  82479. * The dirty misc flag value
  82480. */
  82481. static readonly MATERIAL_MiscDirtyFlag: number;
  82482. /**
  82483. * The dirty prepass flag value
  82484. */
  82485. static readonly MATERIAL_PrePassDirtyFlag: number;
  82486. /**
  82487. * The all dirty flag value
  82488. */
  82489. static readonly MATERIAL_AllDirtyFlag: number;
  82490. /**
  82491. * Returns the triangle fill mode
  82492. */
  82493. static readonly MATERIAL_TriangleFillMode: number;
  82494. /**
  82495. * Returns the wireframe mode
  82496. */
  82497. static readonly MATERIAL_WireFrameFillMode: number;
  82498. /**
  82499. * Returns the point fill mode
  82500. */
  82501. static readonly MATERIAL_PointFillMode: number;
  82502. /**
  82503. * Returns the point list draw mode
  82504. */
  82505. static readonly MATERIAL_PointListDrawMode: number;
  82506. /**
  82507. * Returns the line list draw mode
  82508. */
  82509. static readonly MATERIAL_LineListDrawMode: number;
  82510. /**
  82511. * Returns the line loop draw mode
  82512. */
  82513. static readonly MATERIAL_LineLoopDrawMode: number;
  82514. /**
  82515. * Returns the line strip draw mode
  82516. */
  82517. static readonly MATERIAL_LineStripDrawMode: number;
  82518. /**
  82519. * Returns the triangle strip draw mode
  82520. */
  82521. static readonly MATERIAL_TriangleStripDrawMode: number;
  82522. /**
  82523. * Returns the triangle fan draw mode
  82524. */
  82525. static readonly MATERIAL_TriangleFanDrawMode: number;
  82526. /**
  82527. * Stores the clock-wise side orientation
  82528. */
  82529. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82530. /**
  82531. * Stores the counter clock-wise side orientation
  82532. */
  82533. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82534. /**
  82535. * Nothing
  82536. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82537. */
  82538. static readonly ACTION_NothingTrigger: number;
  82539. /**
  82540. * On pick
  82541. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82542. */
  82543. static readonly ACTION_OnPickTrigger: number;
  82544. /**
  82545. * On left pick
  82546. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82547. */
  82548. static readonly ACTION_OnLeftPickTrigger: number;
  82549. /**
  82550. * On right pick
  82551. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82552. */
  82553. static readonly ACTION_OnRightPickTrigger: number;
  82554. /**
  82555. * On center pick
  82556. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82557. */
  82558. static readonly ACTION_OnCenterPickTrigger: number;
  82559. /**
  82560. * On pick down
  82561. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82562. */
  82563. static readonly ACTION_OnPickDownTrigger: number;
  82564. /**
  82565. * On double pick
  82566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82567. */
  82568. static readonly ACTION_OnDoublePickTrigger: number;
  82569. /**
  82570. * On pick up
  82571. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82572. */
  82573. static readonly ACTION_OnPickUpTrigger: number;
  82574. /**
  82575. * On pick out.
  82576. * This trigger will only be raised if you also declared a OnPickDown
  82577. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82578. */
  82579. static readonly ACTION_OnPickOutTrigger: number;
  82580. /**
  82581. * On long press
  82582. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82583. */
  82584. static readonly ACTION_OnLongPressTrigger: number;
  82585. /**
  82586. * On pointer over
  82587. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82588. */
  82589. static readonly ACTION_OnPointerOverTrigger: number;
  82590. /**
  82591. * On pointer out
  82592. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82593. */
  82594. static readonly ACTION_OnPointerOutTrigger: number;
  82595. /**
  82596. * On every frame
  82597. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82598. */
  82599. static readonly ACTION_OnEveryFrameTrigger: number;
  82600. /**
  82601. * On intersection enter
  82602. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82603. */
  82604. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82605. /**
  82606. * On intersection exit
  82607. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82608. */
  82609. static readonly ACTION_OnIntersectionExitTrigger: number;
  82610. /**
  82611. * On key down
  82612. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82613. */
  82614. static readonly ACTION_OnKeyDownTrigger: number;
  82615. /**
  82616. * On key up
  82617. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82618. */
  82619. static readonly ACTION_OnKeyUpTrigger: number;
  82620. /**
  82621. * Billboard mode will only apply to Y axis
  82622. */
  82623. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82624. /**
  82625. * Billboard mode will apply to all axes
  82626. */
  82627. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82628. /**
  82629. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82630. */
  82631. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82632. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82633. * Test order :
  82634. * Is the bounding sphere outside the frustum ?
  82635. * If not, are the bounding box vertices outside the frustum ?
  82636. * It not, then the cullable object is in the frustum.
  82637. */
  82638. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82639. /** Culling strategy : Bounding Sphere Only.
  82640. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82641. * It's also less accurate than the standard because some not visible objects can still be selected.
  82642. * Test : is the bounding sphere outside the frustum ?
  82643. * If not, then the cullable object is in the frustum.
  82644. */
  82645. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82646. /** Culling strategy : Optimistic Inclusion.
  82647. * This in an inclusion test first, then the standard exclusion test.
  82648. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82649. * 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.
  82650. * Anyway, it's as accurate as the standard strategy.
  82651. * Test :
  82652. * Is the cullable object bounding sphere center in the frustum ?
  82653. * If not, apply the default culling strategy.
  82654. */
  82655. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82656. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82657. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82658. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82659. * 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.
  82660. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82661. * Test :
  82662. * Is the cullable object bounding sphere center in the frustum ?
  82663. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82664. */
  82665. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82666. /**
  82667. * No logging while loading
  82668. */
  82669. static readonly SCENELOADER_NO_LOGGING: number;
  82670. /**
  82671. * Minimal logging while loading
  82672. */
  82673. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82674. /**
  82675. * Summary logging while loading
  82676. */
  82677. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82678. /**
  82679. * Detailled logging while loading
  82680. */
  82681. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82682. /**
  82683. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82684. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82685. */
  82686. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82687. /**
  82688. * Constant used to retrieve the position texture index in the textures array in the prepass
  82689. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82690. */
  82691. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82692. /**
  82693. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82694. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82695. */
  82696. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82697. /**
  82698. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82699. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82700. */
  82701. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82702. /**
  82703. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82704. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82705. */
  82706. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82707. /**
  82708. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82709. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82710. */
  82711. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82712. /**
  82713. * Constant used to retrieve albedo index in the textures array in the prepass
  82714. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82715. */
  82716. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82717. }
  82718. }
  82719. declare module BABYLON {
  82720. /**
  82721. * This represents the required contract to create a new type of texture loader.
  82722. */
  82723. export interface IInternalTextureLoader {
  82724. /**
  82725. * Defines wether the loader supports cascade loading the different faces.
  82726. */
  82727. supportCascades: boolean;
  82728. /**
  82729. * This returns if the loader support the current file information.
  82730. * @param extension defines the file extension of the file being loaded
  82731. * @param mimeType defines the optional mime type of the file being loaded
  82732. * @returns true if the loader can load the specified file
  82733. */
  82734. canLoad(extension: string, mimeType?: string): boolean;
  82735. /**
  82736. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82737. * @param data contains the texture data
  82738. * @param texture defines the BabylonJS internal texture
  82739. * @param createPolynomials will be true if polynomials have been requested
  82740. * @param onLoad defines the callback to trigger once the texture is ready
  82741. * @param onError defines the callback to trigger in case of error
  82742. * @param options options to be passed to the loader
  82743. */
  82744. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82745. /**
  82746. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82747. * @param data contains the texture data
  82748. * @param texture defines the BabylonJS internal texture
  82749. * @param callback defines the method to call once ready to upload
  82750. * @param options options to be passed to the loader
  82751. */
  82752. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82753. }
  82754. }
  82755. declare module BABYLON {
  82756. /**
  82757. * Class used to store and describe the pipeline context associated with an effect
  82758. */
  82759. export interface IPipelineContext {
  82760. /**
  82761. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82762. */
  82763. isAsync: boolean;
  82764. /**
  82765. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82766. */
  82767. isReady: boolean;
  82768. /** @hidden */
  82769. _getVertexShaderCode(): string | null;
  82770. /** @hidden */
  82771. _getFragmentShaderCode(): string | null;
  82772. /** @hidden */
  82773. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82774. }
  82775. }
  82776. declare module BABYLON {
  82777. /**
  82778. * Class used to store gfx data (like WebGLBuffer)
  82779. */
  82780. export class DataBuffer {
  82781. /**
  82782. * Gets or sets the number of objects referencing this buffer
  82783. */
  82784. references: number;
  82785. /** Gets or sets the size of the underlying buffer */
  82786. capacity: number;
  82787. /**
  82788. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82789. */
  82790. is32Bits: boolean;
  82791. /**
  82792. * Gets the underlying buffer
  82793. */
  82794. get underlyingResource(): any;
  82795. }
  82796. }
  82797. declare module BABYLON {
  82798. /** @hidden */
  82799. export interface IShaderProcessor {
  82800. attributeProcessor?: (attribute: string) => string;
  82801. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82802. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82803. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82804. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82805. lineProcessor?: (line: string, isFragment: boolean) => string;
  82806. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82807. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82808. }
  82809. }
  82810. declare module BABYLON {
  82811. /** @hidden */
  82812. export interface ProcessingOptions {
  82813. defines: string[];
  82814. indexParameters: any;
  82815. isFragment: boolean;
  82816. shouldUseHighPrecisionShader: boolean;
  82817. supportsUniformBuffers: boolean;
  82818. shadersRepository: string;
  82819. includesShadersStore: {
  82820. [key: string]: string;
  82821. };
  82822. processor?: IShaderProcessor;
  82823. version: string;
  82824. platformName: string;
  82825. lookForClosingBracketForUniformBuffer?: boolean;
  82826. }
  82827. }
  82828. declare module BABYLON {
  82829. /** @hidden */
  82830. export class ShaderCodeNode {
  82831. line: string;
  82832. children: ShaderCodeNode[];
  82833. additionalDefineKey?: string;
  82834. additionalDefineValue?: string;
  82835. isValid(preprocessors: {
  82836. [key: string]: string;
  82837. }): boolean;
  82838. process(preprocessors: {
  82839. [key: string]: string;
  82840. }, options: ProcessingOptions): string;
  82841. }
  82842. }
  82843. declare module BABYLON {
  82844. /** @hidden */
  82845. export class ShaderCodeCursor {
  82846. private _lines;
  82847. lineIndex: number;
  82848. get currentLine(): string;
  82849. get canRead(): boolean;
  82850. set lines(value: string[]);
  82851. }
  82852. }
  82853. declare module BABYLON {
  82854. /** @hidden */
  82855. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82856. process(preprocessors: {
  82857. [key: string]: string;
  82858. }, options: ProcessingOptions): string;
  82859. }
  82860. }
  82861. declare module BABYLON {
  82862. /** @hidden */
  82863. export class ShaderDefineExpression {
  82864. isTrue(preprocessors: {
  82865. [key: string]: string;
  82866. }): boolean;
  82867. private static _OperatorPriority;
  82868. private static _Stack;
  82869. static postfixToInfix(postfix: string[]): string;
  82870. static infixToPostfix(infix: string): string[];
  82871. }
  82872. }
  82873. declare module BABYLON {
  82874. /** @hidden */
  82875. export class ShaderCodeTestNode extends ShaderCodeNode {
  82876. testExpression: ShaderDefineExpression;
  82877. isValid(preprocessors: {
  82878. [key: string]: string;
  82879. }): boolean;
  82880. }
  82881. }
  82882. declare module BABYLON {
  82883. /** @hidden */
  82884. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82885. define: string;
  82886. not: boolean;
  82887. constructor(define: string, not?: boolean);
  82888. isTrue(preprocessors: {
  82889. [key: string]: string;
  82890. }): boolean;
  82891. }
  82892. }
  82893. declare module BABYLON {
  82894. /** @hidden */
  82895. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82896. leftOperand: ShaderDefineExpression;
  82897. rightOperand: ShaderDefineExpression;
  82898. isTrue(preprocessors: {
  82899. [key: string]: string;
  82900. }): boolean;
  82901. }
  82902. }
  82903. declare module BABYLON {
  82904. /** @hidden */
  82905. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82906. leftOperand: ShaderDefineExpression;
  82907. rightOperand: ShaderDefineExpression;
  82908. isTrue(preprocessors: {
  82909. [key: string]: string;
  82910. }): boolean;
  82911. }
  82912. }
  82913. declare module BABYLON {
  82914. /** @hidden */
  82915. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82916. define: string;
  82917. operand: string;
  82918. testValue: string;
  82919. constructor(define: string, operand: string, testValue: string);
  82920. isTrue(preprocessors: {
  82921. [key: string]: string;
  82922. }): boolean;
  82923. }
  82924. }
  82925. declare module BABYLON {
  82926. /**
  82927. * Class used to enable access to offline support
  82928. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82929. */
  82930. export interface IOfflineProvider {
  82931. /**
  82932. * Gets a boolean indicating if scene must be saved in the database
  82933. */
  82934. enableSceneOffline: boolean;
  82935. /**
  82936. * Gets a boolean indicating if textures must be saved in the database
  82937. */
  82938. enableTexturesOffline: boolean;
  82939. /**
  82940. * Open the offline support and make it available
  82941. * @param successCallback defines the callback to call on success
  82942. * @param errorCallback defines the callback to call on error
  82943. */
  82944. open(successCallback: () => void, errorCallback: () => void): void;
  82945. /**
  82946. * Loads an image from the offline support
  82947. * @param url defines the url to load from
  82948. * @param image defines the target DOM image
  82949. */
  82950. loadImage(url: string, image: HTMLImageElement): void;
  82951. /**
  82952. * Loads a file from offline support
  82953. * @param url defines the URL to load from
  82954. * @param sceneLoaded defines a callback to call on success
  82955. * @param progressCallBack defines a callback to call when progress changed
  82956. * @param errorCallback defines a callback to call on error
  82957. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82958. */
  82959. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82960. }
  82961. }
  82962. declare module BABYLON {
  82963. /**
  82964. * Class used to help managing file picking and drag'n'drop
  82965. * File Storage
  82966. */
  82967. export class FilesInputStore {
  82968. /**
  82969. * List of files ready to be loaded
  82970. */
  82971. static FilesToLoad: {
  82972. [key: string]: File;
  82973. };
  82974. }
  82975. }
  82976. declare module BABYLON {
  82977. /**
  82978. * Class used to define a retry strategy when error happens while loading assets
  82979. */
  82980. export class RetryStrategy {
  82981. /**
  82982. * Function used to defines an exponential back off strategy
  82983. * @param maxRetries defines the maximum number of retries (3 by default)
  82984. * @param baseInterval defines the interval between retries
  82985. * @returns the strategy function to use
  82986. */
  82987. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82988. }
  82989. }
  82990. declare module BABYLON {
  82991. /**
  82992. * @ignore
  82993. * Application error to support additional information when loading a file
  82994. */
  82995. export abstract class BaseError extends Error {
  82996. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82997. }
  82998. }
  82999. declare module BABYLON {
  83000. /** @ignore */
  83001. export class LoadFileError extends BaseError {
  83002. request?: WebRequest;
  83003. file?: File;
  83004. /**
  83005. * Creates a new LoadFileError
  83006. * @param message defines the message of the error
  83007. * @param request defines the optional web request
  83008. * @param file defines the optional file
  83009. */
  83010. constructor(message: string, object?: WebRequest | File);
  83011. }
  83012. /** @ignore */
  83013. export class RequestFileError extends BaseError {
  83014. request: WebRequest;
  83015. /**
  83016. * Creates a new LoadFileError
  83017. * @param message defines the message of the error
  83018. * @param request defines the optional web request
  83019. */
  83020. constructor(message: string, request: WebRequest);
  83021. }
  83022. /** @ignore */
  83023. export class ReadFileError extends BaseError {
  83024. file: File;
  83025. /**
  83026. * Creates a new ReadFileError
  83027. * @param message defines the message of the error
  83028. * @param file defines the optional file
  83029. */
  83030. constructor(message: string, file: File);
  83031. }
  83032. /**
  83033. * @hidden
  83034. */
  83035. export class FileTools {
  83036. /**
  83037. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  83038. */
  83039. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  83040. /**
  83041. * Gets or sets the base URL to use to load assets
  83042. */
  83043. static BaseUrl: string;
  83044. /**
  83045. * Default behaviour for cors in the application.
  83046. * It can be a string if the expected behavior is identical in the entire app.
  83047. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  83048. */
  83049. static CorsBehavior: string | ((url: string | string[]) => string);
  83050. /**
  83051. * Gets or sets a function used to pre-process url before using them to load assets
  83052. */
  83053. static PreprocessUrl: (url: string) => string;
  83054. /**
  83055. * Removes unwanted characters from an url
  83056. * @param url defines the url to clean
  83057. * @returns the cleaned url
  83058. */
  83059. private static _CleanUrl;
  83060. /**
  83061. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  83062. * @param url define the url we are trying
  83063. * @param element define the dom element where to configure the cors policy
  83064. */
  83065. static SetCorsBehavior(url: string | string[], element: {
  83066. crossOrigin: string | null;
  83067. }): void;
  83068. /**
  83069. * Loads an image as an HTMLImageElement.
  83070. * @param input url string, ArrayBuffer, or Blob to load
  83071. * @param onLoad callback called when the image successfully loads
  83072. * @param onError callback called when the image fails to load
  83073. * @param offlineProvider offline provider for caching
  83074. * @param mimeType optional mime type
  83075. * @returns the HTMLImageElement of the loaded image
  83076. */
  83077. 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>;
  83078. /**
  83079. * Reads a file from a File object
  83080. * @param file defines the file to load
  83081. * @param onSuccess defines the callback to call when data is loaded
  83082. * @param onProgress defines the callback to call during loading process
  83083. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  83084. * @param onError defines the callback to call when an error occurs
  83085. * @returns a file request object
  83086. */
  83087. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  83088. /**
  83089. * Loads a file from a url
  83090. * @param url url to load
  83091. * @param onSuccess callback called when the file successfully loads
  83092. * @param onProgress callback called while file is loading (if the server supports this mode)
  83093. * @param offlineProvider defines the offline provider for caching
  83094. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83095. * @param onError callback called when the file fails to load
  83096. * @returns a file request object
  83097. */
  83098. 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;
  83099. /**
  83100. * Loads a file
  83101. * @param url url to load
  83102. * @param onSuccess callback called when the file successfully loads
  83103. * @param onProgress callback called while file is loading (if the server supports this mode)
  83104. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83105. * @param onError callback called when the file fails to load
  83106. * @param onOpened callback called when the web request is opened
  83107. * @returns a file request object
  83108. */
  83109. 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;
  83110. /**
  83111. * Checks if the loaded document was accessed via `file:`-Protocol.
  83112. * @returns boolean
  83113. */
  83114. static IsFileURL(): boolean;
  83115. }
  83116. }
  83117. declare module BABYLON {
  83118. /** @hidden */
  83119. export class ShaderProcessor {
  83120. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  83121. private static _ProcessPrecision;
  83122. private static _ExtractOperation;
  83123. private static _BuildSubExpression;
  83124. private static _BuildExpression;
  83125. private static _MoveCursorWithinIf;
  83126. private static _MoveCursor;
  83127. private static _EvaluatePreProcessors;
  83128. private static _PreparePreProcessors;
  83129. private static _ProcessShaderConversion;
  83130. private static _ProcessIncludes;
  83131. /**
  83132. * Loads a file from a url
  83133. * @param url url to load
  83134. * @param onSuccess callback called when the file successfully loads
  83135. * @param onProgress callback called while file is loading (if the server supports this mode)
  83136. * @param offlineProvider defines the offline provider for caching
  83137. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  83138. * @param onError callback called when the file fails to load
  83139. * @returns a file request object
  83140. * @hidden
  83141. */
  83142. 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;
  83143. }
  83144. }
  83145. declare module BABYLON {
  83146. /**
  83147. * @hidden
  83148. */
  83149. export interface IColor4Like {
  83150. r: float;
  83151. g: float;
  83152. b: float;
  83153. a: float;
  83154. }
  83155. /**
  83156. * @hidden
  83157. */
  83158. export interface IColor3Like {
  83159. r: float;
  83160. g: float;
  83161. b: float;
  83162. }
  83163. /**
  83164. * @hidden
  83165. */
  83166. export interface IVector4Like {
  83167. x: float;
  83168. y: float;
  83169. z: float;
  83170. w: float;
  83171. }
  83172. /**
  83173. * @hidden
  83174. */
  83175. export interface IVector3Like {
  83176. x: float;
  83177. y: float;
  83178. z: float;
  83179. }
  83180. /**
  83181. * @hidden
  83182. */
  83183. export interface IVector2Like {
  83184. x: float;
  83185. y: float;
  83186. }
  83187. /**
  83188. * @hidden
  83189. */
  83190. export interface IMatrixLike {
  83191. toArray(): DeepImmutable<Float32Array | Array<number>>;
  83192. updateFlag: int;
  83193. }
  83194. /**
  83195. * @hidden
  83196. */
  83197. export interface IViewportLike {
  83198. x: float;
  83199. y: float;
  83200. width: float;
  83201. height: float;
  83202. }
  83203. /**
  83204. * @hidden
  83205. */
  83206. export interface IPlaneLike {
  83207. normal: IVector3Like;
  83208. d: float;
  83209. normalize(): void;
  83210. }
  83211. }
  83212. declare module BABYLON {
  83213. /**
  83214. * Interface used to define common properties for effect fallbacks
  83215. */
  83216. export interface IEffectFallbacks {
  83217. /**
  83218. * Removes the defines that should be removed when falling back.
  83219. * @param currentDefines defines the current define statements for the shader.
  83220. * @param effect defines the current effect we try to compile
  83221. * @returns The resulting defines with defines of the current rank removed.
  83222. */
  83223. reduce(currentDefines: string, effect: Effect): string;
  83224. /**
  83225. * Removes the fallback from the bound mesh.
  83226. */
  83227. unBindMesh(): void;
  83228. /**
  83229. * Checks to see if more fallbacks are still availible.
  83230. */
  83231. hasMoreFallbacks: boolean;
  83232. }
  83233. }
  83234. declare module BABYLON {
  83235. /**
  83236. * Interface for the size containing width and height
  83237. */
  83238. export interface ISize {
  83239. /**
  83240. * Width
  83241. */
  83242. width: number;
  83243. /**
  83244. * Heighht
  83245. */
  83246. height: number;
  83247. }
  83248. /**
  83249. * Size containing widht and height
  83250. */
  83251. export class Size implements ISize {
  83252. /**
  83253. * Width
  83254. */
  83255. width: number;
  83256. /**
  83257. * Height
  83258. */
  83259. height: number;
  83260. /**
  83261. * Creates a Size object from the given width and height (floats).
  83262. * @param width width of the new size
  83263. * @param height height of the new size
  83264. */
  83265. constructor(width: number, height: number);
  83266. /**
  83267. * Returns a string with the Size width and height
  83268. * @returns a string with the Size width and height
  83269. */
  83270. toString(): string;
  83271. /**
  83272. * "Size"
  83273. * @returns the string "Size"
  83274. */
  83275. getClassName(): string;
  83276. /**
  83277. * Returns the Size hash code.
  83278. * @returns a hash code for a unique width and height
  83279. */
  83280. getHashCode(): number;
  83281. /**
  83282. * Updates the current size from the given one.
  83283. * @param src the given size
  83284. */
  83285. copyFrom(src: Size): void;
  83286. /**
  83287. * Updates in place the current Size from the given floats.
  83288. * @param width width of the new size
  83289. * @param height height of the new size
  83290. * @returns the updated Size.
  83291. */
  83292. copyFromFloats(width: number, height: number): Size;
  83293. /**
  83294. * Updates in place the current Size from the given floats.
  83295. * @param width width to set
  83296. * @param height height to set
  83297. * @returns the updated Size.
  83298. */
  83299. set(width: number, height: number): Size;
  83300. /**
  83301. * Multiplies the width and height by numbers
  83302. * @param w factor to multiple the width by
  83303. * @param h factor to multiple the height by
  83304. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83305. */
  83306. multiplyByFloats(w: number, h: number): Size;
  83307. /**
  83308. * Clones the size
  83309. * @returns a new Size copied from the given one.
  83310. */
  83311. clone(): Size;
  83312. /**
  83313. * True if the current Size and the given one width and height are strictly equal.
  83314. * @param other the other size to compare against
  83315. * @returns True if the current Size and the given one width and height are strictly equal.
  83316. */
  83317. equals(other: Size): boolean;
  83318. /**
  83319. * The surface of the Size : width * height (float).
  83320. */
  83321. get surface(): number;
  83322. /**
  83323. * Create a new size of zero
  83324. * @returns a new Size set to (0.0, 0.0)
  83325. */
  83326. static Zero(): Size;
  83327. /**
  83328. * Sums the width and height of two sizes
  83329. * @param otherSize size to add to this size
  83330. * @returns a new Size set as the addition result of the current Size and the given one.
  83331. */
  83332. add(otherSize: Size): Size;
  83333. /**
  83334. * Subtracts the width and height of two
  83335. * @param otherSize size to subtract to this size
  83336. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83337. */
  83338. subtract(otherSize: Size): Size;
  83339. /**
  83340. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83341. * @param start starting size to lerp between
  83342. * @param end end size to lerp between
  83343. * @param amount amount to lerp between the start and end values
  83344. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83345. */
  83346. static Lerp(start: Size, end: Size, amount: number): Size;
  83347. }
  83348. }
  83349. declare module BABYLON {
  83350. /**
  83351. * Base class of all the textures in babylon.
  83352. * It groups all the common properties required to work with Thin Engine.
  83353. */
  83354. export class ThinTexture {
  83355. protected _wrapU: number;
  83356. /**
  83357. * | Value | Type | Description |
  83358. * | ----- | ------------------ | ----------- |
  83359. * | 0 | CLAMP_ADDRESSMODE | |
  83360. * | 1 | WRAP_ADDRESSMODE | |
  83361. * | 2 | MIRROR_ADDRESSMODE | |
  83362. */
  83363. get wrapU(): number;
  83364. set wrapU(value: number);
  83365. protected _wrapV: number;
  83366. /**
  83367. * | Value | Type | Description |
  83368. * | ----- | ------------------ | ----------- |
  83369. * | 0 | CLAMP_ADDRESSMODE | |
  83370. * | 1 | WRAP_ADDRESSMODE | |
  83371. * | 2 | MIRROR_ADDRESSMODE | |
  83372. */
  83373. get wrapV(): number;
  83374. set wrapV(value: number);
  83375. /**
  83376. * | Value | Type | Description |
  83377. * | ----- | ------------------ | ----------- |
  83378. * | 0 | CLAMP_ADDRESSMODE | |
  83379. * | 1 | WRAP_ADDRESSMODE | |
  83380. * | 2 | MIRROR_ADDRESSMODE | |
  83381. */
  83382. wrapR: number;
  83383. /**
  83384. * With compliant hardware and browser (supporting anisotropic filtering)
  83385. * this defines the level of anisotropic filtering in the texture.
  83386. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  83387. */
  83388. anisotropicFilteringLevel: number;
  83389. /**
  83390. * Define the current state of the loading sequence when in delayed load mode.
  83391. */
  83392. delayLoadState: number;
  83393. /**
  83394. * How a texture is mapped.
  83395. * Unused in thin texture mode.
  83396. */
  83397. get coordinatesMode(): number;
  83398. /**
  83399. * Define if the texture is a cube texture or if false a 2d texture.
  83400. */
  83401. get isCube(): boolean;
  83402. set isCube(value: boolean);
  83403. /**
  83404. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  83405. */
  83406. get is3D(): boolean;
  83407. set is3D(value: boolean);
  83408. /**
  83409. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  83410. */
  83411. get is2DArray(): boolean;
  83412. set is2DArray(value: boolean);
  83413. /**
  83414. * Get the class name of the texture.
  83415. * @returns "ThinTexture"
  83416. */
  83417. getClassName(): string;
  83418. /** @hidden */
  83419. _texture: Nullable<InternalTexture>;
  83420. protected _engine: Nullable<ThinEngine>;
  83421. private _cachedSize;
  83422. private _cachedBaseSize;
  83423. /**
  83424. * Instantiates a new ThinTexture.
  83425. * Base class of all the textures in babylon.
  83426. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  83427. * @param internalTexture Define the internalTexture to wrap
  83428. */
  83429. constructor(internalTexture: Nullable<InternalTexture>);
  83430. /**
  83431. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  83432. * @returns true if fully ready
  83433. */
  83434. isReady(): boolean;
  83435. /**
  83436. * Triggers the load sequence in delayed load mode.
  83437. */
  83438. delayLoad(): void;
  83439. /**
  83440. * Get the underlying lower level texture from Babylon.
  83441. * @returns the insternal texture
  83442. */
  83443. getInternalTexture(): Nullable<InternalTexture>;
  83444. /**
  83445. * Get the size of the texture.
  83446. * @returns the texture size.
  83447. */
  83448. getSize(): ISize;
  83449. /**
  83450. * Get the base size of the texture.
  83451. * It can be different from the size if the texture has been resized for POT for instance
  83452. * @returns the base size
  83453. */
  83454. getBaseSize(): ISize;
  83455. /**
  83456. * Update the sampling mode of the texture.
  83457. * Default is Trilinear mode.
  83458. *
  83459. * | Value | Type | Description |
  83460. * | ----- | ------------------ | ----------- |
  83461. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  83462. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  83463. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  83464. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  83465. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  83466. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  83467. * | 7 | NEAREST_LINEAR | |
  83468. * | 8 | NEAREST_NEAREST | |
  83469. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  83470. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  83471. * | 11 | LINEAR_LINEAR | |
  83472. * | 12 | LINEAR_NEAREST | |
  83473. *
  83474. * > _mag_: magnification filter (close to the viewer)
  83475. * > _min_: minification filter (far from the viewer)
  83476. * > _mip_: filter used between mip map levels
  83477. *@param samplingMode Define the new sampling mode of the texture
  83478. */
  83479. updateSamplingMode(samplingMode: number): void;
  83480. /**
  83481. * Release and destroy the underlying lower level texture aka internalTexture.
  83482. */
  83483. releaseInternalTexture(): void;
  83484. /**
  83485. * Dispose the texture and release its associated resources.
  83486. */
  83487. dispose(): void;
  83488. }
  83489. }
  83490. declare module BABYLON {
  83491. /**
  83492. * Defines an array and its length.
  83493. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  83494. */
  83495. export interface ISmartArrayLike<T> {
  83496. /**
  83497. * The data of the array.
  83498. */
  83499. data: Array<T>;
  83500. /**
  83501. * The active length of the array.
  83502. */
  83503. length: number;
  83504. }
  83505. /**
  83506. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83507. */
  83508. export class SmartArray<T> implements ISmartArrayLike<T> {
  83509. /**
  83510. * The full set of data from the array.
  83511. */
  83512. data: Array<T>;
  83513. /**
  83514. * The active length of the array.
  83515. */
  83516. length: number;
  83517. protected _id: number;
  83518. /**
  83519. * Instantiates a Smart Array.
  83520. * @param capacity defines the default capacity of the array.
  83521. */
  83522. constructor(capacity: number);
  83523. /**
  83524. * Pushes a value at the end of the active data.
  83525. * @param value defines the object to push in the array.
  83526. */
  83527. push(value: T): void;
  83528. /**
  83529. * Iterates over the active data and apply the lambda to them.
  83530. * @param func defines the action to apply on each value.
  83531. */
  83532. forEach(func: (content: T) => void): void;
  83533. /**
  83534. * Sorts the full sets of data.
  83535. * @param compareFn defines the comparison function to apply.
  83536. */
  83537. sort(compareFn: (a: T, b: T) => number): void;
  83538. /**
  83539. * Resets the active data to an empty array.
  83540. */
  83541. reset(): void;
  83542. /**
  83543. * Releases all the data from the array as well as the array.
  83544. */
  83545. dispose(): void;
  83546. /**
  83547. * Concats the active data with a given array.
  83548. * @param array defines the data to concatenate with.
  83549. */
  83550. concat(array: any): void;
  83551. /**
  83552. * Returns the position of a value in the active data.
  83553. * @param value defines the value to find the index for
  83554. * @returns the index if found in the active data otherwise -1
  83555. */
  83556. indexOf(value: T): number;
  83557. /**
  83558. * Returns whether an element is part of the active data.
  83559. * @param value defines the value to look for
  83560. * @returns true if found in the active data otherwise false
  83561. */
  83562. contains(value: T): boolean;
  83563. private static _GlobalId;
  83564. }
  83565. /**
  83566. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  83567. * The data in this array can only be present once
  83568. */
  83569. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  83570. private _duplicateId;
  83571. /**
  83572. * Pushes a value at the end of the active data.
  83573. * THIS DOES NOT PREVENT DUPPLICATE DATA
  83574. * @param value defines the object to push in the array.
  83575. */
  83576. push(value: T): void;
  83577. /**
  83578. * Pushes a value at the end of the active data.
  83579. * If the data is already present, it won t be added again
  83580. * @param value defines the object to push in the array.
  83581. * @returns true if added false if it was already present
  83582. */
  83583. pushNoDuplicate(value: T): boolean;
  83584. /**
  83585. * Resets the active data to an empty array.
  83586. */
  83587. reset(): void;
  83588. /**
  83589. * Concats the active data with a given array.
  83590. * This ensures no dupplicate will be present in the result.
  83591. * @param array defines the data to concatenate with.
  83592. */
  83593. concatWithNoDuplicate(array: any): void;
  83594. }
  83595. }
  83596. declare module BABYLON {
  83597. /**
  83598. * Class used to evalaute queries containing `and` and `or` operators
  83599. */
  83600. export class AndOrNotEvaluator {
  83601. /**
  83602. * Evaluate a query
  83603. * @param query defines the query to evaluate
  83604. * @param evaluateCallback defines the callback used to filter result
  83605. * @returns true if the query matches
  83606. */
  83607. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  83608. private static _HandleParenthesisContent;
  83609. private static _SimplifyNegation;
  83610. }
  83611. }
  83612. declare module BABYLON {
  83613. /**
  83614. * Class used to store custom tags
  83615. */
  83616. export class Tags {
  83617. /**
  83618. * Adds support for tags on the given object
  83619. * @param obj defines the object to use
  83620. */
  83621. static EnableFor(obj: any): void;
  83622. /**
  83623. * Removes tags support
  83624. * @param obj defines the object to use
  83625. */
  83626. static DisableFor(obj: any): void;
  83627. /**
  83628. * Gets a boolean indicating if the given object has tags
  83629. * @param obj defines the object to use
  83630. * @returns a boolean
  83631. */
  83632. static HasTags(obj: any): boolean;
  83633. /**
  83634. * Gets the tags available on a given object
  83635. * @param obj defines the object to use
  83636. * @param asString defines if the tags must be returned as a string instead of an array of strings
  83637. * @returns the tags
  83638. */
  83639. static GetTags(obj: any, asString?: boolean): any;
  83640. /**
  83641. * Adds tags to an object
  83642. * @param obj defines the object to use
  83643. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  83644. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  83645. */
  83646. static AddTagsTo(obj: any, tagsString: string): void;
  83647. /**
  83648. * @hidden
  83649. */
  83650. static _AddTagTo(obj: any, tag: string): void;
  83651. /**
  83652. * Removes specific tags from a specific object
  83653. * @param obj defines the object to use
  83654. * @param tagsString defines the tags to remove
  83655. */
  83656. static RemoveTagsFrom(obj: any, tagsString: string): void;
  83657. /**
  83658. * @hidden
  83659. */
  83660. static _RemoveTagFrom(obj: any, tag: string): void;
  83661. /**
  83662. * Defines if tags hosted on an object match a given query
  83663. * @param obj defines the object to use
  83664. * @param tagsQuery defines the tag query
  83665. * @returns a boolean
  83666. */
  83667. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  83668. }
  83669. }
  83670. declare module BABYLON {
  83671. /**
  83672. * Scalar computation library
  83673. */
  83674. export class Scalar {
  83675. /**
  83676. * Two pi constants convenient for computation.
  83677. */
  83678. static TwoPi: number;
  83679. /**
  83680. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83681. * @param a number
  83682. * @param b number
  83683. * @param epsilon (default = 1.401298E-45)
  83684. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  83685. */
  83686. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  83687. /**
  83688. * Returns a string : the upper case translation of the number i to hexadecimal.
  83689. * @param i number
  83690. * @returns the upper case translation of the number i to hexadecimal.
  83691. */
  83692. static ToHex(i: number): string;
  83693. /**
  83694. * Returns -1 if value is negative and +1 is value is positive.
  83695. * @param value the value
  83696. * @returns the value itself if it's equal to zero.
  83697. */
  83698. static Sign(value: number): number;
  83699. /**
  83700. * Returns the value itself if it's between min and max.
  83701. * Returns min if the value is lower than min.
  83702. * Returns max if the value is greater than max.
  83703. * @param value the value to clmap
  83704. * @param min the min value to clamp to (default: 0)
  83705. * @param max the max value to clamp to (default: 1)
  83706. * @returns the clamped value
  83707. */
  83708. static Clamp(value: number, min?: number, max?: number): number;
  83709. /**
  83710. * the log2 of value.
  83711. * @param value the value to compute log2 of
  83712. * @returns the log2 of value.
  83713. */
  83714. static Log2(value: number): number;
  83715. /**
  83716. * Loops the value, so that it is never larger than length and never smaller than 0.
  83717. *
  83718. * This is similar to the modulo operator but it works with floating point numbers.
  83719. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  83720. * With t = 5 and length = 2.5, the result would be 0.0.
  83721. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  83722. * @param value the value
  83723. * @param length the length
  83724. * @returns the looped value
  83725. */
  83726. static Repeat(value: number, length: number): number;
  83727. /**
  83728. * Normalize the value between 0.0 and 1.0 using min and max values
  83729. * @param value value to normalize
  83730. * @param min max to normalize between
  83731. * @param max min to normalize between
  83732. * @returns the normalized value
  83733. */
  83734. static Normalize(value: number, min: number, max: number): number;
  83735. /**
  83736. * Denormalize the value from 0.0 and 1.0 using min and max values
  83737. * @param normalized value to denormalize
  83738. * @param min max to denormalize between
  83739. * @param max min to denormalize between
  83740. * @returns the denormalized value
  83741. */
  83742. static Denormalize(normalized: number, min: number, max: number): number;
  83743. /**
  83744. * Calculates the shortest difference between two given angles given in degrees.
  83745. * @param current current angle in degrees
  83746. * @param target target angle in degrees
  83747. * @returns the delta
  83748. */
  83749. static DeltaAngle(current: number, target: number): number;
  83750. /**
  83751. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  83752. * @param tx value
  83753. * @param length length
  83754. * @returns The returned value will move back and forth between 0 and length
  83755. */
  83756. static PingPong(tx: number, length: number): number;
  83757. /**
  83758. * Interpolates between min and max with smoothing at the limits.
  83759. *
  83760. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  83761. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  83762. * @param from from
  83763. * @param to to
  83764. * @param tx value
  83765. * @returns the smooth stepped value
  83766. */
  83767. static SmoothStep(from: number, to: number, tx: number): number;
  83768. /**
  83769. * Moves a value current towards target.
  83770. *
  83771. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  83772. * Negative values of maxDelta pushes the value away from target.
  83773. * @param current current value
  83774. * @param target target value
  83775. * @param maxDelta max distance to move
  83776. * @returns resulting value
  83777. */
  83778. static MoveTowards(current: number, target: number, maxDelta: number): number;
  83779. /**
  83780. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83781. *
  83782. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  83783. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  83784. * @param current current value
  83785. * @param target target value
  83786. * @param maxDelta max distance to move
  83787. * @returns resulting angle
  83788. */
  83789. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  83790. /**
  83791. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  83792. * @param start start value
  83793. * @param end target value
  83794. * @param amount amount to lerp between
  83795. * @returns the lerped value
  83796. */
  83797. static Lerp(start: number, end: number, amount: number): number;
  83798. /**
  83799. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  83800. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  83801. * @param start start value
  83802. * @param end target value
  83803. * @param amount amount to lerp between
  83804. * @returns the lerped value
  83805. */
  83806. static LerpAngle(start: number, end: number, amount: number): number;
  83807. /**
  83808. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  83809. * @param a start value
  83810. * @param b target value
  83811. * @param value value between a and b
  83812. * @returns the inverseLerp value
  83813. */
  83814. static InverseLerp(a: number, b: number, value: number): number;
  83815. /**
  83816. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  83817. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  83818. * @param value1 spline value
  83819. * @param tangent1 spline value
  83820. * @param value2 spline value
  83821. * @param tangent2 spline value
  83822. * @param amount input value
  83823. * @returns hermite result
  83824. */
  83825. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  83826. /**
  83827. * Returns a random float number between and min and max values
  83828. * @param min min value of random
  83829. * @param max max value of random
  83830. * @returns random value
  83831. */
  83832. static RandomRange(min: number, max: number): number;
  83833. /**
  83834. * This function returns percentage of a number in a given range.
  83835. *
  83836. * RangeToPercent(40,20,60) will return 0.5 (50%)
  83837. * RangeToPercent(34,0,100) will return 0.34 (34%)
  83838. * @param number to convert to percentage
  83839. * @param min min range
  83840. * @param max max range
  83841. * @returns the percentage
  83842. */
  83843. static RangeToPercent(number: number, min: number, max: number): number;
  83844. /**
  83845. * This function returns number that corresponds to the percentage in a given range.
  83846. *
  83847. * PercentToRange(0.34,0,100) will return 34.
  83848. * @param percent to convert to number
  83849. * @param min min range
  83850. * @param max max range
  83851. * @returns the number
  83852. */
  83853. static PercentToRange(percent: number, min: number, max: number): number;
  83854. /**
  83855. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83856. * @param angle The angle to normalize in radian.
  83857. * @return The converted angle.
  83858. */
  83859. static NormalizeRadians(angle: number): number;
  83860. }
  83861. }
  83862. declare module BABYLON {
  83863. /**
  83864. * Constant used to convert a value to gamma space
  83865. * @ignorenaming
  83866. */
  83867. export const ToGammaSpace: number;
  83868. /**
  83869. * Constant used to convert a value to linear space
  83870. * @ignorenaming
  83871. */
  83872. export const ToLinearSpace = 2.2;
  83873. /**
  83874. * Constant used to define the minimal number value in Babylon.js
  83875. * @ignorenaming
  83876. */
  83877. let Epsilon: number;
  83878. }
  83879. declare module BABYLON {
  83880. /**
  83881. * Class used to represent a viewport on screen
  83882. */
  83883. export class Viewport {
  83884. /** viewport left coordinate */
  83885. x: number;
  83886. /** viewport top coordinate */
  83887. y: number;
  83888. /**viewport width */
  83889. width: number;
  83890. /** viewport height */
  83891. height: number;
  83892. /**
  83893. * Creates a Viewport object located at (x, y) and sized (width, height)
  83894. * @param x defines viewport left coordinate
  83895. * @param y defines viewport top coordinate
  83896. * @param width defines the viewport width
  83897. * @param height defines the viewport height
  83898. */
  83899. constructor(
  83900. /** viewport left coordinate */
  83901. x: number,
  83902. /** viewport top coordinate */
  83903. y: number,
  83904. /**viewport width */
  83905. width: number,
  83906. /** viewport height */
  83907. height: number);
  83908. /**
  83909. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83910. * @param renderWidth defines the rendering width
  83911. * @param renderHeight defines the rendering height
  83912. * @returns a new Viewport
  83913. */
  83914. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83915. /**
  83916. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83917. * @param renderWidth defines the rendering width
  83918. * @param renderHeight defines the rendering height
  83919. * @param ref defines the target viewport
  83920. * @returns the current viewport
  83921. */
  83922. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83923. /**
  83924. * Returns a new Viewport copied from the current one
  83925. * @returns a new Viewport
  83926. */
  83927. clone(): Viewport;
  83928. }
  83929. }
  83930. declare module BABYLON {
  83931. /**
  83932. * Class containing a set of static utilities functions for arrays.
  83933. */
  83934. export class ArrayTools {
  83935. /**
  83936. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83937. * @param size the number of element to construct and put in the array
  83938. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83939. * @returns a new array filled with new objects
  83940. */
  83941. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83942. }
  83943. }
  83944. declare module BABYLON {
  83945. /**
  83946. * Represents a plane by the equation ax + by + cz + d = 0
  83947. */
  83948. export class Plane {
  83949. private static _TmpMatrix;
  83950. /**
  83951. * Normal of the plane (a,b,c)
  83952. */
  83953. normal: Vector3;
  83954. /**
  83955. * d component of the plane
  83956. */
  83957. d: number;
  83958. /**
  83959. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83960. * @param a a component of the plane
  83961. * @param b b component of the plane
  83962. * @param c c component of the plane
  83963. * @param d d component of the plane
  83964. */
  83965. constructor(a: number, b: number, c: number, d: number);
  83966. /**
  83967. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83968. */
  83969. asArray(): number[];
  83970. /**
  83971. * @returns a new plane copied from the current Plane.
  83972. */
  83973. clone(): Plane;
  83974. /**
  83975. * @returns the string "Plane".
  83976. */
  83977. getClassName(): string;
  83978. /**
  83979. * @returns the Plane hash code.
  83980. */
  83981. getHashCode(): number;
  83982. /**
  83983. * Normalize the current Plane in place.
  83984. * @returns the updated Plane.
  83985. */
  83986. normalize(): Plane;
  83987. /**
  83988. * Applies a transformation the plane and returns the result
  83989. * @param transformation the transformation matrix to be applied to the plane
  83990. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83991. */
  83992. transform(transformation: DeepImmutable<Matrix>): Plane;
  83993. /**
  83994. * Compute the dot product between the point and the plane normal
  83995. * @param point point to calculate the dot product with
  83996. * @returns the dot product (float) of the point coordinates and the plane normal.
  83997. */
  83998. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83999. /**
  84000. * Updates the current Plane from the plane defined by the three given points.
  84001. * @param point1 one of the points used to contruct the plane
  84002. * @param point2 one of the points used to contruct the plane
  84003. * @param point3 one of the points used to contruct the plane
  84004. * @returns the updated Plane.
  84005. */
  84006. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  84007. /**
  84008. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  84009. * Note that for this function to work as expected you should make sure that:
  84010. * - direction and the plane normal are normalized
  84011. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  84012. * @param direction the direction to check if the plane is facing
  84013. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  84014. * @returns True if the plane is facing the given direction
  84015. */
  84016. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  84017. /**
  84018. * Calculates the distance to a point
  84019. * @param point point to calculate distance to
  84020. * @returns the signed distance (float) from the given point to the Plane.
  84021. */
  84022. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  84023. /**
  84024. * Creates a plane from an array
  84025. * @param array the array to create a plane from
  84026. * @returns a new Plane from the given array.
  84027. */
  84028. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  84029. /**
  84030. * Creates a plane from three points
  84031. * @param point1 point used to create the plane
  84032. * @param point2 point used to create the plane
  84033. * @param point3 point used to create the plane
  84034. * @returns a new Plane defined by the three given points.
  84035. */
  84036. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  84037. /**
  84038. * Creates a plane from an origin point and a normal
  84039. * @param origin origin of the plane to be constructed
  84040. * @param normal normal of the plane to be constructed
  84041. * @returns a new Plane the normal vector to this plane at the given origin point.
  84042. * Note : the vector "normal" is updated because normalized.
  84043. */
  84044. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  84045. /**
  84046. * Calculates the distance from a plane and a point
  84047. * @param origin origin of the plane to be constructed
  84048. * @param normal normal of the plane to be constructed
  84049. * @param point point to calculate distance to
  84050. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  84051. */
  84052. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  84053. }
  84054. }
  84055. declare module BABYLON {
  84056. /** @hidden */
  84057. export class PerformanceConfigurator {
  84058. /** @hidden */
  84059. static MatrixUse64Bits: boolean;
  84060. /** @hidden */
  84061. static MatrixTrackPrecisionChange: boolean;
  84062. /** @hidden */
  84063. static MatrixCurrentType: any;
  84064. /** @hidden */
  84065. static MatrixTrackedMatrices: Array<any> | null;
  84066. /** @hidden */
  84067. static SetMatrixPrecision(use64bits: boolean): void;
  84068. }
  84069. }
  84070. declare module BABYLON {
  84071. /**
  84072. * Class representing a vector containing 2 coordinates
  84073. */
  84074. export class Vector2 {
  84075. /** defines the first coordinate */
  84076. x: number;
  84077. /** defines the second coordinate */
  84078. y: number;
  84079. /**
  84080. * Creates a new Vector2 from the given x and y coordinates
  84081. * @param x defines the first coordinate
  84082. * @param y defines the second coordinate
  84083. */
  84084. constructor(
  84085. /** defines the first coordinate */
  84086. x?: number,
  84087. /** defines the second coordinate */
  84088. y?: number);
  84089. /**
  84090. * Gets a string with the Vector2 coordinates
  84091. * @returns a string with the Vector2 coordinates
  84092. */
  84093. toString(): string;
  84094. /**
  84095. * Gets class name
  84096. * @returns the string "Vector2"
  84097. */
  84098. getClassName(): string;
  84099. /**
  84100. * Gets current vector hash code
  84101. * @returns the Vector2 hash code as a number
  84102. */
  84103. getHashCode(): number;
  84104. /**
  84105. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  84106. * @param array defines the source array
  84107. * @param index defines the offset in source array
  84108. * @returns the current Vector2
  84109. */
  84110. toArray(array: FloatArray, index?: number): Vector2;
  84111. /**
  84112. * Update the current vector from an array
  84113. * @param array defines the destination array
  84114. * @param index defines the offset in the destination array
  84115. * @returns the current Vector3
  84116. */
  84117. fromArray(array: FloatArray, index?: number): Vector2;
  84118. /**
  84119. * Copy the current vector to an array
  84120. * @returns a new array with 2 elements: the Vector2 coordinates.
  84121. */
  84122. asArray(): number[];
  84123. /**
  84124. * Sets the Vector2 coordinates with the given Vector2 coordinates
  84125. * @param source defines the source Vector2
  84126. * @returns the current updated Vector2
  84127. */
  84128. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  84129. /**
  84130. * Sets the Vector2 coordinates with the given floats
  84131. * @param x defines the first coordinate
  84132. * @param y defines the second coordinate
  84133. * @returns the current updated Vector2
  84134. */
  84135. copyFromFloats(x: number, y: number): Vector2;
  84136. /**
  84137. * Sets the Vector2 coordinates with the given floats
  84138. * @param x defines the first coordinate
  84139. * @param y defines the second coordinate
  84140. * @returns the current updated Vector2
  84141. */
  84142. set(x: number, y: number): Vector2;
  84143. /**
  84144. * Add another vector with the current one
  84145. * @param otherVector defines the other vector
  84146. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  84147. */
  84148. add(otherVector: DeepImmutable<Vector2>): Vector2;
  84149. /**
  84150. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  84151. * @param otherVector defines the other vector
  84152. * @param result defines the target vector
  84153. * @returns the unmodified current Vector2
  84154. */
  84155. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84156. /**
  84157. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  84158. * @param otherVector defines the other vector
  84159. * @returns the current updated Vector2
  84160. */
  84161. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84162. /**
  84163. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  84164. * @param otherVector defines the other vector
  84165. * @returns a new Vector2
  84166. */
  84167. addVector3(otherVector: Vector3): Vector2;
  84168. /**
  84169. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  84170. * @param otherVector defines the other vector
  84171. * @returns a new Vector2
  84172. */
  84173. subtract(otherVector: Vector2): Vector2;
  84174. /**
  84175. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  84176. * @param otherVector defines the other vector
  84177. * @param result defines the target vector
  84178. * @returns the unmodified current Vector2
  84179. */
  84180. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84181. /**
  84182. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  84183. * @param otherVector defines the other vector
  84184. * @returns the current updated Vector2
  84185. */
  84186. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84187. /**
  84188. * Multiplies in place the current Vector2 coordinates by the given ones
  84189. * @param otherVector defines the other vector
  84190. * @returns the current updated Vector2
  84191. */
  84192. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84193. /**
  84194. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  84195. * @param otherVector defines the other vector
  84196. * @returns a new Vector2
  84197. */
  84198. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  84199. /**
  84200. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  84201. * @param otherVector defines the other vector
  84202. * @param result defines the target vector
  84203. * @returns the unmodified current Vector2
  84204. */
  84205. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84206. /**
  84207. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  84208. * @param x defines the first coordinate
  84209. * @param y defines the second coordinate
  84210. * @returns a new Vector2
  84211. */
  84212. multiplyByFloats(x: number, y: number): Vector2;
  84213. /**
  84214. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  84215. * @param otherVector defines the other vector
  84216. * @returns a new Vector2
  84217. */
  84218. divide(otherVector: Vector2): Vector2;
  84219. /**
  84220. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  84221. * @param otherVector defines the other vector
  84222. * @param result defines the target vector
  84223. * @returns the unmodified current Vector2
  84224. */
  84225. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  84226. /**
  84227. * Divides the current Vector2 coordinates by the given ones
  84228. * @param otherVector defines the other vector
  84229. * @returns the current updated Vector2
  84230. */
  84231. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  84232. /**
  84233. * Gets a new Vector2 with current Vector2 negated coordinates
  84234. * @returns a new Vector2
  84235. */
  84236. negate(): Vector2;
  84237. /**
  84238. * Negate this vector in place
  84239. * @returns this
  84240. */
  84241. negateInPlace(): Vector2;
  84242. /**
  84243. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  84244. * @param result defines the Vector3 object where to store the result
  84245. * @returns the current Vector2
  84246. */
  84247. negateToRef(result: Vector2): Vector2;
  84248. /**
  84249. * Multiply the Vector2 coordinates by scale
  84250. * @param scale defines the scaling factor
  84251. * @returns the current updated Vector2
  84252. */
  84253. scaleInPlace(scale: number): Vector2;
  84254. /**
  84255. * Returns a new Vector2 scaled by "scale" from the current Vector2
  84256. * @param scale defines the scaling factor
  84257. * @returns a new Vector2
  84258. */
  84259. scale(scale: number): Vector2;
  84260. /**
  84261. * Scale the current Vector2 values by a factor to a given Vector2
  84262. * @param scale defines the scale factor
  84263. * @param result defines the Vector2 object where to store the result
  84264. * @returns the unmodified current Vector2
  84265. */
  84266. scaleToRef(scale: number, result: Vector2): Vector2;
  84267. /**
  84268. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  84269. * @param scale defines the scale factor
  84270. * @param result defines the Vector2 object where to store the result
  84271. * @returns the unmodified current Vector2
  84272. */
  84273. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  84274. /**
  84275. * Gets a boolean if two vectors are equals
  84276. * @param otherVector defines the other vector
  84277. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  84278. */
  84279. equals(otherVector: DeepImmutable<Vector2>): boolean;
  84280. /**
  84281. * Gets a boolean if two vectors are equals (using an epsilon value)
  84282. * @param otherVector defines the other vector
  84283. * @param epsilon defines the minimal distance to consider equality
  84284. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  84285. */
  84286. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  84287. /**
  84288. * Gets a new Vector2 from current Vector2 floored values
  84289. * @returns a new Vector2
  84290. */
  84291. floor(): Vector2;
  84292. /**
  84293. * Gets a new Vector2 from current Vector2 floored values
  84294. * @returns a new Vector2
  84295. */
  84296. fract(): Vector2;
  84297. /**
  84298. * Gets the length of the vector
  84299. * @returns the vector length (float)
  84300. */
  84301. length(): number;
  84302. /**
  84303. * Gets the vector squared length
  84304. * @returns the vector squared length (float)
  84305. */
  84306. lengthSquared(): number;
  84307. /**
  84308. * Normalize the vector
  84309. * @returns the current updated Vector2
  84310. */
  84311. normalize(): Vector2;
  84312. /**
  84313. * Gets a new Vector2 copied from the Vector2
  84314. * @returns a new Vector2
  84315. */
  84316. clone(): Vector2;
  84317. /**
  84318. * Gets a new Vector2(0, 0)
  84319. * @returns a new Vector2
  84320. */
  84321. static Zero(): Vector2;
  84322. /**
  84323. * Gets a new Vector2(1, 1)
  84324. * @returns a new Vector2
  84325. */
  84326. static One(): Vector2;
  84327. /**
  84328. * Gets a new Vector2 set from the given index element of the given array
  84329. * @param array defines the data source
  84330. * @param offset defines the offset in the data source
  84331. * @returns a new Vector2
  84332. */
  84333. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  84334. /**
  84335. * Sets "result" from the given index element of the given array
  84336. * @param array defines the data source
  84337. * @param offset defines the offset in the data source
  84338. * @param result defines the target vector
  84339. */
  84340. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  84341. /**
  84342. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  84343. * @param value1 defines 1st point of control
  84344. * @param value2 defines 2nd point of control
  84345. * @param value3 defines 3rd point of control
  84346. * @param value4 defines 4th point of control
  84347. * @param amount defines the interpolation factor
  84348. * @returns a new Vector2
  84349. */
  84350. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  84351. /**
  84352. * 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".
  84353. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  84354. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  84355. * @param value defines the value to clamp
  84356. * @param min defines the lower limit
  84357. * @param max defines the upper limit
  84358. * @returns a new Vector2
  84359. */
  84360. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  84361. /**
  84362. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  84363. * @param value1 defines the 1st control point
  84364. * @param tangent1 defines the outgoing tangent
  84365. * @param value2 defines the 2nd control point
  84366. * @param tangent2 defines the incoming tangent
  84367. * @param amount defines the interpolation factor
  84368. * @returns a new Vector2
  84369. */
  84370. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  84371. /**
  84372. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  84373. * @param start defines the start vector
  84374. * @param end defines the end vector
  84375. * @param amount defines the interpolation factor
  84376. * @returns a new Vector2
  84377. */
  84378. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  84379. /**
  84380. * Gets the dot product of the vector "left" and the vector "right"
  84381. * @param left defines first vector
  84382. * @param right defines second vector
  84383. * @returns the dot product (float)
  84384. */
  84385. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  84386. /**
  84387. * Returns a new Vector2 equal to the normalized given vector
  84388. * @param vector defines the vector to normalize
  84389. * @returns a new Vector2
  84390. */
  84391. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  84392. /**
  84393. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  84394. * @param left defines 1st vector
  84395. * @param right defines 2nd vector
  84396. * @returns a new Vector2
  84397. */
  84398. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84399. /**
  84400. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  84401. * @param left defines 1st vector
  84402. * @param right defines 2nd vector
  84403. * @returns a new Vector2
  84404. */
  84405. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  84406. /**
  84407. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  84408. * @param vector defines the vector to transform
  84409. * @param transformation defines the matrix to apply
  84410. * @returns a new Vector2
  84411. */
  84412. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  84413. /**
  84414. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  84415. * @param vector defines the vector to transform
  84416. * @param transformation defines the matrix to apply
  84417. * @param result defines the target vector
  84418. */
  84419. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  84420. /**
  84421. * Determines if a given vector is included in a triangle
  84422. * @param p defines the vector to test
  84423. * @param p0 defines 1st triangle point
  84424. * @param p1 defines 2nd triangle point
  84425. * @param p2 defines 3rd triangle point
  84426. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  84427. */
  84428. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  84429. /**
  84430. * Gets the distance between the vectors "value1" and "value2"
  84431. * @param value1 defines first vector
  84432. * @param value2 defines second vector
  84433. * @returns the distance between vectors
  84434. */
  84435. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84436. /**
  84437. * Returns the squared distance between the vectors "value1" and "value2"
  84438. * @param value1 defines first vector
  84439. * @param value2 defines second vector
  84440. * @returns the squared distance between vectors
  84441. */
  84442. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  84443. /**
  84444. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  84445. * @param value1 defines first vector
  84446. * @param value2 defines second vector
  84447. * @returns a new Vector2
  84448. */
  84449. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  84450. /**
  84451. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  84452. * @param p defines the middle point
  84453. * @param segA defines one point of the segment
  84454. * @param segB defines the other point of the segment
  84455. * @returns the shortest distance
  84456. */
  84457. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  84458. }
  84459. /**
  84460. * Class used to store (x,y,z) vector representation
  84461. * A Vector3 is the main object used in 3D geometry
  84462. * It can represent etiher the coordinates of a point the space, either a direction
  84463. * Reminder: js uses a left handed forward facing system
  84464. */
  84465. export class Vector3 {
  84466. private static _UpReadOnly;
  84467. private static _ZeroReadOnly;
  84468. /** @hidden */
  84469. _x: number;
  84470. /** @hidden */
  84471. _y: number;
  84472. /** @hidden */
  84473. _z: number;
  84474. /** @hidden */
  84475. _isDirty: boolean;
  84476. /** Gets or sets the x coordinate */
  84477. get x(): number;
  84478. set x(value: number);
  84479. /** Gets or sets the y coordinate */
  84480. get y(): number;
  84481. set y(value: number);
  84482. /** Gets or sets the z coordinate */
  84483. get z(): number;
  84484. set z(value: number);
  84485. /**
  84486. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  84487. * @param x defines the first coordinates (on X axis)
  84488. * @param y defines the second coordinates (on Y axis)
  84489. * @param z defines the third coordinates (on Z axis)
  84490. */
  84491. constructor(x?: number, y?: number, z?: number);
  84492. /**
  84493. * Creates a string representation of the Vector3
  84494. * @returns a string with the Vector3 coordinates.
  84495. */
  84496. toString(): string;
  84497. /**
  84498. * Gets the class name
  84499. * @returns the string "Vector3"
  84500. */
  84501. getClassName(): string;
  84502. /**
  84503. * Creates the Vector3 hash code
  84504. * @returns a number which tends to be unique between Vector3 instances
  84505. */
  84506. getHashCode(): number;
  84507. /**
  84508. * Creates an array containing three elements : the coordinates of the Vector3
  84509. * @returns a new array of numbers
  84510. */
  84511. asArray(): number[];
  84512. /**
  84513. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  84514. * @param array defines the destination array
  84515. * @param index defines the offset in the destination array
  84516. * @returns the current Vector3
  84517. */
  84518. toArray(array: FloatArray, index?: number): Vector3;
  84519. /**
  84520. * Update the current vector from an array
  84521. * @param array defines the destination array
  84522. * @param index defines the offset in the destination array
  84523. * @returns the current Vector3
  84524. */
  84525. fromArray(array: FloatArray, index?: number): Vector3;
  84526. /**
  84527. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  84528. * @returns a new Quaternion object, computed from the Vector3 coordinates
  84529. */
  84530. toQuaternion(): Quaternion;
  84531. /**
  84532. * Adds the given vector to the current Vector3
  84533. * @param otherVector defines the second operand
  84534. * @returns the current updated Vector3
  84535. */
  84536. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84537. /**
  84538. * Adds the given coordinates to the current Vector3
  84539. * @param x defines the x coordinate of the operand
  84540. * @param y defines the y coordinate of the operand
  84541. * @param z defines the z coordinate of the operand
  84542. * @returns the current updated Vector3
  84543. */
  84544. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84545. /**
  84546. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  84547. * @param otherVector defines the second operand
  84548. * @returns the resulting Vector3
  84549. */
  84550. add(otherVector: DeepImmutable<Vector3>): Vector3;
  84551. /**
  84552. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  84553. * @param otherVector defines the second operand
  84554. * @param result defines the Vector3 object where to store the result
  84555. * @returns the current Vector3
  84556. */
  84557. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84558. /**
  84559. * Subtract the given vector from the current Vector3
  84560. * @param otherVector defines the second operand
  84561. * @returns the current updated Vector3
  84562. */
  84563. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84564. /**
  84565. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  84566. * @param otherVector defines the second operand
  84567. * @returns the resulting Vector3
  84568. */
  84569. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  84570. /**
  84571. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  84572. * @param otherVector defines the second operand
  84573. * @param result defines the Vector3 object where to store the result
  84574. * @returns the current Vector3
  84575. */
  84576. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84577. /**
  84578. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  84579. * @param x defines the x coordinate of the operand
  84580. * @param y defines the y coordinate of the operand
  84581. * @param z defines the z coordinate of the operand
  84582. * @returns the resulting Vector3
  84583. */
  84584. subtractFromFloats(x: number, y: number, z: number): Vector3;
  84585. /**
  84586. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  84587. * @param x defines the x coordinate of the operand
  84588. * @param y defines the y coordinate of the operand
  84589. * @param z defines the z coordinate of the operand
  84590. * @param result defines the Vector3 object where to store the result
  84591. * @returns the current Vector3
  84592. */
  84593. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  84594. /**
  84595. * Gets a new Vector3 set with the current Vector3 negated coordinates
  84596. * @returns a new Vector3
  84597. */
  84598. negate(): Vector3;
  84599. /**
  84600. * Negate this vector in place
  84601. * @returns this
  84602. */
  84603. negateInPlace(): Vector3;
  84604. /**
  84605. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  84606. * @param result defines the Vector3 object where to store the result
  84607. * @returns the current Vector3
  84608. */
  84609. negateToRef(result: Vector3): Vector3;
  84610. /**
  84611. * Multiplies the Vector3 coordinates by the float "scale"
  84612. * @param scale defines the multiplier factor
  84613. * @returns the current updated Vector3
  84614. */
  84615. scaleInPlace(scale: number): Vector3;
  84616. /**
  84617. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  84618. * @param scale defines the multiplier factor
  84619. * @returns a new Vector3
  84620. */
  84621. scale(scale: number): Vector3;
  84622. /**
  84623. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  84624. * @param scale defines the multiplier factor
  84625. * @param result defines the Vector3 object where to store the result
  84626. * @returns the current Vector3
  84627. */
  84628. scaleToRef(scale: number, result: Vector3): Vector3;
  84629. /**
  84630. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  84631. * @param scale defines the scale factor
  84632. * @param result defines the Vector3 object where to store the result
  84633. * @returns the unmodified current Vector3
  84634. */
  84635. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  84636. /**
  84637. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84638. * @param origin defines the origin of the projection ray
  84639. * @param plane defines the plane to project to
  84640. * @returns the projected vector3
  84641. */
  84642. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  84643. /**
  84644. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  84645. * @param origin defines the origin of the projection ray
  84646. * @param plane defines the plane to project to
  84647. * @param result defines the Vector3 where to store the result
  84648. */
  84649. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  84650. /**
  84651. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  84652. * @param otherVector defines the second operand
  84653. * @returns true if both vectors are equals
  84654. */
  84655. equals(otherVector: DeepImmutable<Vector3>): boolean;
  84656. /**
  84657. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  84658. * @param otherVector defines the second operand
  84659. * @param epsilon defines the minimal distance to define values as equals
  84660. * @returns true if both vectors are distant less than epsilon
  84661. */
  84662. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  84663. /**
  84664. * Returns true if the current Vector3 coordinates equals the given floats
  84665. * @param x defines the x coordinate of the operand
  84666. * @param y defines the y coordinate of the operand
  84667. * @param z defines the z coordinate of the operand
  84668. * @returns true if both vectors are equals
  84669. */
  84670. equalsToFloats(x: number, y: number, z: number): boolean;
  84671. /**
  84672. * Multiplies the current Vector3 coordinates by the given ones
  84673. * @param otherVector defines the second operand
  84674. * @returns the current updated Vector3
  84675. */
  84676. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  84677. /**
  84678. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  84679. * @param otherVector defines the second operand
  84680. * @returns the new Vector3
  84681. */
  84682. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  84683. /**
  84684. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  84685. * @param otherVector defines the second operand
  84686. * @param result defines the Vector3 object where to store the result
  84687. * @returns the current Vector3
  84688. */
  84689. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84690. /**
  84691. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  84692. * @param x defines the x coordinate of the operand
  84693. * @param y defines the y coordinate of the operand
  84694. * @param z defines the z coordinate of the operand
  84695. * @returns the new Vector3
  84696. */
  84697. multiplyByFloats(x: number, y: number, z: number): Vector3;
  84698. /**
  84699. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  84700. * @param otherVector defines the second operand
  84701. * @returns the new Vector3
  84702. */
  84703. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  84704. /**
  84705. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  84706. * @param otherVector defines the second operand
  84707. * @param result defines the Vector3 object where to store the result
  84708. * @returns the current Vector3
  84709. */
  84710. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  84711. /**
  84712. * Divides the current Vector3 coordinates by the given ones.
  84713. * @param otherVector defines the second operand
  84714. * @returns the current updated Vector3
  84715. */
  84716. divideInPlace(otherVector: Vector3): Vector3;
  84717. /**
  84718. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  84719. * @param other defines the second operand
  84720. * @returns the current updated Vector3
  84721. */
  84722. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84723. /**
  84724. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  84725. * @param other defines the second operand
  84726. * @returns the current updated Vector3
  84727. */
  84728. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  84729. /**
  84730. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  84731. * @param x defines the x coordinate of the operand
  84732. * @param y defines the y coordinate of the operand
  84733. * @param z defines the z coordinate of the operand
  84734. * @returns the current updated Vector3
  84735. */
  84736. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84737. /**
  84738. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  84739. * @param x defines the x coordinate of the operand
  84740. * @param y defines the y coordinate of the operand
  84741. * @param z defines the z coordinate of the operand
  84742. * @returns the current updated Vector3
  84743. */
  84744. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  84745. /**
  84746. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  84747. * Check if is non uniform within a certain amount of decimal places to account for this
  84748. * @param epsilon the amount the values can differ
  84749. * @returns if the the vector is non uniform to a certain number of decimal places
  84750. */
  84751. isNonUniformWithinEpsilon(epsilon: number): boolean;
  84752. /**
  84753. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  84754. */
  84755. get isNonUniform(): boolean;
  84756. /**
  84757. * Gets a new Vector3 from current Vector3 floored values
  84758. * @returns a new Vector3
  84759. */
  84760. floor(): Vector3;
  84761. /**
  84762. * Gets a new Vector3 from current Vector3 floored values
  84763. * @returns a new Vector3
  84764. */
  84765. fract(): Vector3;
  84766. /**
  84767. * Gets the length of the Vector3
  84768. * @returns the length of the Vector3
  84769. */
  84770. length(): number;
  84771. /**
  84772. * Gets the squared length of the Vector3
  84773. * @returns squared length of the Vector3
  84774. */
  84775. lengthSquared(): number;
  84776. /**
  84777. * Normalize the current Vector3.
  84778. * Please note that this is an in place operation.
  84779. * @returns the current updated Vector3
  84780. */
  84781. normalize(): Vector3;
  84782. /**
  84783. * Reorders the x y z properties of the vector in place
  84784. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  84785. * @returns the current updated vector
  84786. */
  84787. reorderInPlace(order: string): this;
  84788. /**
  84789. * Rotates the vector around 0,0,0 by a quaternion
  84790. * @param quaternion the rotation quaternion
  84791. * @param result vector to store the result
  84792. * @returns the resulting vector
  84793. */
  84794. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  84795. /**
  84796. * Rotates a vector around a given point
  84797. * @param quaternion the rotation quaternion
  84798. * @param point the point to rotate around
  84799. * @param result vector to store the result
  84800. * @returns the resulting vector
  84801. */
  84802. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  84803. /**
  84804. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  84805. * The cross product is then orthogonal to both current and "other"
  84806. * @param other defines the right operand
  84807. * @returns the cross product
  84808. */
  84809. cross(other: Vector3): Vector3;
  84810. /**
  84811. * Normalize the current Vector3 with the given input length.
  84812. * Please note that this is an in place operation.
  84813. * @param len the length of the vector
  84814. * @returns the current updated Vector3
  84815. */
  84816. normalizeFromLength(len: number): Vector3;
  84817. /**
  84818. * Normalize the current Vector3 to a new vector
  84819. * @returns the new Vector3
  84820. */
  84821. normalizeToNew(): Vector3;
  84822. /**
  84823. * Normalize the current Vector3 to the reference
  84824. * @param reference define the Vector3 to update
  84825. * @returns the updated Vector3
  84826. */
  84827. normalizeToRef(reference: Vector3): Vector3;
  84828. /**
  84829. * Creates a new Vector3 copied from the current Vector3
  84830. * @returns the new Vector3
  84831. */
  84832. clone(): Vector3;
  84833. /**
  84834. * Copies the given vector coordinates to the current Vector3 ones
  84835. * @param source defines the source Vector3
  84836. * @returns the current updated Vector3
  84837. */
  84838. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  84839. /**
  84840. * Copies the given floats to the current Vector3 coordinates
  84841. * @param x defines the x coordinate of the operand
  84842. * @param y defines the y coordinate of the operand
  84843. * @param z defines the z coordinate of the operand
  84844. * @returns the current updated Vector3
  84845. */
  84846. copyFromFloats(x: number, y: number, z: number): Vector3;
  84847. /**
  84848. * Copies the given floats to the current Vector3 coordinates
  84849. * @param x defines the x coordinate of the operand
  84850. * @param y defines the y coordinate of the operand
  84851. * @param z defines the z coordinate of the operand
  84852. * @returns the current updated Vector3
  84853. */
  84854. set(x: number, y: number, z: number): Vector3;
  84855. /**
  84856. * Copies the given float to the current Vector3 coordinates
  84857. * @param v defines the x, y and z coordinates of the operand
  84858. * @returns the current updated Vector3
  84859. */
  84860. setAll(v: number): Vector3;
  84861. /**
  84862. * Get the clip factor between two vectors
  84863. * @param vector0 defines the first operand
  84864. * @param vector1 defines the second operand
  84865. * @param axis defines the axis to use
  84866. * @param size defines the size along the axis
  84867. * @returns the clip factor
  84868. */
  84869. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84870. /**
  84871. * Get angle between two vectors
  84872. * @param vector0 angle between vector0 and vector1
  84873. * @param vector1 angle between vector0 and vector1
  84874. * @param normal direction of the normal
  84875. * @return the angle between vector0 and vector1
  84876. */
  84877. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84878. /**
  84879. * Returns a new Vector3 set from the index "offset" of the given array
  84880. * @param array defines the source array
  84881. * @param offset defines the offset in the source array
  84882. * @returns the new Vector3
  84883. */
  84884. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84885. /**
  84886. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84887. * @param array defines the source array
  84888. * @param offset defines the offset in the source array
  84889. * @returns the new Vector3
  84890. * @deprecated Please use FromArray instead.
  84891. */
  84892. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84893. /**
  84894. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84895. * @param array defines the source array
  84896. * @param offset defines the offset in the source array
  84897. * @param result defines the Vector3 where to store the result
  84898. */
  84899. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84900. /**
  84901. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84902. * @param array defines the source array
  84903. * @param offset defines the offset in the source array
  84904. * @param result defines the Vector3 where to store the result
  84905. * @deprecated Please use FromArrayToRef instead.
  84906. */
  84907. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84908. /**
  84909. * Sets the given vector "result" with the given floats.
  84910. * @param x defines the x coordinate of the source
  84911. * @param y defines the y coordinate of the source
  84912. * @param z defines the z coordinate of the source
  84913. * @param result defines the Vector3 where to store the result
  84914. */
  84915. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84916. /**
  84917. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84918. * @returns a new empty Vector3
  84919. */
  84920. static Zero(): Vector3;
  84921. /**
  84922. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84923. * @returns a new unit Vector3
  84924. */
  84925. static One(): Vector3;
  84926. /**
  84927. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84928. * @returns a new up Vector3
  84929. */
  84930. static Up(): Vector3;
  84931. /**
  84932. * Gets a up Vector3 that must not be updated
  84933. */
  84934. static get UpReadOnly(): DeepImmutable<Vector3>;
  84935. /**
  84936. * Gets a zero Vector3 that must not be updated
  84937. */
  84938. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84939. /**
  84940. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84941. * @returns a new down Vector3
  84942. */
  84943. static Down(): Vector3;
  84944. /**
  84945. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84946. * @param rightHandedSystem is the scene right-handed (negative z)
  84947. * @returns a new forward Vector3
  84948. */
  84949. static Forward(rightHandedSystem?: boolean): Vector3;
  84950. /**
  84951. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84952. * @param rightHandedSystem is the scene right-handed (negative-z)
  84953. * @returns a new forward Vector3
  84954. */
  84955. static Backward(rightHandedSystem?: boolean): Vector3;
  84956. /**
  84957. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84958. * @returns a new right Vector3
  84959. */
  84960. static Right(): Vector3;
  84961. /**
  84962. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84963. * @returns a new left Vector3
  84964. */
  84965. static Left(): Vector3;
  84966. /**
  84967. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84968. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84969. * @param vector defines the Vector3 to transform
  84970. * @param transformation defines the transformation matrix
  84971. * @returns the transformed Vector3
  84972. */
  84973. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84974. /**
  84975. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84976. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84977. * @param vector defines the Vector3 to transform
  84978. * @param transformation defines the transformation matrix
  84979. * @param result defines the Vector3 where to store the result
  84980. */
  84981. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84982. /**
  84983. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84984. * This method computes tranformed coordinates only, not transformed direction vectors
  84985. * @param x define the x coordinate of the source vector
  84986. * @param y define the y coordinate of the source vector
  84987. * @param z define the z coordinate of the source vector
  84988. * @param transformation defines the transformation matrix
  84989. * @param result defines the Vector3 where to store the result
  84990. */
  84991. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84992. /**
  84993. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84995. * @param vector defines the Vector3 to transform
  84996. * @param transformation defines the transformation matrix
  84997. * @returns the new Vector3
  84998. */
  84999. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  85000. /**
  85001. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  85002. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85003. * @param vector defines the Vector3 to transform
  85004. * @param transformation defines the transformation matrix
  85005. * @param result defines the Vector3 where to store the result
  85006. */
  85007. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85008. /**
  85009. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  85010. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  85011. * @param x define the x coordinate of the source vector
  85012. * @param y define the y coordinate of the source vector
  85013. * @param z define the z coordinate of the source vector
  85014. * @param transformation defines the transformation matrix
  85015. * @param result defines the Vector3 where to store the result
  85016. */
  85017. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  85018. /**
  85019. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  85020. * @param value1 defines the first control point
  85021. * @param value2 defines the second control point
  85022. * @param value3 defines the third control point
  85023. * @param value4 defines the fourth control point
  85024. * @param amount defines the amount on the spline to use
  85025. * @returns the new Vector3
  85026. */
  85027. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  85028. /**
  85029. * 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"
  85030. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  85031. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  85032. * @param value defines the current value
  85033. * @param min defines the lower range value
  85034. * @param max defines the upper range value
  85035. * @returns the new Vector3
  85036. */
  85037. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  85038. /**
  85039. * 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"
  85040. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  85041. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  85042. * @param value defines the current value
  85043. * @param min defines the lower range value
  85044. * @param max defines the upper range value
  85045. * @param result defines the Vector3 where to store the result
  85046. */
  85047. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  85048. /**
  85049. * Checks if a given vector is inside a specific range
  85050. * @param v defines the vector to test
  85051. * @param min defines the minimum range
  85052. * @param max defines the maximum range
  85053. */
  85054. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  85055. /**
  85056. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  85057. * @param value1 defines the first control point
  85058. * @param tangent1 defines the first tangent vector
  85059. * @param value2 defines the second control point
  85060. * @param tangent2 defines the second tangent vector
  85061. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  85062. * @returns the new Vector3
  85063. */
  85064. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  85065. /**
  85066. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  85067. * @param start defines the start value
  85068. * @param end defines the end value
  85069. * @param amount max defines amount between both (between 0 and 1)
  85070. * @returns the new Vector3
  85071. */
  85072. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  85073. /**
  85074. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  85075. * @param start defines the start value
  85076. * @param end defines the end value
  85077. * @param amount max defines amount between both (between 0 and 1)
  85078. * @param result defines the Vector3 where to store the result
  85079. */
  85080. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  85081. /**
  85082. * Returns the dot product (float) between the vectors "left" and "right"
  85083. * @param left defines the left operand
  85084. * @param right defines the right operand
  85085. * @returns the dot product
  85086. */
  85087. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  85088. /**
  85089. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  85090. * The cross product is then orthogonal to both "left" and "right"
  85091. * @param left defines the left operand
  85092. * @param right defines the right operand
  85093. * @returns the cross product
  85094. */
  85095. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85096. /**
  85097. * Sets the given vector "result" with the cross product of "left" and "right"
  85098. * The cross product is then orthogonal to both "left" and "right"
  85099. * @param left defines the left operand
  85100. * @param right defines the right operand
  85101. * @param result defines the Vector3 where to store the result
  85102. */
  85103. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  85104. /**
  85105. * Returns a new Vector3 as the normalization of the given vector
  85106. * @param vector defines the Vector3 to normalize
  85107. * @returns the new Vector3
  85108. */
  85109. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  85110. /**
  85111. * Sets the given vector "result" with the normalization of the given first vector
  85112. * @param vector defines the Vector3 to normalize
  85113. * @param result defines the Vector3 where to store the result
  85114. */
  85115. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  85116. /**
  85117. * Project a Vector3 onto screen space
  85118. * @param vector defines the Vector3 to project
  85119. * @param world defines the world matrix to use
  85120. * @param transform defines the transform (view x projection) matrix to use
  85121. * @param viewport defines the screen viewport to use
  85122. * @returns the new Vector3
  85123. */
  85124. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  85125. /**
  85126. * Project a Vector3 onto screen space to reference
  85127. * @param vector defines the Vector3 to project
  85128. * @param world defines the world matrix to use
  85129. * @param transform defines the transform (view x projection) matrix to use
  85130. * @param viewport defines the screen viewport to use
  85131. * @param result the vector in which the screen space will be stored
  85132. * @returns the new Vector3
  85133. */
  85134. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  85135. /** @hidden */
  85136. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  85137. /**
  85138. * Unproject from screen space to object space
  85139. * @param source defines the screen space Vector3 to use
  85140. * @param viewportWidth defines the current width of the viewport
  85141. * @param viewportHeight defines the current height of the viewport
  85142. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85143. * @param transform defines the transform (view x projection) matrix to use
  85144. * @returns the new Vector3
  85145. */
  85146. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  85147. /**
  85148. * Unproject from screen space to object space
  85149. * @param source defines the screen space Vector3 to use
  85150. * @param viewportWidth defines the current width of the viewport
  85151. * @param viewportHeight defines the current height of the viewport
  85152. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85153. * @param view defines the view matrix to use
  85154. * @param projection defines the projection matrix to use
  85155. * @returns the new Vector3
  85156. */
  85157. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  85158. /**
  85159. * Unproject from screen space to object space
  85160. * @param source defines the screen space Vector3 to use
  85161. * @param viewportWidth defines the current width of the viewport
  85162. * @param viewportHeight defines the current height of the viewport
  85163. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85164. * @param view defines the view matrix to use
  85165. * @param projection defines the projection matrix to use
  85166. * @param result defines the Vector3 where to store the result
  85167. */
  85168. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85169. /**
  85170. * Unproject from screen space to object space
  85171. * @param sourceX defines the screen space x coordinate to use
  85172. * @param sourceY defines the screen space y coordinate to use
  85173. * @param sourceZ defines the screen space z coordinate to use
  85174. * @param viewportWidth defines the current width of the viewport
  85175. * @param viewportHeight defines the current height of the viewport
  85176. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  85177. * @param view defines the view matrix to use
  85178. * @param projection defines the projection matrix to use
  85179. * @param result defines the Vector3 where to store the result
  85180. */
  85181. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  85182. /**
  85183. * Gets the minimal coordinate values between two Vector3
  85184. * @param left defines the first operand
  85185. * @param right defines the second operand
  85186. * @returns the new Vector3
  85187. */
  85188. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85189. /**
  85190. * Gets the maximal coordinate values between two Vector3
  85191. * @param left defines the first operand
  85192. * @param right defines the second operand
  85193. * @returns the new Vector3
  85194. */
  85195. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  85196. /**
  85197. * Returns the distance between the vectors "value1" and "value2"
  85198. * @param value1 defines the first operand
  85199. * @param value2 defines the second operand
  85200. * @returns the distance
  85201. */
  85202. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85203. /**
  85204. * Returns the squared distance between the vectors "value1" and "value2"
  85205. * @param value1 defines the first operand
  85206. * @param value2 defines the second operand
  85207. * @returns the squared distance
  85208. */
  85209. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  85210. /**
  85211. * Returns a new Vector3 located at the center between "value1" and "value2"
  85212. * @param value1 defines the first operand
  85213. * @param value2 defines the second operand
  85214. * @returns the new Vector3
  85215. */
  85216. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  85217. /**
  85218. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  85219. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  85220. * to something in order to rotate it from its local system to the given target system
  85221. * Note: axis1, axis2 and axis3 are normalized during this operation
  85222. * @param axis1 defines the first axis
  85223. * @param axis2 defines the second axis
  85224. * @param axis3 defines the third axis
  85225. * @returns a new Vector3
  85226. */
  85227. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  85228. /**
  85229. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  85230. * @param axis1 defines the first axis
  85231. * @param axis2 defines the second axis
  85232. * @param axis3 defines the third axis
  85233. * @param ref defines the Vector3 where to store the result
  85234. */
  85235. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  85236. }
  85237. /**
  85238. * Vector4 class created for EulerAngle class conversion to Quaternion
  85239. */
  85240. export class Vector4 {
  85241. /** x value of the vector */
  85242. x: number;
  85243. /** y value of the vector */
  85244. y: number;
  85245. /** z value of the vector */
  85246. z: number;
  85247. /** w value of the vector */
  85248. w: number;
  85249. /**
  85250. * Creates a Vector4 object from the given floats.
  85251. * @param x x value of the vector
  85252. * @param y y value of the vector
  85253. * @param z z value of the vector
  85254. * @param w w value of the vector
  85255. */
  85256. constructor(
  85257. /** x value of the vector */
  85258. x: number,
  85259. /** y value of the vector */
  85260. y: number,
  85261. /** z value of the vector */
  85262. z: number,
  85263. /** w value of the vector */
  85264. w: number);
  85265. /**
  85266. * Returns the string with the Vector4 coordinates.
  85267. * @returns a string containing all the vector values
  85268. */
  85269. toString(): string;
  85270. /**
  85271. * Returns the string "Vector4".
  85272. * @returns "Vector4"
  85273. */
  85274. getClassName(): string;
  85275. /**
  85276. * Returns the Vector4 hash code.
  85277. * @returns a unique hash code
  85278. */
  85279. getHashCode(): number;
  85280. /**
  85281. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  85282. * @returns the resulting array
  85283. */
  85284. asArray(): number[];
  85285. /**
  85286. * Populates the given array from the given index with the Vector4 coordinates.
  85287. * @param array array to populate
  85288. * @param index index of the array to start at (default: 0)
  85289. * @returns the Vector4.
  85290. */
  85291. toArray(array: FloatArray, index?: number): Vector4;
  85292. /**
  85293. * Update the current vector from an array
  85294. * @param array defines the destination array
  85295. * @param index defines the offset in the destination array
  85296. * @returns the current Vector3
  85297. */
  85298. fromArray(array: FloatArray, index?: number): Vector4;
  85299. /**
  85300. * Adds the given vector to the current Vector4.
  85301. * @param otherVector the vector to add
  85302. * @returns the updated Vector4.
  85303. */
  85304. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85305. /**
  85306. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  85307. * @param otherVector the vector to add
  85308. * @returns the resulting vector
  85309. */
  85310. add(otherVector: DeepImmutable<Vector4>): Vector4;
  85311. /**
  85312. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  85313. * @param otherVector the vector to add
  85314. * @param result the vector to store the result
  85315. * @returns the current Vector4.
  85316. */
  85317. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85318. /**
  85319. * Subtract in place the given vector from the current Vector4.
  85320. * @param otherVector the vector to subtract
  85321. * @returns the updated Vector4.
  85322. */
  85323. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85324. /**
  85325. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  85326. * @param otherVector the vector to add
  85327. * @returns the new vector with the result
  85328. */
  85329. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  85330. /**
  85331. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  85332. * @param otherVector the vector to subtract
  85333. * @param result the vector to store the result
  85334. * @returns the current Vector4.
  85335. */
  85336. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85337. /**
  85338. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85339. */
  85340. /**
  85341. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85342. * @param x value to subtract
  85343. * @param y value to subtract
  85344. * @param z value to subtract
  85345. * @param w value to subtract
  85346. * @returns new vector containing the result
  85347. */
  85348. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85349. /**
  85350. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  85351. * @param x value to subtract
  85352. * @param y value to subtract
  85353. * @param z value to subtract
  85354. * @param w value to subtract
  85355. * @param result the vector to store the result in
  85356. * @returns the current Vector4.
  85357. */
  85358. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  85359. /**
  85360. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  85361. * @returns a new vector with the negated values
  85362. */
  85363. negate(): Vector4;
  85364. /**
  85365. * Negate this vector in place
  85366. * @returns this
  85367. */
  85368. negateInPlace(): Vector4;
  85369. /**
  85370. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  85371. * @param result defines the Vector3 object where to store the result
  85372. * @returns the current Vector4
  85373. */
  85374. negateToRef(result: Vector4): Vector4;
  85375. /**
  85376. * Multiplies the current Vector4 coordinates by scale (float).
  85377. * @param scale the number to scale with
  85378. * @returns the updated Vector4.
  85379. */
  85380. scaleInPlace(scale: number): Vector4;
  85381. /**
  85382. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  85383. * @param scale the number to scale with
  85384. * @returns a new vector with the result
  85385. */
  85386. scale(scale: number): Vector4;
  85387. /**
  85388. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  85389. * @param scale the number to scale with
  85390. * @param result a vector to store the result in
  85391. * @returns the current Vector4.
  85392. */
  85393. scaleToRef(scale: number, result: Vector4): Vector4;
  85394. /**
  85395. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  85396. * @param scale defines the scale factor
  85397. * @param result defines the Vector4 object where to store the result
  85398. * @returns the unmodified current Vector4
  85399. */
  85400. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  85401. /**
  85402. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  85403. * @param otherVector the vector to compare against
  85404. * @returns true if they are equal
  85405. */
  85406. equals(otherVector: DeepImmutable<Vector4>): boolean;
  85407. /**
  85408. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  85409. * @param otherVector vector to compare against
  85410. * @param epsilon (Default: very small number)
  85411. * @returns true if they are equal
  85412. */
  85413. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  85414. /**
  85415. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  85416. * @param x x value to compare against
  85417. * @param y y value to compare against
  85418. * @param z z value to compare against
  85419. * @param w w value to compare against
  85420. * @returns true if equal
  85421. */
  85422. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  85423. /**
  85424. * Multiplies in place the current Vector4 by the given one.
  85425. * @param otherVector vector to multiple with
  85426. * @returns the updated Vector4.
  85427. */
  85428. multiplyInPlace(otherVector: Vector4): Vector4;
  85429. /**
  85430. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  85431. * @param otherVector vector to multiple with
  85432. * @returns resulting new vector
  85433. */
  85434. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  85435. /**
  85436. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  85437. * @param otherVector vector to multiple with
  85438. * @param result vector to store the result
  85439. * @returns the current Vector4.
  85440. */
  85441. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85442. /**
  85443. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  85444. * @param x x value multiply with
  85445. * @param y y value multiply with
  85446. * @param z z value multiply with
  85447. * @param w w value multiply with
  85448. * @returns resulting new vector
  85449. */
  85450. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  85451. /**
  85452. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  85453. * @param otherVector vector to devide with
  85454. * @returns resulting new vector
  85455. */
  85456. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  85457. /**
  85458. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  85459. * @param otherVector vector to devide with
  85460. * @param result vector to store the result
  85461. * @returns the current Vector4.
  85462. */
  85463. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  85464. /**
  85465. * Divides the current Vector3 coordinates by the given ones.
  85466. * @param otherVector vector to devide with
  85467. * @returns the updated Vector3.
  85468. */
  85469. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  85470. /**
  85471. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  85472. * @param other defines the second operand
  85473. * @returns the current updated Vector4
  85474. */
  85475. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85476. /**
  85477. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  85478. * @param other defines the second operand
  85479. * @returns the current updated Vector4
  85480. */
  85481. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  85482. /**
  85483. * Gets a new Vector4 from current Vector4 floored values
  85484. * @returns a new Vector4
  85485. */
  85486. floor(): Vector4;
  85487. /**
  85488. * Gets a new Vector4 from current Vector3 floored values
  85489. * @returns a new Vector4
  85490. */
  85491. fract(): Vector4;
  85492. /**
  85493. * Returns the Vector4 length (float).
  85494. * @returns the length
  85495. */
  85496. length(): number;
  85497. /**
  85498. * Returns the Vector4 squared length (float).
  85499. * @returns the length squared
  85500. */
  85501. lengthSquared(): number;
  85502. /**
  85503. * Normalizes in place the Vector4.
  85504. * @returns the updated Vector4.
  85505. */
  85506. normalize(): Vector4;
  85507. /**
  85508. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  85509. * @returns this converted to a new vector3
  85510. */
  85511. toVector3(): Vector3;
  85512. /**
  85513. * Returns a new Vector4 copied from the current one.
  85514. * @returns the new cloned vector
  85515. */
  85516. clone(): Vector4;
  85517. /**
  85518. * Updates the current Vector4 with the given one coordinates.
  85519. * @param source the source vector to copy from
  85520. * @returns the updated Vector4.
  85521. */
  85522. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  85523. /**
  85524. * Updates the current Vector4 coordinates with the given floats.
  85525. * @param x float to copy from
  85526. * @param y float to copy from
  85527. * @param z float to copy from
  85528. * @param w float to copy from
  85529. * @returns the updated Vector4.
  85530. */
  85531. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  85532. /**
  85533. * Updates the current Vector4 coordinates with the given floats.
  85534. * @param x float to set from
  85535. * @param y float to set from
  85536. * @param z float to set from
  85537. * @param w float to set from
  85538. * @returns the updated Vector4.
  85539. */
  85540. set(x: number, y: number, z: number, w: number): Vector4;
  85541. /**
  85542. * Copies the given float to the current Vector3 coordinates
  85543. * @param v defines the x, y, z and w coordinates of the operand
  85544. * @returns the current updated Vector3
  85545. */
  85546. setAll(v: number): Vector4;
  85547. /**
  85548. * Returns a new Vector4 set from the starting index of the given array.
  85549. * @param array the array to pull values from
  85550. * @param offset the offset into the array to start at
  85551. * @returns the new vector
  85552. */
  85553. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  85554. /**
  85555. * Updates the given vector "result" from the starting index of the given array.
  85556. * @param array the array to pull values from
  85557. * @param offset the offset into the array to start at
  85558. * @param result the vector to store the result in
  85559. */
  85560. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  85561. /**
  85562. * Updates the given vector "result" from the starting index of the given Float32Array.
  85563. * @param array the array to pull values from
  85564. * @param offset the offset into the array to start at
  85565. * @param result the vector to store the result in
  85566. */
  85567. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  85568. /**
  85569. * Updates the given vector "result" coordinates from the given floats.
  85570. * @param x float to set from
  85571. * @param y float to set from
  85572. * @param z float to set from
  85573. * @param w float to set from
  85574. * @param result the vector to the floats in
  85575. */
  85576. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  85577. /**
  85578. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  85579. * @returns the new vector
  85580. */
  85581. static Zero(): Vector4;
  85582. /**
  85583. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  85584. * @returns the new vector
  85585. */
  85586. static One(): Vector4;
  85587. /**
  85588. * Returns a new normalized Vector4 from the given one.
  85589. * @param vector the vector to normalize
  85590. * @returns the vector
  85591. */
  85592. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  85593. /**
  85594. * Updates the given vector "result" from the normalization of the given one.
  85595. * @param vector the vector to normalize
  85596. * @param result the vector to store the result in
  85597. */
  85598. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  85599. /**
  85600. * Returns a vector with the minimum values from the left and right vectors
  85601. * @param left left vector to minimize
  85602. * @param right right vector to minimize
  85603. * @returns a new vector with the minimum of the left and right vector values
  85604. */
  85605. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85606. /**
  85607. * Returns a vector with the maximum values from the left and right vectors
  85608. * @param left left vector to maximize
  85609. * @param right right vector to maximize
  85610. * @returns a new vector with the maximum of the left and right vector values
  85611. */
  85612. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  85613. /**
  85614. * Returns the distance (float) between the vectors "value1" and "value2".
  85615. * @param value1 value to calulate the distance between
  85616. * @param value2 value to calulate the distance between
  85617. * @return the distance between the two vectors
  85618. */
  85619. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85620. /**
  85621. * Returns the squared distance (float) between the vectors "value1" and "value2".
  85622. * @param value1 value to calulate the distance between
  85623. * @param value2 value to calulate the distance between
  85624. * @return the distance between the two vectors squared
  85625. */
  85626. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  85627. /**
  85628. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  85629. * @param value1 value to calulate the center between
  85630. * @param value2 value to calulate the center between
  85631. * @return the center between the two vectors
  85632. */
  85633. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  85634. /**
  85635. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  85636. * This methods computes transformed normalized direction vectors only.
  85637. * @param vector the vector to transform
  85638. * @param transformation the transformation matrix to apply
  85639. * @returns the new vector
  85640. */
  85641. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  85642. /**
  85643. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  85644. * This methods computes transformed normalized direction vectors only.
  85645. * @param vector the vector to transform
  85646. * @param transformation the transformation matrix to apply
  85647. * @param result the vector to store the result in
  85648. */
  85649. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85650. /**
  85651. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  85652. * This methods computes transformed normalized direction vectors only.
  85653. * @param x value to transform
  85654. * @param y value to transform
  85655. * @param z value to transform
  85656. * @param w value to transform
  85657. * @param transformation the transformation matrix to apply
  85658. * @param result the vector to store the results in
  85659. */
  85660. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  85661. /**
  85662. * Creates a new Vector4 from a Vector3
  85663. * @param source defines the source data
  85664. * @param w defines the 4th component (default is 0)
  85665. * @returns a new Vector4
  85666. */
  85667. static FromVector3(source: Vector3, w?: number): Vector4;
  85668. }
  85669. /**
  85670. * Class used to store quaternion data
  85671. * @see https://en.wikipedia.org/wiki/Quaternion
  85672. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  85673. */
  85674. export class Quaternion {
  85675. /** @hidden */
  85676. _x: number;
  85677. /** @hidden */
  85678. _y: number;
  85679. /** @hidden */
  85680. _z: number;
  85681. /** @hidden */
  85682. _w: number;
  85683. /** @hidden */
  85684. _isDirty: boolean;
  85685. /** Gets or sets the x coordinate */
  85686. get x(): number;
  85687. set x(value: number);
  85688. /** Gets or sets the y coordinate */
  85689. get y(): number;
  85690. set y(value: number);
  85691. /** Gets or sets the z coordinate */
  85692. get z(): number;
  85693. set z(value: number);
  85694. /** Gets or sets the w coordinate */
  85695. get w(): number;
  85696. set w(value: number);
  85697. /**
  85698. * Creates a new Quaternion from the given floats
  85699. * @param x defines the first component (0 by default)
  85700. * @param y defines the second component (0 by default)
  85701. * @param z defines the third component (0 by default)
  85702. * @param w defines the fourth component (1.0 by default)
  85703. */
  85704. constructor(x?: number, y?: number, z?: number, w?: number);
  85705. /**
  85706. * Gets a string representation for the current quaternion
  85707. * @returns a string with the Quaternion coordinates
  85708. */
  85709. toString(): string;
  85710. /**
  85711. * Gets the class name of the quaternion
  85712. * @returns the string "Quaternion"
  85713. */
  85714. getClassName(): string;
  85715. /**
  85716. * Gets a hash code for this quaternion
  85717. * @returns the quaternion hash code
  85718. */
  85719. getHashCode(): number;
  85720. /**
  85721. * Copy the quaternion to an array
  85722. * @returns a new array populated with 4 elements from the quaternion coordinates
  85723. */
  85724. asArray(): number[];
  85725. /**
  85726. * Check if two quaternions are equals
  85727. * @param otherQuaternion defines the second operand
  85728. * @return true if the current quaternion and the given one coordinates are strictly equals
  85729. */
  85730. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  85731. /**
  85732. * Gets a boolean if two quaternions are equals (using an epsilon value)
  85733. * @param otherQuaternion defines the other quaternion
  85734. * @param epsilon defines the minimal distance to consider equality
  85735. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  85736. */
  85737. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  85738. /**
  85739. * Clone the current quaternion
  85740. * @returns a new quaternion copied from the current one
  85741. */
  85742. clone(): Quaternion;
  85743. /**
  85744. * Copy a quaternion to the current one
  85745. * @param other defines the other quaternion
  85746. * @returns the updated current quaternion
  85747. */
  85748. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  85749. /**
  85750. * Updates the current quaternion with the given float coordinates
  85751. * @param x defines the x coordinate
  85752. * @param y defines the y coordinate
  85753. * @param z defines the z coordinate
  85754. * @param w defines the w coordinate
  85755. * @returns the updated current quaternion
  85756. */
  85757. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  85758. /**
  85759. * Updates the current quaternion from the given float coordinates
  85760. * @param x defines the x coordinate
  85761. * @param y defines the y coordinate
  85762. * @param z defines the z coordinate
  85763. * @param w defines the w coordinate
  85764. * @returns the updated current quaternion
  85765. */
  85766. set(x: number, y: number, z: number, w: number): Quaternion;
  85767. /**
  85768. * Adds two quaternions
  85769. * @param other defines the second operand
  85770. * @returns a new quaternion as the addition result of the given one and the current quaternion
  85771. */
  85772. add(other: DeepImmutable<Quaternion>): Quaternion;
  85773. /**
  85774. * Add a quaternion to the current one
  85775. * @param other defines the quaternion to add
  85776. * @returns the current quaternion
  85777. */
  85778. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  85779. /**
  85780. * Subtract two quaternions
  85781. * @param other defines the second operand
  85782. * @returns a new quaternion as the subtraction result of the given one from the current one
  85783. */
  85784. subtract(other: Quaternion): Quaternion;
  85785. /**
  85786. * Multiplies the current quaternion by a scale factor
  85787. * @param value defines the scale factor
  85788. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  85789. */
  85790. scale(value: number): Quaternion;
  85791. /**
  85792. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  85793. * @param scale defines the scale factor
  85794. * @param result defines the Quaternion object where to store the result
  85795. * @returns the unmodified current quaternion
  85796. */
  85797. scaleToRef(scale: number, result: Quaternion): Quaternion;
  85798. /**
  85799. * Multiplies in place the current quaternion by a scale factor
  85800. * @param value defines the scale factor
  85801. * @returns the current modified quaternion
  85802. */
  85803. scaleInPlace(value: number): Quaternion;
  85804. /**
  85805. * Scale the current quaternion values by a factor and add the result to a given quaternion
  85806. * @param scale defines the scale factor
  85807. * @param result defines the Quaternion object where to store the result
  85808. * @returns the unmodified current quaternion
  85809. */
  85810. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  85811. /**
  85812. * Multiplies two quaternions
  85813. * @param q1 defines the second operand
  85814. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  85815. */
  85816. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  85817. /**
  85818. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  85819. * @param q1 defines the second operand
  85820. * @param result defines the target quaternion
  85821. * @returns the current quaternion
  85822. */
  85823. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  85824. /**
  85825. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  85826. * @param q1 defines the second operand
  85827. * @returns the currentupdated quaternion
  85828. */
  85829. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  85830. /**
  85831. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  85832. * @param ref defines the target quaternion
  85833. * @returns the current quaternion
  85834. */
  85835. conjugateToRef(ref: Quaternion): Quaternion;
  85836. /**
  85837. * Conjugates in place (1-q) the current quaternion
  85838. * @returns the current updated quaternion
  85839. */
  85840. conjugateInPlace(): Quaternion;
  85841. /**
  85842. * Conjugates in place (1-q) the current quaternion
  85843. * @returns a new quaternion
  85844. */
  85845. conjugate(): Quaternion;
  85846. /**
  85847. * Gets length of current quaternion
  85848. * @returns the quaternion length (float)
  85849. */
  85850. length(): number;
  85851. /**
  85852. * Normalize in place the current quaternion
  85853. * @returns the current updated quaternion
  85854. */
  85855. normalize(): Quaternion;
  85856. /**
  85857. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85858. * @param order is a reserved parameter and is ignored for now
  85859. * @returns a new Vector3 containing the Euler angles
  85860. */
  85861. toEulerAngles(order?: string): Vector3;
  85862. /**
  85863. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85864. * @param result defines the vector which will be filled with the Euler angles
  85865. * @returns the current unchanged quaternion
  85866. */
  85867. toEulerAnglesToRef(result: Vector3): Quaternion;
  85868. /**
  85869. * Updates the given rotation matrix with the current quaternion values
  85870. * @param result defines the target matrix
  85871. * @returns the current unchanged quaternion
  85872. */
  85873. toRotationMatrix(result: Matrix): Quaternion;
  85874. /**
  85875. * Updates the current quaternion from the given rotation matrix values
  85876. * @param matrix defines the source matrix
  85877. * @returns the current updated quaternion
  85878. */
  85879. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85880. /**
  85881. * Creates a new quaternion from a rotation matrix
  85882. * @param matrix defines the source matrix
  85883. * @returns a new quaternion created from the given rotation matrix values
  85884. */
  85885. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85886. /**
  85887. * Updates the given quaternion with the given rotation matrix values
  85888. * @param matrix defines the source matrix
  85889. * @param result defines the target quaternion
  85890. */
  85891. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85892. /**
  85893. * Returns the dot product (float) between the quaternions "left" and "right"
  85894. * @param left defines the left operand
  85895. * @param right defines the right operand
  85896. * @returns the dot product
  85897. */
  85898. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85899. /**
  85900. * Checks if the two quaternions are close to each other
  85901. * @param quat0 defines the first quaternion to check
  85902. * @param quat1 defines the second quaternion to check
  85903. * @returns true if the two quaternions are close to each other
  85904. */
  85905. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85906. /**
  85907. * Creates an empty quaternion
  85908. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85909. */
  85910. static Zero(): Quaternion;
  85911. /**
  85912. * Inverse a given quaternion
  85913. * @param q defines the source quaternion
  85914. * @returns a new quaternion as the inverted current quaternion
  85915. */
  85916. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85917. /**
  85918. * Inverse a given quaternion
  85919. * @param q defines the source quaternion
  85920. * @param result the quaternion the result will be stored in
  85921. * @returns the result quaternion
  85922. */
  85923. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85924. /**
  85925. * Creates an identity quaternion
  85926. * @returns the identity quaternion
  85927. */
  85928. static Identity(): Quaternion;
  85929. /**
  85930. * Gets a boolean indicating if the given quaternion is identity
  85931. * @param quaternion defines the quaternion to check
  85932. * @returns true if the quaternion is identity
  85933. */
  85934. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85935. /**
  85936. * Creates a quaternion from a rotation around an axis
  85937. * @param axis defines the axis to use
  85938. * @param angle defines the angle to use
  85939. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85940. */
  85941. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85942. /**
  85943. * Creates a rotation around an axis and stores it into the given quaternion
  85944. * @param axis defines the axis to use
  85945. * @param angle defines the angle to use
  85946. * @param result defines the target quaternion
  85947. * @returns the target quaternion
  85948. */
  85949. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85950. /**
  85951. * Creates a new quaternion from data stored into an array
  85952. * @param array defines the data source
  85953. * @param offset defines the offset in the source array where the data starts
  85954. * @returns a new quaternion
  85955. */
  85956. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85957. /**
  85958. * Updates the given quaternion "result" from the starting index of the given array.
  85959. * @param array the array to pull values from
  85960. * @param offset the offset into the array to start at
  85961. * @param result the quaternion to store the result in
  85962. */
  85963. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85964. /**
  85965. * Create a quaternion from Euler rotation angles
  85966. * @param x Pitch
  85967. * @param y Yaw
  85968. * @param z Roll
  85969. * @returns the new Quaternion
  85970. */
  85971. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85972. /**
  85973. * Updates a quaternion from Euler rotation angles
  85974. * @param x Pitch
  85975. * @param y Yaw
  85976. * @param z Roll
  85977. * @param result the quaternion to store the result
  85978. * @returns the updated quaternion
  85979. */
  85980. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85981. /**
  85982. * Create a quaternion from Euler rotation vector
  85983. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85984. * @returns the new Quaternion
  85985. */
  85986. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85987. /**
  85988. * Updates a quaternion from Euler rotation vector
  85989. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85990. * @param result the quaternion to store the result
  85991. * @returns the updated quaternion
  85992. */
  85993. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85994. /**
  85995. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85996. * @param yaw defines the rotation around Y axis
  85997. * @param pitch defines the rotation around X axis
  85998. * @param roll defines the rotation around Z axis
  85999. * @returns the new quaternion
  86000. */
  86001. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  86002. /**
  86003. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  86004. * @param yaw defines the rotation around Y axis
  86005. * @param pitch defines the rotation around X axis
  86006. * @param roll defines the rotation around Z axis
  86007. * @param result defines the target quaternion
  86008. */
  86009. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  86010. /**
  86011. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  86012. * @param alpha defines the rotation around first axis
  86013. * @param beta defines the rotation around second axis
  86014. * @param gamma defines the rotation around third axis
  86015. * @returns the new quaternion
  86016. */
  86017. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  86018. /**
  86019. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  86020. * @param alpha defines the rotation around first axis
  86021. * @param beta defines the rotation around second axis
  86022. * @param gamma defines the rotation around third axis
  86023. * @param result defines the target quaternion
  86024. */
  86025. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  86026. /**
  86027. * 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)
  86028. * @param axis1 defines the first axis
  86029. * @param axis2 defines the second axis
  86030. * @param axis3 defines the third axis
  86031. * @returns the new quaternion
  86032. */
  86033. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  86034. /**
  86035. * 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
  86036. * @param axis1 defines the first axis
  86037. * @param axis2 defines the second axis
  86038. * @param axis3 defines the third axis
  86039. * @param ref defines the target quaternion
  86040. */
  86041. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  86042. /**
  86043. * Interpolates between two quaternions
  86044. * @param left defines first quaternion
  86045. * @param right defines second quaternion
  86046. * @param amount defines the gradient to use
  86047. * @returns the new interpolated quaternion
  86048. */
  86049. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  86050. /**
  86051. * Interpolates between two quaternions and stores it into a target quaternion
  86052. * @param left defines first quaternion
  86053. * @param right defines second quaternion
  86054. * @param amount defines the gradient to use
  86055. * @param result defines the target quaternion
  86056. */
  86057. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  86058. /**
  86059. * Interpolate between two quaternions using Hermite interpolation
  86060. * @param value1 defines first quaternion
  86061. * @param tangent1 defines the incoming tangent
  86062. * @param value2 defines second quaternion
  86063. * @param tangent2 defines the outgoing tangent
  86064. * @param amount defines the target quaternion
  86065. * @returns the new interpolated quaternion
  86066. */
  86067. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  86068. }
  86069. /**
  86070. * Class used to store matrix data (4x4)
  86071. */
  86072. export class Matrix {
  86073. /**
  86074. * Gets the precision of matrix computations
  86075. */
  86076. static get Use64Bits(): boolean;
  86077. private static _updateFlagSeed;
  86078. private static _identityReadOnly;
  86079. private _isIdentity;
  86080. private _isIdentityDirty;
  86081. private _isIdentity3x2;
  86082. private _isIdentity3x2Dirty;
  86083. /**
  86084. * Gets the update flag of the matrix which is an unique number for the matrix.
  86085. * It will be incremented every time the matrix data change.
  86086. * You can use it to speed the comparison between two versions of the same matrix.
  86087. */
  86088. updateFlag: number;
  86089. private readonly _m;
  86090. /**
  86091. * Gets the internal data of the matrix
  86092. */
  86093. get m(): DeepImmutable<Float32Array | Array<number>>;
  86094. /** @hidden */
  86095. _markAsUpdated(): void;
  86096. /** @hidden */
  86097. private _updateIdentityStatus;
  86098. /**
  86099. * Creates an empty matrix (filled with zeros)
  86100. */
  86101. constructor();
  86102. /**
  86103. * Check if the current matrix is identity
  86104. * @returns true is the matrix is the identity matrix
  86105. */
  86106. isIdentity(): boolean;
  86107. /**
  86108. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  86109. * @returns true is the matrix is the identity matrix
  86110. */
  86111. isIdentityAs3x2(): boolean;
  86112. /**
  86113. * Gets the determinant of the matrix
  86114. * @returns the matrix determinant
  86115. */
  86116. determinant(): number;
  86117. /**
  86118. * Returns the matrix as a Float32Array or Array<number>
  86119. * @returns the matrix underlying array
  86120. */
  86121. toArray(): DeepImmutable<Float32Array | Array<number>>;
  86122. /**
  86123. * Returns the matrix as a Float32Array or Array<number>
  86124. * @returns the matrix underlying array.
  86125. */
  86126. asArray(): DeepImmutable<Float32Array | Array<number>>;
  86127. /**
  86128. * Inverts the current matrix in place
  86129. * @returns the current inverted matrix
  86130. */
  86131. invert(): Matrix;
  86132. /**
  86133. * Sets all the matrix elements to zero
  86134. * @returns the current matrix
  86135. */
  86136. reset(): Matrix;
  86137. /**
  86138. * Adds the current matrix with a second one
  86139. * @param other defines the matrix to add
  86140. * @returns a new matrix as the addition of the current matrix and the given one
  86141. */
  86142. add(other: DeepImmutable<Matrix>): Matrix;
  86143. /**
  86144. * Sets the given matrix "result" to the addition of the current matrix and the given one
  86145. * @param other defines the matrix to add
  86146. * @param result defines the target matrix
  86147. * @returns the current matrix
  86148. */
  86149. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86150. /**
  86151. * Adds in place the given matrix to the current matrix
  86152. * @param other defines the second operand
  86153. * @returns the current updated matrix
  86154. */
  86155. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  86156. /**
  86157. * Sets the given matrix to the current inverted Matrix
  86158. * @param other defines the target matrix
  86159. * @returns the unmodified current matrix
  86160. */
  86161. invertToRef(other: Matrix): Matrix;
  86162. /**
  86163. * add a value at the specified position in the current Matrix
  86164. * @param index the index of the value within the matrix. between 0 and 15.
  86165. * @param value the value to be added
  86166. * @returns the current updated matrix
  86167. */
  86168. addAtIndex(index: number, value: number): Matrix;
  86169. /**
  86170. * mutiply the specified position in the current Matrix by a value
  86171. * @param index the index of the value within the matrix. between 0 and 15.
  86172. * @param value the value to be added
  86173. * @returns the current updated matrix
  86174. */
  86175. multiplyAtIndex(index: number, value: number): Matrix;
  86176. /**
  86177. * Inserts the translation vector (using 3 floats) in the current matrix
  86178. * @param x defines the 1st component of the translation
  86179. * @param y defines the 2nd component of the translation
  86180. * @param z defines the 3rd component of the translation
  86181. * @returns the current updated matrix
  86182. */
  86183. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86184. /**
  86185. * Adds the translation vector (using 3 floats) in the current matrix
  86186. * @param x defines the 1st component of the translation
  86187. * @param y defines the 2nd component of the translation
  86188. * @param z defines the 3rd component of the translation
  86189. * @returns the current updated matrix
  86190. */
  86191. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  86192. /**
  86193. * Inserts the translation vector in the current matrix
  86194. * @param vector3 defines the translation to insert
  86195. * @returns the current updated matrix
  86196. */
  86197. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  86198. /**
  86199. * Gets the translation value of the current matrix
  86200. * @returns a new Vector3 as the extracted translation from the matrix
  86201. */
  86202. getTranslation(): Vector3;
  86203. /**
  86204. * Fill a Vector3 with the extracted translation from the matrix
  86205. * @param result defines the Vector3 where to store the translation
  86206. * @returns the current matrix
  86207. */
  86208. getTranslationToRef(result: Vector3): Matrix;
  86209. /**
  86210. * Remove rotation and scaling part from the matrix
  86211. * @returns the updated matrix
  86212. */
  86213. removeRotationAndScaling(): Matrix;
  86214. /**
  86215. * Multiply two matrices
  86216. * @param other defines the second operand
  86217. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  86218. */
  86219. multiply(other: DeepImmutable<Matrix>): Matrix;
  86220. /**
  86221. * Copy the current matrix from the given one
  86222. * @param other defines the source matrix
  86223. * @returns the current updated matrix
  86224. */
  86225. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  86226. /**
  86227. * Populates the given array from the starting index with the current matrix values
  86228. * @param array defines the target array
  86229. * @param offset defines the offset in the target array where to start storing values
  86230. * @returns the current matrix
  86231. */
  86232. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  86233. /**
  86234. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  86235. * @param other defines the second operand
  86236. * @param result defines the matrix where to store the multiplication
  86237. * @returns the current matrix
  86238. */
  86239. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  86240. /**
  86241. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  86242. * @param other defines the second operand
  86243. * @param result defines the array where to store the multiplication
  86244. * @param offset defines the offset in the target array where to start storing values
  86245. * @returns the current matrix
  86246. */
  86247. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  86248. /**
  86249. * Check equality between this matrix and a second one
  86250. * @param value defines the second matrix to compare
  86251. * @returns true is the current matrix and the given one values are strictly equal
  86252. */
  86253. equals(value: DeepImmutable<Matrix>): boolean;
  86254. /**
  86255. * Clone the current matrix
  86256. * @returns a new matrix from the current matrix
  86257. */
  86258. clone(): Matrix;
  86259. /**
  86260. * Returns the name of the current matrix class
  86261. * @returns the string "Matrix"
  86262. */
  86263. getClassName(): string;
  86264. /**
  86265. * Gets the hash code of the current matrix
  86266. * @returns the hash code
  86267. */
  86268. getHashCode(): number;
  86269. /**
  86270. * Decomposes the current Matrix into a translation, rotation and scaling components
  86271. * @param scale defines the scale vector3 given as a reference to update
  86272. * @param rotation defines the rotation quaternion given as a reference to update
  86273. * @param translation defines the translation vector3 given as a reference to update
  86274. * @returns true if operation was successful
  86275. */
  86276. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  86277. /**
  86278. * Gets specific row of the matrix
  86279. * @param index defines the number of the row to get
  86280. * @returns the index-th row of the current matrix as a new Vector4
  86281. */
  86282. getRow(index: number): Nullable<Vector4>;
  86283. /**
  86284. * Sets the index-th row of the current matrix to the vector4 values
  86285. * @param index defines the number of the row to set
  86286. * @param row defines the target vector4
  86287. * @returns the updated current matrix
  86288. */
  86289. setRow(index: number, row: Vector4): Matrix;
  86290. /**
  86291. * Compute the transpose of the matrix
  86292. * @returns the new transposed matrix
  86293. */
  86294. transpose(): Matrix;
  86295. /**
  86296. * Compute the transpose of the matrix and store it in a given matrix
  86297. * @param result defines the target matrix
  86298. * @returns the current matrix
  86299. */
  86300. transposeToRef(result: Matrix): Matrix;
  86301. /**
  86302. * Sets the index-th row of the current matrix with the given 4 x float values
  86303. * @param index defines the row index
  86304. * @param x defines the x component to set
  86305. * @param y defines the y component to set
  86306. * @param z defines the z component to set
  86307. * @param w defines the w component to set
  86308. * @returns the updated current matrix
  86309. */
  86310. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  86311. /**
  86312. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  86313. * @param scale defines the scale factor
  86314. * @returns a new matrix
  86315. */
  86316. scale(scale: number): Matrix;
  86317. /**
  86318. * Scale the current matrix values by a factor to a given result matrix
  86319. * @param scale defines the scale factor
  86320. * @param result defines the matrix to store the result
  86321. * @returns the current matrix
  86322. */
  86323. scaleToRef(scale: number, result: Matrix): Matrix;
  86324. /**
  86325. * Scale the current matrix values by a factor and add the result to a given matrix
  86326. * @param scale defines the scale factor
  86327. * @param result defines the Matrix to store the result
  86328. * @returns the current matrix
  86329. */
  86330. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  86331. /**
  86332. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  86333. * @param ref matrix to store the result
  86334. */
  86335. toNormalMatrix(ref: Matrix): void;
  86336. /**
  86337. * Gets only rotation part of the current matrix
  86338. * @returns a new matrix sets to the extracted rotation matrix from the current one
  86339. */
  86340. getRotationMatrix(): Matrix;
  86341. /**
  86342. * Extracts the rotation matrix from the current one and sets it as the given "result"
  86343. * @param result defines the target matrix to store data to
  86344. * @returns the current matrix
  86345. */
  86346. getRotationMatrixToRef(result: Matrix): Matrix;
  86347. /**
  86348. * Toggles model matrix from being right handed to left handed in place and vice versa
  86349. */
  86350. toggleModelMatrixHandInPlace(): void;
  86351. /**
  86352. * Toggles projection matrix from being right handed to left handed in place and vice versa
  86353. */
  86354. toggleProjectionMatrixHandInPlace(): void;
  86355. /**
  86356. * Creates a matrix from an array
  86357. * @param array defines the source array
  86358. * @param offset defines an offset in the source array
  86359. * @returns a new Matrix set from the starting index of the given array
  86360. */
  86361. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  86362. /**
  86363. * Copy the content of an array into a given matrix
  86364. * @param array defines the source array
  86365. * @param offset defines an offset in the source array
  86366. * @param result defines the target matrix
  86367. */
  86368. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  86369. /**
  86370. * Stores an array into a matrix after having multiplied each component by a given factor
  86371. * @param array defines the source array
  86372. * @param offset defines the offset in the source array
  86373. * @param scale defines the scaling factor
  86374. * @param result defines the target matrix
  86375. */
  86376. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  86377. /**
  86378. * Gets an identity matrix that must not be updated
  86379. */
  86380. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  86381. /**
  86382. * Stores a list of values (16) inside a given matrix
  86383. * @param initialM11 defines 1st value of 1st row
  86384. * @param initialM12 defines 2nd value of 1st row
  86385. * @param initialM13 defines 3rd value of 1st row
  86386. * @param initialM14 defines 4th value of 1st row
  86387. * @param initialM21 defines 1st value of 2nd row
  86388. * @param initialM22 defines 2nd value of 2nd row
  86389. * @param initialM23 defines 3rd value of 2nd row
  86390. * @param initialM24 defines 4th value of 2nd row
  86391. * @param initialM31 defines 1st value of 3rd row
  86392. * @param initialM32 defines 2nd value of 3rd row
  86393. * @param initialM33 defines 3rd value of 3rd row
  86394. * @param initialM34 defines 4th value of 3rd row
  86395. * @param initialM41 defines 1st value of 4th row
  86396. * @param initialM42 defines 2nd value of 4th row
  86397. * @param initialM43 defines 3rd value of 4th row
  86398. * @param initialM44 defines 4th value of 4th row
  86399. * @param result defines the target matrix
  86400. */
  86401. 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;
  86402. /**
  86403. * Creates new matrix from a list of values (16)
  86404. * @param initialM11 defines 1st value of 1st row
  86405. * @param initialM12 defines 2nd value of 1st row
  86406. * @param initialM13 defines 3rd value of 1st row
  86407. * @param initialM14 defines 4th value of 1st row
  86408. * @param initialM21 defines 1st value of 2nd row
  86409. * @param initialM22 defines 2nd value of 2nd row
  86410. * @param initialM23 defines 3rd value of 2nd row
  86411. * @param initialM24 defines 4th value of 2nd row
  86412. * @param initialM31 defines 1st value of 3rd row
  86413. * @param initialM32 defines 2nd value of 3rd row
  86414. * @param initialM33 defines 3rd value of 3rd row
  86415. * @param initialM34 defines 4th value of 3rd row
  86416. * @param initialM41 defines 1st value of 4th row
  86417. * @param initialM42 defines 2nd value of 4th row
  86418. * @param initialM43 defines 3rd value of 4th row
  86419. * @param initialM44 defines 4th value of 4th row
  86420. * @returns the new matrix
  86421. */
  86422. 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;
  86423. /**
  86424. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86425. * @param scale defines the scale vector3
  86426. * @param rotation defines the rotation quaternion
  86427. * @param translation defines the translation vector3
  86428. * @returns a new matrix
  86429. */
  86430. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  86431. /**
  86432. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  86433. * @param scale defines the scale vector3
  86434. * @param rotation defines the rotation quaternion
  86435. * @param translation defines the translation vector3
  86436. * @param result defines the target matrix
  86437. */
  86438. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  86439. /**
  86440. * Creates a new identity matrix
  86441. * @returns a new identity matrix
  86442. */
  86443. static Identity(): Matrix;
  86444. /**
  86445. * Creates a new identity matrix and stores the result in a given matrix
  86446. * @param result defines the target matrix
  86447. */
  86448. static IdentityToRef(result: Matrix): void;
  86449. /**
  86450. * Creates a new zero matrix
  86451. * @returns a new zero matrix
  86452. */
  86453. static Zero(): Matrix;
  86454. /**
  86455. * Creates a new rotation matrix for "angle" radians around the X axis
  86456. * @param angle defines the angle (in radians) to use
  86457. * @return the new matrix
  86458. */
  86459. static RotationX(angle: number): Matrix;
  86460. /**
  86461. * Creates a new matrix as the invert of a given matrix
  86462. * @param source defines the source matrix
  86463. * @returns the new matrix
  86464. */
  86465. static Invert(source: DeepImmutable<Matrix>): Matrix;
  86466. /**
  86467. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  86468. * @param angle defines the angle (in radians) to use
  86469. * @param result defines the target matrix
  86470. */
  86471. static RotationXToRef(angle: number, result: Matrix): void;
  86472. /**
  86473. * Creates a new rotation matrix for "angle" radians around the Y axis
  86474. * @param angle defines the angle (in radians) to use
  86475. * @return the new matrix
  86476. */
  86477. static RotationY(angle: number): Matrix;
  86478. /**
  86479. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  86480. * @param angle defines the angle (in radians) to use
  86481. * @param result defines the target matrix
  86482. */
  86483. static RotationYToRef(angle: number, result: Matrix): void;
  86484. /**
  86485. * Creates a new rotation matrix for "angle" radians around the Z axis
  86486. * @param angle defines the angle (in radians) to use
  86487. * @return the new matrix
  86488. */
  86489. static RotationZ(angle: number): Matrix;
  86490. /**
  86491. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  86492. * @param angle defines the angle (in radians) to use
  86493. * @param result defines the target matrix
  86494. */
  86495. static RotationZToRef(angle: number, result: Matrix): void;
  86496. /**
  86497. * Creates a new rotation matrix for "angle" radians around the given axis
  86498. * @param axis defines the axis to use
  86499. * @param angle defines the angle (in radians) to use
  86500. * @return the new matrix
  86501. */
  86502. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  86503. /**
  86504. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  86505. * @param axis defines the axis to use
  86506. * @param angle defines the angle (in radians) to use
  86507. * @param result defines the target matrix
  86508. */
  86509. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  86510. /**
  86511. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  86512. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  86513. * @param from defines the vector to align
  86514. * @param to defines the vector to align to
  86515. * @param result defines the target matrix
  86516. */
  86517. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  86518. /**
  86519. * Creates a rotation matrix
  86520. * @param yaw defines the yaw angle in radians (Y axis)
  86521. * @param pitch defines the pitch angle in radians (X axis)
  86522. * @param roll defines the roll angle in radians (Z axis)
  86523. * @returns the new rotation matrix
  86524. */
  86525. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  86526. /**
  86527. * Creates a rotation matrix and stores it in a given matrix
  86528. * @param yaw defines the yaw angle in radians (Y axis)
  86529. * @param pitch defines the pitch angle in radians (X axis)
  86530. * @param roll defines the roll angle in radians (Z axis)
  86531. * @param result defines the target matrix
  86532. */
  86533. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  86534. /**
  86535. * Creates a scaling matrix
  86536. * @param x defines the scale factor on X axis
  86537. * @param y defines the scale factor on Y axis
  86538. * @param z defines the scale factor on Z axis
  86539. * @returns the new matrix
  86540. */
  86541. static Scaling(x: number, y: number, z: number): Matrix;
  86542. /**
  86543. * Creates a scaling matrix and stores it in a given matrix
  86544. * @param x defines the scale factor on X axis
  86545. * @param y defines the scale factor on Y axis
  86546. * @param z defines the scale factor on Z axis
  86547. * @param result defines the target matrix
  86548. */
  86549. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  86550. /**
  86551. * Creates a translation matrix
  86552. * @param x defines the translation on X axis
  86553. * @param y defines the translation on Y axis
  86554. * @param z defines the translationon Z axis
  86555. * @returns the new matrix
  86556. */
  86557. static Translation(x: number, y: number, z: number): Matrix;
  86558. /**
  86559. * Creates a translation matrix and stores it in a given matrix
  86560. * @param x defines the translation on X axis
  86561. * @param y defines the translation on Y axis
  86562. * @param z defines the translationon Z axis
  86563. * @param result defines the target matrix
  86564. */
  86565. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  86566. /**
  86567. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86568. * @param startValue defines the start value
  86569. * @param endValue defines the end value
  86570. * @param gradient defines the gradient factor
  86571. * @returns the new matrix
  86572. */
  86573. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86574. /**
  86575. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  86576. * @param startValue defines the start value
  86577. * @param endValue defines the end value
  86578. * @param gradient defines the gradient factor
  86579. * @param result defines the Matrix object where to store data
  86580. */
  86581. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86582. /**
  86583. * Builds a new matrix whose values are computed by:
  86584. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86585. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86586. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86587. * @param startValue defines the first matrix
  86588. * @param endValue defines the second matrix
  86589. * @param gradient defines the gradient between the two matrices
  86590. * @returns the new matrix
  86591. */
  86592. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  86593. /**
  86594. * Update a matrix to values which are computed by:
  86595. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  86596. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  86597. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  86598. * @param startValue defines the first matrix
  86599. * @param endValue defines the second matrix
  86600. * @param gradient defines the gradient between the two matrices
  86601. * @param result defines the target matrix
  86602. */
  86603. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  86604. /**
  86605. * 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"
  86606. * This function works in left handed mode
  86607. * @param eye defines the final position of the entity
  86608. * @param target defines where the entity should look at
  86609. * @param up defines the up vector for the entity
  86610. * @returns the new matrix
  86611. */
  86612. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86613. /**
  86614. * 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".
  86615. * This function works in left handed mode
  86616. * @param eye defines the final position of the entity
  86617. * @param target defines where the entity should look at
  86618. * @param up defines the up vector for the entity
  86619. * @param result defines the target matrix
  86620. */
  86621. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86622. /**
  86623. * 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"
  86624. * This function works in right handed mode
  86625. * @param eye defines the final position of the entity
  86626. * @param target defines where the entity should look at
  86627. * @param up defines the up vector for the entity
  86628. * @returns the new matrix
  86629. */
  86630. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  86631. /**
  86632. * 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".
  86633. * This function works in right handed mode
  86634. * @param eye defines the final position of the entity
  86635. * @param target defines where the entity should look at
  86636. * @param up defines the up vector for the entity
  86637. * @param result defines the target matrix
  86638. */
  86639. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  86640. /**
  86641. * Create a left-handed orthographic projection matrix
  86642. * @param width defines the viewport width
  86643. * @param height defines the viewport height
  86644. * @param znear defines the near clip plane
  86645. * @param zfar defines the far clip plane
  86646. * @returns a new matrix as a left-handed orthographic projection matrix
  86647. */
  86648. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86649. /**
  86650. * Store a left-handed orthographic projection to a given matrix
  86651. * @param width defines the viewport width
  86652. * @param height defines the viewport height
  86653. * @param znear defines the near clip plane
  86654. * @param zfar defines the far clip plane
  86655. * @param result defines the target matrix
  86656. */
  86657. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  86658. /**
  86659. * Create a left-handed orthographic projection matrix
  86660. * @param left defines the viewport left coordinate
  86661. * @param right defines the viewport right coordinate
  86662. * @param bottom defines the viewport bottom coordinate
  86663. * @param top defines the viewport top coordinate
  86664. * @param znear defines the near clip plane
  86665. * @param zfar defines the far clip plane
  86666. * @returns a new matrix as a left-handed orthographic projection matrix
  86667. */
  86668. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86669. /**
  86670. * Stores a left-handed orthographic projection into a given matrix
  86671. * @param left defines the viewport left coordinate
  86672. * @param right defines the viewport right coordinate
  86673. * @param bottom defines the viewport bottom coordinate
  86674. * @param top defines the viewport top coordinate
  86675. * @param znear defines the near clip plane
  86676. * @param zfar defines the far clip plane
  86677. * @param result defines the target matrix
  86678. */
  86679. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86680. /**
  86681. * Creates a right-handed orthographic projection matrix
  86682. * @param left defines the viewport left coordinate
  86683. * @param right defines the viewport right coordinate
  86684. * @param bottom defines the viewport bottom coordinate
  86685. * @param top defines the viewport top coordinate
  86686. * @param znear defines the near clip plane
  86687. * @param zfar defines the far clip plane
  86688. * @returns a new matrix as a right-handed orthographic projection matrix
  86689. */
  86690. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  86691. /**
  86692. * Stores a right-handed orthographic projection into a given matrix
  86693. * @param left defines the viewport left coordinate
  86694. * @param right defines the viewport right coordinate
  86695. * @param bottom defines the viewport bottom coordinate
  86696. * @param top defines the viewport top coordinate
  86697. * @param znear defines the near clip plane
  86698. * @param zfar defines the far clip plane
  86699. * @param result defines the target matrix
  86700. */
  86701. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  86702. /**
  86703. * Creates a left-handed perspective projection matrix
  86704. * @param width defines the viewport width
  86705. * @param height defines the viewport height
  86706. * @param znear defines the near clip plane
  86707. * @param zfar defines the far clip plane
  86708. * @returns a new matrix as a left-handed perspective projection matrix
  86709. */
  86710. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  86711. /**
  86712. * Creates a left-handed perspective projection matrix
  86713. * @param fov defines the horizontal field of view
  86714. * @param aspect defines the aspect ratio
  86715. * @param znear defines the near clip plane
  86716. * @param zfar defines the far clip plane
  86717. * @returns a new matrix as a left-handed perspective projection matrix
  86718. */
  86719. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86720. /**
  86721. * Stores a left-handed perspective projection into a given matrix
  86722. * @param fov defines the horizontal field of view
  86723. * @param aspect defines the aspect ratio
  86724. * @param znear defines the near clip plane
  86725. * @param zfar defines the far clip plane
  86726. * @param result defines the target matrix
  86727. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86728. */
  86729. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86730. /**
  86731. * Stores a left-handed perspective projection into a given matrix with depth reversed
  86732. * @param fov defines the horizontal field of view
  86733. * @param aspect defines the aspect ratio
  86734. * @param znear defines the near clip plane
  86735. * @param zfar not used as infinity is used as far clip
  86736. * @param result defines the target matrix
  86737. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86738. */
  86739. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86740. /**
  86741. * Creates a right-handed perspective projection matrix
  86742. * @param fov defines the horizontal field of view
  86743. * @param aspect defines the aspect ratio
  86744. * @param znear defines the near clip plane
  86745. * @param zfar defines the far clip plane
  86746. * @returns a new matrix as a right-handed perspective projection matrix
  86747. */
  86748. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  86749. /**
  86750. * Stores a right-handed perspective projection into a given matrix
  86751. * @param fov defines the horizontal field of view
  86752. * @param aspect defines the aspect ratio
  86753. * @param znear defines the near clip plane
  86754. * @param zfar defines the far clip plane
  86755. * @param result defines the target matrix
  86756. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86757. */
  86758. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86759. /**
  86760. * Stores a right-handed perspective projection into a given matrix
  86761. * @param fov defines the horizontal field of view
  86762. * @param aspect defines the aspect ratio
  86763. * @param znear defines the near clip plane
  86764. * @param zfar not used as infinity is used as far clip
  86765. * @param result defines the target matrix
  86766. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  86767. */
  86768. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  86769. /**
  86770. * Stores a perspective projection for WebVR info a given matrix
  86771. * @param fov defines the field of view
  86772. * @param znear defines the near clip plane
  86773. * @param zfar defines the far clip plane
  86774. * @param result defines the target matrix
  86775. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  86776. */
  86777. static PerspectiveFovWebVRToRef(fov: {
  86778. upDegrees: number;
  86779. downDegrees: number;
  86780. leftDegrees: number;
  86781. rightDegrees: number;
  86782. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  86783. /**
  86784. * Computes a complete transformation matrix
  86785. * @param viewport defines the viewport to use
  86786. * @param world defines the world matrix
  86787. * @param view defines the view matrix
  86788. * @param projection defines the projection matrix
  86789. * @param zmin defines the near clip plane
  86790. * @param zmax defines the far clip plane
  86791. * @returns the transformation matrix
  86792. */
  86793. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  86794. /**
  86795. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  86796. * @param matrix defines the matrix to use
  86797. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  86798. */
  86799. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86800. /**
  86801. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  86802. * @param matrix defines the matrix to use
  86803. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  86804. */
  86805. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  86806. /**
  86807. * Compute the transpose of a given matrix
  86808. * @param matrix defines the matrix to transpose
  86809. * @returns the new matrix
  86810. */
  86811. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  86812. /**
  86813. * Compute the transpose of a matrix and store it in a target matrix
  86814. * @param matrix defines the matrix to transpose
  86815. * @param result defines the target matrix
  86816. */
  86817. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  86818. /**
  86819. * Computes a reflection matrix from a plane
  86820. * @param plane defines the reflection plane
  86821. * @returns a new matrix
  86822. */
  86823. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  86824. /**
  86825. * Computes a reflection matrix from a plane
  86826. * @param plane defines the reflection plane
  86827. * @param result defines the target matrix
  86828. */
  86829. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  86830. /**
  86831. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  86832. * @param xaxis defines the value of the 1st axis
  86833. * @param yaxis defines the value of the 2nd axis
  86834. * @param zaxis defines the value of the 3rd axis
  86835. * @param result defines the target matrix
  86836. */
  86837. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  86838. /**
  86839. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  86840. * @param quat defines the quaternion to use
  86841. * @param result defines the target matrix
  86842. */
  86843. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86844. }
  86845. /**
  86846. * @hidden
  86847. */
  86848. export class TmpVectors {
  86849. static Vector2: Vector2[];
  86850. static Vector3: Vector3[];
  86851. static Vector4: Vector4[];
  86852. static Quaternion: Quaternion[];
  86853. static Matrix: Matrix[];
  86854. }
  86855. }
  86856. declare module BABYLON {
  86857. /**
  86858. * Defines potential orientation for back face culling
  86859. */
  86860. export enum Orientation {
  86861. /**
  86862. * Clockwise
  86863. */
  86864. CW = 0,
  86865. /** Counter clockwise */
  86866. CCW = 1
  86867. }
  86868. /** Class used to represent a Bezier curve */
  86869. export class BezierCurve {
  86870. /**
  86871. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86872. * @param t defines the time
  86873. * @param x1 defines the left coordinate on X axis
  86874. * @param y1 defines the left coordinate on Y axis
  86875. * @param x2 defines the right coordinate on X axis
  86876. * @param y2 defines the right coordinate on Y axis
  86877. * @returns the interpolated value
  86878. */
  86879. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86880. }
  86881. /**
  86882. * Defines angle representation
  86883. */
  86884. export class Angle {
  86885. private _radians;
  86886. /**
  86887. * Creates an Angle object of "radians" radians (float).
  86888. * @param radians the angle in radians
  86889. */
  86890. constructor(radians: number);
  86891. /**
  86892. * Get value in degrees
  86893. * @returns the Angle value in degrees (float)
  86894. */
  86895. degrees(): number;
  86896. /**
  86897. * Get value in radians
  86898. * @returns the Angle value in radians (float)
  86899. */
  86900. radians(): number;
  86901. /**
  86902. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86903. * @param a defines first point as the origin
  86904. * @param b defines point
  86905. * @returns a new Angle
  86906. */
  86907. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86908. /**
  86909. * Gets a new Angle object from the given float in radians
  86910. * @param radians defines the angle value in radians
  86911. * @returns a new Angle
  86912. */
  86913. static FromRadians(radians: number): Angle;
  86914. /**
  86915. * Gets a new Angle object from the given float in degrees
  86916. * @param degrees defines the angle value in degrees
  86917. * @returns a new Angle
  86918. */
  86919. static FromDegrees(degrees: number): Angle;
  86920. }
  86921. /**
  86922. * This represents an arc in a 2d space.
  86923. */
  86924. export class Arc2 {
  86925. /** Defines the start point of the arc */
  86926. startPoint: Vector2;
  86927. /** Defines the mid point of the arc */
  86928. midPoint: Vector2;
  86929. /** Defines the end point of the arc */
  86930. endPoint: Vector2;
  86931. /**
  86932. * Defines the center point of the arc.
  86933. */
  86934. centerPoint: Vector2;
  86935. /**
  86936. * Defines the radius of the arc.
  86937. */
  86938. radius: number;
  86939. /**
  86940. * Defines the angle of the arc (from mid point to end point).
  86941. */
  86942. angle: Angle;
  86943. /**
  86944. * Defines the start angle of the arc (from start point to middle point).
  86945. */
  86946. startAngle: Angle;
  86947. /**
  86948. * Defines the orientation of the arc (clock wise/counter clock wise).
  86949. */
  86950. orientation: Orientation;
  86951. /**
  86952. * Creates an Arc object from the three given points : start, middle and end.
  86953. * @param startPoint Defines the start point of the arc
  86954. * @param midPoint Defines the midlle point of the arc
  86955. * @param endPoint Defines the end point of the arc
  86956. */
  86957. constructor(
  86958. /** Defines the start point of the arc */
  86959. startPoint: Vector2,
  86960. /** Defines the mid point of the arc */
  86961. midPoint: Vector2,
  86962. /** Defines the end point of the arc */
  86963. endPoint: Vector2);
  86964. }
  86965. /**
  86966. * Represents a 2D path made up of multiple 2D points
  86967. */
  86968. export class Path2 {
  86969. private _points;
  86970. private _length;
  86971. /**
  86972. * If the path start and end point are the same
  86973. */
  86974. closed: boolean;
  86975. /**
  86976. * Creates a Path2 object from the starting 2D coordinates x and y.
  86977. * @param x the starting points x value
  86978. * @param y the starting points y value
  86979. */
  86980. constructor(x: number, y: number);
  86981. /**
  86982. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86983. * @param x the added points x value
  86984. * @param y the added points y value
  86985. * @returns the updated Path2.
  86986. */
  86987. addLineTo(x: number, y: number): Path2;
  86988. /**
  86989. * 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.
  86990. * @param midX middle point x value
  86991. * @param midY middle point y value
  86992. * @param endX end point x value
  86993. * @param endY end point y value
  86994. * @param numberOfSegments (default: 36)
  86995. * @returns the updated Path2.
  86996. */
  86997. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86998. /**
  86999. * Closes the Path2.
  87000. * @returns the Path2.
  87001. */
  87002. close(): Path2;
  87003. /**
  87004. * Gets the sum of the distance between each sequential point in the path
  87005. * @returns the Path2 total length (float).
  87006. */
  87007. length(): number;
  87008. /**
  87009. * Gets the points which construct the path
  87010. * @returns the Path2 internal array of points.
  87011. */
  87012. getPoints(): Vector2[];
  87013. /**
  87014. * Retreives the point at the distance aways from the starting point
  87015. * @param normalizedLengthPosition the length along the path to retreive the point from
  87016. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  87017. */
  87018. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  87019. /**
  87020. * Creates a new path starting from an x and y position
  87021. * @param x starting x value
  87022. * @param y starting y value
  87023. * @returns a new Path2 starting at the coordinates (x, y).
  87024. */
  87025. static StartingAt(x: number, y: number): Path2;
  87026. }
  87027. /**
  87028. * Represents a 3D path made up of multiple 3D points
  87029. */
  87030. export class Path3D {
  87031. /**
  87032. * an array of Vector3, the curve axis of the Path3D
  87033. */
  87034. path: Vector3[];
  87035. private _curve;
  87036. private _distances;
  87037. private _tangents;
  87038. private _normals;
  87039. private _binormals;
  87040. private _raw;
  87041. private _alignTangentsWithPath;
  87042. private readonly _pointAtData;
  87043. /**
  87044. * new Path3D(path, normal, raw)
  87045. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  87046. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  87047. * @param path an array of Vector3, the curve axis of the Path3D
  87048. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  87049. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  87050. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  87051. */
  87052. constructor(
  87053. /**
  87054. * an array of Vector3, the curve axis of the Path3D
  87055. */
  87056. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  87057. /**
  87058. * Returns the Path3D array of successive Vector3 designing its curve.
  87059. * @returns the Path3D array of successive Vector3 designing its curve.
  87060. */
  87061. getCurve(): Vector3[];
  87062. /**
  87063. * Returns the Path3D array of successive Vector3 designing its curve.
  87064. * @returns the Path3D array of successive Vector3 designing its curve.
  87065. */
  87066. getPoints(): Vector3[];
  87067. /**
  87068. * @returns the computed length (float) of the path.
  87069. */
  87070. length(): number;
  87071. /**
  87072. * Returns an array populated with tangent vectors on each Path3D curve point.
  87073. * @returns an array populated with tangent vectors on each Path3D curve point.
  87074. */
  87075. getTangents(): Vector3[];
  87076. /**
  87077. * Returns an array populated with normal vectors on each Path3D curve point.
  87078. * @returns an array populated with normal vectors on each Path3D curve point.
  87079. */
  87080. getNormals(): Vector3[];
  87081. /**
  87082. * Returns an array populated with binormal vectors on each Path3D curve point.
  87083. * @returns an array populated with binormal vectors on each Path3D curve point.
  87084. */
  87085. getBinormals(): Vector3[];
  87086. /**
  87087. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  87088. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  87089. */
  87090. getDistances(): number[];
  87091. /**
  87092. * Returns an interpolated point along this path
  87093. * @param position the position of the point along this path, from 0.0 to 1.0
  87094. * @returns a new Vector3 as the point
  87095. */
  87096. getPointAt(position: number): Vector3;
  87097. /**
  87098. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  87099. * @param position the position of the point along this path, from 0.0 to 1.0
  87100. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  87101. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  87102. */
  87103. getTangentAt(position: number, interpolated?: boolean): Vector3;
  87104. /**
  87105. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  87106. * @param position the position of the point along this path, from 0.0 to 1.0
  87107. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  87108. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  87109. */
  87110. getNormalAt(position: number, interpolated?: boolean): Vector3;
  87111. /**
  87112. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  87113. * @param position the position of the point along this path, from 0.0 to 1.0
  87114. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  87115. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  87116. */
  87117. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  87118. /**
  87119. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  87120. * @param position the position of the point along this path, from 0.0 to 1.0
  87121. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  87122. */
  87123. getDistanceAt(position: number): number;
  87124. /**
  87125. * Returns the array index of the previous point of an interpolated point along this path
  87126. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87127. * @returns the array index
  87128. */
  87129. getPreviousPointIndexAt(position: number): number;
  87130. /**
  87131. * 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)
  87132. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  87133. * @returns the sub position
  87134. */
  87135. getSubPositionAt(position: number): number;
  87136. /**
  87137. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  87138. * @param target the vector of which to get the closest position to
  87139. * @returns the position of the closest virtual point on this path to the target vector
  87140. */
  87141. getClosestPositionTo(target: Vector3): number;
  87142. /**
  87143. * Returns a sub path (slice) of this path
  87144. * @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
  87145. * @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
  87146. * @returns a sub path (slice) of this path
  87147. */
  87148. slice(start?: number, end?: number): Path3D;
  87149. /**
  87150. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  87151. * @param path path which all values are copied into the curves points
  87152. * @param firstNormal which should be projected onto the curve
  87153. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  87154. * @returns the same object updated.
  87155. */
  87156. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  87157. private _compute;
  87158. private _getFirstNonNullVector;
  87159. private _getLastNonNullVector;
  87160. private _normalVector;
  87161. /**
  87162. * Updates the point at data for an interpolated point along this curve
  87163. * @param position the position of the point along this curve, from 0.0 to 1.0
  87164. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  87165. * @returns the (updated) point at data
  87166. */
  87167. private _updatePointAtData;
  87168. /**
  87169. * Updates the point at data from the specified parameters
  87170. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  87171. * @param point the interpolated point
  87172. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  87173. */
  87174. private _setPointAtData;
  87175. /**
  87176. * Updates the point at interpolation matrix for the tangents, normals and binormals
  87177. */
  87178. private _updateInterpolationMatrix;
  87179. }
  87180. /**
  87181. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87182. * A Curve3 is designed from a series of successive Vector3.
  87183. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  87184. */
  87185. export class Curve3 {
  87186. private _points;
  87187. private _length;
  87188. /**
  87189. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  87190. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  87191. * @param v1 (Vector3) the control point
  87192. * @param v2 (Vector3) the end point of the Quadratic Bezier
  87193. * @param nbPoints (integer) the wanted number of points in the curve
  87194. * @returns the created Curve3
  87195. */
  87196. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87197. /**
  87198. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  87199. * @param v0 (Vector3) the origin point of the Cubic Bezier
  87200. * @param v1 (Vector3) the first control point
  87201. * @param v2 (Vector3) the second control point
  87202. * @param v3 (Vector3) the end point of the Cubic Bezier
  87203. * @param nbPoints (integer) the wanted number of points in the curve
  87204. * @returns the created Curve3
  87205. */
  87206. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87207. /**
  87208. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  87209. * @param p1 (Vector3) the origin point of the Hermite Spline
  87210. * @param t1 (Vector3) the tangent vector at the origin point
  87211. * @param p2 (Vector3) the end point of the Hermite Spline
  87212. * @param t2 (Vector3) the tangent vector at the end point
  87213. * @param nbPoints (integer) the wanted number of points in the curve
  87214. * @returns the created Curve3
  87215. */
  87216. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  87217. /**
  87218. * Returns a Curve3 object along a CatmullRom Spline curve :
  87219. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  87220. * @param nbPoints (integer) the wanted number of points between each curve control points
  87221. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  87222. * @returns the created Curve3
  87223. */
  87224. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  87225. /**
  87226. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  87227. * A Curve3 is designed from a series of successive Vector3.
  87228. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  87229. * @param points points which make up the curve
  87230. */
  87231. constructor(points: Vector3[]);
  87232. /**
  87233. * @returns the Curve3 stored array of successive Vector3
  87234. */
  87235. getPoints(): Vector3[];
  87236. /**
  87237. * @returns the computed length (float) of the curve.
  87238. */
  87239. length(): number;
  87240. /**
  87241. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  87242. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  87243. * curveA and curveB keep unchanged.
  87244. * @param curve the curve to continue from this curve
  87245. * @returns the newly constructed curve
  87246. */
  87247. continue(curve: DeepImmutable<Curve3>): Curve3;
  87248. private _computeLength;
  87249. }
  87250. }
  87251. declare module BABYLON {
  87252. /**
  87253. * This represents the main contract an easing function should follow.
  87254. * Easing functions are used throughout the animation system.
  87255. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87256. */
  87257. export interface IEasingFunction {
  87258. /**
  87259. * Given an input gradient between 0 and 1, this returns the corrseponding value
  87260. * of the easing function.
  87261. * The link below provides some of the most common examples of easing functions.
  87262. * @see https://easings.net/
  87263. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87264. * @returns the corresponding value on the curve defined by the easing function
  87265. */
  87266. ease(gradient: number): number;
  87267. }
  87268. /**
  87269. * Base class used for every default easing function.
  87270. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87271. */
  87272. export class EasingFunction implements IEasingFunction {
  87273. /**
  87274. * Interpolation follows the mathematical formula associated with the easing function.
  87275. */
  87276. static readonly EASINGMODE_EASEIN: number;
  87277. /**
  87278. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  87279. */
  87280. static readonly EASINGMODE_EASEOUT: number;
  87281. /**
  87282. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  87283. */
  87284. static readonly EASINGMODE_EASEINOUT: number;
  87285. private _easingMode;
  87286. /**
  87287. * Sets the easing mode of the current function.
  87288. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  87289. */
  87290. setEasingMode(easingMode: number): void;
  87291. /**
  87292. * Gets the current easing mode.
  87293. * @returns the easing mode
  87294. */
  87295. getEasingMode(): number;
  87296. /**
  87297. * @hidden
  87298. */
  87299. easeInCore(gradient: number): number;
  87300. /**
  87301. * Given an input gradient between 0 and 1, this returns the corresponding value
  87302. * of the easing function.
  87303. * @param gradient Defines the value between 0 and 1 we want the easing value for
  87304. * @returns the corresponding value on the curve defined by the easing function
  87305. */
  87306. ease(gradient: number): number;
  87307. }
  87308. /**
  87309. * Easing function with a circle shape (see link below).
  87310. * @see https://easings.net/#easeInCirc
  87311. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87312. */
  87313. export class CircleEase extends EasingFunction implements IEasingFunction {
  87314. /** @hidden */
  87315. easeInCore(gradient: number): number;
  87316. }
  87317. /**
  87318. * Easing function with a ease back shape (see link below).
  87319. * @see https://easings.net/#easeInBack
  87320. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87321. */
  87322. export class BackEase extends EasingFunction implements IEasingFunction {
  87323. /** Defines the amplitude of the function */
  87324. amplitude: number;
  87325. /**
  87326. * Instantiates a back ease easing
  87327. * @see https://easings.net/#easeInBack
  87328. * @param amplitude Defines the amplitude of the function
  87329. */
  87330. constructor(
  87331. /** Defines the amplitude of the function */
  87332. amplitude?: number);
  87333. /** @hidden */
  87334. easeInCore(gradient: number): number;
  87335. }
  87336. /**
  87337. * Easing function with a bouncing shape (see link below).
  87338. * @see https://easings.net/#easeInBounce
  87339. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87340. */
  87341. export class BounceEase extends EasingFunction implements IEasingFunction {
  87342. /** Defines the number of bounces */
  87343. bounces: number;
  87344. /** Defines the amplitude of the bounce */
  87345. bounciness: number;
  87346. /**
  87347. * Instantiates a bounce easing
  87348. * @see https://easings.net/#easeInBounce
  87349. * @param bounces Defines the number of bounces
  87350. * @param bounciness Defines the amplitude of the bounce
  87351. */
  87352. constructor(
  87353. /** Defines the number of bounces */
  87354. bounces?: number,
  87355. /** Defines the amplitude of the bounce */
  87356. bounciness?: number);
  87357. /** @hidden */
  87358. easeInCore(gradient: number): number;
  87359. }
  87360. /**
  87361. * Easing function with a power of 3 shape (see link below).
  87362. * @see https://easings.net/#easeInCubic
  87363. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87364. */
  87365. export class CubicEase extends EasingFunction implements IEasingFunction {
  87366. /** @hidden */
  87367. easeInCore(gradient: number): number;
  87368. }
  87369. /**
  87370. * Easing function with an elastic shape (see link below).
  87371. * @see https://easings.net/#easeInElastic
  87372. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87373. */
  87374. export class ElasticEase extends EasingFunction implements IEasingFunction {
  87375. /** Defines the number of oscillations*/
  87376. oscillations: number;
  87377. /** Defines the amplitude of the oscillations*/
  87378. springiness: number;
  87379. /**
  87380. * Instantiates an elastic easing function
  87381. * @see https://easings.net/#easeInElastic
  87382. * @param oscillations Defines the number of oscillations
  87383. * @param springiness Defines the amplitude of the oscillations
  87384. */
  87385. constructor(
  87386. /** Defines the number of oscillations*/
  87387. oscillations?: number,
  87388. /** Defines the amplitude of the oscillations*/
  87389. springiness?: number);
  87390. /** @hidden */
  87391. easeInCore(gradient: number): number;
  87392. }
  87393. /**
  87394. * Easing function with an exponential shape (see link below).
  87395. * @see https://easings.net/#easeInExpo
  87396. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87397. */
  87398. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  87399. /** Defines the exponent of the function */
  87400. exponent: number;
  87401. /**
  87402. * Instantiates an exponential easing function
  87403. * @see https://easings.net/#easeInExpo
  87404. * @param exponent Defines the exponent of the function
  87405. */
  87406. constructor(
  87407. /** Defines the exponent of the function */
  87408. exponent?: number);
  87409. /** @hidden */
  87410. easeInCore(gradient: number): number;
  87411. }
  87412. /**
  87413. * Easing function with a power shape (see link below).
  87414. * @see https://easings.net/#easeInQuad
  87415. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87416. */
  87417. export class PowerEase extends EasingFunction implements IEasingFunction {
  87418. /** Defines the power of the function */
  87419. power: number;
  87420. /**
  87421. * Instantiates an power base easing function
  87422. * @see https://easings.net/#easeInQuad
  87423. * @param power Defines the power of the function
  87424. */
  87425. constructor(
  87426. /** Defines the power of the function */
  87427. power?: number);
  87428. /** @hidden */
  87429. easeInCore(gradient: number): number;
  87430. }
  87431. /**
  87432. * Easing function with a power of 2 shape (see link below).
  87433. * @see https://easings.net/#easeInQuad
  87434. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87435. */
  87436. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  87437. /** @hidden */
  87438. easeInCore(gradient: number): number;
  87439. }
  87440. /**
  87441. * Easing function with a power of 4 shape (see link below).
  87442. * @see https://easings.net/#easeInQuart
  87443. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87444. */
  87445. export class QuarticEase extends EasingFunction implements IEasingFunction {
  87446. /** @hidden */
  87447. easeInCore(gradient: number): number;
  87448. }
  87449. /**
  87450. * Easing function with a power of 5 shape (see link below).
  87451. * @see https://easings.net/#easeInQuint
  87452. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87453. */
  87454. export class QuinticEase extends EasingFunction implements IEasingFunction {
  87455. /** @hidden */
  87456. easeInCore(gradient: number): number;
  87457. }
  87458. /**
  87459. * Easing function with a sin shape (see link below).
  87460. * @see https://easings.net/#easeInSine
  87461. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87462. */
  87463. export class SineEase extends EasingFunction implements IEasingFunction {
  87464. /** @hidden */
  87465. easeInCore(gradient: number): number;
  87466. }
  87467. /**
  87468. * Easing function with a bezier shape (see link below).
  87469. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87470. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  87471. */
  87472. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  87473. /** Defines the x component of the start tangent in the bezier curve */
  87474. x1: number;
  87475. /** Defines the y component of the start tangent in the bezier curve */
  87476. y1: number;
  87477. /** Defines the x component of the end tangent in the bezier curve */
  87478. x2: number;
  87479. /** Defines the y component of the end tangent in the bezier curve */
  87480. y2: number;
  87481. /**
  87482. * Instantiates a bezier function
  87483. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  87484. * @param x1 Defines the x component of the start tangent in the bezier curve
  87485. * @param y1 Defines the y component of the start tangent in the bezier curve
  87486. * @param x2 Defines the x component of the end tangent in the bezier curve
  87487. * @param y2 Defines the y component of the end tangent in the bezier curve
  87488. */
  87489. constructor(
  87490. /** Defines the x component of the start tangent in the bezier curve */
  87491. x1?: number,
  87492. /** Defines the y component of the start tangent in the bezier curve */
  87493. y1?: number,
  87494. /** Defines the x component of the end tangent in the bezier curve */
  87495. x2?: number,
  87496. /** Defines the y component of the end tangent in the bezier curve */
  87497. y2?: number);
  87498. /** @hidden */
  87499. easeInCore(gradient: number): number;
  87500. }
  87501. }
  87502. declare module BABYLON {
  87503. /**
  87504. * Class used to hold a RBG color
  87505. */
  87506. export class Color3 {
  87507. /**
  87508. * Defines the red component (between 0 and 1, default is 0)
  87509. */
  87510. r: number;
  87511. /**
  87512. * Defines the green component (between 0 and 1, default is 0)
  87513. */
  87514. g: number;
  87515. /**
  87516. * Defines the blue component (between 0 and 1, default is 0)
  87517. */
  87518. b: number;
  87519. /**
  87520. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  87521. * @param r defines the red component (between 0 and 1, default is 0)
  87522. * @param g defines the green component (between 0 and 1, default is 0)
  87523. * @param b defines the blue component (between 0 and 1, default is 0)
  87524. */
  87525. constructor(
  87526. /**
  87527. * Defines the red component (between 0 and 1, default is 0)
  87528. */
  87529. r?: number,
  87530. /**
  87531. * Defines the green component (between 0 and 1, default is 0)
  87532. */
  87533. g?: number,
  87534. /**
  87535. * Defines the blue component (between 0 and 1, default is 0)
  87536. */
  87537. b?: number);
  87538. /**
  87539. * Creates a string with the Color3 current values
  87540. * @returns the string representation of the Color3 object
  87541. */
  87542. toString(): string;
  87543. /**
  87544. * Returns the string "Color3"
  87545. * @returns "Color3"
  87546. */
  87547. getClassName(): string;
  87548. /**
  87549. * Compute the Color3 hash code
  87550. * @returns an unique number that can be used to hash Color3 objects
  87551. */
  87552. getHashCode(): number;
  87553. /**
  87554. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  87555. * @param array defines the array where to store the r,g,b components
  87556. * @param index defines an optional index in the target array to define where to start storing values
  87557. * @returns the current Color3 object
  87558. */
  87559. toArray(array: FloatArray, index?: number): Color3;
  87560. /**
  87561. * Update the current color with values stored in an array from the starting index of the given array
  87562. * @param array defines the source array
  87563. * @param offset defines an offset in the source array
  87564. * @returns the current Color3 object
  87565. */
  87566. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87567. /**
  87568. * Returns a new Color4 object from the current Color3 and the given alpha
  87569. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  87570. * @returns a new Color4 object
  87571. */
  87572. toColor4(alpha?: number): Color4;
  87573. /**
  87574. * Returns a new array populated with 3 numeric elements : red, green and blue values
  87575. * @returns the new array
  87576. */
  87577. asArray(): number[];
  87578. /**
  87579. * Returns the luminance value
  87580. * @returns a float value
  87581. */
  87582. toLuminance(): number;
  87583. /**
  87584. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  87585. * @param otherColor defines the second operand
  87586. * @returns the new Color3 object
  87587. */
  87588. multiply(otherColor: DeepImmutable<Color3>): Color3;
  87589. /**
  87590. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  87591. * @param otherColor defines the second operand
  87592. * @param result defines the Color3 object where to store the result
  87593. * @returns the current Color3
  87594. */
  87595. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87596. /**
  87597. * Determines equality between Color3 objects
  87598. * @param otherColor defines the second operand
  87599. * @returns true if the rgb values are equal to the given ones
  87600. */
  87601. equals(otherColor: DeepImmutable<Color3>): boolean;
  87602. /**
  87603. * Determines equality between the current Color3 object and a set of r,b,g values
  87604. * @param r defines the red component to check
  87605. * @param g defines the green component to check
  87606. * @param b defines the blue component to check
  87607. * @returns true if the rgb values are equal to the given ones
  87608. */
  87609. equalsFloats(r: number, g: number, b: number): boolean;
  87610. /**
  87611. * Multiplies in place each rgb value by scale
  87612. * @param scale defines the scaling factor
  87613. * @returns the updated Color3
  87614. */
  87615. scale(scale: number): Color3;
  87616. /**
  87617. * Multiplies the rgb values by scale and stores the result into "result"
  87618. * @param scale defines the scaling factor
  87619. * @param result defines the Color3 object where to store the result
  87620. * @returns the unmodified current Color3
  87621. */
  87622. scaleToRef(scale: number, result: Color3): Color3;
  87623. /**
  87624. * Scale the current Color3 values by a factor and add the result to a given Color3
  87625. * @param scale defines the scale factor
  87626. * @param result defines color to store the result into
  87627. * @returns the unmodified current Color3
  87628. */
  87629. scaleAndAddToRef(scale: number, result: Color3): Color3;
  87630. /**
  87631. * Clamps the rgb values by the min and max values and stores the result into "result"
  87632. * @param min defines minimum clamping value (default is 0)
  87633. * @param max defines maximum clamping value (default is 1)
  87634. * @param result defines color to store the result into
  87635. * @returns the original Color3
  87636. */
  87637. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  87638. /**
  87639. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  87640. * @param otherColor defines the second operand
  87641. * @returns the new Color3
  87642. */
  87643. add(otherColor: DeepImmutable<Color3>): Color3;
  87644. /**
  87645. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  87646. * @param otherColor defines the second operand
  87647. * @param result defines Color3 object to store the result into
  87648. * @returns the unmodified current Color3
  87649. */
  87650. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87651. /**
  87652. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  87653. * @param otherColor defines the second operand
  87654. * @returns the new Color3
  87655. */
  87656. subtract(otherColor: DeepImmutable<Color3>): Color3;
  87657. /**
  87658. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  87659. * @param otherColor defines the second operand
  87660. * @param result defines Color3 object to store the result into
  87661. * @returns the unmodified current Color3
  87662. */
  87663. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  87664. /**
  87665. * Copy the current object
  87666. * @returns a new Color3 copied the current one
  87667. */
  87668. clone(): Color3;
  87669. /**
  87670. * Copies the rgb values from the source in the current Color3
  87671. * @param source defines the source Color3 object
  87672. * @returns the updated Color3 object
  87673. */
  87674. copyFrom(source: DeepImmutable<Color3>): Color3;
  87675. /**
  87676. * Updates the Color3 rgb values from the given floats
  87677. * @param r defines the red component to read from
  87678. * @param g defines the green component to read from
  87679. * @param b defines the blue component to read from
  87680. * @returns the current Color3 object
  87681. */
  87682. copyFromFloats(r: number, g: number, b: number): Color3;
  87683. /**
  87684. * Updates the Color3 rgb values from the given floats
  87685. * @param r defines the red component to read from
  87686. * @param g defines the green component to read from
  87687. * @param b defines the blue component to read from
  87688. * @returns the current Color3 object
  87689. */
  87690. set(r: number, g: number, b: number): Color3;
  87691. /**
  87692. * Compute the Color3 hexadecimal code as a string
  87693. * @returns a string containing the hexadecimal representation of the Color3 object
  87694. */
  87695. toHexString(): string;
  87696. /**
  87697. * Computes a new Color3 converted from the current one to linear space
  87698. * @returns a new Color3 object
  87699. */
  87700. toLinearSpace(): Color3;
  87701. /**
  87702. * Converts current color in rgb space to HSV values
  87703. * @returns a new color3 representing the HSV values
  87704. */
  87705. toHSV(): Color3;
  87706. /**
  87707. * Converts current color in rgb space to HSV values
  87708. * @param result defines the Color3 where to store the HSV values
  87709. */
  87710. toHSVToRef(result: Color3): void;
  87711. /**
  87712. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  87713. * @param convertedColor defines the Color3 object where to store the linear space version
  87714. * @returns the unmodified Color3
  87715. */
  87716. toLinearSpaceToRef(convertedColor: Color3): Color3;
  87717. /**
  87718. * Computes a new Color3 converted from the current one to gamma space
  87719. * @returns a new Color3 object
  87720. */
  87721. toGammaSpace(): Color3;
  87722. /**
  87723. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  87724. * @param convertedColor defines the Color3 object where to store the gamma space version
  87725. * @returns the unmodified Color3
  87726. */
  87727. toGammaSpaceToRef(convertedColor: Color3): Color3;
  87728. private static _BlackReadOnly;
  87729. /**
  87730. * Convert Hue, saturation and value to a Color3 (RGB)
  87731. * @param hue defines the hue
  87732. * @param saturation defines the saturation
  87733. * @param value defines the value
  87734. * @param result defines the Color3 where to store the RGB values
  87735. */
  87736. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  87737. /**
  87738. * Creates a new Color3 from the string containing valid hexadecimal values
  87739. * @param hex defines a string containing valid hexadecimal values
  87740. * @returns a new Color3 object
  87741. */
  87742. static FromHexString(hex: string): Color3;
  87743. /**
  87744. * Creates a new Color3 from the starting index of the given array
  87745. * @param array defines the source array
  87746. * @param offset defines an offset in the source array
  87747. * @returns a new Color3 object
  87748. */
  87749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  87750. /**
  87751. * Creates a new Color3 from the starting index element of the given array
  87752. * @param array defines the source array to read from
  87753. * @param offset defines the offset in the source array
  87754. * @param result defines the target Color3 object
  87755. */
  87756. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  87757. /**
  87758. * Creates a new Color3 from integer values (< 256)
  87759. * @param r defines the red component to read from (value between 0 and 255)
  87760. * @param g defines the green component to read from (value between 0 and 255)
  87761. * @param b defines the blue component to read from (value between 0 and 255)
  87762. * @returns a new Color3 object
  87763. */
  87764. static FromInts(r: number, g: number, b: number): Color3;
  87765. /**
  87766. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87767. * @param start defines the start Color3 value
  87768. * @param end defines the end Color3 value
  87769. * @param amount defines the gradient value between start and end
  87770. * @returns a new Color3 object
  87771. */
  87772. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  87773. /**
  87774. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  87775. * @param left defines the start value
  87776. * @param right defines the end value
  87777. * @param amount defines the gradient factor
  87778. * @param result defines the Color3 object where to store the result
  87779. */
  87780. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  87781. /**
  87782. * Returns a Color3 value containing a red color
  87783. * @returns a new Color3 object
  87784. */
  87785. static Red(): Color3;
  87786. /**
  87787. * Returns a Color3 value containing a green color
  87788. * @returns a new Color3 object
  87789. */
  87790. static Green(): Color3;
  87791. /**
  87792. * Returns a Color3 value containing a blue color
  87793. * @returns a new Color3 object
  87794. */
  87795. static Blue(): Color3;
  87796. /**
  87797. * Returns a Color3 value containing a black color
  87798. * @returns a new Color3 object
  87799. */
  87800. static Black(): Color3;
  87801. /**
  87802. * Gets a Color3 value containing a black color that must not be updated
  87803. */
  87804. static get BlackReadOnly(): DeepImmutable<Color3>;
  87805. /**
  87806. * Returns a Color3 value containing a white color
  87807. * @returns a new Color3 object
  87808. */
  87809. static White(): Color3;
  87810. /**
  87811. * Returns a Color3 value containing a purple color
  87812. * @returns a new Color3 object
  87813. */
  87814. static Purple(): Color3;
  87815. /**
  87816. * Returns a Color3 value containing a magenta color
  87817. * @returns a new Color3 object
  87818. */
  87819. static Magenta(): Color3;
  87820. /**
  87821. * Returns a Color3 value containing a yellow color
  87822. * @returns a new Color3 object
  87823. */
  87824. static Yellow(): Color3;
  87825. /**
  87826. * Returns a Color3 value containing a gray color
  87827. * @returns a new Color3 object
  87828. */
  87829. static Gray(): Color3;
  87830. /**
  87831. * Returns a Color3 value containing a teal color
  87832. * @returns a new Color3 object
  87833. */
  87834. static Teal(): Color3;
  87835. /**
  87836. * Returns a Color3 value containing a random color
  87837. * @returns a new Color3 object
  87838. */
  87839. static Random(): Color3;
  87840. }
  87841. /**
  87842. * Class used to hold a RBGA color
  87843. */
  87844. export class Color4 {
  87845. /**
  87846. * Defines the red component (between 0 and 1, default is 0)
  87847. */
  87848. r: number;
  87849. /**
  87850. * Defines the green component (between 0 and 1, default is 0)
  87851. */
  87852. g: number;
  87853. /**
  87854. * Defines the blue component (between 0 and 1, default is 0)
  87855. */
  87856. b: number;
  87857. /**
  87858. * Defines the alpha component (between 0 and 1, default is 1)
  87859. */
  87860. a: number;
  87861. /**
  87862. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87863. * @param r defines the red component (between 0 and 1, default is 0)
  87864. * @param g defines the green component (between 0 and 1, default is 0)
  87865. * @param b defines the blue component (between 0 and 1, default is 0)
  87866. * @param a defines the alpha component (between 0 and 1, default is 1)
  87867. */
  87868. constructor(
  87869. /**
  87870. * Defines the red component (between 0 and 1, default is 0)
  87871. */
  87872. r?: number,
  87873. /**
  87874. * Defines the green component (between 0 and 1, default is 0)
  87875. */
  87876. g?: number,
  87877. /**
  87878. * Defines the blue component (between 0 and 1, default is 0)
  87879. */
  87880. b?: number,
  87881. /**
  87882. * Defines the alpha component (between 0 and 1, default is 1)
  87883. */
  87884. a?: number);
  87885. /**
  87886. * Adds in place the given Color4 values to the current Color4 object
  87887. * @param right defines the second operand
  87888. * @returns the current updated Color4 object
  87889. */
  87890. addInPlace(right: DeepImmutable<Color4>): Color4;
  87891. /**
  87892. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87893. * @returns the new array
  87894. */
  87895. asArray(): number[];
  87896. /**
  87897. * Stores from the starting index in the given array the Color4 successive values
  87898. * @param array defines the array where to store the r,g,b components
  87899. * @param index defines an optional index in the target array to define where to start storing values
  87900. * @returns the current Color4 object
  87901. */
  87902. toArray(array: number[], index?: number): Color4;
  87903. /**
  87904. * Update the current color with values stored in an array from the starting index of the given array
  87905. * @param array defines the source array
  87906. * @param offset defines an offset in the source array
  87907. * @returns the current Color4 object
  87908. */
  87909. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87910. /**
  87911. * Determines equality between Color4 objects
  87912. * @param otherColor defines the second operand
  87913. * @returns true if the rgba values are equal to the given ones
  87914. */
  87915. equals(otherColor: DeepImmutable<Color4>): boolean;
  87916. /**
  87917. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87918. * @param right defines the second operand
  87919. * @returns a new Color4 object
  87920. */
  87921. add(right: DeepImmutable<Color4>): Color4;
  87922. /**
  87923. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87924. * @param right defines the second operand
  87925. * @returns a new Color4 object
  87926. */
  87927. subtract(right: DeepImmutable<Color4>): Color4;
  87928. /**
  87929. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87930. * @param right defines the second operand
  87931. * @param result defines the Color4 object where to store the result
  87932. * @returns the current Color4 object
  87933. */
  87934. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87935. /**
  87936. * Creates a new Color4 with the current Color4 values multiplied by scale
  87937. * @param scale defines the scaling factor to apply
  87938. * @returns a new Color4 object
  87939. */
  87940. scale(scale: number): Color4;
  87941. /**
  87942. * Multiplies the current Color4 values by scale and stores the result in "result"
  87943. * @param scale defines the scaling factor to apply
  87944. * @param result defines the Color4 object where to store the result
  87945. * @returns the current unmodified Color4
  87946. */
  87947. scaleToRef(scale: number, result: Color4): Color4;
  87948. /**
  87949. * Scale the current Color4 values by a factor and add the result to a given Color4
  87950. * @param scale defines the scale factor
  87951. * @param result defines the Color4 object where to store the result
  87952. * @returns the unmodified current Color4
  87953. */
  87954. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87955. /**
  87956. * Clamps the rgb values by the min and max values and stores the result into "result"
  87957. * @param min defines minimum clamping value (default is 0)
  87958. * @param max defines maximum clamping value (default is 1)
  87959. * @param result defines color to store the result into.
  87960. * @returns the cuurent Color4
  87961. */
  87962. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87963. /**
  87964. * Multipy an Color4 value by another and return a new Color4 object
  87965. * @param color defines the Color4 value to multiply by
  87966. * @returns a new Color4 object
  87967. */
  87968. multiply(color: Color4): Color4;
  87969. /**
  87970. * Multipy a Color4 value by another and push the result in a reference value
  87971. * @param color defines the Color4 value to multiply by
  87972. * @param result defines the Color4 to fill the result in
  87973. * @returns the result Color4
  87974. */
  87975. multiplyToRef(color: Color4, result: Color4): Color4;
  87976. /**
  87977. * Creates a string with the Color4 current values
  87978. * @returns the string representation of the Color4 object
  87979. */
  87980. toString(): string;
  87981. /**
  87982. * Returns the string "Color4"
  87983. * @returns "Color4"
  87984. */
  87985. getClassName(): string;
  87986. /**
  87987. * Compute the Color4 hash code
  87988. * @returns an unique number that can be used to hash Color4 objects
  87989. */
  87990. getHashCode(): number;
  87991. /**
  87992. * Creates a new Color4 copied from the current one
  87993. * @returns a new Color4 object
  87994. */
  87995. clone(): Color4;
  87996. /**
  87997. * Copies the given Color4 values into the current one
  87998. * @param source defines the source Color4 object
  87999. * @returns the current updated Color4 object
  88000. */
  88001. copyFrom(source: Color4): Color4;
  88002. /**
  88003. * Copies the given float values into the current one
  88004. * @param r defines the red component to read from
  88005. * @param g defines the green component to read from
  88006. * @param b defines the blue component to read from
  88007. * @param a defines the alpha component to read from
  88008. * @returns the current updated Color4 object
  88009. */
  88010. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  88011. /**
  88012. * Copies the given float values into the current one
  88013. * @param r defines the red component to read from
  88014. * @param g defines the green component to read from
  88015. * @param b defines the blue component to read from
  88016. * @param a defines the alpha component to read from
  88017. * @returns the current updated Color4 object
  88018. */
  88019. set(r: number, g: number, b: number, a: number): Color4;
  88020. /**
  88021. * Compute the Color4 hexadecimal code as a string
  88022. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  88023. * @returns a string containing the hexadecimal representation of the Color4 object
  88024. */
  88025. toHexString(returnAsColor3?: boolean): string;
  88026. /**
  88027. * Computes a new Color4 converted from the current one to linear space
  88028. * @returns a new Color4 object
  88029. */
  88030. toLinearSpace(): Color4;
  88031. /**
  88032. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  88033. * @param convertedColor defines the Color4 object where to store the linear space version
  88034. * @returns the unmodified Color4
  88035. */
  88036. toLinearSpaceToRef(convertedColor: Color4): Color4;
  88037. /**
  88038. * Computes a new Color4 converted from the current one to gamma space
  88039. * @returns a new Color4 object
  88040. */
  88041. toGammaSpace(): Color4;
  88042. /**
  88043. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  88044. * @param convertedColor defines the Color4 object where to store the gamma space version
  88045. * @returns the unmodified Color4
  88046. */
  88047. toGammaSpaceToRef(convertedColor: Color4): Color4;
  88048. /**
  88049. * Creates a new Color4 from the string containing valid hexadecimal values
  88050. * @param hex defines a string containing valid hexadecimal values
  88051. * @returns a new Color4 object
  88052. */
  88053. static FromHexString(hex: string): Color4;
  88054. /**
  88055. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  88056. * @param left defines the start value
  88057. * @param right defines the end value
  88058. * @param amount defines the gradient factor
  88059. * @returns a new Color4 object
  88060. */
  88061. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  88062. /**
  88063. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  88064. * @param left defines the start value
  88065. * @param right defines the end value
  88066. * @param amount defines the gradient factor
  88067. * @param result defines the Color4 object where to store data
  88068. */
  88069. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  88070. /**
  88071. * Creates a new Color4 from a Color3 and an alpha value
  88072. * @param color3 defines the source Color3 to read from
  88073. * @param alpha defines the alpha component (1.0 by default)
  88074. * @returns a new Color4 object
  88075. */
  88076. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  88077. /**
  88078. * Creates a new Color4 from the starting index element of the given array
  88079. * @param array defines the source array to read from
  88080. * @param offset defines the offset in the source array
  88081. * @returns a new Color4 object
  88082. */
  88083. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  88084. /**
  88085. * Creates a new Color4 from the starting index element of the given array
  88086. * @param array defines the source array to read from
  88087. * @param offset defines the offset in the source array
  88088. * @param result defines the target Color4 object
  88089. */
  88090. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  88091. /**
  88092. * Creates a new Color3 from integer values (< 256)
  88093. * @param r defines the red component to read from (value between 0 and 255)
  88094. * @param g defines the green component to read from (value between 0 and 255)
  88095. * @param b defines the blue component to read from (value between 0 and 255)
  88096. * @param a defines the alpha component to read from (value between 0 and 255)
  88097. * @returns a new Color3 object
  88098. */
  88099. static FromInts(r: number, g: number, b: number, a: number): Color4;
  88100. /**
  88101. * Check the content of a given array and convert it to an array containing RGBA data
  88102. * If the original array was already containing count * 4 values then it is returned directly
  88103. * @param colors defines the array to check
  88104. * @param count defines the number of RGBA data to expect
  88105. * @returns an array containing count * 4 values (RGBA)
  88106. */
  88107. static CheckColors4(colors: number[], count: number): number[];
  88108. }
  88109. /**
  88110. * @hidden
  88111. */
  88112. export class TmpColors {
  88113. static Color3: Color3[];
  88114. static Color4: Color4[];
  88115. }
  88116. }
  88117. declare module BABYLON {
  88118. /**
  88119. * Defines an interface which represents an animation key frame
  88120. */
  88121. export interface IAnimationKey {
  88122. /**
  88123. * Frame of the key frame
  88124. */
  88125. frame: number;
  88126. /**
  88127. * Value at the specifies key frame
  88128. */
  88129. value: any;
  88130. /**
  88131. * The input tangent for the cubic hermite spline
  88132. */
  88133. inTangent?: any;
  88134. /**
  88135. * The output tangent for the cubic hermite spline
  88136. */
  88137. outTangent?: any;
  88138. /**
  88139. * The animation interpolation type
  88140. */
  88141. interpolation?: AnimationKeyInterpolation;
  88142. }
  88143. /**
  88144. * Enum for the animation key frame interpolation type
  88145. */
  88146. export enum AnimationKeyInterpolation {
  88147. /**
  88148. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  88149. */
  88150. STEP = 1
  88151. }
  88152. }
  88153. declare module BABYLON {
  88154. /**
  88155. * Represents the range of an animation
  88156. */
  88157. export class AnimationRange {
  88158. /**The name of the animation range**/
  88159. name: string;
  88160. /**The starting frame of the animation */
  88161. from: number;
  88162. /**The ending frame of the animation*/
  88163. to: number;
  88164. /**
  88165. * Initializes the range of an animation
  88166. * @param name The name of the animation range
  88167. * @param from The starting frame of the animation
  88168. * @param to The ending frame of the animation
  88169. */
  88170. constructor(
  88171. /**The name of the animation range**/
  88172. name: string,
  88173. /**The starting frame of the animation */
  88174. from: number,
  88175. /**The ending frame of the animation*/
  88176. to: number);
  88177. /**
  88178. * Makes a copy of the animation range
  88179. * @returns A copy of the animation range
  88180. */
  88181. clone(): AnimationRange;
  88182. }
  88183. }
  88184. declare module BABYLON {
  88185. /**
  88186. * Composed of a frame, and an action function
  88187. */
  88188. export class AnimationEvent {
  88189. /** The frame for which the event is triggered **/
  88190. frame: number;
  88191. /** The event to perform when triggered **/
  88192. action: (currentFrame: number) => void;
  88193. /** Specifies if the event should be triggered only once**/
  88194. onlyOnce?: boolean | undefined;
  88195. /**
  88196. * Specifies if the animation event is done
  88197. */
  88198. isDone: boolean;
  88199. /**
  88200. * Initializes the animation event
  88201. * @param frame The frame for which the event is triggered
  88202. * @param action The event to perform when triggered
  88203. * @param onlyOnce Specifies if the event should be triggered only once
  88204. */
  88205. constructor(
  88206. /** The frame for which the event is triggered **/
  88207. frame: number,
  88208. /** The event to perform when triggered **/
  88209. action: (currentFrame: number) => void,
  88210. /** Specifies if the event should be triggered only once**/
  88211. onlyOnce?: boolean | undefined);
  88212. /** @hidden */
  88213. _clone(): AnimationEvent;
  88214. }
  88215. }
  88216. declare module BABYLON {
  88217. /**
  88218. * Interface used to define a behavior
  88219. */
  88220. export interface Behavior<T> {
  88221. /** gets or sets behavior's name */
  88222. name: string;
  88223. /**
  88224. * Function called when the behavior needs to be initialized (after attaching it to a target)
  88225. */
  88226. init(): void;
  88227. /**
  88228. * Called when the behavior is attached to a target
  88229. * @param target defines the target where the behavior is attached to
  88230. */
  88231. attach(target: T): void;
  88232. /**
  88233. * Called when the behavior is detached from its target
  88234. */
  88235. detach(): void;
  88236. }
  88237. /**
  88238. * Interface implemented by classes supporting behaviors
  88239. */
  88240. export interface IBehaviorAware<T> {
  88241. /**
  88242. * Attach a behavior
  88243. * @param behavior defines the behavior to attach
  88244. * @returns the current host
  88245. */
  88246. addBehavior(behavior: Behavior<T>): T;
  88247. /**
  88248. * Remove a behavior from the current object
  88249. * @param behavior defines the behavior to detach
  88250. * @returns the current host
  88251. */
  88252. removeBehavior(behavior: Behavior<T>): T;
  88253. /**
  88254. * Gets a behavior using its name to search
  88255. * @param name defines the name to search
  88256. * @returns the behavior or null if not found
  88257. */
  88258. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  88259. }
  88260. }
  88261. declare module BABYLON {
  88262. /**
  88263. * Class used to store data that will be store in GPU memory
  88264. */
  88265. export class Buffer {
  88266. private _engine;
  88267. private _buffer;
  88268. /** @hidden */
  88269. _data: Nullable<DataArray>;
  88270. private _updatable;
  88271. private _instanced;
  88272. private _divisor;
  88273. private _isAlreadyOwned;
  88274. /**
  88275. * Gets the byte stride.
  88276. */
  88277. readonly byteStride: number;
  88278. /**
  88279. * Constructor
  88280. * @param engine the engine
  88281. * @param data the data to use for this buffer
  88282. * @param updatable whether the data is updatable
  88283. * @param stride the stride (optional)
  88284. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88285. * @param instanced whether the buffer is instanced (optional)
  88286. * @param useBytes set to true if the stride in in bytes (optional)
  88287. * @param divisor sets an optional divisor for instances (1 by default)
  88288. */
  88289. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  88290. /**
  88291. * Create a new VertexBuffer based on the current buffer
  88292. * @param kind defines the vertex buffer kind (position, normal, etc.)
  88293. * @param offset defines offset in the buffer (0 by default)
  88294. * @param size defines the size in floats of attributes (position is 3 for instance)
  88295. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  88296. * @param instanced defines if the vertex buffer contains indexed data
  88297. * @param useBytes defines if the offset and stride are in bytes *
  88298. * @param divisor sets an optional divisor for instances (1 by default)
  88299. * @returns the new vertex buffer
  88300. */
  88301. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  88302. /**
  88303. * Gets a boolean indicating if the Buffer is updatable?
  88304. * @returns true if the buffer is updatable
  88305. */
  88306. isUpdatable(): boolean;
  88307. /**
  88308. * Gets current buffer's data
  88309. * @returns a DataArray or null
  88310. */
  88311. getData(): Nullable<DataArray>;
  88312. /**
  88313. * Gets underlying native buffer
  88314. * @returns underlying native buffer
  88315. */
  88316. getBuffer(): Nullable<DataBuffer>;
  88317. /**
  88318. * Gets the stride in float32 units (i.e. byte stride / 4).
  88319. * May not be an integer if the byte stride is not divisible by 4.
  88320. * @returns the stride in float32 units
  88321. * @deprecated Please use byteStride instead.
  88322. */
  88323. getStrideSize(): number;
  88324. /**
  88325. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88326. * @param data defines the data to store
  88327. */
  88328. create(data?: Nullable<DataArray>): void;
  88329. /** @hidden */
  88330. _rebuild(): void;
  88331. /**
  88332. * Update current buffer data
  88333. * @param data defines the data to store
  88334. */
  88335. update(data: DataArray): void;
  88336. /**
  88337. * Updates the data directly.
  88338. * @param data the new data
  88339. * @param offset the new offset
  88340. * @param vertexCount the vertex count (optional)
  88341. * @param useBytes set to true if the offset is in bytes
  88342. */
  88343. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  88344. /** @hidden */
  88345. _increaseReferences(): void;
  88346. /**
  88347. * Release all resources
  88348. */
  88349. dispose(): void;
  88350. }
  88351. /**
  88352. * Specialized buffer used to store vertex data
  88353. */
  88354. export class VertexBuffer {
  88355. /** @hidden */
  88356. _buffer: Buffer;
  88357. private _kind;
  88358. private _size;
  88359. private _ownsBuffer;
  88360. private _instanced;
  88361. private _instanceDivisor;
  88362. /**
  88363. * The byte type.
  88364. */
  88365. static readonly BYTE: number;
  88366. /**
  88367. * The unsigned byte type.
  88368. */
  88369. static readonly UNSIGNED_BYTE: number;
  88370. /**
  88371. * The short type.
  88372. */
  88373. static readonly SHORT: number;
  88374. /**
  88375. * The unsigned short type.
  88376. */
  88377. static readonly UNSIGNED_SHORT: number;
  88378. /**
  88379. * The integer type.
  88380. */
  88381. static readonly INT: number;
  88382. /**
  88383. * The unsigned integer type.
  88384. */
  88385. static readonly UNSIGNED_INT: number;
  88386. /**
  88387. * The float type.
  88388. */
  88389. static readonly FLOAT: number;
  88390. /**
  88391. * Gets or sets the instance divisor when in instanced mode
  88392. */
  88393. get instanceDivisor(): number;
  88394. set instanceDivisor(value: number);
  88395. /**
  88396. * Gets the byte stride.
  88397. */
  88398. readonly byteStride: number;
  88399. /**
  88400. * Gets the byte offset.
  88401. */
  88402. readonly byteOffset: number;
  88403. /**
  88404. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  88405. */
  88406. readonly normalized: boolean;
  88407. /**
  88408. * Gets the data type of each component in the array.
  88409. */
  88410. readonly type: number;
  88411. /**
  88412. * Constructor
  88413. * @param engine the engine
  88414. * @param data the data to use for this vertex buffer
  88415. * @param kind the vertex buffer kind
  88416. * @param updatable whether the data is updatable
  88417. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  88418. * @param stride the stride (optional)
  88419. * @param instanced whether the buffer is instanced (optional)
  88420. * @param offset the offset of the data (optional)
  88421. * @param size the number of components (optional)
  88422. * @param type the type of the component (optional)
  88423. * @param normalized whether the data contains normalized data (optional)
  88424. * @param useBytes set to true if stride and offset are in bytes (optional)
  88425. * @param divisor defines the instance divisor to use (1 by default)
  88426. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  88427. */
  88428. 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, takeBufferOwnership?: boolean);
  88429. /** @hidden */
  88430. _rebuild(): void;
  88431. /**
  88432. * Returns the kind of the VertexBuffer (string)
  88433. * @returns a string
  88434. */
  88435. getKind(): string;
  88436. /**
  88437. * Gets a boolean indicating if the VertexBuffer is updatable?
  88438. * @returns true if the buffer is updatable
  88439. */
  88440. isUpdatable(): boolean;
  88441. /**
  88442. * Gets current buffer's data
  88443. * @returns a DataArray or null
  88444. */
  88445. getData(): Nullable<DataArray>;
  88446. /**
  88447. * Gets underlying native buffer
  88448. * @returns underlying native buffer
  88449. */
  88450. getBuffer(): Nullable<DataBuffer>;
  88451. /**
  88452. * Gets the stride in float32 units (i.e. byte stride / 4).
  88453. * May not be an integer if the byte stride is not divisible by 4.
  88454. * @returns the stride in float32 units
  88455. * @deprecated Please use byteStride instead.
  88456. */
  88457. getStrideSize(): number;
  88458. /**
  88459. * Returns the offset as a multiple of the type byte length.
  88460. * @returns the offset in bytes
  88461. * @deprecated Please use byteOffset instead.
  88462. */
  88463. getOffset(): number;
  88464. /**
  88465. * Returns the number of components per vertex attribute (integer)
  88466. * @returns the size in float
  88467. */
  88468. getSize(): number;
  88469. /**
  88470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  88471. * @returns true if this buffer is instanced
  88472. */
  88473. getIsInstanced(): boolean;
  88474. /**
  88475. * Returns the instancing divisor, zero for non-instanced (integer).
  88476. * @returns a number
  88477. */
  88478. getInstanceDivisor(): number;
  88479. /**
  88480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  88481. * @param data defines the data to store
  88482. */
  88483. create(data?: DataArray): void;
  88484. /**
  88485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  88486. * This function will create a new buffer if the current one is not updatable
  88487. * @param data defines the data to store
  88488. */
  88489. update(data: DataArray): void;
  88490. /**
  88491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  88492. * Returns the directly updated WebGLBuffer.
  88493. * @param data the new data
  88494. * @param offset the new offset
  88495. * @param useBytes set to true if the offset is in bytes
  88496. */
  88497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  88498. /**
  88499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  88500. */
  88501. dispose(): void;
  88502. /**
  88503. * Enumerates each value of this vertex buffer as numbers.
  88504. * @param count the number of values to enumerate
  88505. * @param callback the callback function called for each value
  88506. */
  88507. forEach(count: number, callback: (value: number, index: number) => void): void;
  88508. /**
  88509. * Positions
  88510. */
  88511. static readonly PositionKind: string;
  88512. /**
  88513. * Normals
  88514. */
  88515. static readonly NormalKind: string;
  88516. /**
  88517. * Tangents
  88518. */
  88519. static readonly TangentKind: string;
  88520. /**
  88521. * Texture coordinates
  88522. */
  88523. static readonly UVKind: string;
  88524. /**
  88525. * Texture coordinates 2
  88526. */
  88527. static readonly UV2Kind: string;
  88528. /**
  88529. * Texture coordinates 3
  88530. */
  88531. static readonly UV3Kind: string;
  88532. /**
  88533. * Texture coordinates 4
  88534. */
  88535. static readonly UV4Kind: string;
  88536. /**
  88537. * Texture coordinates 5
  88538. */
  88539. static readonly UV5Kind: string;
  88540. /**
  88541. * Texture coordinates 6
  88542. */
  88543. static readonly UV6Kind: string;
  88544. /**
  88545. * Colors
  88546. */
  88547. static readonly ColorKind: string;
  88548. /**
  88549. * Matrix indices (for bones)
  88550. */
  88551. static readonly MatricesIndicesKind: string;
  88552. /**
  88553. * Matrix weights (for bones)
  88554. */
  88555. static readonly MatricesWeightsKind: string;
  88556. /**
  88557. * Additional matrix indices (for bones)
  88558. */
  88559. static readonly MatricesIndicesExtraKind: string;
  88560. /**
  88561. * Additional matrix weights (for bones)
  88562. */
  88563. static readonly MatricesWeightsExtraKind: string;
  88564. /**
  88565. * Deduces the stride given a kind.
  88566. * @param kind The kind string to deduce
  88567. * @returns The deduced stride
  88568. */
  88569. static DeduceStride(kind: string): number;
  88570. /**
  88571. * Gets the byte length of the given type.
  88572. * @param type the type
  88573. * @returns the number of bytes
  88574. */
  88575. static GetTypeByteLength(type: number): number;
  88576. /**
  88577. * Enumerates each value of the given parameters as numbers.
  88578. * @param data the data to enumerate
  88579. * @param byteOffset the byte offset of the data
  88580. * @param byteStride the byte stride of the data
  88581. * @param componentCount the number of components per element
  88582. * @param componentType the type of the component
  88583. * @param count the number of values to enumerate
  88584. * @param normalized whether the data is normalized
  88585. * @param callback the callback function called for each value
  88586. */
  88587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  88588. private static _GetFloatValue;
  88589. }
  88590. }
  88591. declare module BABYLON {
  88592. /**
  88593. * @hidden
  88594. */
  88595. export class IntersectionInfo {
  88596. bu: Nullable<number>;
  88597. bv: Nullable<number>;
  88598. distance: number;
  88599. faceId: number;
  88600. subMeshId: number;
  88601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88602. }
  88603. }
  88604. declare module BABYLON {
  88605. /**
  88606. * Class used to store bounding sphere information
  88607. */
  88608. export class BoundingSphere {
  88609. /**
  88610. * Gets the center of the bounding sphere in local space
  88611. */
  88612. readonly center: Vector3;
  88613. /**
  88614. * Radius of the bounding sphere in local space
  88615. */
  88616. radius: number;
  88617. /**
  88618. * Gets the center of the bounding sphere in world space
  88619. */
  88620. readonly centerWorld: Vector3;
  88621. /**
  88622. * Radius of the bounding sphere in world space
  88623. */
  88624. radiusWorld: number;
  88625. /**
  88626. * Gets the minimum vector in local space
  88627. */
  88628. readonly minimum: Vector3;
  88629. /**
  88630. * Gets the maximum vector in local space
  88631. */
  88632. readonly maximum: Vector3;
  88633. private _worldMatrix;
  88634. private static readonly TmpVector3;
  88635. /**
  88636. * Creates a new bounding sphere
  88637. * @param min defines the minimum vector (in local space)
  88638. * @param max defines the maximum vector (in local space)
  88639. * @param worldMatrix defines the new world matrix
  88640. */
  88641. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88642. /**
  88643. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88644. * @param min defines the new minimum vector (in local space)
  88645. * @param max defines the new maximum vector (in local space)
  88646. * @param worldMatrix defines the new world matrix
  88647. */
  88648. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88649. /**
  88650. * Scale the current bounding sphere by applying a scale factor
  88651. * @param factor defines the scale factor to apply
  88652. * @returns the current bounding box
  88653. */
  88654. scale(factor: number): BoundingSphere;
  88655. /**
  88656. * Gets the world matrix of the bounding box
  88657. * @returns a matrix
  88658. */
  88659. getWorldMatrix(): DeepImmutable<Matrix>;
  88660. /** @hidden */
  88661. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88662. /**
  88663. * Tests if the bounding sphere is intersecting the frustum planes
  88664. * @param frustumPlanes defines the frustum planes to test
  88665. * @returns true if there is an intersection
  88666. */
  88667. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88668. /**
  88669. * Tests if the bounding sphere center is in between the frustum planes.
  88670. * Used for optimistic fast inclusion.
  88671. * @param frustumPlanes defines the frustum planes to test
  88672. * @returns true if the sphere center is in between the frustum planes
  88673. */
  88674. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88675. /**
  88676. * Tests if a point is inside the bounding sphere
  88677. * @param point defines the point to test
  88678. * @returns true if the point is inside the bounding sphere
  88679. */
  88680. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88681. /**
  88682. * Checks if two sphere intersct
  88683. * @param sphere0 sphere 0
  88684. * @param sphere1 sphere 1
  88685. * @returns true if the speres intersect
  88686. */
  88687. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88688. }
  88689. }
  88690. declare module BABYLON {
  88691. /**
  88692. * Class used to store bounding box information
  88693. */
  88694. export class BoundingBox implements ICullable {
  88695. /**
  88696. * Gets the 8 vectors representing the bounding box in local space
  88697. */
  88698. readonly vectors: Vector3[];
  88699. /**
  88700. * Gets the center of the bounding box in local space
  88701. */
  88702. readonly center: Vector3;
  88703. /**
  88704. * Gets the center of the bounding box in world space
  88705. */
  88706. readonly centerWorld: Vector3;
  88707. /**
  88708. * Gets the extend size in local space
  88709. */
  88710. readonly extendSize: Vector3;
  88711. /**
  88712. * Gets the extend size in world space
  88713. */
  88714. readonly extendSizeWorld: Vector3;
  88715. /**
  88716. * Gets the OBB (object bounding box) directions
  88717. */
  88718. readonly directions: Vector3[];
  88719. /**
  88720. * Gets the 8 vectors representing the bounding box in world space
  88721. */
  88722. readonly vectorsWorld: Vector3[];
  88723. /**
  88724. * Gets the minimum vector in world space
  88725. */
  88726. readonly minimumWorld: Vector3;
  88727. /**
  88728. * Gets the maximum vector in world space
  88729. */
  88730. readonly maximumWorld: Vector3;
  88731. /**
  88732. * Gets the minimum vector in local space
  88733. */
  88734. readonly minimum: Vector3;
  88735. /**
  88736. * Gets the maximum vector in local space
  88737. */
  88738. readonly maximum: Vector3;
  88739. private _worldMatrix;
  88740. private static readonly TmpVector3;
  88741. /**
  88742. * @hidden
  88743. */
  88744. _tag: number;
  88745. /**
  88746. * Creates a new bounding box
  88747. * @param min defines the minimum vector (in local space)
  88748. * @param max defines the maximum vector (in local space)
  88749. * @param worldMatrix defines the new world matrix
  88750. */
  88751. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88752. /**
  88753. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88754. * @param min defines the new minimum vector (in local space)
  88755. * @param max defines the new maximum vector (in local space)
  88756. * @param worldMatrix defines the new world matrix
  88757. */
  88758. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88759. /**
  88760. * Scale the current bounding box by applying a scale factor
  88761. * @param factor defines the scale factor to apply
  88762. * @returns the current bounding box
  88763. */
  88764. scale(factor: number): BoundingBox;
  88765. /**
  88766. * Gets the world matrix of the bounding box
  88767. * @returns a matrix
  88768. */
  88769. getWorldMatrix(): DeepImmutable<Matrix>;
  88770. /** @hidden */
  88771. _update(world: DeepImmutable<Matrix>): void;
  88772. /**
  88773. * Tests if the bounding box is intersecting the frustum planes
  88774. * @param frustumPlanes defines the frustum planes to test
  88775. * @returns true if there is an intersection
  88776. */
  88777. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88778. /**
  88779. * Tests if the bounding box is entirely inside the frustum planes
  88780. * @param frustumPlanes defines the frustum planes to test
  88781. * @returns true if there is an inclusion
  88782. */
  88783. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88784. /**
  88785. * Tests if a point is inside the bounding box
  88786. * @param point defines the point to test
  88787. * @returns true if the point is inside the bounding box
  88788. */
  88789. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88790. /**
  88791. * Tests if the bounding box intersects with a bounding sphere
  88792. * @param sphere defines the sphere to test
  88793. * @returns true if there is an intersection
  88794. */
  88795. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88796. /**
  88797. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88798. * @param min defines the min vector to use
  88799. * @param max defines the max vector to use
  88800. * @returns true if there is an intersection
  88801. */
  88802. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88803. /**
  88804. * Tests if two bounding boxes are intersections
  88805. * @param box0 defines the first box to test
  88806. * @param box1 defines the second box to test
  88807. * @returns true if there is an intersection
  88808. */
  88809. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88810. /**
  88811. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88812. * @param minPoint defines the minimum vector of the bounding box
  88813. * @param maxPoint defines the maximum vector of the bounding box
  88814. * @param sphereCenter defines the sphere center
  88815. * @param sphereRadius defines the sphere radius
  88816. * @returns true if there is an intersection
  88817. */
  88818. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88819. /**
  88820. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88821. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88822. * @param frustumPlanes defines the frustum planes to test
  88823. * @return true if there is an inclusion
  88824. */
  88825. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88826. /**
  88827. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88828. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88829. * @param frustumPlanes defines the frustum planes to test
  88830. * @return true if there is an intersection
  88831. */
  88832. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88833. }
  88834. }
  88835. declare module BABYLON {
  88836. /** @hidden */
  88837. export class Collider {
  88838. /** Define if a collision was found */
  88839. collisionFound: boolean;
  88840. /**
  88841. * Define last intersection point in local space
  88842. */
  88843. intersectionPoint: Vector3;
  88844. /**
  88845. * Define last collided mesh
  88846. */
  88847. collidedMesh: Nullable<AbstractMesh>;
  88848. private _collisionPoint;
  88849. private _planeIntersectionPoint;
  88850. private _tempVector;
  88851. private _tempVector2;
  88852. private _tempVector3;
  88853. private _tempVector4;
  88854. private _edge;
  88855. private _baseToVertex;
  88856. private _destinationPoint;
  88857. private _slidePlaneNormal;
  88858. private _displacementVector;
  88859. /** @hidden */
  88860. _radius: Vector3;
  88861. /** @hidden */
  88862. _retry: number;
  88863. private _velocity;
  88864. private _basePoint;
  88865. private _epsilon;
  88866. /** @hidden */
  88867. _velocityWorldLength: number;
  88868. /** @hidden */
  88869. _basePointWorld: Vector3;
  88870. private _velocityWorld;
  88871. private _normalizedVelocity;
  88872. /** @hidden */
  88873. _initialVelocity: Vector3;
  88874. /** @hidden */
  88875. _initialPosition: Vector3;
  88876. private _nearestDistance;
  88877. private _collisionMask;
  88878. get collisionMask(): number;
  88879. set collisionMask(mask: number);
  88880. /**
  88881. * Gets the plane normal used to compute the sliding response (in local space)
  88882. */
  88883. get slidePlaneNormal(): Vector3;
  88884. /** @hidden */
  88885. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88886. /** @hidden */
  88887. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88888. /** @hidden */
  88889. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88890. /** @hidden */
  88891. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88892. /** @hidden */
  88893. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88894. /** @hidden */
  88895. _getResponse(pos: Vector3, vel: Vector3): void;
  88896. }
  88897. }
  88898. declare module BABYLON {
  88899. /**
  88900. * Interface for cullable objects
  88901. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88902. */
  88903. export interface ICullable {
  88904. /**
  88905. * Checks if the object or part of the object is in the frustum
  88906. * @param frustumPlanes Camera near/planes
  88907. * @returns true if the object is in frustum otherwise false
  88908. */
  88909. isInFrustum(frustumPlanes: Plane[]): boolean;
  88910. /**
  88911. * Checks if a cullable object (mesh...) is in the camera frustum
  88912. * Unlike isInFrustum this cheks the full bounding box
  88913. * @param frustumPlanes Camera near/planes
  88914. * @returns true if the object is in frustum otherwise false
  88915. */
  88916. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88917. }
  88918. /**
  88919. * Info for a bounding data of a mesh
  88920. */
  88921. export class BoundingInfo implements ICullable {
  88922. /**
  88923. * Bounding box for the mesh
  88924. */
  88925. readonly boundingBox: BoundingBox;
  88926. /**
  88927. * Bounding sphere for the mesh
  88928. */
  88929. readonly boundingSphere: BoundingSphere;
  88930. private _isLocked;
  88931. private static readonly TmpVector3;
  88932. /**
  88933. * Constructs bounding info
  88934. * @param minimum min vector of the bounding box/sphere
  88935. * @param maximum max vector of the bounding box/sphere
  88936. * @param worldMatrix defines the new world matrix
  88937. */
  88938. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88939. /**
  88940. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88941. * @param min defines the new minimum vector (in local space)
  88942. * @param max defines the new maximum vector (in local space)
  88943. * @param worldMatrix defines the new world matrix
  88944. */
  88945. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88946. /**
  88947. * min vector of the bounding box/sphere
  88948. */
  88949. get minimum(): Vector3;
  88950. /**
  88951. * max vector of the bounding box/sphere
  88952. */
  88953. get maximum(): Vector3;
  88954. /**
  88955. * If the info is locked and won't be updated to avoid perf overhead
  88956. */
  88957. get isLocked(): boolean;
  88958. set isLocked(value: boolean);
  88959. /**
  88960. * Updates the bounding sphere and box
  88961. * @param world world matrix to be used to update
  88962. */
  88963. update(world: DeepImmutable<Matrix>): void;
  88964. /**
  88965. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88966. * @param center New center of the bounding info
  88967. * @param extend New extend of the bounding info
  88968. * @returns the current bounding info
  88969. */
  88970. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88971. /**
  88972. * Scale the current bounding info by applying a scale factor
  88973. * @param factor defines the scale factor to apply
  88974. * @returns the current bounding info
  88975. */
  88976. scale(factor: number): BoundingInfo;
  88977. /**
  88978. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88979. * @param frustumPlanes defines the frustum to test
  88980. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88981. * @returns true if the bounding info is in the frustum planes
  88982. */
  88983. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88984. /**
  88985. * Gets the world distance between the min and max points of the bounding box
  88986. */
  88987. get diagonalLength(): number;
  88988. /**
  88989. * Checks if a cullable object (mesh...) is in the camera frustum
  88990. * Unlike isInFrustum this cheks the full bounding box
  88991. * @param frustumPlanes Camera near/planes
  88992. * @returns true if the object is in frustum otherwise false
  88993. */
  88994. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88995. /** @hidden */
  88996. _checkCollision(collider: Collider): boolean;
  88997. /**
  88998. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88999. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89000. * @param point the point to check intersection with
  89001. * @returns if the point intersects
  89002. */
  89003. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  89004. /**
  89005. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  89006. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89007. * @param boundingInfo the bounding info to check intersection with
  89008. * @param precise if the intersection should be done using OBB
  89009. * @returns if the bounding info intersects
  89010. */
  89011. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  89012. }
  89013. }
  89014. declare module BABYLON {
  89015. /**
  89016. * Extracts minimum and maximum values from a list of indexed positions
  89017. * @param positions defines the positions to use
  89018. * @param indices defines the indices to the positions
  89019. * @param indexStart defines the start index
  89020. * @param indexCount defines the end index
  89021. * @param bias defines bias value to add to the result
  89022. * @return minimum and maximum values
  89023. */
  89024. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  89025. minimum: Vector3;
  89026. maximum: Vector3;
  89027. };
  89028. /**
  89029. * Extracts minimum and maximum values from a list of positions
  89030. * @param positions defines the positions to use
  89031. * @param start defines the start index in the positions array
  89032. * @param count defines the number of positions to handle
  89033. * @param bias defines bias value to add to the result
  89034. * @param stride defines the stride size to use (distance between two positions in the positions array)
  89035. * @return minimum and maximum values
  89036. */
  89037. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  89038. minimum: Vector3;
  89039. maximum: Vector3;
  89040. };
  89041. }
  89042. declare module BABYLON {
  89043. /**
  89044. * Class used to manipulate GUIDs
  89045. */
  89046. export class GUID {
  89047. /**
  89048. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  89049. * Be aware Math.random() could cause collisions, but:
  89050. * "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"
  89051. * @returns a pseudo random id
  89052. */
  89053. static RandomId(): string;
  89054. }
  89055. }
  89056. declare module BABYLON {
  89057. /**
  89058. * Base class of all the textures in babylon.
  89059. * It groups all the common properties the materials, post process, lights... might need
  89060. * in order to make a correct use of the texture.
  89061. */
  89062. export class BaseTexture extends ThinTexture implements IAnimatable {
  89063. /**
  89064. * Default anisotropic filtering level for the application.
  89065. * It is set to 4 as a good tradeoff between perf and quality.
  89066. */
  89067. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  89068. /**
  89069. * Gets or sets the unique id of the texture
  89070. */
  89071. uniqueId: number;
  89072. /**
  89073. * Define the name of the texture.
  89074. */
  89075. name: string;
  89076. /**
  89077. * Gets or sets an object used to store user defined information.
  89078. */
  89079. metadata: any;
  89080. /**
  89081. * For internal use only. Please do not use.
  89082. */
  89083. reservedDataStore: any;
  89084. private _hasAlpha;
  89085. /**
  89086. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  89087. */
  89088. set hasAlpha(value: boolean);
  89089. get hasAlpha(): boolean;
  89090. /**
  89091. * Defines if the alpha value should be determined via the rgb values.
  89092. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  89093. */
  89094. getAlphaFromRGB: boolean;
  89095. /**
  89096. * Intensity or strength of the texture.
  89097. * It is commonly used by materials to fine tune the intensity of the texture
  89098. */
  89099. level: number;
  89100. /**
  89101. * Define the UV chanel to use starting from 0 and defaulting to 0.
  89102. * This is part of the texture as textures usually maps to one uv set.
  89103. */
  89104. coordinatesIndex: number;
  89105. protected _coordinatesMode: number;
  89106. /**
  89107. * How a texture is mapped.
  89108. *
  89109. * | Value | Type | Description |
  89110. * | ----- | ----------------------------------- | ----------- |
  89111. * | 0 | EXPLICIT_MODE | |
  89112. * | 1 | SPHERICAL_MODE | |
  89113. * | 2 | PLANAR_MODE | |
  89114. * | 3 | CUBIC_MODE | |
  89115. * | 4 | PROJECTION_MODE | |
  89116. * | 5 | SKYBOX_MODE | |
  89117. * | 6 | INVCUBIC_MODE | |
  89118. * | 7 | EQUIRECTANGULAR_MODE | |
  89119. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  89120. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  89121. */
  89122. set coordinatesMode(value: number);
  89123. get coordinatesMode(): number;
  89124. /**
  89125. * | Value | Type | Description |
  89126. * | ----- | ------------------ | ----------- |
  89127. * | 0 | CLAMP_ADDRESSMODE | |
  89128. * | 1 | WRAP_ADDRESSMODE | |
  89129. * | 2 | MIRROR_ADDRESSMODE | |
  89130. */
  89131. get wrapU(): number;
  89132. set wrapU(value: number);
  89133. /**
  89134. * | Value | Type | Description |
  89135. * | ----- | ------------------ | ----------- |
  89136. * | 0 | CLAMP_ADDRESSMODE | |
  89137. * | 1 | WRAP_ADDRESSMODE | |
  89138. * | 2 | MIRROR_ADDRESSMODE | |
  89139. */
  89140. get wrapV(): number;
  89141. set wrapV(value: number);
  89142. /**
  89143. * | Value | Type | Description |
  89144. * | ----- | ------------------ | ----------- |
  89145. * | 0 | CLAMP_ADDRESSMODE | |
  89146. * | 1 | WRAP_ADDRESSMODE | |
  89147. * | 2 | MIRROR_ADDRESSMODE | |
  89148. */
  89149. wrapR: number;
  89150. /**
  89151. * With compliant hardware and browser (supporting anisotropic filtering)
  89152. * this defines the level of anisotropic filtering in the texture.
  89153. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  89154. */
  89155. anisotropicFilteringLevel: number;
  89156. private _isCube;
  89157. /**
  89158. * Define if the texture is a cube texture or if false a 2d texture.
  89159. */
  89160. get isCube(): boolean;
  89161. set isCube(value: boolean);
  89162. /**
  89163. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  89164. */
  89165. get is3D(): boolean;
  89166. set is3D(value: boolean);
  89167. /**
  89168. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  89169. */
  89170. get is2DArray(): boolean;
  89171. set is2DArray(value: boolean);
  89172. private _gammaSpace;
  89173. /**
  89174. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  89175. * HDR texture are usually stored in linear space.
  89176. * This only impacts the PBR and Background materials
  89177. */
  89178. get gammaSpace(): boolean;
  89179. set gammaSpace(gamma: boolean);
  89180. /**
  89181. * Gets or sets whether or not the texture contains RGBD data.
  89182. */
  89183. get isRGBD(): boolean;
  89184. set isRGBD(value: boolean);
  89185. /**
  89186. * Is Z inverted in the texture (useful in a cube texture).
  89187. */
  89188. invertZ: boolean;
  89189. /**
  89190. * Are mip maps generated for this texture or not.
  89191. */
  89192. get noMipmap(): boolean;
  89193. /**
  89194. * @hidden
  89195. */
  89196. lodLevelInAlpha: boolean;
  89197. /**
  89198. * With prefiltered texture, defined the offset used during the prefiltering steps.
  89199. */
  89200. get lodGenerationOffset(): number;
  89201. set lodGenerationOffset(value: number);
  89202. /**
  89203. * With prefiltered texture, defined the scale used during the prefiltering steps.
  89204. */
  89205. get lodGenerationScale(): number;
  89206. set lodGenerationScale(value: number);
  89207. /**
  89208. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  89209. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  89210. * average roughness values.
  89211. */
  89212. get linearSpecularLOD(): boolean;
  89213. set linearSpecularLOD(value: boolean);
  89214. /**
  89215. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  89216. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  89217. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  89218. */
  89219. get irradianceTexture(): Nullable<BaseTexture>;
  89220. set irradianceTexture(value: Nullable<BaseTexture>);
  89221. /**
  89222. * Define if the texture is a render target.
  89223. */
  89224. isRenderTarget: boolean;
  89225. /**
  89226. * Define the unique id of the texture in the scene.
  89227. */
  89228. get uid(): string;
  89229. /** @hidden */
  89230. _prefiltered: boolean;
  89231. /**
  89232. * Return a string representation of the texture.
  89233. * @returns the texture as a string
  89234. */
  89235. toString(): string;
  89236. /**
  89237. * Get the class name of the texture.
  89238. * @returns "BaseTexture"
  89239. */
  89240. getClassName(): string;
  89241. /**
  89242. * Define the list of animation attached to the texture.
  89243. */
  89244. animations: Animation[];
  89245. /**
  89246. * An event triggered when the texture is disposed.
  89247. */
  89248. onDisposeObservable: Observable<BaseTexture>;
  89249. private _onDisposeObserver;
  89250. /**
  89251. * Callback triggered when the texture has been disposed.
  89252. * Kept for back compatibility, you can use the onDisposeObservable instead.
  89253. */
  89254. set onDispose(callback: () => void);
  89255. protected _scene: Nullable<Scene>;
  89256. /** @hidden */
  89257. _texture: Nullable<InternalTexture>;
  89258. private _uid;
  89259. /**
  89260. * Define if the texture is preventinga material to render or not.
  89261. * If not and the texture is not ready, the engine will use a default black texture instead.
  89262. */
  89263. get isBlocking(): boolean;
  89264. /**
  89265. * Instantiates a new BaseTexture.
  89266. * Base class of all the textures in babylon.
  89267. * It groups all the common properties the materials, post process, lights... might need
  89268. * in order to make a correct use of the texture.
  89269. * @param sceneOrEngine Define the scene or engine the texture blongs to
  89270. */
  89271. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  89272. /**
  89273. * Get the scene the texture belongs to.
  89274. * @returns the scene or null if undefined
  89275. */
  89276. getScene(): Nullable<Scene>;
  89277. /** @hidden */
  89278. protected _getEngine(): Nullable<ThinEngine>;
  89279. /**
  89280. * Checks if the texture has the same transform matrix than another texture
  89281. * @param texture texture to check against
  89282. * @returns true if the transforms are the same, else false
  89283. */
  89284. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  89285. /**
  89286. * Get the texture transform matrix used to offset tile the texture for istance.
  89287. * @returns the transformation matrix
  89288. */
  89289. getTextureMatrix(): Matrix;
  89290. /**
  89291. * Get the texture reflection matrix used to rotate/transform the reflection.
  89292. * @returns the reflection matrix
  89293. */
  89294. getReflectionTextureMatrix(): Matrix;
  89295. /**
  89296. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89297. * @returns true if ready or not blocking
  89298. */
  89299. isReadyOrNotBlocking(): boolean;
  89300. /**
  89301. * Scales the texture if is `canRescale()`
  89302. * @param ratio the resize factor we want to use to rescale
  89303. */
  89304. scale(ratio: number): void;
  89305. /**
  89306. * Get if the texture can rescale.
  89307. */
  89308. get canRescale(): boolean;
  89309. /** @hidden */
  89310. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89311. /** @hidden */
  89312. _rebuild(): void;
  89313. /**
  89314. * Clones the texture.
  89315. * @returns the cloned texture
  89316. */
  89317. clone(): Nullable<BaseTexture>;
  89318. /**
  89319. * Get the texture underlying type (INT, FLOAT...)
  89320. */
  89321. get textureType(): number;
  89322. /**
  89323. * Get the texture underlying format (RGB, RGBA...)
  89324. */
  89325. get textureFormat(): number;
  89326. /**
  89327. * Indicates that textures need to be re-calculated for all materials
  89328. */
  89329. protected _markAllSubMeshesAsTexturesDirty(): void;
  89330. /**
  89331. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89332. * This will returns an RGBA array buffer containing either in values (0-255) or
  89333. * float values (0-1) depending of the underlying buffer type.
  89334. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89335. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89336. * @param buffer defines a user defined buffer to fill with data (can be null)
  89337. * @returns The Array buffer containing the pixels data.
  89338. */
  89339. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89340. /** @hidden */
  89341. get _lodTextureHigh(): Nullable<BaseTexture>;
  89342. /** @hidden */
  89343. get _lodTextureMid(): Nullable<BaseTexture>;
  89344. /** @hidden */
  89345. get _lodTextureLow(): Nullable<BaseTexture>;
  89346. /**
  89347. * Dispose the texture and release its associated resources.
  89348. */
  89349. dispose(): void;
  89350. /**
  89351. * Serialize the texture into a JSON representation that can be parsed later on.
  89352. * @returns the JSON representation of the texture
  89353. */
  89354. serialize(): any;
  89355. /**
  89356. * Helper function to be called back once a list of texture contains only ready textures.
  89357. * @param textures Define the list of textures to wait for
  89358. * @param callback Define the callback triggered once the entire list will be ready
  89359. */
  89360. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89361. private static _isScene;
  89362. }
  89363. }
  89364. declare module BABYLON {
  89365. /** @hidden */
  89366. export class WebGLDataBuffer extends DataBuffer {
  89367. private _buffer;
  89368. constructor(resource: WebGLBuffer);
  89369. get underlyingResource(): any;
  89370. }
  89371. }
  89372. declare module BABYLON {
  89373. /** @hidden */
  89374. export class WebGLPipelineContext implements IPipelineContext {
  89375. engine: ThinEngine;
  89376. program: Nullable<WebGLProgram>;
  89377. context?: WebGLRenderingContext;
  89378. vertexShader?: WebGLShader;
  89379. fragmentShader?: WebGLShader;
  89380. isParallelCompiled: boolean;
  89381. onCompiled?: () => void;
  89382. transformFeedback?: WebGLTransformFeedback | null;
  89383. vertexCompilationError: Nullable<string>;
  89384. fragmentCompilationError: Nullable<string>;
  89385. programLinkError: Nullable<string>;
  89386. programValidationError: Nullable<string>;
  89387. get isAsync(): boolean;
  89388. get isReady(): boolean;
  89389. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89390. _getVertexShaderCode(): string | null;
  89391. _getFragmentShaderCode(): string | null;
  89392. }
  89393. }
  89394. declare module BABYLON {
  89395. interface ThinEngine {
  89396. /**
  89397. * Create an uniform buffer
  89398. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89399. * @param elements defines the content of the uniform buffer
  89400. * @returns the webGL uniform buffer
  89401. */
  89402. createUniformBuffer(elements: FloatArray): DataBuffer;
  89403. /**
  89404. * Create a dynamic uniform buffer
  89405. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89406. * @param elements defines the content of the uniform buffer
  89407. * @returns the webGL uniform buffer
  89408. */
  89409. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  89410. /**
  89411. * Update an existing uniform buffer
  89412. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89413. * @param uniformBuffer defines the target uniform buffer
  89414. * @param elements defines the content to update
  89415. * @param offset defines the offset in the uniform buffer where update should start
  89416. * @param count defines the size of the data to update
  89417. */
  89418. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  89419. /**
  89420. * Bind an uniform buffer to the current webGL context
  89421. * @param buffer defines the buffer to bind
  89422. */
  89423. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  89424. /**
  89425. * Bind a buffer to the current webGL context at a given location
  89426. * @param buffer defines the buffer to bind
  89427. * @param location defines the index where to bind the buffer
  89428. */
  89429. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  89430. /**
  89431. * Bind a specific block at a given index in a specific shader program
  89432. * @param pipelineContext defines the pipeline context to use
  89433. * @param blockName defines the block name
  89434. * @param index defines the index where to bind the block
  89435. */
  89436. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  89437. }
  89438. }
  89439. declare module BABYLON {
  89440. /**
  89441. * Uniform buffer objects.
  89442. *
  89443. * Handles blocks of uniform on the GPU.
  89444. *
  89445. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89446. *
  89447. * For more information, please refer to :
  89448. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89449. */
  89450. export class UniformBuffer {
  89451. private _engine;
  89452. private _buffer;
  89453. private _data;
  89454. private _bufferData;
  89455. private _dynamic?;
  89456. private _uniformLocations;
  89457. private _uniformSizes;
  89458. private _uniformLocationPointer;
  89459. private _needSync;
  89460. private _noUBO;
  89461. private _currentEffect;
  89462. /** @hidden */
  89463. _alreadyBound: boolean;
  89464. private static _MAX_UNIFORM_SIZE;
  89465. private static _tempBuffer;
  89466. /**
  89467. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89468. * This is dynamic to allow compat with webgl 1 and 2.
  89469. * You will need to pass the name of the uniform as well as the value.
  89470. */
  89471. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89472. /**
  89473. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89474. * This is dynamic to allow compat with webgl 1 and 2.
  89475. * You will need to pass the name of the uniform as well as the value.
  89476. */
  89477. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89478. /**
  89479. * Lambda to Update a single float in a uniform buffer.
  89480. * This is dynamic to allow compat with webgl 1 and 2.
  89481. * You will need to pass the name of the uniform as well as the value.
  89482. */
  89483. updateFloat: (name: string, x: number) => void;
  89484. /**
  89485. * Lambda to Update a vec2 of float in a uniform buffer.
  89486. * This is dynamic to allow compat with webgl 1 and 2.
  89487. * You will need to pass the name of the uniform as well as the value.
  89488. */
  89489. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89490. /**
  89491. * Lambda to Update a vec3 of float in a uniform buffer.
  89492. * This is dynamic to allow compat with webgl 1 and 2.
  89493. * You will need to pass the name of the uniform as well as the value.
  89494. */
  89495. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89496. /**
  89497. * Lambda to Update a vec4 of float in a uniform buffer.
  89498. * This is dynamic to allow compat with webgl 1 and 2.
  89499. * You will need to pass the name of the uniform as well as the value.
  89500. */
  89501. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89502. /**
  89503. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89504. * This is dynamic to allow compat with webgl 1 and 2.
  89505. * You will need to pass the name of the uniform as well as the value.
  89506. */
  89507. updateMatrix: (name: string, mat: Matrix) => void;
  89508. /**
  89509. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89510. * This is dynamic to allow compat with webgl 1 and 2.
  89511. * You will need to pass the name of the uniform as well as the value.
  89512. */
  89513. updateVector3: (name: string, vector: Vector3) => void;
  89514. /**
  89515. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89516. * This is dynamic to allow compat with webgl 1 and 2.
  89517. * You will need to pass the name of the uniform as well as the value.
  89518. */
  89519. updateVector4: (name: string, vector: Vector4) => void;
  89520. /**
  89521. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89522. * This is dynamic to allow compat with webgl 1 and 2.
  89523. * You will need to pass the name of the uniform as well as the value.
  89524. */
  89525. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89526. /**
  89527. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89528. * This is dynamic to allow compat with webgl 1 and 2.
  89529. * You will need to pass the name of the uniform as well as the value.
  89530. */
  89531. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89532. /**
  89533. * Instantiates a new Uniform buffer objects.
  89534. *
  89535. * Handles blocks of uniform on the GPU.
  89536. *
  89537. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89538. *
  89539. * For more information, please refer to :
  89540. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89541. * @param engine Define the engine the buffer is associated with
  89542. * @param data Define the data contained in the buffer
  89543. * @param dynamic Define if the buffer is updatable
  89544. */
  89545. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89546. /**
  89547. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89548. * or just falling back on setUniformXXX calls.
  89549. */
  89550. get useUbo(): boolean;
  89551. /**
  89552. * Indicates if the WebGL underlying uniform buffer is in sync
  89553. * with the javascript cache data.
  89554. */
  89555. get isSync(): boolean;
  89556. /**
  89557. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89558. * Also, a dynamic UniformBuffer will disable cache verification and always
  89559. * update the underlying WebGL uniform buffer to the GPU.
  89560. * @returns if Dynamic, otherwise false
  89561. */
  89562. isDynamic(): boolean;
  89563. /**
  89564. * The data cache on JS side.
  89565. * @returns the underlying data as a float array
  89566. */
  89567. getData(): Float32Array;
  89568. /**
  89569. * The underlying WebGL Uniform buffer.
  89570. * @returns the webgl buffer
  89571. */
  89572. getBuffer(): Nullable<DataBuffer>;
  89573. /**
  89574. * std140 layout specifies how to align data within an UBO structure.
  89575. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89576. * for specs.
  89577. */
  89578. private _fillAlignment;
  89579. /**
  89580. * Adds an uniform in the buffer.
  89581. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89582. * for the layout to be correct !
  89583. * @param name Name of the uniform, as used in the uniform block in the shader.
  89584. * @param size Data size, or data directly.
  89585. */
  89586. addUniform(name: string, size: number | number[]): void;
  89587. /**
  89588. * Adds a Matrix 4x4 to the uniform buffer.
  89589. * @param name Name of the uniform, as used in the uniform block in the shader.
  89590. * @param mat A 4x4 matrix.
  89591. */
  89592. addMatrix(name: string, mat: Matrix): void;
  89593. /**
  89594. * Adds a vec2 to the uniform buffer.
  89595. * @param name Name of the uniform, as used in the uniform block in the shader.
  89596. * @param x Define the x component value of the vec2
  89597. * @param y Define the y component value of the vec2
  89598. */
  89599. addFloat2(name: string, x: number, y: number): void;
  89600. /**
  89601. * Adds a vec3 to the uniform buffer.
  89602. * @param name Name of the uniform, as used in the uniform block in the shader.
  89603. * @param x Define the x component value of the vec3
  89604. * @param y Define the y component value of the vec3
  89605. * @param z Define the z component value of the vec3
  89606. */
  89607. addFloat3(name: string, x: number, y: number, z: number): void;
  89608. /**
  89609. * Adds a vec3 to the uniform buffer.
  89610. * @param name Name of the uniform, as used in the uniform block in the shader.
  89611. * @param color Define the vec3 from a Color
  89612. */
  89613. addColor3(name: string, color: Color3): void;
  89614. /**
  89615. * Adds a vec4 to the uniform buffer.
  89616. * @param name Name of the uniform, as used in the uniform block in the shader.
  89617. * @param color Define the rgb components from a Color
  89618. * @param alpha Define the a component of the vec4
  89619. */
  89620. addColor4(name: string, color: Color3, alpha: number): void;
  89621. /**
  89622. * Adds a vec3 to the uniform buffer.
  89623. * @param name Name of the uniform, as used in the uniform block in the shader.
  89624. * @param vector Define the vec3 components from a Vector
  89625. */
  89626. addVector3(name: string, vector: Vector3): void;
  89627. /**
  89628. * Adds a Matrix 3x3 to the uniform buffer.
  89629. * @param name Name of the uniform, as used in the uniform block in the shader.
  89630. */
  89631. addMatrix3x3(name: string): void;
  89632. /**
  89633. * Adds a Matrix 2x2 to the uniform buffer.
  89634. * @param name Name of the uniform, as used in the uniform block in the shader.
  89635. */
  89636. addMatrix2x2(name: string): void;
  89637. /**
  89638. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89639. */
  89640. create(): void;
  89641. /** @hidden */
  89642. _rebuild(): void;
  89643. /**
  89644. * Updates the WebGL Uniform Buffer on the GPU.
  89645. * If the `dynamic` flag is set to true, no cache comparison is done.
  89646. * Otherwise, the buffer will be updated only if the cache differs.
  89647. */
  89648. update(): void;
  89649. /**
  89650. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89651. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89652. * @param data Define the flattened data
  89653. * @param size Define the size of the data.
  89654. */
  89655. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89656. private _valueCache;
  89657. private _cacheMatrix;
  89658. private _updateMatrix3x3ForUniform;
  89659. private _updateMatrix3x3ForEffect;
  89660. private _updateMatrix2x2ForEffect;
  89661. private _updateMatrix2x2ForUniform;
  89662. private _updateFloatForEffect;
  89663. private _updateFloatForUniform;
  89664. private _updateFloat2ForEffect;
  89665. private _updateFloat2ForUniform;
  89666. private _updateFloat3ForEffect;
  89667. private _updateFloat3ForUniform;
  89668. private _updateFloat4ForEffect;
  89669. private _updateFloat4ForUniform;
  89670. private _updateMatrixForEffect;
  89671. private _updateMatrixForUniform;
  89672. private _updateVector3ForEffect;
  89673. private _updateVector3ForUniform;
  89674. private _updateVector4ForEffect;
  89675. private _updateVector4ForUniform;
  89676. private _updateColor3ForEffect;
  89677. private _updateColor3ForUniform;
  89678. private _updateColor4ForEffect;
  89679. private _updateColor4ForUniform;
  89680. /**
  89681. * Sets a sampler uniform on the effect.
  89682. * @param name Define the name of the sampler.
  89683. * @param texture Define the texture to set in the sampler
  89684. */
  89685. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89686. /**
  89687. * Directly updates the value of the uniform in the cache AND on the GPU.
  89688. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89689. * @param data Define the flattened data
  89690. */
  89691. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89692. /**
  89693. * Binds this uniform buffer to an effect.
  89694. * @param effect Define the effect to bind the buffer to
  89695. * @param name Name of the uniform block in the shader.
  89696. */
  89697. bindToEffect(effect: Effect, name: string): void;
  89698. /**
  89699. * Disposes the uniform buffer.
  89700. */
  89701. dispose(): void;
  89702. }
  89703. }
  89704. declare module BABYLON {
  89705. /**
  89706. * Manages the defines for the Material
  89707. */
  89708. export class MaterialDefines {
  89709. /** @hidden */
  89710. protected _keys: string[];
  89711. private _isDirty;
  89712. /** @hidden */
  89713. _renderId: number;
  89714. /** @hidden */
  89715. _areLightsDirty: boolean;
  89716. /** @hidden */
  89717. _areLightsDisposed: boolean;
  89718. /** @hidden */
  89719. _areAttributesDirty: boolean;
  89720. /** @hidden */
  89721. _areTexturesDirty: boolean;
  89722. /** @hidden */
  89723. _areFresnelDirty: boolean;
  89724. /** @hidden */
  89725. _areMiscDirty: boolean;
  89726. /** @hidden */
  89727. _arePrePassDirty: boolean;
  89728. /** @hidden */
  89729. _areImageProcessingDirty: boolean;
  89730. /** @hidden */
  89731. _normals: boolean;
  89732. /** @hidden */
  89733. _uvs: boolean;
  89734. /** @hidden */
  89735. _needNormals: boolean;
  89736. /** @hidden */
  89737. _needUVs: boolean;
  89738. [id: string]: any;
  89739. /**
  89740. * Specifies if the material needs to be re-calculated
  89741. */
  89742. get isDirty(): boolean;
  89743. /**
  89744. * Marks the material to indicate that it has been re-calculated
  89745. */
  89746. markAsProcessed(): void;
  89747. /**
  89748. * Marks the material to indicate that it needs to be re-calculated
  89749. */
  89750. markAsUnprocessed(): void;
  89751. /**
  89752. * Marks the material to indicate all of its defines need to be re-calculated
  89753. */
  89754. markAllAsDirty(): void;
  89755. /**
  89756. * Marks the material to indicate that image processing needs to be re-calculated
  89757. */
  89758. markAsImageProcessingDirty(): void;
  89759. /**
  89760. * Marks the material to indicate the lights need to be re-calculated
  89761. * @param disposed Defines whether the light is dirty due to dispose or not
  89762. */
  89763. markAsLightDirty(disposed?: boolean): void;
  89764. /**
  89765. * Marks the attribute state as changed
  89766. */
  89767. markAsAttributesDirty(): void;
  89768. /**
  89769. * Marks the texture state as changed
  89770. */
  89771. markAsTexturesDirty(): void;
  89772. /**
  89773. * Marks the fresnel state as changed
  89774. */
  89775. markAsFresnelDirty(): void;
  89776. /**
  89777. * Marks the misc state as changed
  89778. */
  89779. markAsMiscDirty(): void;
  89780. /**
  89781. * Marks the prepass state as changed
  89782. */
  89783. markAsPrePassDirty(): void;
  89784. /**
  89785. * Rebuilds the material defines
  89786. */
  89787. rebuild(): void;
  89788. /**
  89789. * Specifies if two material defines are equal
  89790. * @param other - A material define instance to compare to
  89791. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89792. */
  89793. isEqual(other: MaterialDefines): boolean;
  89794. /**
  89795. * Clones this instance's defines to another instance
  89796. * @param other - material defines to clone values to
  89797. */
  89798. cloneTo(other: MaterialDefines): void;
  89799. /**
  89800. * Resets the material define values
  89801. */
  89802. reset(): void;
  89803. /**
  89804. * Converts the material define values to a string
  89805. * @returns - String of material define information
  89806. */
  89807. toString(): string;
  89808. }
  89809. }
  89810. declare module BABYLON {
  89811. /**
  89812. * Enum that determines the text-wrapping mode to use.
  89813. */
  89814. export enum InspectableType {
  89815. /**
  89816. * Checkbox for booleans
  89817. */
  89818. Checkbox = 0,
  89819. /**
  89820. * Sliders for numbers
  89821. */
  89822. Slider = 1,
  89823. /**
  89824. * Vector3
  89825. */
  89826. Vector3 = 2,
  89827. /**
  89828. * Quaternions
  89829. */
  89830. Quaternion = 3,
  89831. /**
  89832. * Color3
  89833. */
  89834. Color3 = 4,
  89835. /**
  89836. * String
  89837. */
  89838. String = 5
  89839. }
  89840. /**
  89841. * Interface used to define custom inspectable properties.
  89842. * This interface is used by the inspector to display custom property grids
  89843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89844. */
  89845. export interface IInspectable {
  89846. /**
  89847. * Gets the label to display
  89848. */
  89849. label: string;
  89850. /**
  89851. * Gets the name of the property to edit
  89852. */
  89853. propertyName: string;
  89854. /**
  89855. * Gets the type of the editor to use
  89856. */
  89857. type: InspectableType;
  89858. /**
  89859. * Gets the minimum value of the property when using in "slider" mode
  89860. */
  89861. min?: number;
  89862. /**
  89863. * Gets the maximum value of the property when using in "slider" mode
  89864. */
  89865. max?: number;
  89866. /**
  89867. * Gets the setp to use when using in "slider" mode
  89868. */
  89869. step?: number;
  89870. }
  89871. }
  89872. declare module BABYLON {
  89873. /**
  89874. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89875. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89876. * 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.
  89877. */
  89878. export abstract class Light extends Node {
  89879. /**
  89880. * Falloff Default: light is falling off following the material specification:
  89881. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89882. */
  89883. static readonly FALLOFF_DEFAULT: number;
  89884. /**
  89885. * Falloff Physical: light is falling off following the inverse squared distance law.
  89886. */
  89887. static readonly FALLOFF_PHYSICAL: number;
  89888. /**
  89889. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89890. * to enhance interoperability with other engines.
  89891. */
  89892. static readonly FALLOFF_GLTF: number;
  89893. /**
  89894. * Falloff Standard: light is falling off like in the standard material
  89895. * to enhance interoperability with other materials.
  89896. */
  89897. static readonly FALLOFF_STANDARD: number;
  89898. /**
  89899. * If every light affecting the material is in this lightmapMode,
  89900. * material.lightmapTexture adds or multiplies
  89901. * (depends on material.useLightmapAsShadowmap)
  89902. * after every other light calculations.
  89903. */
  89904. static readonly LIGHTMAP_DEFAULT: number;
  89905. /**
  89906. * material.lightmapTexture as only diffuse lighting from this light
  89907. * adds only specular lighting from this light
  89908. * adds dynamic shadows
  89909. */
  89910. static readonly LIGHTMAP_SPECULAR: number;
  89911. /**
  89912. * material.lightmapTexture as only lighting
  89913. * no light calculation from this light
  89914. * only adds dynamic shadows from this light
  89915. */
  89916. static readonly LIGHTMAP_SHADOWSONLY: number;
  89917. /**
  89918. * Each light type uses the default quantity according to its type:
  89919. * point/spot lights use luminous intensity
  89920. * directional lights use illuminance
  89921. */
  89922. static readonly INTENSITYMODE_AUTOMATIC: number;
  89923. /**
  89924. * lumen (lm)
  89925. */
  89926. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89927. /**
  89928. * candela (lm/sr)
  89929. */
  89930. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89931. /**
  89932. * lux (lm/m^2)
  89933. */
  89934. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89935. /**
  89936. * nit (cd/m^2)
  89937. */
  89938. static readonly INTENSITYMODE_LUMINANCE: number;
  89939. /**
  89940. * Light type const id of the point light.
  89941. */
  89942. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89943. /**
  89944. * Light type const id of the directional light.
  89945. */
  89946. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89947. /**
  89948. * Light type const id of the spot light.
  89949. */
  89950. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89951. /**
  89952. * Light type const id of the hemispheric light.
  89953. */
  89954. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89955. /**
  89956. * Diffuse gives the basic color to an object.
  89957. */
  89958. diffuse: Color3;
  89959. /**
  89960. * Specular produces a highlight color on an object.
  89961. * Note: This is note affecting PBR materials.
  89962. */
  89963. specular: Color3;
  89964. /**
  89965. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89966. * falling off base on range or angle.
  89967. * This can be set to any values in Light.FALLOFF_x.
  89968. *
  89969. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89970. * other types of materials.
  89971. */
  89972. falloffType: number;
  89973. /**
  89974. * Strength of the light.
  89975. * Note: By default it is define in the framework own unit.
  89976. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89977. */
  89978. intensity: number;
  89979. private _range;
  89980. protected _inverseSquaredRange: number;
  89981. /**
  89982. * Defines how far from the source the light is impacting in scene units.
  89983. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89984. */
  89985. get range(): number;
  89986. /**
  89987. * Defines how far from the source the light is impacting in scene units.
  89988. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89989. */
  89990. set range(value: number);
  89991. /**
  89992. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89993. * of light.
  89994. */
  89995. private _photometricScale;
  89996. private _intensityMode;
  89997. /**
  89998. * Gets the photometric scale used to interpret the intensity.
  89999. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90000. */
  90001. get intensityMode(): number;
  90002. /**
  90003. * Sets the photometric scale used to interpret the intensity.
  90004. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90005. */
  90006. set intensityMode(value: number);
  90007. private _radius;
  90008. /**
  90009. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90010. */
  90011. get radius(): number;
  90012. /**
  90013. * sets the light radius used by PBR Materials to simulate soft area lights.
  90014. */
  90015. set radius(value: number);
  90016. private _renderPriority;
  90017. /**
  90018. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90019. * exceeding the number allowed of the materials.
  90020. */
  90021. renderPriority: number;
  90022. private _shadowEnabled;
  90023. /**
  90024. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90025. * the current shadow generator.
  90026. */
  90027. get shadowEnabled(): boolean;
  90028. /**
  90029. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90030. * the current shadow generator.
  90031. */
  90032. set shadowEnabled(value: boolean);
  90033. private _includedOnlyMeshes;
  90034. /**
  90035. * Gets the only meshes impacted by this light.
  90036. */
  90037. get includedOnlyMeshes(): AbstractMesh[];
  90038. /**
  90039. * Sets the only meshes impacted by this light.
  90040. */
  90041. set includedOnlyMeshes(value: AbstractMesh[]);
  90042. private _excludedMeshes;
  90043. /**
  90044. * Gets the meshes not impacted by this light.
  90045. */
  90046. get excludedMeshes(): AbstractMesh[];
  90047. /**
  90048. * Sets the meshes not impacted by this light.
  90049. */
  90050. set excludedMeshes(value: AbstractMesh[]);
  90051. private _excludeWithLayerMask;
  90052. /**
  90053. * Gets the layer id use to find what meshes are not impacted by the light.
  90054. * Inactive if 0
  90055. */
  90056. get excludeWithLayerMask(): number;
  90057. /**
  90058. * Sets the layer id use to find what meshes are not impacted by the light.
  90059. * Inactive if 0
  90060. */
  90061. set excludeWithLayerMask(value: number);
  90062. private _includeOnlyWithLayerMask;
  90063. /**
  90064. * Gets the layer id use to find what meshes are impacted by the light.
  90065. * Inactive if 0
  90066. */
  90067. get includeOnlyWithLayerMask(): number;
  90068. /**
  90069. * Sets the layer id use to find what meshes are impacted by the light.
  90070. * Inactive if 0
  90071. */
  90072. set includeOnlyWithLayerMask(value: number);
  90073. private _lightmapMode;
  90074. /**
  90075. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90076. */
  90077. get lightmapMode(): number;
  90078. /**
  90079. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90080. */
  90081. set lightmapMode(value: number);
  90082. /**
  90083. * Shadow generator associted to the light.
  90084. * @hidden Internal use only.
  90085. */
  90086. _shadowGenerator: Nullable<IShadowGenerator>;
  90087. /**
  90088. * @hidden Internal use only.
  90089. */
  90090. _excludedMeshesIds: string[];
  90091. /**
  90092. * @hidden Internal use only.
  90093. */
  90094. _includedOnlyMeshesIds: string[];
  90095. /**
  90096. * The current light unifom buffer.
  90097. * @hidden Internal use only.
  90098. */
  90099. _uniformBuffer: UniformBuffer;
  90100. /** @hidden */
  90101. _renderId: number;
  90102. /**
  90103. * Creates a Light object in the scene.
  90104. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90105. * @param name The firendly name of the light
  90106. * @param scene The scene the light belongs too
  90107. */
  90108. constructor(name: string, scene: Scene);
  90109. protected abstract _buildUniformLayout(): void;
  90110. /**
  90111. * Sets the passed Effect "effect" with the Light information.
  90112. * @param effect The effect to update
  90113. * @param lightIndex The index of the light in the effect to update
  90114. * @returns The light
  90115. */
  90116. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90117. /**
  90118. * Sets the passed Effect "effect" with the Light textures.
  90119. * @param effect The effect to update
  90120. * @param lightIndex The index of the light in the effect to update
  90121. * @returns The light
  90122. */
  90123. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90124. /**
  90125. * Binds the lights information from the scene to the effect for the given mesh.
  90126. * @param lightIndex Light index
  90127. * @param scene The scene where the light belongs to
  90128. * @param effect The effect we are binding the data to
  90129. * @param useSpecular Defines if specular is supported
  90130. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90131. */
  90132. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90133. /**
  90134. * Sets the passed Effect "effect" with the Light information.
  90135. * @param effect The effect to update
  90136. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90137. * @returns The light
  90138. */
  90139. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90140. /**
  90141. * Returns the string "Light".
  90142. * @returns the class name
  90143. */
  90144. getClassName(): string;
  90145. /** @hidden */
  90146. readonly _isLight: boolean;
  90147. /**
  90148. * Converts the light information to a readable string for debug purpose.
  90149. * @param fullDetails Supports for multiple levels of logging within scene loading
  90150. * @returns the human readable light info
  90151. */
  90152. toString(fullDetails?: boolean): string;
  90153. /** @hidden */
  90154. protected _syncParentEnabledState(): void;
  90155. /**
  90156. * Set the enabled state of this node.
  90157. * @param value - the new enabled state
  90158. */
  90159. setEnabled(value: boolean): void;
  90160. /**
  90161. * Returns the Light associated shadow generator if any.
  90162. * @return the associated shadow generator.
  90163. */
  90164. getShadowGenerator(): Nullable<IShadowGenerator>;
  90165. /**
  90166. * Returns a Vector3, the absolute light position in the World.
  90167. * @returns the world space position of the light
  90168. */
  90169. getAbsolutePosition(): Vector3;
  90170. /**
  90171. * Specifies if the light will affect the passed mesh.
  90172. * @param mesh The mesh to test against the light
  90173. * @return true the mesh is affected otherwise, false.
  90174. */
  90175. canAffectMesh(mesh: AbstractMesh): boolean;
  90176. /**
  90177. * Sort function to order lights for rendering.
  90178. * @param a First Light object to compare to second.
  90179. * @param b Second Light object to compare first.
  90180. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90181. */
  90182. static CompareLightsPriority(a: Light, b: Light): number;
  90183. /**
  90184. * Releases resources associated with this node.
  90185. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90186. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90187. */
  90188. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90189. /**
  90190. * Returns the light type ID (integer).
  90191. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90192. */
  90193. getTypeID(): number;
  90194. /**
  90195. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90196. * @returns the scaled intensity in intensity mode unit
  90197. */
  90198. getScaledIntensity(): number;
  90199. /**
  90200. * Returns a new Light object, named "name", from the current one.
  90201. * @param name The name of the cloned light
  90202. * @param newParent The parent of this light, if it has one
  90203. * @returns the new created light
  90204. */
  90205. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  90206. /**
  90207. * Serializes the current light into a Serialization object.
  90208. * @returns the serialized object.
  90209. */
  90210. serialize(): any;
  90211. /**
  90212. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90213. * This new light is named "name" and added to the passed scene.
  90214. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90215. * @param name The friendly name of the light
  90216. * @param scene The scene the new light will belong to
  90217. * @returns the constructor function
  90218. */
  90219. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90220. /**
  90221. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90222. * @param parsedLight The JSON representation of the light
  90223. * @param scene The scene to create the parsed light in
  90224. * @returns the created light after parsing
  90225. */
  90226. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90227. private _hookArrayForExcluded;
  90228. private _hookArrayForIncludedOnly;
  90229. private _resyncMeshes;
  90230. /**
  90231. * Forces the meshes to update their light related information in their rendering used effects
  90232. * @hidden Internal Use Only
  90233. */
  90234. _markMeshesAsLightDirty(): void;
  90235. /**
  90236. * Recomputes the cached photometric scale if needed.
  90237. */
  90238. private _computePhotometricScale;
  90239. /**
  90240. * Returns the Photometric Scale according to the light type and intensity mode.
  90241. */
  90242. private _getPhotometricScale;
  90243. /**
  90244. * Reorder the light in the scene according to their defined priority.
  90245. * @hidden Internal Use Only
  90246. */
  90247. _reorderLightsInScene(): void;
  90248. /**
  90249. * Prepares the list of defines specific to the light type.
  90250. * @param defines the list of defines
  90251. * @param lightIndex defines the index of the light for the effect
  90252. */
  90253. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90254. }
  90255. }
  90256. declare module BABYLON {
  90257. /** Defines supported spaces */
  90258. export enum Space {
  90259. /** Local (object) space */
  90260. LOCAL = 0,
  90261. /** World space */
  90262. WORLD = 1,
  90263. /** Bone space */
  90264. BONE = 2
  90265. }
  90266. /** Defines the 3 main axes */
  90267. export class Axis {
  90268. /** X axis */
  90269. static X: Vector3;
  90270. /** Y axis */
  90271. static Y: Vector3;
  90272. /** Z axis */
  90273. static Z: Vector3;
  90274. }
  90275. /**
  90276. * Defines cartesian components.
  90277. */
  90278. export enum Coordinate {
  90279. /** X axis */
  90280. X = 0,
  90281. /** Y axis */
  90282. Y = 1,
  90283. /** Z axis */
  90284. Z = 2
  90285. }
  90286. }
  90287. declare module BABYLON {
  90288. /**
  90289. * Interface describing all the common properties and methods a shadow light needs to implement.
  90290. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90291. * as well as binding the different shadow properties to the effects.
  90292. */
  90293. export interface IShadowLight extends Light {
  90294. /**
  90295. * The light id in the scene (used in scene.findLighById for instance)
  90296. */
  90297. id: string;
  90298. /**
  90299. * The position the shdow will be casted from.
  90300. */
  90301. position: Vector3;
  90302. /**
  90303. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90304. */
  90305. direction: Vector3;
  90306. /**
  90307. * The transformed position. Position of the light in world space taking parenting in account.
  90308. */
  90309. transformedPosition: Vector3;
  90310. /**
  90311. * The transformed direction. Direction of the light in world space taking parenting in account.
  90312. */
  90313. transformedDirection: Vector3;
  90314. /**
  90315. * The friendly name of the light in the scene.
  90316. */
  90317. name: string;
  90318. /**
  90319. * Defines the shadow projection clipping minimum z value.
  90320. */
  90321. shadowMinZ: number;
  90322. /**
  90323. * Defines the shadow projection clipping maximum z value.
  90324. */
  90325. shadowMaxZ: number;
  90326. /**
  90327. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90328. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90329. */
  90330. computeTransformedInformation(): boolean;
  90331. /**
  90332. * Gets the scene the light belongs to.
  90333. * @returns The scene
  90334. */
  90335. getScene(): Scene;
  90336. /**
  90337. * Callback defining a custom Projection Matrix Builder.
  90338. * This can be used to override the default projection matrix computation.
  90339. */
  90340. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90341. /**
  90342. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90343. * @param matrix The materix to updated with the projection information
  90344. * @param viewMatrix The transform matrix of the light
  90345. * @param renderList The list of mesh to render in the map
  90346. * @returns The current light
  90347. */
  90348. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90349. /**
  90350. * Gets the current depth scale used in ESM.
  90351. * @returns The scale
  90352. */
  90353. getDepthScale(): number;
  90354. /**
  90355. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90356. * @returns true if a cube texture needs to be use
  90357. */
  90358. needCube(): boolean;
  90359. /**
  90360. * Detects if the projection matrix requires to be recomputed this frame.
  90361. * @returns true if it requires to be recomputed otherwise, false.
  90362. */
  90363. needProjectionMatrixCompute(): boolean;
  90364. /**
  90365. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90366. */
  90367. forceProjectionMatrixCompute(): void;
  90368. /**
  90369. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90370. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90371. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90372. */
  90373. getShadowDirection(faceIndex?: number): Vector3;
  90374. /**
  90375. * Gets the minZ used for shadow according to both the scene and the light.
  90376. * @param activeCamera The camera we are returning the min for
  90377. * @returns the depth min z
  90378. */
  90379. getDepthMinZ(activeCamera: Camera): number;
  90380. /**
  90381. * Gets the maxZ used for shadow according to both the scene and the light.
  90382. * @param activeCamera The camera we are returning the max for
  90383. * @returns the depth max z
  90384. */
  90385. getDepthMaxZ(activeCamera: Camera): number;
  90386. }
  90387. /**
  90388. * Base implementation IShadowLight
  90389. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90390. */
  90391. export abstract class ShadowLight extends Light implements IShadowLight {
  90392. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90393. protected _position: Vector3;
  90394. protected _setPosition(value: Vector3): void;
  90395. /**
  90396. * Sets the position the shadow will be casted from. Also use as the light position for both
  90397. * point and spot lights.
  90398. */
  90399. get position(): Vector3;
  90400. /**
  90401. * Sets the position the shadow will be casted from. Also use as the light position for both
  90402. * point and spot lights.
  90403. */
  90404. set position(value: Vector3);
  90405. protected _direction: Vector3;
  90406. protected _setDirection(value: Vector3): void;
  90407. /**
  90408. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90409. * Also use as the light direction on spot and directional lights.
  90410. */
  90411. get direction(): Vector3;
  90412. /**
  90413. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90414. * Also use as the light direction on spot and directional lights.
  90415. */
  90416. set direction(value: Vector3);
  90417. protected _shadowMinZ: number;
  90418. /**
  90419. * Gets the shadow projection clipping minimum z value.
  90420. */
  90421. get shadowMinZ(): number;
  90422. /**
  90423. * Sets the shadow projection clipping minimum z value.
  90424. */
  90425. set shadowMinZ(value: number);
  90426. protected _shadowMaxZ: number;
  90427. /**
  90428. * Sets the shadow projection clipping maximum z value.
  90429. */
  90430. get shadowMaxZ(): number;
  90431. /**
  90432. * Gets the shadow projection clipping maximum z value.
  90433. */
  90434. set shadowMaxZ(value: number);
  90435. /**
  90436. * Callback defining a custom Projection Matrix Builder.
  90437. * This can be used to override the default projection matrix computation.
  90438. */
  90439. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90440. /**
  90441. * The transformed position. Position of the light in world space taking parenting in account.
  90442. */
  90443. transformedPosition: Vector3;
  90444. /**
  90445. * The transformed direction. Direction of the light in world space taking parenting in account.
  90446. */
  90447. transformedDirection: Vector3;
  90448. private _needProjectionMatrixCompute;
  90449. /**
  90450. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90451. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90452. */
  90453. computeTransformedInformation(): boolean;
  90454. /**
  90455. * Return the depth scale used for the shadow map.
  90456. * @returns the depth scale.
  90457. */
  90458. getDepthScale(): number;
  90459. /**
  90460. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90461. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90462. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90463. */
  90464. getShadowDirection(faceIndex?: number): Vector3;
  90465. /**
  90466. * Returns the ShadowLight absolute position in the World.
  90467. * @returns the position vector in world space
  90468. */
  90469. getAbsolutePosition(): Vector3;
  90470. /**
  90471. * Sets the ShadowLight direction toward the passed target.
  90472. * @param target The point to target in local space
  90473. * @returns the updated ShadowLight direction
  90474. */
  90475. setDirectionToTarget(target: Vector3): Vector3;
  90476. /**
  90477. * Returns the light rotation in euler definition.
  90478. * @returns the x y z rotation in local space.
  90479. */
  90480. getRotation(): Vector3;
  90481. /**
  90482. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90483. * @returns true if a cube texture needs to be use
  90484. */
  90485. needCube(): boolean;
  90486. /**
  90487. * Detects if the projection matrix requires to be recomputed this frame.
  90488. * @returns true if it requires to be recomputed otherwise, false.
  90489. */
  90490. needProjectionMatrixCompute(): boolean;
  90491. /**
  90492. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90493. */
  90494. forceProjectionMatrixCompute(): void;
  90495. /** @hidden */
  90496. _initCache(): void;
  90497. /** @hidden */
  90498. _isSynchronized(): boolean;
  90499. /**
  90500. * Computes the world matrix of the node
  90501. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90502. * @returns the world matrix
  90503. */
  90504. computeWorldMatrix(force?: boolean): Matrix;
  90505. /**
  90506. * Gets the minZ used for shadow according to both the scene and the light.
  90507. * @param activeCamera The camera we are returning the min for
  90508. * @returns the depth min z
  90509. */
  90510. getDepthMinZ(activeCamera: Camera): number;
  90511. /**
  90512. * Gets the maxZ used for shadow according to both the scene and the light.
  90513. * @param activeCamera The camera we are returning the max for
  90514. * @returns the depth max z
  90515. */
  90516. getDepthMaxZ(activeCamera: Camera): number;
  90517. /**
  90518. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90519. * @param matrix The materix to updated with the projection information
  90520. * @param viewMatrix The transform matrix of the light
  90521. * @param renderList The list of mesh to render in the map
  90522. * @returns The current light
  90523. */
  90524. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90525. }
  90526. }
  90527. declare module BABYLON {
  90528. /**
  90529. * Configuration needed for prepass-capable materials
  90530. */
  90531. export class PrePassConfiguration {
  90532. /**
  90533. * Previous world matrices of meshes carrying this material
  90534. * Used for computing velocity
  90535. */
  90536. previousWorldMatrices: {
  90537. [index: number]: Matrix;
  90538. };
  90539. /**
  90540. * Previous view project matrix
  90541. * Used for computing velocity
  90542. */
  90543. previousViewProjection: Matrix;
  90544. /**
  90545. * Previous bones of meshes carrying this material
  90546. * Used for computing velocity
  90547. */
  90548. previousBones: {
  90549. [index: number]: Float32Array;
  90550. };
  90551. /**
  90552. * Add the required uniforms to the current list.
  90553. * @param uniforms defines the current uniform list.
  90554. */
  90555. static AddUniforms(uniforms: string[]): void;
  90556. /**
  90557. * Add the required samplers to the current list.
  90558. * @param samplers defines the current sampler list.
  90559. */
  90560. static AddSamplers(samplers: string[]): void;
  90561. /**
  90562. * Binds the material data.
  90563. * @param effect defines the effect to update
  90564. * @param scene defines the scene the material belongs to.
  90565. * @param mesh The mesh
  90566. * @param world World matrix of this mesh
  90567. * @param isFrozen Is the material frozen
  90568. */
  90569. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  90570. }
  90571. }
  90572. declare module BABYLON {
  90573. /**
  90574. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  90575. * This is the base of the follow, arc rotate cameras and Free camera
  90576. * @see https://doc.babylonjs.com/features/cameras
  90577. */
  90578. export class TargetCamera extends Camera {
  90579. private static _RigCamTransformMatrix;
  90580. private static _TargetTransformMatrix;
  90581. private static _TargetFocalPoint;
  90582. private _tmpUpVector;
  90583. private _tmpTargetVector;
  90584. /**
  90585. * Define the current direction the camera is moving to
  90586. */
  90587. cameraDirection: Vector3;
  90588. /**
  90589. * Define the current rotation the camera is rotating to
  90590. */
  90591. cameraRotation: Vector2;
  90592. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  90593. ignoreParentScaling: boolean;
  90594. /**
  90595. * When set, the up vector of the camera will be updated by the rotation of the camera
  90596. */
  90597. updateUpVectorFromRotation: boolean;
  90598. private _tmpQuaternion;
  90599. /**
  90600. * Define the current rotation of the camera
  90601. */
  90602. rotation: Vector3;
  90603. /**
  90604. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  90605. */
  90606. rotationQuaternion: Quaternion;
  90607. /**
  90608. * Define the current speed of the camera
  90609. */
  90610. speed: number;
  90611. /**
  90612. * Add constraint to the camera to prevent it to move freely in all directions and
  90613. * around all axis.
  90614. */
  90615. noRotationConstraint: boolean;
  90616. /**
  90617. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  90618. * panning
  90619. */
  90620. invertRotation: boolean;
  90621. /**
  90622. * Speed multiplier for inverse camera panning
  90623. */
  90624. inverseRotationSpeed: number;
  90625. /**
  90626. * Define the current target of the camera as an object or a position.
  90627. */
  90628. lockedTarget: any;
  90629. /** @hidden */
  90630. _currentTarget: Vector3;
  90631. /** @hidden */
  90632. _initialFocalDistance: number;
  90633. /** @hidden */
  90634. _viewMatrix: Matrix;
  90635. /** @hidden */
  90636. _camMatrix: Matrix;
  90637. /** @hidden */
  90638. _cameraTransformMatrix: Matrix;
  90639. /** @hidden */
  90640. _cameraRotationMatrix: Matrix;
  90641. /** @hidden */
  90642. _referencePoint: Vector3;
  90643. /** @hidden */
  90644. _transformedReferencePoint: Vector3;
  90645. /** @hidden */
  90646. _reset: () => void;
  90647. private _defaultUp;
  90648. /**
  90649. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  90650. * This is the base of the follow, arc rotate cameras and Free camera
  90651. * @see https://doc.babylonjs.com/features/cameras
  90652. * @param name Defines the name of the camera in the scene
  90653. * @param position Defines the start position of the camera in the scene
  90654. * @param scene Defines the scene the camera belongs to
  90655. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90656. */
  90657. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90658. /**
  90659. * Gets the position in front of the camera at a given distance.
  90660. * @param distance The distance from the camera we want the position to be
  90661. * @returns the position
  90662. */
  90663. getFrontPosition(distance: number): Vector3;
  90664. /** @hidden */
  90665. _getLockedTargetPosition(): Nullable<Vector3>;
  90666. private _storedPosition;
  90667. private _storedRotation;
  90668. private _storedRotationQuaternion;
  90669. /**
  90670. * Store current camera state of the camera (fov, position, rotation, etc..)
  90671. * @returns the camera
  90672. */
  90673. storeState(): Camera;
  90674. /**
  90675. * Restored camera state. You must call storeState() first
  90676. * @returns whether it was successful or not
  90677. * @hidden
  90678. */
  90679. _restoreStateValues(): boolean;
  90680. /** @hidden */
  90681. _initCache(): void;
  90682. /** @hidden */
  90683. _updateCache(ignoreParentClass?: boolean): void;
  90684. /** @hidden */
  90685. _isSynchronizedViewMatrix(): boolean;
  90686. /** @hidden */
  90687. _computeLocalCameraSpeed(): number;
  90688. /**
  90689. * Defines the target the camera should look at.
  90690. * @param target Defines the new target as a Vector or a mesh
  90691. */
  90692. setTarget(target: Vector3): void;
  90693. /**
  90694. * Defines the target point of the camera.
  90695. * The camera looks towards it form the radius distance.
  90696. */
  90697. get target(): Vector3;
  90698. set target(value: Vector3);
  90699. /**
  90700. * Return the current target position of the camera. This value is expressed in local space.
  90701. * @returns the target position
  90702. */
  90703. getTarget(): Vector3;
  90704. /** @hidden */
  90705. _decideIfNeedsToMove(): boolean;
  90706. /** @hidden */
  90707. _updatePosition(): void;
  90708. /** @hidden */
  90709. _checkInputs(): void;
  90710. protected _updateCameraRotationMatrix(): void;
  90711. /**
  90712. * 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)
  90713. * @returns the current camera
  90714. */
  90715. private _rotateUpVectorWithCameraRotationMatrix;
  90716. private _cachedRotationZ;
  90717. private _cachedQuaternionRotationZ;
  90718. /** @hidden */
  90719. _getViewMatrix(): Matrix;
  90720. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  90721. /**
  90722. * @hidden
  90723. */
  90724. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90725. /**
  90726. * @hidden
  90727. */
  90728. _updateRigCameras(): void;
  90729. private _getRigCamPositionAndTarget;
  90730. /**
  90731. * Gets the current object class name.
  90732. * @return the class name
  90733. */
  90734. getClassName(): string;
  90735. }
  90736. }
  90737. declare module BABYLON {
  90738. /**
  90739. * @ignore
  90740. * This is a list of all the different input types that are available in the application.
  90741. * Fo instance: ArcRotateCameraGamepadInput...
  90742. */
  90743. export var CameraInputTypes: {};
  90744. /**
  90745. * This is the contract to implement in order to create a new input class.
  90746. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  90747. */
  90748. export interface ICameraInput<TCamera extends Camera> {
  90749. /**
  90750. * Defines the camera the input is attached to.
  90751. */
  90752. camera: Nullable<TCamera>;
  90753. /**
  90754. * Gets the class name of the current intput.
  90755. * @returns the class name
  90756. */
  90757. getClassName(): string;
  90758. /**
  90759. * Get the friendly name associated with the input class.
  90760. * @returns the input friendly name
  90761. */
  90762. getSimpleName(): string;
  90763. /**
  90764. * Attach the input controls to a specific dom element to get the input from.
  90765. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90766. */
  90767. attachControl(noPreventDefault?: boolean): void;
  90768. /**
  90769. * Detach the current controls from the specified dom element.
  90770. */
  90771. detachControl(): void;
  90772. /**
  90773. * Update the current camera state depending on the inputs that have been used this frame.
  90774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90775. */
  90776. checkInputs?: () => void;
  90777. }
  90778. /**
  90779. * Represents a map of input types to input instance or input index to input instance.
  90780. */
  90781. export interface CameraInputsMap<TCamera extends Camera> {
  90782. /**
  90783. * Accessor to the input by input type.
  90784. */
  90785. [name: string]: ICameraInput<TCamera>;
  90786. /**
  90787. * Accessor to the input by input index.
  90788. */
  90789. [idx: number]: ICameraInput<TCamera>;
  90790. }
  90791. /**
  90792. * This represents the input manager used within a camera.
  90793. * It helps dealing with all the different kind of input attached to a camera.
  90794. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90795. */
  90796. export class CameraInputsManager<TCamera extends Camera> {
  90797. /**
  90798. * Defines the list of inputs attahed to the camera.
  90799. */
  90800. attached: CameraInputsMap<TCamera>;
  90801. /**
  90802. * Defines the dom element the camera is collecting inputs from.
  90803. * This is null if the controls have not been attached.
  90804. */
  90805. attachedToElement: boolean;
  90806. /**
  90807. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90808. */
  90809. noPreventDefault: boolean;
  90810. /**
  90811. * Defined the camera the input manager belongs to.
  90812. */
  90813. camera: TCamera;
  90814. /**
  90815. * Update the current camera state depending on the inputs that have been used this frame.
  90816. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90817. */
  90818. checkInputs: () => void;
  90819. /**
  90820. * Instantiate a new Camera Input Manager.
  90821. * @param camera Defines the camera the input manager blongs to
  90822. */
  90823. constructor(camera: TCamera);
  90824. /**
  90825. * Add an input method to a camera
  90826. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90827. * @param input camera input method
  90828. */
  90829. add(input: ICameraInput<TCamera>): void;
  90830. /**
  90831. * Remove a specific input method from a camera
  90832. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  90833. * @param inputToRemove camera input method
  90834. */
  90835. remove(inputToRemove: ICameraInput<TCamera>): void;
  90836. /**
  90837. * Remove a specific input type from a camera
  90838. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  90839. * @param inputType the type of the input to remove
  90840. */
  90841. removeByType(inputType: string): void;
  90842. private _addCheckInputs;
  90843. /**
  90844. * Attach the input controls to the currently attached dom element to listen the events from.
  90845. * @param input Defines the input to attach
  90846. */
  90847. attachInput(input: ICameraInput<TCamera>): void;
  90848. /**
  90849. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  90850. * @param element Defines the dom element to collect the events from
  90851. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90852. */
  90853. attachElement(noPreventDefault?: boolean): void;
  90854. /**
  90855. * Detach the current manager inputs controls from a specific dom element.
  90856. * @param element Defines the dom element to collect the events from
  90857. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  90858. */
  90859. detachElement(disconnect?: boolean): void;
  90860. /**
  90861. * Rebuild the dynamic inputCheck function from the current list of
  90862. * defined inputs in the manager.
  90863. */
  90864. rebuildInputCheck(): void;
  90865. /**
  90866. * Remove all attached input methods from a camera
  90867. */
  90868. clear(): void;
  90869. /**
  90870. * Serialize the current input manager attached to a camera.
  90871. * This ensures than once parsed,
  90872. * the input associated to the camera will be identical to the current ones
  90873. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  90874. */
  90875. serialize(serializedCamera: any): void;
  90876. /**
  90877. * Parses an input manager serialized JSON to restore the previous list of inputs
  90878. * and states associated to a camera.
  90879. * @param parsedCamera Defines the JSON to parse
  90880. */
  90881. parse(parsedCamera: any): void;
  90882. }
  90883. }
  90884. declare module BABYLON {
  90885. /**
  90886. * Gather the list of keyboard event types as constants.
  90887. */
  90888. export class KeyboardEventTypes {
  90889. /**
  90890. * The keydown event is fired when a key becomes active (pressed).
  90891. */
  90892. static readonly KEYDOWN: number;
  90893. /**
  90894. * The keyup event is fired when a key has been released.
  90895. */
  90896. static readonly KEYUP: number;
  90897. }
  90898. /**
  90899. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90900. */
  90901. export class KeyboardInfo {
  90902. /**
  90903. * Defines the type of event (KeyboardEventTypes)
  90904. */
  90905. type: number;
  90906. /**
  90907. * Defines the related dom event
  90908. */
  90909. event: KeyboardEvent;
  90910. /**
  90911. * Instantiates a new keyboard info.
  90912. * This class is used to store keyboard related info for the onKeyboardObservable event.
  90913. * @param type Defines the type of event (KeyboardEventTypes)
  90914. * @param event Defines the related dom event
  90915. */
  90916. constructor(
  90917. /**
  90918. * Defines the type of event (KeyboardEventTypes)
  90919. */
  90920. type: number,
  90921. /**
  90922. * Defines the related dom event
  90923. */
  90924. event: KeyboardEvent);
  90925. }
  90926. /**
  90927. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90928. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  90929. */
  90930. export class KeyboardInfoPre extends KeyboardInfo {
  90931. /**
  90932. * Defines the type of event (KeyboardEventTypes)
  90933. */
  90934. type: number;
  90935. /**
  90936. * Defines the related dom event
  90937. */
  90938. event: KeyboardEvent;
  90939. /**
  90940. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  90941. */
  90942. skipOnPointerObservable: boolean;
  90943. /**
  90944. * Instantiates a new keyboard pre info.
  90945. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  90946. * @param type Defines the type of event (KeyboardEventTypes)
  90947. * @param event Defines the related dom event
  90948. */
  90949. constructor(
  90950. /**
  90951. * Defines the type of event (KeyboardEventTypes)
  90952. */
  90953. type: number,
  90954. /**
  90955. * Defines the related dom event
  90956. */
  90957. event: KeyboardEvent);
  90958. }
  90959. }
  90960. declare module BABYLON {
  90961. /**
  90962. * Manage the keyboard inputs to control the movement of a free camera.
  90963. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  90964. */
  90965. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  90966. /**
  90967. * Defines the camera the input is attached to.
  90968. */
  90969. camera: FreeCamera;
  90970. /**
  90971. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  90972. */
  90973. keysUp: number[];
  90974. /**
  90975. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  90976. */
  90977. keysUpward: number[];
  90978. /**
  90979. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  90980. */
  90981. keysDown: number[];
  90982. /**
  90983. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  90984. */
  90985. keysDownward: number[];
  90986. /**
  90987. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  90988. */
  90989. keysLeft: number[];
  90990. /**
  90991. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  90992. */
  90993. keysRight: number[];
  90994. private _keys;
  90995. private _onCanvasBlurObserver;
  90996. private _onKeyboardObserver;
  90997. private _engine;
  90998. private _scene;
  90999. /**
  91000. * Attach the input controls to a specific dom element to get the input from.
  91001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91002. */
  91003. attachControl(noPreventDefault?: boolean): void;
  91004. /**
  91005. * Detach the current controls from the specified dom element.
  91006. */
  91007. detachControl(): void;
  91008. /**
  91009. * Update the current camera state depending on the inputs that have been used this frame.
  91010. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91011. */
  91012. checkInputs(): void;
  91013. /**
  91014. * Gets the class name of the current intput.
  91015. * @returns the class name
  91016. */
  91017. getClassName(): string;
  91018. /** @hidden */
  91019. _onLostFocus(): void;
  91020. /**
  91021. * Get the friendly name associated with the input class.
  91022. * @returns the input friendly name
  91023. */
  91024. getSimpleName(): string;
  91025. }
  91026. }
  91027. declare module BABYLON {
  91028. /**
  91029. * Interface used to define Action
  91030. */
  91031. export interface IAction {
  91032. /**
  91033. * Trigger for the action
  91034. */
  91035. trigger: number;
  91036. /** Options of the trigger */
  91037. triggerOptions: any;
  91038. /**
  91039. * Gets the trigger parameters
  91040. * @returns the trigger parameters
  91041. */
  91042. getTriggerParameter(): any;
  91043. /**
  91044. * Internal only - executes current action event
  91045. * @hidden
  91046. */
  91047. _executeCurrent(evt?: ActionEvent): void;
  91048. /**
  91049. * Serialize placeholder for child classes
  91050. * @param parent of child
  91051. * @returns the serialized object
  91052. */
  91053. serialize(parent: any): any;
  91054. /**
  91055. * Internal only
  91056. * @hidden
  91057. */
  91058. _prepare(): void;
  91059. /**
  91060. * Internal only - manager for action
  91061. * @hidden
  91062. */
  91063. _actionManager: Nullable<AbstractActionManager>;
  91064. /**
  91065. * Adds action to chain of actions, may be a DoNothingAction
  91066. * @param action defines the next action to execute
  91067. * @returns The action passed in
  91068. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91069. */
  91070. then(action: IAction): IAction;
  91071. }
  91072. /**
  91073. * The action to be carried out following a trigger
  91074. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91075. */
  91076. export class Action implements IAction {
  91077. /** the trigger, with or without parameters, for the action */
  91078. triggerOptions: any;
  91079. /**
  91080. * Trigger for the action
  91081. */
  91082. trigger: number;
  91083. /**
  91084. * Internal only - manager for action
  91085. * @hidden
  91086. */
  91087. _actionManager: ActionManager;
  91088. private _nextActiveAction;
  91089. private _child;
  91090. private _condition?;
  91091. private _triggerParameter;
  91092. /**
  91093. * An event triggered prior to action being executed.
  91094. */
  91095. onBeforeExecuteObservable: Observable<Action>;
  91096. /**
  91097. * Creates a new Action
  91098. * @param triggerOptions the trigger, with or without parameters, for the action
  91099. * @param condition an optional determinant of action
  91100. */
  91101. constructor(
  91102. /** the trigger, with or without parameters, for the action */
  91103. triggerOptions: any, condition?: Condition);
  91104. /**
  91105. * Internal only
  91106. * @hidden
  91107. */
  91108. _prepare(): void;
  91109. /**
  91110. * Gets the trigger parameters
  91111. * @returns the trigger parameters
  91112. */
  91113. getTriggerParameter(): any;
  91114. /**
  91115. * Internal only - executes current action event
  91116. * @hidden
  91117. */
  91118. _executeCurrent(evt?: ActionEvent): void;
  91119. /**
  91120. * Execute placeholder for child classes
  91121. * @param evt optional action event
  91122. */
  91123. execute(evt?: ActionEvent): void;
  91124. /**
  91125. * Skips to next active action
  91126. */
  91127. skipToNextActiveAction(): void;
  91128. /**
  91129. * Adds action to chain of actions, may be a DoNothingAction
  91130. * @param action defines the next action to execute
  91131. * @returns The action passed in
  91132. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91133. */
  91134. then(action: Action): Action;
  91135. /**
  91136. * Internal only
  91137. * @hidden
  91138. */
  91139. _getProperty(propertyPath: string): string;
  91140. /**
  91141. * Internal only
  91142. * @hidden
  91143. */
  91144. _getEffectiveTarget(target: any, propertyPath: string): any;
  91145. /**
  91146. * Serialize placeholder for child classes
  91147. * @param parent of child
  91148. * @returns the serialized object
  91149. */
  91150. serialize(parent: any): any;
  91151. /**
  91152. * Internal only called by serialize
  91153. * @hidden
  91154. */
  91155. protected _serialize(serializedAction: any, parent?: any): any;
  91156. /**
  91157. * Internal only
  91158. * @hidden
  91159. */
  91160. static _SerializeValueAsString: (value: any) => string;
  91161. /**
  91162. * Internal only
  91163. * @hidden
  91164. */
  91165. static _GetTargetProperty: (target: Scene | Node) => {
  91166. name: string;
  91167. targetType: string;
  91168. value: string;
  91169. };
  91170. }
  91171. }
  91172. declare module BABYLON {
  91173. /**
  91174. * A Condition applied to an Action
  91175. */
  91176. export class Condition {
  91177. /**
  91178. * Internal only - manager for action
  91179. * @hidden
  91180. */
  91181. _actionManager: ActionManager;
  91182. /**
  91183. * Internal only
  91184. * @hidden
  91185. */
  91186. _evaluationId: number;
  91187. /**
  91188. * Internal only
  91189. * @hidden
  91190. */
  91191. _currentResult: boolean;
  91192. /**
  91193. * Creates a new Condition
  91194. * @param actionManager the manager of the action the condition is applied to
  91195. */
  91196. constructor(actionManager: ActionManager);
  91197. /**
  91198. * Check if the current condition is valid
  91199. * @returns a boolean
  91200. */
  91201. isValid(): boolean;
  91202. /**
  91203. * Internal only
  91204. * @hidden
  91205. */
  91206. _getProperty(propertyPath: string): string;
  91207. /**
  91208. * Internal only
  91209. * @hidden
  91210. */
  91211. _getEffectiveTarget(target: any, propertyPath: string): any;
  91212. /**
  91213. * Serialize placeholder for child classes
  91214. * @returns the serialized object
  91215. */
  91216. serialize(): any;
  91217. /**
  91218. * Internal only
  91219. * @hidden
  91220. */
  91221. protected _serialize(serializedCondition: any): any;
  91222. }
  91223. /**
  91224. * Defines specific conditional operators as extensions of Condition
  91225. */
  91226. export class ValueCondition extends Condition {
  91227. /** path to specify the property of the target the conditional operator uses */
  91228. propertyPath: string;
  91229. /** the value compared by the conditional operator against the current value of the property */
  91230. value: any;
  91231. /** the conditional operator, default ValueCondition.IsEqual */
  91232. operator: number;
  91233. /**
  91234. * Internal only
  91235. * @hidden
  91236. */
  91237. private static _IsEqual;
  91238. /**
  91239. * Internal only
  91240. * @hidden
  91241. */
  91242. private static _IsDifferent;
  91243. /**
  91244. * Internal only
  91245. * @hidden
  91246. */
  91247. private static _IsGreater;
  91248. /**
  91249. * Internal only
  91250. * @hidden
  91251. */
  91252. private static _IsLesser;
  91253. /**
  91254. * returns the number for IsEqual
  91255. */
  91256. static get IsEqual(): number;
  91257. /**
  91258. * Returns the number for IsDifferent
  91259. */
  91260. static get IsDifferent(): number;
  91261. /**
  91262. * Returns the number for IsGreater
  91263. */
  91264. static get IsGreater(): number;
  91265. /**
  91266. * Returns the number for IsLesser
  91267. */
  91268. static get IsLesser(): number;
  91269. /**
  91270. * Internal only The action manager for the condition
  91271. * @hidden
  91272. */
  91273. _actionManager: ActionManager;
  91274. /**
  91275. * Internal only
  91276. * @hidden
  91277. */
  91278. private _target;
  91279. /**
  91280. * Internal only
  91281. * @hidden
  91282. */
  91283. private _effectiveTarget;
  91284. /**
  91285. * Internal only
  91286. * @hidden
  91287. */
  91288. private _property;
  91289. /**
  91290. * Creates a new ValueCondition
  91291. * @param actionManager manager for the action the condition applies to
  91292. * @param target for the action
  91293. * @param propertyPath path to specify the property of the target the conditional operator uses
  91294. * @param value the value compared by the conditional operator against the current value of the property
  91295. * @param operator the conditional operator, default ValueCondition.IsEqual
  91296. */
  91297. constructor(actionManager: ActionManager, target: any,
  91298. /** path to specify the property of the target the conditional operator uses */
  91299. propertyPath: string,
  91300. /** the value compared by the conditional operator against the current value of the property */
  91301. value: any,
  91302. /** the conditional operator, default ValueCondition.IsEqual */
  91303. operator?: number);
  91304. /**
  91305. * Compares the given value with the property value for the specified conditional operator
  91306. * @returns the result of the comparison
  91307. */
  91308. isValid(): boolean;
  91309. /**
  91310. * Serialize the ValueCondition into a JSON compatible object
  91311. * @returns serialization object
  91312. */
  91313. serialize(): any;
  91314. /**
  91315. * Gets the name of the conditional operator for the ValueCondition
  91316. * @param operator the conditional operator
  91317. * @returns the name
  91318. */
  91319. static GetOperatorName(operator: number): string;
  91320. }
  91321. /**
  91322. * Defines a predicate condition as an extension of Condition
  91323. */
  91324. export class PredicateCondition extends Condition {
  91325. /** defines the predicate function used to validate the condition */
  91326. predicate: () => boolean;
  91327. /**
  91328. * Internal only - manager for action
  91329. * @hidden
  91330. */
  91331. _actionManager: ActionManager;
  91332. /**
  91333. * Creates a new PredicateCondition
  91334. * @param actionManager manager for the action the condition applies to
  91335. * @param predicate defines the predicate function used to validate the condition
  91336. */
  91337. constructor(actionManager: ActionManager,
  91338. /** defines the predicate function used to validate the condition */
  91339. predicate: () => boolean);
  91340. /**
  91341. * @returns the validity of the predicate condition
  91342. */
  91343. isValid(): boolean;
  91344. }
  91345. /**
  91346. * Defines a state condition as an extension of Condition
  91347. */
  91348. export class StateCondition extends Condition {
  91349. /** Value to compare with target state */
  91350. value: string;
  91351. /**
  91352. * Internal only - manager for action
  91353. * @hidden
  91354. */
  91355. _actionManager: ActionManager;
  91356. /**
  91357. * Internal only
  91358. * @hidden
  91359. */
  91360. private _target;
  91361. /**
  91362. * Creates a new StateCondition
  91363. * @param actionManager manager for the action the condition applies to
  91364. * @param target of the condition
  91365. * @param value to compare with target state
  91366. */
  91367. constructor(actionManager: ActionManager, target: any,
  91368. /** Value to compare with target state */
  91369. value: string);
  91370. /**
  91371. * Gets a boolean indicating if the current condition is met
  91372. * @returns the validity of the state
  91373. */
  91374. isValid(): boolean;
  91375. /**
  91376. * Serialize the StateCondition into a JSON compatible object
  91377. * @returns serialization object
  91378. */
  91379. serialize(): any;
  91380. }
  91381. }
  91382. declare module BABYLON {
  91383. /**
  91384. * This defines an action responsible to toggle a boolean once triggered.
  91385. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91386. */
  91387. export class SwitchBooleanAction extends Action {
  91388. /**
  91389. * The path to the boolean property in the target object
  91390. */
  91391. propertyPath: string;
  91392. private _target;
  91393. private _effectiveTarget;
  91394. private _property;
  91395. /**
  91396. * Instantiate the action
  91397. * @param triggerOptions defines the trigger options
  91398. * @param target defines the object containing the boolean
  91399. * @param propertyPath defines the path to the boolean property in the target object
  91400. * @param condition defines the trigger related conditions
  91401. */
  91402. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91403. /** @hidden */
  91404. _prepare(): void;
  91405. /**
  91406. * Execute the action toggle the boolean value.
  91407. */
  91408. execute(): void;
  91409. /**
  91410. * Serializes the actions and its related information.
  91411. * @param parent defines the object to serialize in
  91412. * @returns the serialized object
  91413. */
  91414. serialize(parent: any): any;
  91415. }
  91416. /**
  91417. * This defines an action responsible to set a the state field of the target
  91418. * to a desired value once triggered.
  91419. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91420. */
  91421. export class SetStateAction extends Action {
  91422. /**
  91423. * The value to store in the state field.
  91424. */
  91425. value: string;
  91426. private _target;
  91427. /**
  91428. * Instantiate the action
  91429. * @param triggerOptions defines the trigger options
  91430. * @param target defines the object containing the state property
  91431. * @param value defines the value to store in the state field
  91432. * @param condition defines the trigger related conditions
  91433. */
  91434. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91435. /**
  91436. * Execute the action and store the value on the target state property.
  91437. */
  91438. execute(): void;
  91439. /**
  91440. * Serializes the actions and its related information.
  91441. * @param parent defines the object to serialize in
  91442. * @returns the serialized object
  91443. */
  91444. serialize(parent: any): any;
  91445. }
  91446. /**
  91447. * This defines an action responsible to set a property of the target
  91448. * to a desired value once triggered.
  91449. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91450. */
  91451. export class SetValueAction extends Action {
  91452. /**
  91453. * The path of the property to set in the target.
  91454. */
  91455. propertyPath: string;
  91456. /**
  91457. * The value to set in the property
  91458. */
  91459. value: any;
  91460. private _target;
  91461. private _effectiveTarget;
  91462. private _property;
  91463. /**
  91464. * Instantiate the action
  91465. * @param triggerOptions defines the trigger options
  91466. * @param target defines the object containing the property
  91467. * @param propertyPath defines the path of the property to set in the target
  91468. * @param value defines the value to set in the property
  91469. * @param condition defines the trigger related conditions
  91470. */
  91471. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91472. /** @hidden */
  91473. _prepare(): void;
  91474. /**
  91475. * Execute the action and set the targetted property to the desired value.
  91476. */
  91477. execute(): void;
  91478. /**
  91479. * Serializes the actions and its related information.
  91480. * @param parent defines the object to serialize in
  91481. * @returns the serialized object
  91482. */
  91483. serialize(parent: any): any;
  91484. }
  91485. /**
  91486. * This defines an action responsible to increment the target value
  91487. * to a desired value once triggered.
  91488. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91489. */
  91490. export class IncrementValueAction extends Action {
  91491. /**
  91492. * The path of the property to increment in the target.
  91493. */
  91494. propertyPath: string;
  91495. /**
  91496. * The value we should increment the property by.
  91497. */
  91498. value: any;
  91499. private _target;
  91500. private _effectiveTarget;
  91501. private _property;
  91502. /**
  91503. * Instantiate the action
  91504. * @param triggerOptions defines the trigger options
  91505. * @param target defines the object containing the property
  91506. * @param propertyPath defines the path of the property to increment in the target
  91507. * @param value defines the value value we should increment the property by
  91508. * @param condition defines the trigger related conditions
  91509. */
  91510. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91511. /** @hidden */
  91512. _prepare(): void;
  91513. /**
  91514. * Execute the action and increment the target of the value amount.
  91515. */
  91516. execute(): void;
  91517. /**
  91518. * Serializes the actions and its related information.
  91519. * @param parent defines the object to serialize in
  91520. * @returns the serialized object
  91521. */
  91522. serialize(parent: any): any;
  91523. }
  91524. /**
  91525. * This defines an action responsible to start an animation once triggered.
  91526. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91527. */
  91528. export class PlayAnimationAction extends Action {
  91529. /**
  91530. * Where the animation should start (animation frame)
  91531. */
  91532. from: number;
  91533. /**
  91534. * Where the animation should stop (animation frame)
  91535. */
  91536. to: number;
  91537. /**
  91538. * Define if the animation should loop or stop after the first play.
  91539. */
  91540. loop?: boolean;
  91541. private _target;
  91542. /**
  91543. * Instantiate the action
  91544. * @param triggerOptions defines the trigger options
  91545. * @param target defines the target animation or animation name
  91546. * @param from defines from where the animation should start (animation frame)
  91547. * @param end defines where the animation should stop (animation frame)
  91548. * @param loop defines if the animation should loop or stop after the first play
  91549. * @param condition defines the trigger related conditions
  91550. */
  91551. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91552. /** @hidden */
  91553. _prepare(): void;
  91554. /**
  91555. * Execute the action and play the animation.
  91556. */
  91557. execute(): void;
  91558. /**
  91559. * Serializes the actions and its related information.
  91560. * @param parent defines the object to serialize in
  91561. * @returns the serialized object
  91562. */
  91563. serialize(parent: any): any;
  91564. }
  91565. /**
  91566. * This defines an action responsible to stop an animation once triggered.
  91567. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91568. */
  91569. export class StopAnimationAction extends Action {
  91570. private _target;
  91571. /**
  91572. * Instantiate the action
  91573. * @param triggerOptions defines the trigger options
  91574. * @param target defines the target animation or animation name
  91575. * @param condition defines the trigger related conditions
  91576. */
  91577. constructor(triggerOptions: any, target: any, condition?: Condition);
  91578. /** @hidden */
  91579. _prepare(): void;
  91580. /**
  91581. * Execute the action and stop the animation.
  91582. */
  91583. execute(): void;
  91584. /**
  91585. * Serializes the actions and its related information.
  91586. * @param parent defines the object to serialize in
  91587. * @returns the serialized object
  91588. */
  91589. serialize(parent: any): any;
  91590. }
  91591. /**
  91592. * This defines an action responsible that does nothing once triggered.
  91593. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91594. */
  91595. export class DoNothingAction extends Action {
  91596. /**
  91597. * Instantiate the action
  91598. * @param triggerOptions defines the trigger options
  91599. * @param condition defines the trigger related conditions
  91600. */
  91601. constructor(triggerOptions?: any, condition?: Condition);
  91602. /**
  91603. * Execute the action and do nothing.
  91604. */
  91605. execute(): void;
  91606. /**
  91607. * Serializes the actions and its related information.
  91608. * @param parent defines the object to serialize in
  91609. * @returns the serialized object
  91610. */
  91611. serialize(parent: any): any;
  91612. }
  91613. /**
  91614. * This defines an action responsible to trigger several actions once triggered.
  91615. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91616. */
  91617. export class CombineAction extends Action {
  91618. /**
  91619. * The list of aggregated animations to run.
  91620. */
  91621. children: Action[];
  91622. /**
  91623. * Instantiate the action
  91624. * @param triggerOptions defines the trigger options
  91625. * @param children defines the list of aggregated animations to run
  91626. * @param condition defines the trigger related conditions
  91627. */
  91628. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91629. /** @hidden */
  91630. _prepare(): void;
  91631. /**
  91632. * Execute the action and executes all the aggregated actions.
  91633. */
  91634. execute(evt: ActionEvent): void;
  91635. /**
  91636. * Serializes the actions and its related information.
  91637. * @param parent defines the object to serialize in
  91638. * @returns the serialized object
  91639. */
  91640. serialize(parent: any): any;
  91641. }
  91642. /**
  91643. * This defines an action responsible to run code (external event) once triggered.
  91644. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91645. */
  91646. export class ExecuteCodeAction extends Action {
  91647. /**
  91648. * The callback function to run.
  91649. */
  91650. func: (evt: ActionEvent) => void;
  91651. /**
  91652. * Instantiate the action
  91653. * @param triggerOptions defines the trigger options
  91654. * @param func defines the callback function to run
  91655. * @param condition defines the trigger related conditions
  91656. */
  91657. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91658. /**
  91659. * Execute the action and run the attached code.
  91660. */
  91661. execute(evt: ActionEvent): void;
  91662. }
  91663. /**
  91664. * This defines an action responsible to set the parent property of the target once triggered.
  91665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91666. */
  91667. export class SetParentAction extends Action {
  91668. private _parent;
  91669. private _target;
  91670. /**
  91671. * Instantiate the action
  91672. * @param triggerOptions defines the trigger options
  91673. * @param target defines the target containing the parent property
  91674. * @param parent defines from where the animation should start (animation frame)
  91675. * @param condition defines the trigger related conditions
  91676. */
  91677. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91678. /** @hidden */
  91679. _prepare(): void;
  91680. /**
  91681. * Execute the action and set the parent property.
  91682. */
  91683. execute(): void;
  91684. /**
  91685. * Serializes the actions and its related information.
  91686. * @param parent defines the object to serialize in
  91687. * @returns the serialized object
  91688. */
  91689. serialize(parent: any): any;
  91690. }
  91691. }
  91692. declare module BABYLON {
  91693. /**
  91694. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91695. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91696. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91697. */
  91698. export class ActionManager extends AbstractActionManager {
  91699. /**
  91700. * Nothing
  91701. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91702. */
  91703. static readonly NothingTrigger: number;
  91704. /**
  91705. * On pick
  91706. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91707. */
  91708. static readonly OnPickTrigger: number;
  91709. /**
  91710. * On left pick
  91711. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91712. */
  91713. static readonly OnLeftPickTrigger: number;
  91714. /**
  91715. * On right pick
  91716. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91717. */
  91718. static readonly OnRightPickTrigger: number;
  91719. /**
  91720. * On center pick
  91721. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91722. */
  91723. static readonly OnCenterPickTrigger: number;
  91724. /**
  91725. * On pick down
  91726. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91727. */
  91728. static readonly OnPickDownTrigger: number;
  91729. /**
  91730. * On double pick
  91731. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91732. */
  91733. static readonly OnDoublePickTrigger: number;
  91734. /**
  91735. * On pick up
  91736. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91737. */
  91738. static readonly OnPickUpTrigger: number;
  91739. /**
  91740. * On pick out.
  91741. * This trigger will only be raised if you also declared a OnPickDown
  91742. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91743. */
  91744. static readonly OnPickOutTrigger: number;
  91745. /**
  91746. * On long press
  91747. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91748. */
  91749. static readonly OnLongPressTrigger: number;
  91750. /**
  91751. * On pointer over
  91752. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91753. */
  91754. static readonly OnPointerOverTrigger: number;
  91755. /**
  91756. * On pointer out
  91757. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91758. */
  91759. static readonly OnPointerOutTrigger: number;
  91760. /**
  91761. * On every frame
  91762. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91763. */
  91764. static readonly OnEveryFrameTrigger: number;
  91765. /**
  91766. * On intersection enter
  91767. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91768. */
  91769. static readonly OnIntersectionEnterTrigger: number;
  91770. /**
  91771. * On intersection exit
  91772. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91773. */
  91774. static readonly OnIntersectionExitTrigger: number;
  91775. /**
  91776. * On key down
  91777. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91778. */
  91779. static readonly OnKeyDownTrigger: number;
  91780. /**
  91781. * On key up
  91782. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91783. */
  91784. static readonly OnKeyUpTrigger: number;
  91785. private _scene;
  91786. /**
  91787. * Creates a new action manager
  91788. * @param scene defines the hosting scene
  91789. */
  91790. constructor(scene: Scene);
  91791. /**
  91792. * Releases all associated resources
  91793. */
  91794. dispose(): void;
  91795. /**
  91796. * Gets hosting scene
  91797. * @returns the hosting scene
  91798. */
  91799. getScene(): Scene;
  91800. /**
  91801. * Does this action manager handles actions of any of the given triggers
  91802. * @param triggers defines the triggers to be tested
  91803. * @return a boolean indicating whether one (or more) of the triggers is handled
  91804. */
  91805. hasSpecificTriggers(triggers: number[]): boolean;
  91806. /**
  91807. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91808. * speed.
  91809. * @param triggerA defines the trigger to be tested
  91810. * @param triggerB defines the trigger to be tested
  91811. * @return a boolean indicating whether one (or more) of the triggers is handled
  91812. */
  91813. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91814. /**
  91815. * Does this action manager handles actions of a given trigger
  91816. * @param trigger defines the trigger to be tested
  91817. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91818. * @return whether the trigger is handled
  91819. */
  91820. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91821. /**
  91822. * Does this action manager has pointer triggers
  91823. */
  91824. get hasPointerTriggers(): boolean;
  91825. /**
  91826. * Does this action manager has pick triggers
  91827. */
  91828. get hasPickTriggers(): boolean;
  91829. /**
  91830. * Registers an action to this action manager
  91831. * @param action defines the action to be registered
  91832. * @return the action amended (prepared) after registration
  91833. */
  91834. registerAction(action: IAction): Nullable<IAction>;
  91835. /**
  91836. * Unregisters an action to this action manager
  91837. * @param action defines the action to be unregistered
  91838. * @return a boolean indicating whether the action has been unregistered
  91839. */
  91840. unregisterAction(action: IAction): Boolean;
  91841. /**
  91842. * Process a specific trigger
  91843. * @param trigger defines the trigger to process
  91844. * @param evt defines the event details to be processed
  91845. */
  91846. processTrigger(trigger: number, evt?: IActionEvent): void;
  91847. /** @hidden */
  91848. _getEffectiveTarget(target: any, propertyPath: string): any;
  91849. /** @hidden */
  91850. _getProperty(propertyPath: string): string;
  91851. /**
  91852. * Serialize this manager to a JSON object
  91853. * @param name defines the property name to store this manager
  91854. * @returns a JSON representation of this manager
  91855. */
  91856. serialize(name: string): any;
  91857. /**
  91858. * Creates a new ActionManager from a JSON data
  91859. * @param parsedActions defines the JSON data to read from
  91860. * @param object defines the hosting mesh
  91861. * @param scene defines the hosting scene
  91862. */
  91863. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91864. /**
  91865. * Get a trigger name by index
  91866. * @param trigger defines the trigger index
  91867. * @returns a trigger name
  91868. */
  91869. static GetTriggerName(trigger: number): string;
  91870. }
  91871. }
  91872. declare module BABYLON {
  91873. /**
  91874. * Class representing a ray with position and direction
  91875. */
  91876. export class Ray {
  91877. /** origin point */
  91878. origin: Vector3;
  91879. /** direction */
  91880. direction: Vector3;
  91881. /** length of the ray */
  91882. length: number;
  91883. private static readonly _TmpVector3;
  91884. private _tmpRay;
  91885. /**
  91886. * Creates a new ray
  91887. * @param origin origin point
  91888. * @param direction direction
  91889. * @param length length of the ray
  91890. */
  91891. constructor(
  91892. /** origin point */
  91893. origin: Vector3,
  91894. /** direction */
  91895. direction: Vector3,
  91896. /** length of the ray */
  91897. length?: number);
  91898. /**
  91899. * Checks if the ray intersects a box
  91900. * This does not account for the ray lenght by design to improve perfs.
  91901. * @param minimum bound of the box
  91902. * @param maximum bound of the box
  91903. * @param intersectionTreshold extra extend to be added to the box in all direction
  91904. * @returns if the box was hit
  91905. */
  91906. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91907. /**
  91908. * Checks if the ray intersects a box
  91909. * This does not account for the ray lenght by design to improve perfs.
  91910. * @param box the bounding box to check
  91911. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91912. * @returns if the box was hit
  91913. */
  91914. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91915. /**
  91916. * If the ray hits a sphere
  91917. * @param sphere the bounding sphere to check
  91918. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91919. * @returns true if it hits the sphere
  91920. */
  91921. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91922. /**
  91923. * If the ray hits a triange
  91924. * @param vertex0 triangle vertex
  91925. * @param vertex1 triangle vertex
  91926. * @param vertex2 triangle vertex
  91927. * @returns intersection information if hit
  91928. */
  91929. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91930. /**
  91931. * Checks if ray intersects a plane
  91932. * @param plane the plane to check
  91933. * @returns the distance away it was hit
  91934. */
  91935. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91936. /**
  91937. * Calculate the intercept of a ray on a given axis
  91938. * @param axis to check 'x' | 'y' | 'z'
  91939. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91940. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91941. */
  91942. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91943. /**
  91944. * Checks if ray intersects a mesh
  91945. * @param mesh the mesh to check
  91946. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91947. * @returns picking info of the intersecton
  91948. */
  91949. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91950. /**
  91951. * Checks if ray intersects a mesh
  91952. * @param meshes the meshes to check
  91953. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91954. * @param results array to store result in
  91955. * @returns Array of picking infos
  91956. */
  91957. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91958. private _comparePickingInfo;
  91959. private static smallnum;
  91960. private static rayl;
  91961. /**
  91962. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91963. * @param sega the first point of the segment to test the intersection against
  91964. * @param segb the second point of the segment to test the intersection against
  91965. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91966. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91967. */
  91968. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91969. /**
  91970. * Update the ray from viewport position
  91971. * @param x position
  91972. * @param y y position
  91973. * @param viewportWidth viewport width
  91974. * @param viewportHeight viewport height
  91975. * @param world world matrix
  91976. * @param view view matrix
  91977. * @param projection projection matrix
  91978. * @returns this ray updated
  91979. */
  91980. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91981. /**
  91982. * Creates a ray with origin and direction of 0,0,0
  91983. * @returns the new ray
  91984. */
  91985. static Zero(): Ray;
  91986. /**
  91987. * Creates a new ray from screen space and viewport
  91988. * @param x position
  91989. * @param y y position
  91990. * @param viewportWidth viewport width
  91991. * @param viewportHeight viewport height
  91992. * @param world world matrix
  91993. * @param view view matrix
  91994. * @param projection projection matrix
  91995. * @returns new ray
  91996. */
  91997. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91998. /**
  91999. * 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
  92000. * transformed to the given world matrix.
  92001. * @param origin The origin point
  92002. * @param end The end point
  92003. * @param world a matrix to transform the ray to. Default is the identity matrix.
  92004. * @returns the new ray
  92005. */
  92006. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  92007. /**
  92008. * Transforms a ray by a matrix
  92009. * @param ray ray to transform
  92010. * @param matrix matrix to apply
  92011. * @returns the resulting new ray
  92012. */
  92013. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  92014. /**
  92015. * Transforms a ray by a matrix
  92016. * @param ray ray to transform
  92017. * @param matrix matrix to apply
  92018. * @param result ray to store result in
  92019. */
  92020. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  92021. /**
  92022. * Unproject a ray from screen space to object space
  92023. * @param sourceX defines the screen space x coordinate to use
  92024. * @param sourceY defines the screen space y coordinate to use
  92025. * @param viewportWidth defines the current width of the viewport
  92026. * @param viewportHeight defines the current height of the viewport
  92027. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  92028. * @param view defines the view matrix to use
  92029. * @param projection defines the projection matrix to use
  92030. */
  92031. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  92032. }
  92033. /**
  92034. * Type used to define predicate used to select faces when a mesh intersection is detected
  92035. */
  92036. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  92037. interface Scene {
  92038. /** @hidden */
  92039. _tempPickingRay: Nullable<Ray>;
  92040. /** @hidden */
  92041. _cachedRayForTransform: Ray;
  92042. /** @hidden */
  92043. _pickWithRayInverseMatrix: Matrix;
  92044. /** @hidden */
  92045. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92046. /** @hidden */
  92047. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92048. /** @hidden */
  92049. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  92050. }
  92051. }
  92052. declare module BABYLON {
  92053. /**
  92054. * Groups all the scene component constants in one place to ease maintenance.
  92055. * @hidden
  92056. */
  92057. export class SceneComponentConstants {
  92058. static readonly NAME_EFFECTLAYER: string;
  92059. static readonly NAME_LAYER: string;
  92060. static readonly NAME_LENSFLARESYSTEM: string;
  92061. static readonly NAME_BOUNDINGBOXRENDERER: string;
  92062. static readonly NAME_PARTICLESYSTEM: string;
  92063. static readonly NAME_GAMEPAD: string;
  92064. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  92065. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  92066. static readonly NAME_PREPASSRENDERER: string;
  92067. static readonly NAME_DEPTHRENDERER: string;
  92068. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  92069. static readonly NAME_SPRITE: string;
  92070. static readonly NAME_SUBSURFACE: string;
  92071. static readonly NAME_OUTLINERENDERER: string;
  92072. static readonly NAME_PROCEDURALTEXTURE: string;
  92073. static readonly NAME_SHADOWGENERATOR: string;
  92074. static readonly NAME_OCTREE: string;
  92075. static readonly NAME_PHYSICSENGINE: string;
  92076. static readonly NAME_AUDIO: string;
  92077. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  92078. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  92079. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  92080. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  92081. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  92082. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  92083. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  92084. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  92085. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  92086. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  92087. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  92088. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  92089. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  92090. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  92091. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  92092. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  92093. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  92094. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  92095. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  92096. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  92097. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  92098. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  92099. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  92100. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  92101. static readonly STEP_AFTERRENDER_AUDIO: number;
  92102. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  92103. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  92104. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  92105. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  92106. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  92107. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  92108. static readonly STEP_POINTERMOVE_SPRITE: number;
  92109. static readonly STEP_POINTERDOWN_SPRITE: number;
  92110. static readonly STEP_POINTERUP_SPRITE: number;
  92111. }
  92112. /**
  92113. * This represents a scene component.
  92114. *
  92115. * This is used to decouple the dependency the scene is having on the different workloads like
  92116. * layers, post processes...
  92117. */
  92118. export interface ISceneComponent {
  92119. /**
  92120. * The name of the component. Each component must have a unique name.
  92121. */
  92122. name: string;
  92123. /**
  92124. * The scene the component belongs to.
  92125. */
  92126. scene: Scene;
  92127. /**
  92128. * Register the component to one instance of a scene.
  92129. */
  92130. register(): void;
  92131. /**
  92132. * Rebuilds the elements related to this component in case of
  92133. * context lost for instance.
  92134. */
  92135. rebuild(): void;
  92136. /**
  92137. * Disposes the component and the associated ressources.
  92138. */
  92139. dispose(): void;
  92140. }
  92141. /**
  92142. * This represents a SERIALIZABLE scene component.
  92143. *
  92144. * This extends Scene Component to add Serialization methods on top.
  92145. */
  92146. export interface ISceneSerializableComponent extends ISceneComponent {
  92147. /**
  92148. * Adds all the elements from the container to the scene
  92149. * @param container the container holding the elements
  92150. */
  92151. addFromContainer(container: AbstractScene): void;
  92152. /**
  92153. * Removes all the elements in the container from the scene
  92154. * @param container contains the elements to remove
  92155. * @param dispose if the removed element should be disposed (default: false)
  92156. */
  92157. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  92158. /**
  92159. * Serializes the component data to the specified json object
  92160. * @param serializationObject The object to serialize to
  92161. */
  92162. serialize(serializationObject: any): void;
  92163. }
  92164. /**
  92165. * Strong typing of a Mesh related stage step action
  92166. */
  92167. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  92168. /**
  92169. * Strong typing of a Evaluate Sub Mesh related stage step action
  92170. */
  92171. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  92172. /**
  92173. * Strong typing of a pre active Mesh related stage step action
  92174. */
  92175. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  92176. /**
  92177. * Strong typing of a Camera related stage step action
  92178. */
  92179. export type CameraStageAction = (camera: Camera) => void;
  92180. /**
  92181. * Strong typing of a Camera Frame buffer related stage step action
  92182. */
  92183. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  92184. /**
  92185. * Strong typing of a Render Target related stage step action
  92186. */
  92187. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  92188. /**
  92189. * Strong typing of a RenderingGroup related stage step action
  92190. */
  92191. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  92192. /**
  92193. * Strong typing of a Mesh Render related stage step action
  92194. */
  92195. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  92196. /**
  92197. * Strong typing of a simple stage step action
  92198. */
  92199. export type SimpleStageAction = () => void;
  92200. /**
  92201. * Strong typing of a render target action.
  92202. */
  92203. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  92204. /**
  92205. * Strong typing of a pointer move action.
  92206. */
  92207. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  92208. /**
  92209. * Strong typing of a pointer up/down action.
  92210. */
  92211. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  92212. /**
  92213. * Representation of a stage in the scene (Basically a list of ordered steps)
  92214. * @hidden
  92215. */
  92216. export class Stage<T extends Function> extends Array<{
  92217. index: number;
  92218. component: ISceneComponent;
  92219. action: T;
  92220. }> {
  92221. /**
  92222. * Hide ctor from the rest of the world.
  92223. * @param items The items to add.
  92224. */
  92225. private constructor();
  92226. /**
  92227. * Creates a new Stage.
  92228. * @returns A new instance of a Stage
  92229. */
  92230. static Create<T extends Function>(): Stage<T>;
  92231. /**
  92232. * Registers a step in an ordered way in the targeted stage.
  92233. * @param index Defines the position to register the step in
  92234. * @param component Defines the component attached to the step
  92235. * @param action Defines the action to launch during the step
  92236. */
  92237. registerStep(index: number, component: ISceneComponent, action: T): void;
  92238. /**
  92239. * Clears all the steps from the stage.
  92240. */
  92241. clear(): void;
  92242. }
  92243. }
  92244. declare module BABYLON {
  92245. interface Scene {
  92246. /** @hidden */
  92247. _pointerOverSprite: Nullable<Sprite>;
  92248. /** @hidden */
  92249. _pickedDownSprite: Nullable<Sprite>;
  92250. /** @hidden */
  92251. _tempSpritePickingRay: Nullable<Ray>;
  92252. /**
  92253. * All of the sprite managers added to this scene
  92254. * @see https://doc.babylonjs.com/babylon101/sprites
  92255. */
  92256. spriteManagers: Array<ISpriteManager>;
  92257. /**
  92258. * An event triggered when sprites rendering is about to start
  92259. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92260. */
  92261. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92262. /**
  92263. * An event triggered when sprites rendering is done
  92264. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92265. */
  92266. onAfterSpritesRenderingObservable: Observable<Scene>;
  92267. /** @hidden */
  92268. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92269. /** Launch a ray to try to pick a sprite in the scene
  92270. * @param x position on screen
  92271. * @param y position on screen
  92272. * @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
  92273. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92274. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92275. * @returns a PickingInfo
  92276. */
  92277. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92278. /** Use the given ray to pick a sprite in the scene
  92279. * @param ray The ray (in world space) to use to pick meshes
  92280. * @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
  92281. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92282. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92283. * @returns a PickingInfo
  92284. */
  92285. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92286. /** @hidden */
  92287. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92288. /** Launch a ray to try to pick sprites in the scene
  92289. * @param x position on screen
  92290. * @param y position on screen
  92291. * @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
  92292. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92293. * @returns a PickingInfo array
  92294. */
  92295. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92296. /** Use the given ray to pick sprites in the scene
  92297. * @param ray The ray (in world space) to use to pick meshes
  92298. * @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
  92299. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92300. * @returns a PickingInfo array
  92301. */
  92302. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92303. /**
  92304. * Force the sprite under the pointer
  92305. * @param sprite defines the sprite to use
  92306. */
  92307. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92308. /**
  92309. * Gets the sprite under the pointer
  92310. * @returns a Sprite or null if no sprite is under the pointer
  92311. */
  92312. getPointerOverSprite(): Nullable<Sprite>;
  92313. }
  92314. /**
  92315. * Defines the sprite scene component responsible to manage sprites
  92316. * in a given scene.
  92317. */
  92318. export class SpriteSceneComponent implements ISceneComponent {
  92319. /**
  92320. * The component name helpfull to identify the component in the list of scene components.
  92321. */
  92322. readonly name: string;
  92323. /**
  92324. * The scene the component belongs to.
  92325. */
  92326. scene: Scene;
  92327. /** @hidden */
  92328. private _spritePredicate;
  92329. /**
  92330. * Creates a new instance of the component for the given scene
  92331. * @param scene Defines the scene to register the component in
  92332. */
  92333. constructor(scene: Scene);
  92334. /**
  92335. * Registers the component in a given scene
  92336. */
  92337. register(): void;
  92338. /**
  92339. * Rebuilds the elements related to this component in case of
  92340. * context lost for instance.
  92341. */
  92342. rebuild(): void;
  92343. /**
  92344. * Disposes the component and the associated ressources.
  92345. */
  92346. dispose(): void;
  92347. private _pickSpriteButKeepRay;
  92348. private _pointerMove;
  92349. private _pointerDown;
  92350. private _pointerUp;
  92351. }
  92352. }
  92353. declare module BABYLON {
  92354. /**
  92355. * Class used to provide helper for timing
  92356. */
  92357. export class TimingTools {
  92358. /**
  92359. * Polyfill for setImmediate
  92360. * @param action defines the action to execute after the current execution block
  92361. */
  92362. static SetImmediate(action: () => void): void;
  92363. }
  92364. }
  92365. declare module BABYLON {
  92366. /**
  92367. * Class used to enable instatition of objects by class name
  92368. */
  92369. export class InstantiationTools {
  92370. /**
  92371. * Use this object to register external classes like custom textures or material
  92372. * to allow the laoders to instantiate them
  92373. */
  92374. static RegisteredExternalClasses: {
  92375. [key: string]: Object;
  92376. };
  92377. /**
  92378. * Tries to instantiate a new object from a given class name
  92379. * @param className defines the class name to instantiate
  92380. * @returns the new object or null if the system was not able to do the instantiation
  92381. */
  92382. static Instantiate(className: string): any;
  92383. }
  92384. }
  92385. declare module BABYLON {
  92386. /**
  92387. * Class used to host copy specific utilities
  92388. */
  92389. export class CopyTools {
  92390. /**
  92391. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  92392. * @param texture defines the texture to read pixels from
  92393. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  92394. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  92395. * @returns The base64 encoded string or null
  92396. */
  92397. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Nullable<string>;
  92398. }
  92399. }
  92400. declare module BABYLON {
  92401. /**
  92402. * Define options used to create a depth texture
  92403. */
  92404. export class DepthTextureCreationOptions {
  92405. /** Specifies whether or not a stencil should be allocated in the texture */
  92406. generateStencil?: boolean;
  92407. /** Specifies whether or not bilinear filtering is enable on the texture */
  92408. bilinearFiltering?: boolean;
  92409. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  92410. comparisonFunction?: number;
  92411. /** Specifies if the created texture is a cube texture */
  92412. isCube?: boolean;
  92413. }
  92414. }
  92415. declare module BABYLON {
  92416. interface ThinEngine {
  92417. /**
  92418. * Creates a depth stencil cube texture.
  92419. * This is only available in WebGL 2.
  92420. * @param size The size of face edge in the cube texture.
  92421. * @param options The options defining the cube texture.
  92422. * @returns The cube texture
  92423. */
  92424. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  92425. /**
  92426. * Creates a cube texture
  92427. * @param rootUrl defines the url where the files to load is located
  92428. * @param scene defines the current scene
  92429. * @param files defines the list of files to load (1 per face)
  92430. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92431. * @param onLoad defines an optional callback raised when the texture is loaded
  92432. * @param onError defines an optional callback raised if there is an issue to load the texture
  92433. * @param format defines the format of the data
  92434. * @param forcedExtension defines the extension to use to pick the right loader
  92435. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92436. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92437. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92438. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  92439. * @param loaderOptions options to be passed to the loader
  92440. * @returns the cube texture as an InternalTexture
  92441. */
  92442. 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>, loaderOptions: any): InternalTexture;
  92443. /**
  92444. * Creates a cube texture
  92445. * @param rootUrl defines the url where the files to load is located
  92446. * @param scene defines the current scene
  92447. * @param files defines the list of files to load (1 per face)
  92448. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92449. * @param onLoad defines an optional callback raised when the texture is loaded
  92450. * @param onError defines an optional callback raised if there is an issue to load the texture
  92451. * @param format defines the format of the data
  92452. * @param forcedExtension defines the extension to use to pick the right loader
  92453. * @returns the cube texture as an InternalTexture
  92454. */
  92455. 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;
  92456. /**
  92457. * Creates a cube texture
  92458. * @param rootUrl defines the url where the files to load is located
  92459. * @param scene defines the current scene
  92460. * @param files defines the list of files to load (1 per face)
  92461. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  92462. * @param onLoad defines an optional callback raised when the texture is loaded
  92463. * @param onError defines an optional callback raised if there is an issue to load the texture
  92464. * @param format defines the format of the data
  92465. * @param forcedExtension defines the extension to use to pick the right loader
  92466. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  92467. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92468. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92469. * @returns the cube texture as an InternalTexture
  92470. */
  92471. 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;
  92472. /** @hidden */
  92473. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  92474. /** @hidden */
  92475. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  92476. /** @hidden */
  92477. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92478. /** @hidden */
  92479. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  92480. /**
  92481. * @hidden
  92482. */
  92483. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  92484. }
  92485. }
  92486. declare module BABYLON {
  92487. /**
  92488. * Class for creating a cube texture
  92489. */
  92490. export class CubeTexture extends BaseTexture {
  92491. private _delayedOnLoad;
  92492. /**
  92493. * Observable triggered once the texture has been loaded.
  92494. */
  92495. onLoadObservable: Observable<CubeTexture>;
  92496. /**
  92497. * The url of the texture
  92498. */
  92499. url: string;
  92500. /**
  92501. * Gets or sets the center of the bounding box associated with the cube texture.
  92502. * It must define where the camera used to render the texture was set
  92503. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92504. */
  92505. boundingBoxPosition: Vector3;
  92506. private _boundingBoxSize;
  92507. /**
  92508. * Gets or sets the size of the bounding box associated with the cube texture
  92509. * When defined, the cubemap will switch to local mode
  92510. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  92511. * @example https://www.babylonjs-playground.com/#RNASML
  92512. */
  92513. set boundingBoxSize(value: Vector3);
  92514. /**
  92515. * Returns the bounding box size
  92516. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  92517. */
  92518. get boundingBoxSize(): Vector3;
  92519. protected _rotationY: number;
  92520. /**
  92521. * Sets texture matrix rotation angle around Y axis in radians.
  92522. */
  92523. set rotationY(value: number);
  92524. /**
  92525. * Gets texture matrix rotation angle around Y axis radians.
  92526. */
  92527. get rotationY(): number;
  92528. /**
  92529. * Are mip maps generated for this texture or not.
  92530. */
  92531. get noMipmap(): boolean;
  92532. private _noMipmap;
  92533. private _files;
  92534. protected _forcedExtension: Nullable<string>;
  92535. private _extensions;
  92536. private _textureMatrix;
  92537. private _format;
  92538. private _createPolynomials;
  92539. private _loaderOptions;
  92540. /**
  92541. * Creates a cube texture from an array of image urls
  92542. * @param files defines an array of image urls
  92543. * @param scene defines the hosting scene
  92544. * @param noMipmap specifies if mip maps are not used
  92545. * @returns a cube texture
  92546. */
  92547. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  92548. /**
  92549. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  92550. * @param url defines the url of the prefiltered texture
  92551. * @param scene defines the scene the texture is attached to
  92552. * @param forcedExtension defines the extension of the file if different from the url
  92553. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92554. * @return the prefiltered texture
  92555. */
  92556. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  92557. /**
  92558. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  92559. * as prefiltered data.
  92560. * @param rootUrl defines the url of the texture or the root name of the six images
  92561. * @param null defines the scene or engine the texture is attached to
  92562. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  92563. * @param noMipmap defines if mipmaps should be created or not
  92564. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  92565. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  92566. * @param onError defines a callback triggered in case of error during load
  92567. * @param format defines the internal format to use for the texture once loaded
  92568. * @param prefiltered defines whether or not the texture is created from prefiltered data
  92569. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  92570. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  92571. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  92572. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  92573. * @param loaderOptions options to be passed to the loader
  92574. * @return the cube texture
  92575. */
  92576. 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, loaderOptions?: any);
  92577. /**
  92578. * Get the current class name of the texture useful for serialization or dynamic coding.
  92579. * @returns "CubeTexture"
  92580. */
  92581. getClassName(): string;
  92582. /**
  92583. * Update the url (and optional buffer) of this texture if url was null during construction.
  92584. * @param url the url of the texture
  92585. * @param forcedExtension defines the extension to use
  92586. * @param onLoad callback called when the texture is loaded (defaults to null)
  92587. * @param prefiltered Defines whether the updated texture is prefiltered or not
  92588. */
  92589. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  92590. /**
  92591. * Delays loading of the cube texture
  92592. * @param forcedExtension defines the extension to use
  92593. */
  92594. delayLoad(forcedExtension?: string): void;
  92595. /**
  92596. * Returns the reflection texture matrix
  92597. * @returns the reflection texture matrix
  92598. */
  92599. getReflectionTextureMatrix(): Matrix;
  92600. /**
  92601. * Sets the reflection texture matrix
  92602. * @param value Reflection texture matrix
  92603. */
  92604. setReflectionTextureMatrix(value: Matrix): void;
  92605. /**
  92606. * Parses text to create a cube texture
  92607. * @param parsedTexture define the serialized text to read from
  92608. * @param scene defines the hosting scene
  92609. * @param rootUrl defines the root url of the cube texture
  92610. * @returns a cube texture
  92611. */
  92612. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  92613. /**
  92614. * Makes a clone, or deep copy, of the cube texture
  92615. * @returns a new cube texture
  92616. */
  92617. clone(): CubeTexture;
  92618. }
  92619. }
  92620. declare module BABYLON {
  92621. /**
  92622. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92623. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92624. * 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;
  92625. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92626. */
  92627. export class ColorCurves {
  92628. private _dirty;
  92629. private _tempColor;
  92630. private _globalCurve;
  92631. private _highlightsCurve;
  92632. private _midtonesCurve;
  92633. private _shadowsCurve;
  92634. private _positiveCurve;
  92635. private _negativeCurve;
  92636. private _globalHue;
  92637. private _globalDensity;
  92638. private _globalSaturation;
  92639. private _globalExposure;
  92640. /**
  92641. * Gets the global Hue value.
  92642. * 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).
  92643. */
  92644. get globalHue(): number;
  92645. /**
  92646. * Sets the global Hue value.
  92647. * 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).
  92648. */
  92649. set globalHue(value: number);
  92650. /**
  92651. * Gets the global Density value.
  92652. * 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.
  92653. * Values less than zero provide a filter of opposite hue.
  92654. */
  92655. get globalDensity(): number;
  92656. /**
  92657. * Sets the global Density value.
  92658. * 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.
  92659. * Values less than zero provide a filter of opposite hue.
  92660. */
  92661. set globalDensity(value: number);
  92662. /**
  92663. * Gets the global Saturation value.
  92664. * 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.
  92665. */
  92666. get globalSaturation(): number;
  92667. /**
  92668. * Sets the global Saturation value.
  92669. * 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.
  92670. */
  92671. set globalSaturation(value: number);
  92672. /**
  92673. * Gets the global Exposure value.
  92674. * 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.
  92675. */
  92676. get globalExposure(): number;
  92677. /**
  92678. * Sets the global Exposure value.
  92679. * 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.
  92680. */
  92681. set globalExposure(value: number);
  92682. private _highlightsHue;
  92683. private _highlightsDensity;
  92684. private _highlightsSaturation;
  92685. private _highlightsExposure;
  92686. /**
  92687. * Gets the highlights Hue value.
  92688. * 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).
  92689. */
  92690. get highlightsHue(): number;
  92691. /**
  92692. * Sets the highlights Hue value.
  92693. * 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).
  92694. */
  92695. set highlightsHue(value: number);
  92696. /**
  92697. * Gets the highlights Density value.
  92698. * 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.
  92699. * Values less than zero provide a filter of opposite hue.
  92700. */
  92701. get highlightsDensity(): number;
  92702. /**
  92703. * Sets the highlights Density value.
  92704. * 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.
  92705. * Values less than zero provide a filter of opposite hue.
  92706. */
  92707. set highlightsDensity(value: number);
  92708. /**
  92709. * Gets the highlights Saturation value.
  92710. * 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.
  92711. */
  92712. get highlightsSaturation(): number;
  92713. /**
  92714. * Sets the highlights Saturation value.
  92715. * 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.
  92716. */
  92717. set highlightsSaturation(value: number);
  92718. /**
  92719. * Gets the highlights Exposure value.
  92720. * 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.
  92721. */
  92722. get highlightsExposure(): number;
  92723. /**
  92724. * Sets the highlights Exposure value.
  92725. * 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.
  92726. */
  92727. set highlightsExposure(value: number);
  92728. private _midtonesHue;
  92729. private _midtonesDensity;
  92730. private _midtonesSaturation;
  92731. private _midtonesExposure;
  92732. /**
  92733. * Gets the midtones Hue value.
  92734. * 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).
  92735. */
  92736. get midtonesHue(): number;
  92737. /**
  92738. * Sets the midtones Hue value.
  92739. * 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).
  92740. */
  92741. set midtonesHue(value: number);
  92742. /**
  92743. * Gets the midtones Density value.
  92744. * 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.
  92745. * Values less than zero provide a filter of opposite hue.
  92746. */
  92747. get midtonesDensity(): number;
  92748. /**
  92749. * Sets the midtones Density value.
  92750. * 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.
  92751. * Values less than zero provide a filter of opposite hue.
  92752. */
  92753. set midtonesDensity(value: number);
  92754. /**
  92755. * Gets the midtones Saturation value.
  92756. * 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.
  92757. */
  92758. get midtonesSaturation(): number;
  92759. /**
  92760. * Sets the midtones Saturation value.
  92761. * 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.
  92762. */
  92763. set midtonesSaturation(value: number);
  92764. /**
  92765. * Gets the midtones Exposure value.
  92766. * 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.
  92767. */
  92768. get midtonesExposure(): number;
  92769. /**
  92770. * Sets the midtones Exposure value.
  92771. * 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.
  92772. */
  92773. set midtonesExposure(value: number);
  92774. private _shadowsHue;
  92775. private _shadowsDensity;
  92776. private _shadowsSaturation;
  92777. private _shadowsExposure;
  92778. /**
  92779. * Gets the shadows Hue value.
  92780. * 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).
  92781. */
  92782. get shadowsHue(): number;
  92783. /**
  92784. * Sets the shadows Hue value.
  92785. * 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).
  92786. */
  92787. set shadowsHue(value: number);
  92788. /**
  92789. * Gets the shadows Density value.
  92790. * 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.
  92791. * Values less than zero provide a filter of opposite hue.
  92792. */
  92793. get shadowsDensity(): number;
  92794. /**
  92795. * Sets the shadows Density value.
  92796. * 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.
  92797. * Values less than zero provide a filter of opposite hue.
  92798. */
  92799. set shadowsDensity(value: number);
  92800. /**
  92801. * Gets the shadows Saturation value.
  92802. * 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.
  92803. */
  92804. get shadowsSaturation(): number;
  92805. /**
  92806. * Sets the shadows Saturation value.
  92807. * 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.
  92808. */
  92809. set shadowsSaturation(value: number);
  92810. /**
  92811. * Gets the shadows Exposure value.
  92812. * 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.
  92813. */
  92814. get shadowsExposure(): number;
  92815. /**
  92816. * Sets the shadows Exposure value.
  92817. * 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.
  92818. */
  92819. set shadowsExposure(value: number);
  92820. /**
  92821. * Returns the class name
  92822. * @returns The class name
  92823. */
  92824. getClassName(): string;
  92825. /**
  92826. * Binds the color curves to the shader.
  92827. * @param colorCurves The color curve to bind
  92828. * @param effect The effect to bind to
  92829. * @param positiveUniform The positive uniform shader parameter
  92830. * @param neutralUniform The neutral uniform shader parameter
  92831. * @param negativeUniform The negative uniform shader parameter
  92832. */
  92833. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92834. /**
  92835. * Prepare the list of uniforms associated with the ColorCurves effects.
  92836. * @param uniformsList The list of uniforms used in the effect
  92837. */
  92838. static PrepareUniforms(uniformsList: string[]): void;
  92839. /**
  92840. * Returns color grading data based on a hue, density, saturation and exposure value.
  92841. * @param filterHue The hue of the color filter.
  92842. * @param filterDensity The density of the color filter.
  92843. * @param saturation The saturation.
  92844. * @param exposure The exposure.
  92845. * @param result The result data container.
  92846. */
  92847. private getColorGradingDataToRef;
  92848. /**
  92849. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92850. * @param value The input slider value in range [-100,100].
  92851. * @returns Adjusted value.
  92852. */
  92853. private static applyColorGradingSliderNonlinear;
  92854. /**
  92855. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92856. * @param hue The hue (H) input.
  92857. * @param saturation The saturation (S) input.
  92858. * @param brightness The brightness (B) input.
  92859. * @result An RGBA color represented as Vector4.
  92860. */
  92861. private static fromHSBToRef;
  92862. /**
  92863. * Returns a value clamped between min and max
  92864. * @param value The value to clamp
  92865. * @param min The minimum of value
  92866. * @param max The maximum of value
  92867. * @returns The clamped value.
  92868. */
  92869. private static clamp;
  92870. /**
  92871. * Clones the current color curve instance.
  92872. * @return The cloned curves
  92873. */
  92874. clone(): ColorCurves;
  92875. /**
  92876. * Serializes the current color curve instance to a json representation.
  92877. * @return a JSON representation
  92878. */
  92879. serialize(): any;
  92880. /**
  92881. * Parses the color curve from a json representation.
  92882. * @param source the JSON source to parse
  92883. * @return The parsed curves
  92884. */
  92885. static Parse(source: any): ColorCurves;
  92886. }
  92887. }
  92888. declare module BABYLON {
  92889. /**
  92890. * Interface to follow in your material defines to integrate easily the
  92891. * Image proccessing functions.
  92892. * @hidden
  92893. */
  92894. export interface IImageProcessingConfigurationDefines {
  92895. IMAGEPROCESSING: boolean;
  92896. VIGNETTE: boolean;
  92897. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92898. VIGNETTEBLENDMODEOPAQUE: boolean;
  92899. TONEMAPPING: boolean;
  92900. TONEMAPPING_ACES: boolean;
  92901. CONTRAST: boolean;
  92902. EXPOSURE: boolean;
  92903. COLORCURVES: boolean;
  92904. COLORGRADING: boolean;
  92905. COLORGRADING3D: boolean;
  92906. SAMPLER3DGREENDEPTH: boolean;
  92907. SAMPLER3DBGRMAP: boolean;
  92908. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92909. }
  92910. /**
  92911. * @hidden
  92912. */
  92913. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92914. IMAGEPROCESSING: boolean;
  92915. VIGNETTE: boolean;
  92916. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92917. VIGNETTEBLENDMODEOPAQUE: boolean;
  92918. TONEMAPPING: boolean;
  92919. TONEMAPPING_ACES: boolean;
  92920. CONTRAST: boolean;
  92921. COLORCURVES: boolean;
  92922. COLORGRADING: boolean;
  92923. COLORGRADING3D: boolean;
  92924. SAMPLER3DGREENDEPTH: boolean;
  92925. SAMPLER3DBGRMAP: boolean;
  92926. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92927. EXPOSURE: boolean;
  92928. constructor();
  92929. }
  92930. /**
  92931. * This groups together the common properties used for image processing either in direct forward pass
  92932. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92933. * or not.
  92934. */
  92935. export class ImageProcessingConfiguration {
  92936. /**
  92937. * Default tone mapping applied in BabylonJS.
  92938. */
  92939. static readonly TONEMAPPING_STANDARD: number;
  92940. /**
  92941. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92942. * to other engines rendering to increase portability.
  92943. */
  92944. static readonly TONEMAPPING_ACES: number;
  92945. /**
  92946. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92947. */
  92948. colorCurves: Nullable<ColorCurves>;
  92949. private _colorCurvesEnabled;
  92950. /**
  92951. * Gets wether the color curves effect is enabled.
  92952. */
  92953. get colorCurvesEnabled(): boolean;
  92954. /**
  92955. * Sets wether the color curves effect is enabled.
  92956. */
  92957. set colorCurvesEnabled(value: boolean);
  92958. private _colorGradingTexture;
  92959. /**
  92960. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92961. */
  92962. get colorGradingTexture(): Nullable<BaseTexture>;
  92963. /**
  92964. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92965. */
  92966. set colorGradingTexture(value: Nullable<BaseTexture>);
  92967. private _colorGradingEnabled;
  92968. /**
  92969. * Gets wether the color grading effect is enabled.
  92970. */
  92971. get colorGradingEnabled(): boolean;
  92972. /**
  92973. * Sets wether the color grading effect is enabled.
  92974. */
  92975. set colorGradingEnabled(value: boolean);
  92976. private _colorGradingWithGreenDepth;
  92977. /**
  92978. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92979. */
  92980. get colorGradingWithGreenDepth(): boolean;
  92981. /**
  92982. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92983. */
  92984. set colorGradingWithGreenDepth(value: boolean);
  92985. private _colorGradingBGR;
  92986. /**
  92987. * Gets wether the color grading texture contains BGR values.
  92988. */
  92989. get colorGradingBGR(): boolean;
  92990. /**
  92991. * Sets wether the color grading texture contains BGR values.
  92992. */
  92993. set colorGradingBGR(value: boolean);
  92994. /** @hidden */
  92995. _exposure: number;
  92996. /**
  92997. * Gets the Exposure used in the effect.
  92998. */
  92999. get exposure(): number;
  93000. /**
  93001. * Sets the Exposure used in the effect.
  93002. */
  93003. set exposure(value: number);
  93004. private _toneMappingEnabled;
  93005. /**
  93006. * Gets wether the tone mapping effect is enabled.
  93007. */
  93008. get toneMappingEnabled(): boolean;
  93009. /**
  93010. * Sets wether the tone mapping effect is enabled.
  93011. */
  93012. set toneMappingEnabled(value: boolean);
  93013. private _toneMappingType;
  93014. /**
  93015. * Gets the type of tone mapping effect.
  93016. */
  93017. get toneMappingType(): number;
  93018. /**
  93019. * Sets the type of tone mapping effect used in BabylonJS.
  93020. */
  93021. set toneMappingType(value: number);
  93022. protected _contrast: number;
  93023. /**
  93024. * Gets the contrast used in the effect.
  93025. */
  93026. get contrast(): number;
  93027. /**
  93028. * Sets the contrast used in the effect.
  93029. */
  93030. set contrast(value: number);
  93031. /**
  93032. * Vignette stretch size.
  93033. */
  93034. vignetteStretch: number;
  93035. /**
  93036. * Vignette centre X Offset.
  93037. */
  93038. vignetteCentreX: number;
  93039. /**
  93040. * Vignette centre Y Offset.
  93041. */
  93042. vignetteCentreY: number;
  93043. /**
  93044. * Vignette weight or intensity of the vignette effect.
  93045. */
  93046. vignetteWeight: number;
  93047. /**
  93048. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  93049. * if vignetteEnabled is set to true.
  93050. */
  93051. vignetteColor: Color4;
  93052. /**
  93053. * Camera field of view used by the Vignette effect.
  93054. */
  93055. vignetteCameraFov: number;
  93056. private _vignetteBlendMode;
  93057. /**
  93058. * Gets the vignette blend mode allowing different kind of effect.
  93059. */
  93060. get vignetteBlendMode(): number;
  93061. /**
  93062. * Sets the vignette blend mode allowing different kind of effect.
  93063. */
  93064. set vignetteBlendMode(value: number);
  93065. private _vignetteEnabled;
  93066. /**
  93067. * Gets wether the vignette effect is enabled.
  93068. */
  93069. get vignetteEnabled(): boolean;
  93070. /**
  93071. * Sets wether the vignette effect is enabled.
  93072. */
  93073. set vignetteEnabled(value: boolean);
  93074. private _applyByPostProcess;
  93075. /**
  93076. * Gets wether the image processing is applied through a post process or not.
  93077. */
  93078. get applyByPostProcess(): boolean;
  93079. /**
  93080. * Sets wether the image processing is applied through a post process or not.
  93081. */
  93082. set applyByPostProcess(value: boolean);
  93083. private _isEnabled;
  93084. /**
  93085. * Gets wether the image processing is enabled or not.
  93086. */
  93087. get isEnabled(): boolean;
  93088. /**
  93089. * Sets wether the image processing is enabled or not.
  93090. */
  93091. set isEnabled(value: boolean);
  93092. /**
  93093. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  93094. */
  93095. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  93096. /**
  93097. * Method called each time the image processing information changes requires to recompile the effect.
  93098. */
  93099. protected _updateParameters(): void;
  93100. /**
  93101. * Gets the current class name.
  93102. * @return "ImageProcessingConfiguration"
  93103. */
  93104. getClassName(): string;
  93105. /**
  93106. * Prepare the list of uniforms associated with the Image Processing effects.
  93107. * @param uniforms The list of uniforms used in the effect
  93108. * @param defines the list of defines currently in use
  93109. */
  93110. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  93111. /**
  93112. * Prepare the list of samplers associated with the Image Processing effects.
  93113. * @param samplersList The list of uniforms used in the effect
  93114. * @param defines the list of defines currently in use
  93115. */
  93116. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  93117. /**
  93118. * Prepare the list of defines associated to the shader.
  93119. * @param defines the list of defines to complete
  93120. * @param forPostProcess Define if we are currently in post process mode or not
  93121. */
  93122. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  93123. /**
  93124. * Returns true if all the image processing information are ready.
  93125. * @returns True if ready, otherwise, false
  93126. */
  93127. isReady(): boolean;
  93128. /**
  93129. * Binds the image processing to the shader.
  93130. * @param effect The effect to bind to
  93131. * @param overrideAspectRatio Override the aspect ratio of the effect
  93132. */
  93133. bind(effect: Effect, overrideAspectRatio?: number): void;
  93134. /**
  93135. * Clones the current image processing instance.
  93136. * @return The cloned image processing
  93137. */
  93138. clone(): ImageProcessingConfiguration;
  93139. /**
  93140. * Serializes the current image processing instance to a json representation.
  93141. * @return a JSON representation
  93142. */
  93143. serialize(): any;
  93144. /**
  93145. * Parses the image processing from a json representation.
  93146. * @param source the JSON source to parse
  93147. * @return The parsed image processing
  93148. */
  93149. static Parse(source: any): ImageProcessingConfiguration;
  93150. private static _VIGNETTEMODE_MULTIPLY;
  93151. private static _VIGNETTEMODE_OPAQUE;
  93152. /**
  93153. * Used to apply the vignette as a mix with the pixel color.
  93154. */
  93155. static get VIGNETTEMODE_MULTIPLY(): number;
  93156. /**
  93157. * Used to apply the vignette as a replacement of the pixel color.
  93158. */
  93159. static get VIGNETTEMODE_OPAQUE(): number;
  93160. }
  93161. }
  93162. declare module BABYLON {
  93163. /** @hidden */
  93164. export var postprocessVertexShader: {
  93165. name: string;
  93166. shader: string;
  93167. };
  93168. }
  93169. declare module BABYLON {
  93170. /**
  93171. * Type used to define a render target texture size (either with a number or with a rect width and height)
  93172. */
  93173. export type RenderTargetTextureSize = number | {
  93174. width: number;
  93175. height: number;
  93176. layers?: number;
  93177. };
  93178. interface ThinEngine {
  93179. /**
  93180. * Creates a new render target texture
  93181. * @param size defines the size of the texture
  93182. * @param options defines the options used to create the texture
  93183. * @returns a new render target texture stored in an InternalTexture
  93184. */
  93185. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  93186. /**
  93187. * Creates a depth stencil texture.
  93188. * This is only available in WebGL 2 or with the depth texture extension available.
  93189. * @param size The size of face edge in the texture.
  93190. * @param options The options defining the texture.
  93191. * @returns The texture
  93192. */
  93193. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93194. /** @hidden */
  93195. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  93196. }
  93197. }
  93198. declare module BABYLON {
  93199. /**
  93200. * Defines the kind of connection point for node based material
  93201. */
  93202. export enum NodeMaterialBlockConnectionPointTypes {
  93203. /** Float */
  93204. Float = 1,
  93205. /** Int */
  93206. Int = 2,
  93207. /** Vector2 */
  93208. Vector2 = 4,
  93209. /** Vector3 */
  93210. Vector3 = 8,
  93211. /** Vector4 */
  93212. Vector4 = 16,
  93213. /** Color3 */
  93214. Color3 = 32,
  93215. /** Color4 */
  93216. Color4 = 64,
  93217. /** Matrix */
  93218. Matrix = 128,
  93219. /** Custom object */
  93220. Object = 256,
  93221. /** Detect type based on connection */
  93222. AutoDetect = 1024,
  93223. /** Output type that will be defined by input type */
  93224. BasedOnInput = 2048
  93225. }
  93226. }
  93227. declare module BABYLON {
  93228. /**
  93229. * Enum used to define the target of a block
  93230. */
  93231. export enum NodeMaterialBlockTargets {
  93232. /** Vertex shader */
  93233. Vertex = 1,
  93234. /** Fragment shader */
  93235. Fragment = 2,
  93236. /** Neutral */
  93237. Neutral = 4,
  93238. /** Vertex and Fragment */
  93239. VertexAndFragment = 3
  93240. }
  93241. }
  93242. declare module BABYLON {
  93243. /**
  93244. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  93245. */
  93246. export enum NodeMaterialBlockConnectionPointMode {
  93247. /** Value is an uniform */
  93248. Uniform = 0,
  93249. /** Value is a mesh attribute */
  93250. Attribute = 1,
  93251. /** Value is a varying between vertex and fragment shaders */
  93252. Varying = 2,
  93253. /** Mode is undefined */
  93254. Undefined = 3
  93255. }
  93256. }
  93257. declare module BABYLON {
  93258. /**
  93259. * Enum used to define system values e.g. values automatically provided by the system
  93260. */
  93261. export enum NodeMaterialSystemValues {
  93262. /** World */
  93263. World = 1,
  93264. /** View */
  93265. View = 2,
  93266. /** Projection */
  93267. Projection = 3,
  93268. /** ViewProjection */
  93269. ViewProjection = 4,
  93270. /** WorldView */
  93271. WorldView = 5,
  93272. /** WorldViewProjection */
  93273. WorldViewProjection = 6,
  93274. /** CameraPosition */
  93275. CameraPosition = 7,
  93276. /** Fog Color */
  93277. FogColor = 8,
  93278. /** Delta time */
  93279. DeltaTime = 9
  93280. }
  93281. }
  93282. declare module BABYLON {
  93283. /**
  93284. * Represents a camera frustum
  93285. */
  93286. export class Frustum {
  93287. /**
  93288. * Gets the planes representing the frustum
  93289. * @param transform matrix to be applied to the returned planes
  93290. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93291. */
  93292. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93293. /**
  93294. * Gets the near frustum plane transformed by the transform matrix
  93295. * @param transform transformation matrix to be applied to the resulting frustum plane
  93296. * @param frustumPlane the resuling frustum plane
  93297. */
  93298. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93299. /**
  93300. * Gets the far frustum plane transformed by the transform matrix
  93301. * @param transform transformation matrix to be applied to the resulting frustum plane
  93302. * @param frustumPlane the resuling frustum plane
  93303. */
  93304. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93305. /**
  93306. * Gets the left frustum plane transformed by the transform matrix
  93307. * @param transform transformation matrix to be applied to the resulting frustum plane
  93308. * @param frustumPlane the resuling frustum plane
  93309. */
  93310. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93311. /**
  93312. * Gets the right frustum plane transformed by the transform matrix
  93313. * @param transform transformation matrix to be applied to the resulting frustum plane
  93314. * @param frustumPlane the resuling frustum plane
  93315. */
  93316. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93317. /**
  93318. * Gets the top frustum plane transformed by the transform matrix
  93319. * @param transform transformation matrix to be applied to the resulting frustum plane
  93320. * @param frustumPlane the resuling frustum plane
  93321. */
  93322. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93323. /**
  93324. * Gets the bottom frustum plane transformed by the transform matrix
  93325. * @param transform transformation matrix to be applied to the resulting frustum plane
  93326. * @param frustumPlane the resuling frustum plane
  93327. */
  93328. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93329. /**
  93330. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93331. * @param transform transformation matrix to be applied to the resulting frustum planes
  93332. * @param frustumPlanes the resuling frustum planes
  93333. */
  93334. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93335. }
  93336. }
  93337. declare module BABYLON {
  93338. /**
  93339. * Contains position and normal vectors for a vertex
  93340. */
  93341. export class PositionNormalVertex {
  93342. /** the position of the vertex (defaut: 0,0,0) */
  93343. position: Vector3;
  93344. /** the normal of the vertex (defaut: 0,1,0) */
  93345. normal: Vector3;
  93346. /**
  93347. * Creates a PositionNormalVertex
  93348. * @param position the position of the vertex (defaut: 0,0,0)
  93349. * @param normal the normal of the vertex (defaut: 0,1,0)
  93350. */
  93351. constructor(
  93352. /** the position of the vertex (defaut: 0,0,0) */
  93353. position?: Vector3,
  93354. /** the normal of the vertex (defaut: 0,1,0) */
  93355. normal?: Vector3);
  93356. /**
  93357. * Clones the PositionNormalVertex
  93358. * @returns the cloned PositionNormalVertex
  93359. */
  93360. clone(): PositionNormalVertex;
  93361. }
  93362. /**
  93363. * Contains position, normal and uv vectors for a vertex
  93364. */
  93365. export class PositionNormalTextureVertex {
  93366. /** the position of the vertex (defaut: 0,0,0) */
  93367. position: Vector3;
  93368. /** the normal of the vertex (defaut: 0,1,0) */
  93369. normal: Vector3;
  93370. /** the uv of the vertex (default: 0,0) */
  93371. uv: Vector2;
  93372. /**
  93373. * Creates a PositionNormalTextureVertex
  93374. * @param position the position of the vertex (defaut: 0,0,0)
  93375. * @param normal the normal of the vertex (defaut: 0,1,0)
  93376. * @param uv the uv of the vertex (default: 0,0)
  93377. */
  93378. constructor(
  93379. /** the position of the vertex (defaut: 0,0,0) */
  93380. position?: Vector3,
  93381. /** the normal of the vertex (defaut: 0,1,0) */
  93382. normal?: Vector3,
  93383. /** the uv of the vertex (default: 0,0) */
  93384. uv?: Vector2);
  93385. /**
  93386. * Clones the PositionNormalTextureVertex
  93387. * @returns the cloned PositionNormalTextureVertex
  93388. */
  93389. clone(): PositionNormalTextureVertex;
  93390. }
  93391. }
  93392. declare module BABYLON {
  93393. /**
  93394. * Enum defining the type of animations supported by InputBlock
  93395. */
  93396. export enum AnimatedInputBlockTypes {
  93397. /** No animation */
  93398. None = 0,
  93399. /** Time based animation. Will only work for floats */
  93400. Time = 1
  93401. }
  93402. }
  93403. declare module BABYLON {
  93404. /**
  93405. * Block used to expose an input value
  93406. */
  93407. export class InputBlock extends NodeMaterialBlock {
  93408. private _mode;
  93409. private _associatedVariableName;
  93410. private _storedValue;
  93411. private _valueCallback;
  93412. private _type;
  93413. private _animationType;
  93414. /** Gets or set a value used to limit the range of float values */
  93415. min: number;
  93416. /** Gets or set a value used to limit the range of float values */
  93417. max: number;
  93418. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  93419. isBoolean: boolean;
  93420. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  93421. matrixMode: number;
  93422. /** @hidden */
  93423. _systemValue: Nullable<NodeMaterialSystemValues>;
  93424. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  93425. isConstant: boolean;
  93426. /** Gets or sets the group to use to display this block in the Inspector */
  93427. groupInInspector: string;
  93428. /** Gets an observable raised when the value is changed */
  93429. onValueChangedObservable: Observable<InputBlock>;
  93430. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  93431. convertToGammaSpace: boolean;
  93432. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  93433. convertToLinearSpace: boolean;
  93434. /**
  93435. * Gets or sets the connection point type (default is float)
  93436. */
  93437. get type(): NodeMaterialBlockConnectionPointTypes;
  93438. /**
  93439. * Creates a new InputBlock
  93440. * @param name defines the block name
  93441. * @param target defines the target of that block (Vertex by default)
  93442. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  93443. */
  93444. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  93445. /**
  93446. * Validates if a name is a reserve word.
  93447. * @param newName the new name to be given to the node.
  93448. * @returns false if the name is a reserve word, else true.
  93449. */
  93450. validateBlockName(newName: string): boolean;
  93451. /**
  93452. * Gets the output component
  93453. */
  93454. get output(): NodeMaterialConnectionPoint;
  93455. /**
  93456. * Set the source of this connection point to a vertex attribute
  93457. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  93458. * @returns the current connection point
  93459. */
  93460. setAsAttribute(attributeName?: string): InputBlock;
  93461. /**
  93462. * Set the source of this connection point to a system value
  93463. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  93464. * @returns the current connection point
  93465. */
  93466. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  93467. /**
  93468. * Gets or sets the value of that point.
  93469. * Please note that this value will be ignored if valueCallback is defined
  93470. */
  93471. get value(): any;
  93472. set value(value: any);
  93473. /**
  93474. * Gets or sets a callback used to get the value of that point.
  93475. * Please note that setting this value will force the connection point to ignore the value property
  93476. */
  93477. get valueCallback(): () => any;
  93478. set valueCallback(value: () => any);
  93479. /**
  93480. * Gets or sets the associated variable name in the shader
  93481. */
  93482. get associatedVariableName(): string;
  93483. set associatedVariableName(value: string);
  93484. /** Gets or sets the type of animation applied to the input */
  93485. get animationType(): AnimatedInputBlockTypes;
  93486. set animationType(value: AnimatedInputBlockTypes);
  93487. /**
  93488. * Gets a boolean indicating that this connection point not defined yet
  93489. */
  93490. get isUndefined(): boolean;
  93491. /**
  93492. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  93493. * In this case the connection point name must be the name of the uniform to use.
  93494. * Can only be set on inputs
  93495. */
  93496. get isUniform(): boolean;
  93497. set isUniform(value: boolean);
  93498. /**
  93499. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  93500. * In this case the connection point name must be the name of the attribute to use
  93501. * Can only be set on inputs
  93502. */
  93503. get isAttribute(): boolean;
  93504. set isAttribute(value: boolean);
  93505. /**
  93506. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  93507. * Can only be set on exit points
  93508. */
  93509. get isVarying(): boolean;
  93510. set isVarying(value: boolean);
  93511. /**
  93512. * Gets a boolean indicating that the current connection point is a system value
  93513. */
  93514. get isSystemValue(): boolean;
  93515. /**
  93516. * Gets or sets the current well known value or null if not defined as a system value
  93517. */
  93518. get systemValue(): Nullable<NodeMaterialSystemValues>;
  93519. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  93520. /**
  93521. * Gets the current class name
  93522. * @returns the class name
  93523. */
  93524. getClassName(): string;
  93525. /**
  93526. * Animate the input if animationType !== None
  93527. * @param scene defines the rendering scene
  93528. */
  93529. animate(scene: Scene): void;
  93530. private _emitDefine;
  93531. initialize(state: NodeMaterialBuildState): void;
  93532. /**
  93533. * Set the input block to its default value (based on its type)
  93534. */
  93535. setDefaultValue(): void;
  93536. private _emitConstant;
  93537. /** @hidden */
  93538. get _noContextSwitch(): boolean;
  93539. private _emit;
  93540. /** @hidden */
  93541. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  93542. /** @hidden */
  93543. _transmit(effect: Effect, scene: Scene): void;
  93544. protected _buildBlock(state: NodeMaterialBuildState): void;
  93545. protected _dumpPropertiesCode(): string;
  93546. dispose(): void;
  93547. serialize(): any;
  93548. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93549. }
  93550. }
  93551. declare module BABYLON {
  93552. /**
  93553. * Enum used to define the compatibility state between two connection points
  93554. */
  93555. export enum NodeMaterialConnectionPointCompatibilityStates {
  93556. /** Points are compatibles */
  93557. Compatible = 0,
  93558. /** Points are incompatible because of their types */
  93559. TypeIncompatible = 1,
  93560. /** Points are incompatible because of their targets (vertex vs fragment) */
  93561. TargetIncompatible = 2
  93562. }
  93563. /**
  93564. * Defines the direction of a connection point
  93565. */
  93566. export enum NodeMaterialConnectionPointDirection {
  93567. /** Input */
  93568. Input = 0,
  93569. /** Output */
  93570. Output = 1
  93571. }
  93572. /**
  93573. * Defines a connection point for a block
  93574. */
  93575. export class NodeMaterialConnectionPoint {
  93576. /**
  93577. * Checks if two types are equivalent
  93578. * @param type1 type 1 to check
  93579. * @param type2 type 2 to check
  93580. * @returns true if both types are equivalent, else false
  93581. */
  93582. static AreEquivalentTypes(type1: number, type2: number): boolean;
  93583. /** @hidden */
  93584. _ownerBlock: NodeMaterialBlock;
  93585. /** @hidden */
  93586. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  93587. private _endpoints;
  93588. private _associatedVariableName;
  93589. private _direction;
  93590. /** @hidden */
  93591. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93592. /** @hidden */
  93593. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  93594. /** @hidden */
  93595. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  93596. private _type;
  93597. /** @hidden */
  93598. _enforceAssociatedVariableName: boolean;
  93599. /** Gets the direction of the point */
  93600. get direction(): NodeMaterialConnectionPointDirection;
  93601. /** Indicates that this connection point needs dual validation before being connected to another point */
  93602. needDualDirectionValidation: boolean;
  93603. /**
  93604. * Gets or sets the additional types supported by this connection point
  93605. */
  93606. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93607. /**
  93608. * Gets or sets the additional types excluded by this connection point
  93609. */
  93610. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  93611. /**
  93612. * Observable triggered when this point is connected
  93613. */
  93614. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  93615. /**
  93616. * Gets or sets the associated variable name in the shader
  93617. */
  93618. get associatedVariableName(): string;
  93619. set associatedVariableName(value: string);
  93620. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  93621. get innerType(): NodeMaterialBlockConnectionPointTypes;
  93622. /**
  93623. * Gets or sets the connection point type (default is float)
  93624. */
  93625. get type(): NodeMaterialBlockConnectionPointTypes;
  93626. set type(value: NodeMaterialBlockConnectionPointTypes);
  93627. /**
  93628. * Gets or sets the connection point name
  93629. */
  93630. name: string;
  93631. /**
  93632. * Gets or sets the connection point name
  93633. */
  93634. displayName: string;
  93635. /**
  93636. * Gets or sets a boolean indicating that this connection point can be omitted
  93637. */
  93638. isOptional: boolean;
  93639. /**
  93640. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  93641. */
  93642. isExposedOnFrame: boolean;
  93643. /**
  93644. * Gets or sets number indicating the position that the port is exposed to on a frame
  93645. */
  93646. exposedPortPosition: number;
  93647. /**
  93648. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  93649. */
  93650. define: string;
  93651. /** @hidden */
  93652. _prioritizeVertex: boolean;
  93653. private _target;
  93654. /** Gets or sets the target of that connection point */
  93655. get target(): NodeMaterialBlockTargets;
  93656. set target(value: NodeMaterialBlockTargets);
  93657. /**
  93658. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  93659. */
  93660. get isConnected(): boolean;
  93661. /**
  93662. * Gets a boolean indicating that the current point is connected to an input block
  93663. */
  93664. get isConnectedToInputBlock(): boolean;
  93665. /**
  93666. * Gets a the connected input block (if any)
  93667. */
  93668. get connectInputBlock(): Nullable<InputBlock>;
  93669. /** Get the other side of the connection (if any) */
  93670. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  93671. /** Get the block that owns this connection point */
  93672. get ownerBlock(): NodeMaterialBlock;
  93673. /** Get the block connected on the other side of this connection (if any) */
  93674. get sourceBlock(): Nullable<NodeMaterialBlock>;
  93675. /** Get the block connected on the endpoints of this connection (if any) */
  93676. get connectedBlocks(): Array<NodeMaterialBlock>;
  93677. /** Gets the list of connected endpoints */
  93678. get endpoints(): NodeMaterialConnectionPoint[];
  93679. /** Gets a boolean indicating if that output point is connected to at least one input */
  93680. get hasEndpoints(): boolean;
  93681. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  93682. get isConnectedInVertexShader(): boolean;
  93683. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  93684. get isConnectedInFragmentShader(): boolean;
  93685. /**
  93686. * Creates a block suitable to be used as an input for this input point.
  93687. * If null is returned, a block based on the point type will be created.
  93688. * @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
  93689. */
  93690. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  93691. /**
  93692. * Creates a new connection point
  93693. * @param name defines the connection point name
  93694. * @param ownerBlock defines the block hosting this connection point
  93695. * @param direction defines the direction of the connection point
  93696. */
  93697. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  93698. /**
  93699. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  93700. * @returns the class name
  93701. */
  93702. getClassName(): string;
  93703. /**
  93704. * Gets a boolean indicating if the current point can be connected to another point
  93705. * @param connectionPoint defines the other connection point
  93706. * @returns a boolean
  93707. */
  93708. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  93709. /**
  93710. * Gets a number indicating if the current point can be connected to another point
  93711. * @param connectionPoint defines the other connection point
  93712. * @returns a number defining the compatibility state
  93713. */
  93714. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93715. /**
  93716. * Connect this point to another connection point
  93717. * @param connectionPoint defines the other connection point
  93718. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  93719. * @returns the current connection point
  93720. */
  93721. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  93722. /**
  93723. * Disconnect this point from one of his endpoint
  93724. * @param endpoint defines the other connection point
  93725. * @returns the current connection point
  93726. */
  93727. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  93728. /**
  93729. * Serializes this point in a JSON representation
  93730. * @param isInput defines if the connection point is an input (default is true)
  93731. * @returns the serialized point object
  93732. */
  93733. serialize(isInput?: boolean): any;
  93734. /**
  93735. * Release resources
  93736. */
  93737. dispose(): void;
  93738. }
  93739. }
  93740. declare module BABYLON {
  93741. /**
  93742. * Enum used to define the material modes
  93743. */
  93744. export enum NodeMaterialModes {
  93745. /** Regular material */
  93746. Material = 0,
  93747. /** For post process */
  93748. PostProcess = 1,
  93749. /** For particle system */
  93750. Particle = 2,
  93751. /** For procedural texture */
  93752. ProceduralTexture = 3
  93753. }
  93754. }
  93755. declare module BABYLON {
  93756. /** @hidden */
  93757. export var helperFunctions: {
  93758. name: string;
  93759. shader: string;
  93760. };
  93761. }
  93762. declare module BABYLON {
  93763. /**
  93764. * Block used to read a texture from a sampler
  93765. */
  93766. export class TextureBlock extends NodeMaterialBlock {
  93767. private _defineName;
  93768. private _linearDefineName;
  93769. private _gammaDefineName;
  93770. private _tempTextureRead;
  93771. private _samplerName;
  93772. private _transformedUVName;
  93773. private _textureTransformName;
  93774. private _textureInfoName;
  93775. private _mainUVName;
  93776. private _mainUVDefineName;
  93777. private _fragmentOnly;
  93778. /**
  93779. * Gets or sets the texture associated with the node
  93780. */
  93781. texture: Nullable<Texture>;
  93782. /**
  93783. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  93784. */
  93785. convertToGammaSpace: boolean;
  93786. /**
  93787. * Gets or sets a boolean indicating if content needs to be converted to linear space
  93788. */
  93789. convertToLinearSpace: boolean;
  93790. /**
  93791. * Create a new TextureBlock
  93792. * @param name defines the block name
  93793. */
  93794. constructor(name: string, fragmentOnly?: boolean);
  93795. /**
  93796. * Gets the current class name
  93797. * @returns the class name
  93798. */
  93799. getClassName(): string;
  93800. /**
  93801. * Gets the uv input component
  93802. */
  93803. get uv(): NodeMaterialConnectionPoint;
  93804. /**
  93805. * Gets the rgba output component
  93806. */
  93807. get rgba(): NodeMaterialConnectionPoint;
  93808. /**
  93809. * Gets the rgb output component
  93810. */
  93811. get rgb(): NodeMaterialConnectionPoint;
  93812. /**
  93813. * Gets the r output component
  93814. */
  93815. get r(): NodeMaterialConnectionPoint;
  93816. /**
  93817. * Gets the g output component
  93818. */
  93819. get g(): NodeMaterialConnectionPoint;
  93820. /**
  93821. * Gets the b output component
  93822. */
  93823. get b(): NodeMaterialConnectionPoint;
  93824. /**
  93825. * Gets the a output component
  93826. */
  93827. get a(): NodeMaterialConnectionPoint;
  93828. get target(): NodeMaterialBlockTargets;
  93829. autoConfigure(material: NodeMaterial): void;
  93830. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  93831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93832. isReady(): boolean;
  93833. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93834. private get _isMixed();
  93835. private _injectVertexCode;
  93836. private _writeTextureRead;
  93837. private _writeOutput;
  93838. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  93839. protected _dumpPropertiesCode(): string;
  93840. serialize(): any;
  93841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93842. }
  93843. }
  93844. declare module BABYLON {
  93845. /** @hidden */
  93846. export var reflectionFunction: {
  93847. name: string;
  93848. shader: string;
  93849. };
  93850. }
  93851. declare module BABYLON {
  93852. /**
  93853. * Base block used to read a reflection texture from a sampler
  93854. */
  93855. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  93856. /** @hidden */
  93857. _define3DName: string;
  93858. /** @hidden */
  93859. _defineCubicName: string;
  93860. /** @hidden */
  93861. _defineExplicitName: string;
  93862. /** @hidden */
  93863. _defineProjectionName: string;
  93864. /** @hidden */
  93865. _defineLocalCubicName: string;
  93866. /** @hidden */
  93867. _defineSphericalName: string;
  93868. /** @hidden */
  93869. _definePlanarName: string;
  93870. /** @hidden */
  93871. _defineEquirectangularName: string;
  93872. /** @hidden */
  93873. _defineMirroredEquirectangularFixedName: string;
  93874. /** @hidden */
  93875. _defineEquirectangularFixedName: string;
  93876. /** @hidden */
  93877. _defineSkyboxName: string;
  93878. /** @hidden */
  93879. _defineOppositeZ: string;
  93880. /** @hidden */
  93881. _cubeSamplerName: string;
  93882. /** @hidden */
  93883. _2DSamplerName: string;
  93884. protected _positionUVWName: string;
  93885. protected _directionWName: string;
  93886. protected _reflectionVectorName: string;
  93887. /** @hidden */
  93888. _reflectionCoordsName: string;
  93889. /** @hidden */
  93890. _reflectionMatrixName: string;
  93891. protected _reflectionColorName: string;
  93892. /**
  93893. * Gets or sets the texture associated with the node
  93894. */
  93895. texture: Nullable<BaseTexture>;
  93896. /**
  93897. * Create a new ReflectionTextureBaseBlock
  93898. * @param name defines the block name
  93899. */
  93900. constructor(name: string);
  93901. /**
  93902. * Gets the current class name
  93903. * @returns the class name
  93904. */
  93905. getClassName(): string;
  93906. /**
  93907. * Gets the world position input component
  93908. */
  93909. abstract get position(): NodeMaterialConnectionPoint;
  93910. /**
  93911. * Gets the world position input component
  93912. */
  93913. abstract get worldPosition(): NodeMaterialConnectionPoint;
  93914. /**
  93915. * Gets the world normal input component
  93916. */
  93917. abstract get worldNormal(): NodeMaterialConnectionPoint;
  93918. /**
  93919. * Gets the world input component
  93920. */
  93921. abstract get world(): NodeMaterialConnectionPoint;
  93922. /**
  93923. * Gets the camera (or eye) position component
  93924. */
  93925. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  93926. /**
  93927. * Gets the view input component
  93928. */
  93929. abstract get view(): NodeMaterialConnectionPoint;
  93930. protected _getTexture(): Nullable<BaseTexture>;
  93931. autoConfigure(material: NodeMaterial): void;
  93932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  93933. isReady(): boolean;
  93934. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  93935. /**
  93936. * Gets the code to inject in the vertex shader
  93937. * @param state current state of the node material building
  93938. * @returns the shader code
  93939. */
  93940. handleVertexSide(state: NodeMaterialBuildState): string;
  93941. /**
  93942. * Handles the inits for the fragment code path
  93943. * @param state node material build state
  93944. */
  93945. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  93946. /**
  93947. * Generates the reflection coords code for the fragment code path
  93948. * @param worldNormalVarName name of the world normal variable
  93949. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  93950. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  93951. * @returns the shader code
  93952. */
  93953. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  93954. /**
  93955. * Generates the reflection color code for the fragment code path
  93956. * @param lodVarName name of the lod variable
  93957. * @param swizzleLookupTexture swizzle to use for the final color variable
  93958. * @returns the shader code
  93959. */
  93960. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  93961. /**
  93962. * Generates the code corresponding to the connected output points
  93963. * @param state node material build state
  93964. * @param varName name of the variable to output
  93965. * @returns the shader code
  93966. */
  93967. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  93968. protected _buildBlock(state: NodeMaterialBuildState): this;
  93969. protected _dumpPropertiesCode(): string;
  93970. serialize(): any;
  93971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  93972. }
  93973. }
  93974. declare module BABYLON {
  93975. /**
  93976. * Defines a connection point to be used for points with a custom object type
  93977. */
  93978. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  93979. private _blockType;
  93980. private _blockName;
  93981. private _nameForCheking?;
  93982. /**
  93983. * Creates a new connection point
  93984. * @param name defines the connection point name
  93985. * @param ownerBlock defines the block hosting this connection point
  93986. * @param direction defines the direction of the connection point
  93987. */
  93988. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  93989. /**
  93990. * Gets a number indicating if the current point can be connected to another point
  93991. * @param connectionPoint defines the other connection point
  93992. * @returns a number defining the compatibility state
  93993. */
  93994. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  93995. /**
  93996. * Creates a block suitable to be used as an input for this input point.
  93997. * If null is returned, a block based on the point type will be created.
  93998. * @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
  93999. */
  94000. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  94001. }
  94002. }
  94003. declare module BABYLON {
  94004. /**
  94005. * Enum defining the type of properties that can be edited in the property pages in the NME
  94006. */
  94007. export enum PropertyTypeForEdition {
  94008. /** property is a boolean */
  94009. Boolean = 0,
  94010. /** property is a float */
  94011. Float = 1,
  94012. /** property is a Vector2 */
  94013. Vector2 = 2,
  94014. /** property is a list of values */
  94015. List = 3
  94016. }
  94017. /**
  94018. * Interface that defines an option in a variable of type list
  94019. */
  94020. export interface IEditablePropertyListOption {
  94021. /** label of the option */
  94022. "label": string;
  94023. /** value of the option */
  94024. "value": number;
  94025. }
  94026. /**
  94027. * Interface that defines the options available for an editable property
  94028. */
  94029. export interface IEditablePropertyOption {
  94030. /** min value */
  94031. "min"?: number;
  94032. /** max value */
  94033. "max"?: number;
  94034. /** notifiers: indicates which actions to take when the property is changed */
  94035. "notifiers"?: {
  94036. /** the material should be rebuilt */
  94037. "rebuild"?: boolean;
  94038. /** the preview should be updated */
  94039. "update"?: boolean;
  94040. };
  94041. /** list of the options for a variable of type list */
  94042. "options"?: IEditablePropertyListOption[];
  94043. }
  94044. /**
  94045. * Interface that describes an editable property
  94046. */
  94047. export interface IPropertyDescriptionForEdition {
  94048. /** name of the property */
  94049. "propertyName": string;
  94050. /** display name of the property */
  94051. "displayName": string;
  94052. /** type of the property */
  94053. "type": PropertyTypeForEdition;
  94054. /** group of the property - all properties with the same group value will be displayed in a specific section */
  94055. "groupName": string;
  94056. /** options for the property */
  94057. "options": IEditablePropertyOption;
  94058. }
  94059. /**
  94060. * Decorator that flags a property in a node material block as being editable
  94061. */
  94062. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  94063. }
  94064. declare module BABYLON {
  94065. /**
  94066. * Block used to implement the refraction part of the sub surface module of the PBR material
  94067. */
  94068. export class RefractionBlock extends NodeMaterialBlock {
  94069. /** @hidden */
  94070. _define3DName: string;
  94071. /** @hidden */
  94072. _refractionMatrixName: string;
  94073. /** @hidden */
  94074. _defineLODRefractionAlpha: string;
  94075. /** @hidden */
  94076. _defineLinearSpecularRefraction: string;
  94077. /** @hidden */
  94078. _defineOppositeZ: string;
  94079. /** @hidden */
  94080. _cubeSamplerName: string;
  94081. /** @hidden */
  94082. _2DSamplerName: string;
  94083. /** @hidden */
  94084. _vRefractionMicrosurfaceInfosName: string;
  94085. /** @hidden */
  94086. _vRefractionInfosName: string;
  94087. /** @hidden */
  94088. _vRefractionFilteringInfoName: string;
  94089. private _scene;
  94090. /**
  94091. * The properties below are set by the main PBR block prior to calling methods of this class.
  94092. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  94093. * It's less burden on the user side in the editor part.
  94094. */
  94095. /** @hidden */
  94096. viewConnectionPoint: NodeMaterialConnectionPoint;
  94097. /** @hidden */
  94098. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  94099. /**
  94100. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  94101. * Materials half opaque for instance using refraction could benefit from this control.
  94102. */
  94103. linkRefractionWithTransparency: boolean;
  94104. /**
  94105. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  94106. */
  94107. invertRefractionY: boolean;
  94108. /**
  94109. * Gets or sets the texture associated with the node
  94110. */
  94111. texture: Nullable<BaseTexture>;
  94112. /**
  94113. * Create a new RefractionBlock
  94114. * @param name defines the block name
  94115. */
  94116. constructor(name: string);
  94117. /**
  94118. * Gets the current class name
  94119. * @returns the class name
  94120. */
  94121. getClassName(): string;
  94122. /**
  94123. * Gets the intensity input component
  94124. */
  94125. get intensity(): NodeMaterialConnectionPoint;
  94126. /**
  94127. * Gets the tint at distance input component
  94128. */
  94129. get tintAtDistance(): NodeMaterialConnectionPoint;
  94130. /**
  94131. * Gets the view input component
  94132. */
  94133. get view(): NodeMaterialConnectionPoint;
  94134. /**
  94135. * Gets the refraction object output component
  94136. */
  94137. get refraction(): NodeMaterialConnectionPoint;
  94138. /**
  94139. * Returns true if the block has a texture
  94140. */
  94141. get hasTexture(): boolean;
  94142. protected _getTexture(): Nullable<BaseTexture>;
  94143. autoConfigure(material: NodeMaterial): void;
  94144. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94145. isReady(): boolean;
  94146. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94147. /**
  94148. * Gets the main code of the block (fragment side)
  94149. * @param state current state of the node material building
  94150. * @returns the shader code
  94151. */
  94152. getCode(state: NodeMaterialBuildState): string;
  94153. protected _buildBlock(state: NodeMaterialBuildState): this;
  94154. protected _dumpPropertiesCode(): string;
  94155. serialize(): any;
  94156. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94157. }
  94158. }
  94159. declare module BABYLON {
  94160. /**
  94161. * Base block used as input for post process
  94162. */
  94163. export class CurrentScreenBlock extends NodeMaterialBlock {
  94164. private _samplerName;
  94165. private _linearDefineName;
  94166. private _gammaDefineName;
  94167. private _mainUVName;
  94168. private _tempTextureRead;
  94169. /**
  94170. * Gets or sets the texture associated with the node
  94171. */
  94172. texture: Nullable<BaseTexture>;
  94173. /**
  94174. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94175. */
  94176. convertToGammaSpace: boolean;
  94177. /**
  94178. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94179. */
  94180. convertToLinearSpace: boolean;
  94181. /**
  94182. * Create a new CurrentScreenBlock
  94183. * @param name defines the block name
  94184. */
  94185. constructor(name: string);
  94186. /**
  94187. * Gets the current class name
  94188. * @returns the class name
  94189. */
  94190. getClassName(): string;
  94191. /**
  94192. * Gets the uv input component
  94193. */
  94194. get uv(): NodeMaterialConnectionPoint;
  94195. /**
  94196. * Gets the rgba output component
  94197. */
  94198. get rgba(): NodeMaterialConnectionPoint;
  94199. /**
  94200. * Gets the rgb output component
  94201. */
  94202. get rgb(): NodeMaterialConnectionPoint;
  94203. /**
  94204. * Gets the r output component
  94205. */
  94206. get r(): NodeMaterialConnectionPoint;
  94207. /**
  94208. * Gets the g output component
  94209. */
  94210. get g(): NodeMaterialConnectionPoint;
  94211. /**
  94212. * Gets the b output component
  94213. */
  94214. get b(): NodeMaterialConnectionPoint;
  94215. /**
  94216. * Gets the a output component
  94217. */
  94218. get a(): NodeMaterialConnectionPoint;
  94219. /**
  94220. * Initialize the block and prepare the context for build
  94221. * @param state defines the state that will be used for the build
  94222. */
  94223. initialize(state: NodeMaterialBuildState): void;
  94224. get target(): NodeMaterialBlockTargets;
  94225. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94226. isReady(): boolean;
  94227. private _injectVertexCode;
  94228. private _writeTextureRead;
  94229. private _writeOutput;
  94230. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94231. serialize(): any;
  94232. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94233. }
  94234. }
  94235. declare module BABYLON {
  94236. /**
  94237. * Base block used for the particle texture
  94238. */
  94239. export class ParticleTextureBlock extends NodeMaterialBlock {
  94240. private _samplerName;
  94241. private _linearDefineName;
  94242. private _gammaDefineName;
  94243. private _tempTextureRead;
  94244. /**
  94245. * Gets or sets the texture associated with the node
  94246. */
  94247. texture: Nullable<BaseTexture>;
  94248. /**
  94249. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  94250. */
  94251. convertToGammaSpace: boolean;
  94252. /**
  94253. * Gets or sets a boolean indicating if content needs to be converted to linear space
  94254. */
  94255. convertToLinearSpace: boolean;
  94256. /**
  94257. * Create a new ParticleTextureBlock
  94258. * @param name defines the block name
  94259. */
  94260. constructor(name: string);
  94261. /**
  94262. * Gets the current class name
  94263. * @returns the class name
  94264. */
  94265. getClassName(): string;
  94266. /**
  94267. * Gets the uv input component
  94268. */
  94269. get uv(): NodeMaterialConnectionPoint;
  94270. /**
  94271. * Gets the rgba output component
  94272. */
  94273. get rgba(): NodeMaterialConnectionPoint;
  94274. /**
  94275. * Gets the rgb output component
  94276. */
  94277. get rgb(): NodeMaterialConnectionPoint;
  94278. /**
  94279. * Gets the r output component
  94280. */
  94281. get r(): NodeMaterialConnectionPoint;
  94282. /**
  94283. * Gets the g output component
  94284. */
  94285. get g(): NodeMaterialConnectionPoint;
  94286. /**
  94287. * Gets the b output component
  94288. */
  94289. get b(): NodeMaterialConnectionPoint;
  94290. /**
  94291. * Gets the a output component
  94292. */
  94293. get a(): NodeMaterialConnectionPoint;
  94294. /**
  94295. * Initialize the block and prepare the context for build
  94296. * @param state defines the state that will be used for the build
  94297. */
  94298. initialize(state: NodeMaterialBuildState): void;
  94299. autoConfigure(material: NodeMaterial): void;
  94300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  94301. isReady(): boolean;
  94302. private _writeOutput;
  94303. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  94304. serialize(): any;
  94305. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94306. }
  94307. }
  94308. declare module BABYLON {
  94309. /**
  94310. * Class used to store shared data between 2 NodeMaterialBuildState
  94311. */
  94312. export class NodeMaterialBuildStateSharedData {
  94313. /**
  94314. * Gets the list of emitted varyings
  94315. */
  94316. temps: string[];
  94317. /**
  94318. * Gets the list of emitted varyings
  94319. */
  94320. varyings: string[];
  94321. /**
  94322. * Gets the varying declaration string
  94323. */
  94324. varyingDeclaration: string;
  94325. /**
  94326. * Input blocks
  94327. */
  94328. inputBlocks: InputBlock[];
  94329. /**
  94330. * Input blocks
  94331. */
  94332. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  94333. /**
  94334. * Bindable blocks (Blocks that need to set data to the effect)
  94335. */
  94336. bindableBlocks: NodeMaterialBlock[];
  94337. /**
  94338. * List of blocks that can provide a compilation fallback
  94339. */
  94340. blocksWithFallbacks: NodeMaterialBlock[];
  94341. /**
  94342. * List of blocks that can provide a define update
  94343. */
  94344. blocksWithDefines: NodeMaterialBlock[];
  94345. /**
  94346. * List of blocks that can provide a repeatable content
  94347. */
  94348. repeatableContentBlocks: NodeMaterialBlock[];
  94349. /**
  94350. * List of blocks that can provide a dynamic list of uniforms
  94351. */
  94352. dynamicUniformBlocks: NodeMaterialBlock[];
  94353. /**
  94354. * List of blocks that can block the isReady function for the material
  94355. */
  94356. blockingBlocks: NodeMaterialBlock[];
  94357. /**
  94358. * Gets the list of animated inputs
  94359. */
  94360. animatedInputs: InputBlock[];
  94361. /**
  94362. * Build Id used to avoid multiple recompilations
  94363. */
  94364. buildId: number;
  94365. /** List of emitted variables */
  94366. variableNames: {
  94367. [key: string]: number;
  94368. };
  94369. /** List of emitted defines */
  94370. defineNames: {
  94371. [key: string]: number;
  94372. };
  94373. /** Should emit comments? */
  94374. emitComments: boolean;
  94375. /** Emit build activity */
  94376. verbose: boolean;
  94377. /** Gets or sets the hosting scene */
  94378. scene: Scene;
  94379. /**
  94380. * Gets the compilation hints emitted at compilation time
  94381. */
  94382. hints: {
  94383. needWorldViewMatrix: boolean;
  94384. needWorldViewProjectionMatrix: boolean;
  94385. needAlphaBlending: boolean;
  94386. needAlphaTesting: boolean;
  94387. };
  94388. /**
  94389. * List of compilation checks
  94390. */
  94391. checks: {
  94392. emitVertex: boolean;
  94393. emitFragment: boolean;
  94394. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  94395. };
  94396. /**
  94397. * Is vertex program allowed to be empty?
  94398. */
  94399. allowEmptyVertexProgram: boolean;
  94400. /** Creates a new shared data */
  94401. constructor();
  94402. /**
  94403. * Emits console errors and exceptions if there is a failing check
  94404. */
  94405. emitErrors(): void;
  94406. }
  94407. }
  94408. declare module BABYLON {
  94409. /**
  94410. * Class used to store node based material build state
  94411. */
  94412. export class NodeMaterialBuildState {
  94413. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  94414. supportUniformBuffers: boolean;
  94415. /**
  94416. * Gets the list of emitted attributes
  94417. */
  94418. attributes: string[];
  94419. /**
  94420. * Gets the list of emitted uniforms
  94421. */
  94422. uniforms: string[];
  94423. /**
  94424. * Gets the list of emitted constants
  94425. */
  94426. constants: string[];
  94427. /**
  94428. * Gets the list of emitted samplers
  94429. */
  94430. samplers: string[];
  94431. /**
  94432. * Gets the list of emitted functions
  94433. */
  94434. functions: {
  94435. [key: string]: string;
  94436. };
  94437. /**
  94438. * Gets the list of emitted extensions
  94439. */
  94440. extensions: {
  94441. [key: string]: string;
  94442. };
  94443. /**
  94444. * Gets the target of the compilation state
  94445. */
  94446. target: NodeMaterialBlockTargets;
  94447. /**
  94448. * Gets the list of emitted counters
  94449. */
  94450. counters: {
  94451. [key: string]: number;
  94452. };
  94453. /**
  94454. * Shared data between multiple NodeMaterialBuildState instances
  94455. */
  94456. sharedData: NodeMaterialBuildStateSharedData;
  94457. /** @hidden */
  94458. _vertexState: NodeMaterialBuildState;
  94459. /** @hidden */
  94460. _attributeDeclaration: string;
  94461. /** @hidden */
  94462. _uniformDeclaration: string;
  94463. /** @hidden */
  94464. _constantDeclaration: string;
  94465. /** @hidden */
  94466. _samplerDeclaration: string;
  94467. /** @hidden */
  94468. _varyingTransfer: string;
  94469. /** @hidden */
  94470. _injectAtEnd: string;
  94471. private _repeatableContentAnchorIndex;
  94472. /** @hidden */
  94473. _builtCompilationString: string;
  94474. /**
  94475. * Gets the emitted compilation strings
  94476. */
  94477. compilationString: string;
  94478. /**
  94479. * Finalize the compilation strings
  94480. * @param state defines the current compilation state
  94481. */
  94482. finalize(state: NodeMaterialBuildState): void;
  94483. /** @hidden */
  94484. get _repeatableContentAnchor(): string;
  94485. /** @hidden */
  94486. _getFreeVariableName(prefix: string): string;
  94487. /** @hidden */
  94488. _getFreeDefineName(prefix: string): string;
  94489. /** @hidden */
  94490. _excludeVariableName(name: string): void;
  94491. /** @hidden */
  94492. _emit2DSampler(name: string): void;
  94493. /** @hidden */
  94494. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  94495. /** @hidden */
  94496. _emitExtension(name: string, extension: string, define?: string): void;
  94497. /** @hidden */
  94498. _emitFunction(name: string, code: string, comments: string): void;
  94499. /** @hidden */
  94500. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  94501. replaceStrings?: {
  94502. search: RegExp;
  94503. replace: string;
  94504. }[];
  94505. repeatKey?: string;
  94506. }): string;
  94507. /** @hidden */
  94508. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  94509. repeatKey?: string;
  94510. removeAttributes?: boolean;
  94511. removeUniforms?: boolean;
  94512. removeVaryings?: boolean;
  94513. removeIfDef?: boolean;
  94514. replaceStrings?: {
  94515. search: RegExp;
  94516. replace: string;
  94517. }[];
  94518. }, storeKey?: string): void;
  94519. /** @hidden */
  94520. _registerTempVariable(name: string): boolean;
  94521. /** @hidden */
  94522. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  94523. /** @hidden */
  94524. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  94525. /** @hidden */
  94526. _emitFloat(value: number): string;
  94527. }
  94528. }
  94529. declare module BABYLON {
  94530. /**
  94531. * Helper class used to generate session unique ID
  94532. */
  94533. export class UniqueIdGenerator {
  94534. private static _UniqueIdCounter;
  94535. /**
  94536. * Gets an unique (relatively to the current scene) Id
  94537. */
  94538. static get UniqueId(): number;
  94539. }
  94540. }
  94541. declare module BABYLON {
  94542. /**
  94543. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94544. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94545. */
  94546. export class EffectFallbacks implements IEffectFallbacks {
  94547. private _defines;
  94548. private _currentRank;
  94549. private _maxRank;
  94550. private _mesh;
  94551. /**
  94552. * Removes the fallback from the bound mesh.
  94553. */
  94554. unBindMesh(): void;
  94555. /**
  94556. * Adds a fallback on the specified property.
  94557. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94558. * @param define The name of the define in the shader
  94559. */
  94560. addFallback(rank: number, define: string): void;
  94561. /**
  94562. * Sets the mesh to use CPU skinning when needing to fallback.
  94563. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94564. * @param mesh The mesh to use the fallbacks.
  94565. */
  94566. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94567. /**
  94568. * Checks to see if more fallbacks are still availible.
  94569. */
  94570. get hasMoreFallbacks(): boolean;
  94571. /**
  94572. * Removes the defines that should be removed when falling back.
  94573. * @param currentDefines defines the current define statements for the shader.
  94574. * @param effect defines the current effect we try to compile
  94575. * @returns The resulting defines with defines of the current rank removed.
  94576. */
  94577. reduce(currentDefines: string, effect: Effect): string;
  94578. }
  94579. }
  94580. declare module BABYLON {
  94581. /**
  94582. * Defines a block that can be used inside a node based material
  94583. */
  94584. export class NodeMaterialBlock {
  94585. private _buildId;
  94586. private _buildTarget;
  94587. private _target;
  94588. private _isFinalMerger;
  94589. private _isInput;
  94590. private _name;
  94591. protected _isUnique: boolean;
  94592. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  94593. inputsAreExclusive: boolean;
  94594. /** @hidden */
  94595. _codeVariableName: string;
  94596. /** @hidden */
  94597. _inputs: NodeMaterialConnectionPoint[];
  94598. /** @hidden */
  94599. _outputs: NodeMaterialConnectionPoint[];
  94600. /** @hidden */
  94601. _preparationId: number;
  94602. /**
  94603. * Gets the name of the block
  94604. */
  94605. get name(): string;
  94606. /**
  94607. * Sets the name of the block. Will check if the name is valid.
  94608. */
  94609. set name(newName: string);
  94610. /**
  94611. * Gets or sets the unique id of the node
  94612. */
  94613. uniqueId: number;
  94614. /**
  94615. * Gets or sets the comments associated with this block
  94616. */
  94617. comments: string;
  94618. /**
  94619. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  94620. */
  94621. get isUnique(): boolean;
  94622. /**
  94623. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  94624. */
  94625. get isFinalMerger(): boolean;
  94626. /**
  94627. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  94628. */
  94629. get isInput(): boolean;
  94630. /**
  94631. * Gets or sets the build Id
  94632. */
  94633. get buildId(): number;
  94634. set buildId(value: number);
  94635. /**
  94636. * Gets or sets the target of the block
  94637. */
  94638. get target(): NodeMaterialBlockTargets;
  94639. set target(value: NodeMaterialBlockTargets);
  94640. /**
  94641. * Gets the list of input points
  94642. */
  94643. get inputs(): NodeMaterialConnectionPoint[];
  94644. /** Gets the list of output points */
  94645. get outputs(): NodeMaterialConnectionPoint[];
  94646. /**
  94647. * Find an input by its name
  94648. * @param name defines the name of the input to look for
  94649. * @returns the input or null if not found
  94650. */
  94651. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94652. /**
  94653. * Find an output by its name
  94654. * @param name defines the name of the outputto look for
  94655. * @returns the output or null if not found
  94656. */
  94657. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  94658. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  94659. visibleInInspector: boolean;
  94660. /**
  94661. * Creates a new NodeMaterialBlock
  94662. * @param name defines the block name
  94663. * @param target defines the target of that block (Vertex by default)
  94664. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  94665. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  94666. */
  94667. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  94668. /**
  94669. * Initialize the block and prepare the context for build
  94670. * @param state defines the state that will be used for the build
  94671. */
  94672. initialize(state: NodeMaterialBuildState): void;
  94673. /**
  94674. * Bind data to effect. Will only be called for blocks with isBindable === true
  94675. * @param effect defines the effect to bind data to
  94676. * @param nodeMaterial defines the hosting NodeMaterial
  94677. * @param mesh defines the mesh that will be rendered
  94678. * @param subMesh defines the submesh that will be rendered
  94679. */
  94680. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  94681. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  94682. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  94683. protected _writeFloat(value: number): string;
  94684. /**
  94685. * Gets the current class name e.g. "NodeMaterialBlock"
  94686. * @returns the class name
  94687. */
  94688. getClassName(): string;
  94689. /**
  94690. * Register a new input. Must be called inside a block constructor
  94691. * @param name defines the connection point name
  94692. * @param type defines the connection point type
  94693. * @param isOptional defines a boolean indicating that this input can be omitted
  94694. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94695. * @param point an already created connection point. If not provided, create a new one
  94696. * @returns the current block
  94697. */
  94698. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94699. /**
  94700. * Register a new output. Must be called inside a block constructor
  94701. * @param name defines the connection point name
  94702. * @param type defines the connection point type
  94703. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  94704. * @param point an already created connection point. If not provided, create a new one
  94705. * @returns the current block
  94706. */
  94707. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  94708. /**
  94709. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  94710. * @param forOutput defines an optional connection point to check compatibility with
  94711. * @returns the first available input or null
  94712. */
  94713. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  94714. /**
  94715. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  94716. * @param forBlock defines an optional block to check compatibility with
  94717. * @returns the first available input or null
  94718. */
  94719. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  94720. /**
  94721. * Gets the sibling of the given output
  94722. * @param current defines the current output
  94723. * @returns the next output in the list or null
  94724. */
  94725. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  94726. /**
  94727. * Connect current block with another block
  94728. * @param other defines the block to connect with
  94729. * @param options define the various options to help pick the right connections
  94730. * @returns the current block
  94731. */
  94732. connectTo(other: NodeMaterialBlock, options?: {
  94733. input?: string;
  94734. output?: string;
  94735. outputSwizzle?: string;
  94736. }): this | undefined;
  94737. protected _buildBlock(state: NodeMaterialBuildState): void;
  94738. /**
  94739. * Add uniforms, samplers and uniform buffers at compilation time
  94740. * @param state defines the state to update
  94741. * @param nodeMaterial defines the node material requesting the update
  94742. * @param defines defines the material defines to update
  94743. * @param uniformBuffers defines the list of uniform buffer names
  94744. */
  94745. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  94746. /**
  94747. * Add potential fallbacks if shader compilation fails
  94748. * @param mesh defines the mesh to be rendered
  94749. * @param fallbacks defines the current prioritized list of fallbacks
  94750. */
  94751. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  94752. /**
  94753. * Initialize defines for shader compilation
  94754. * @param mesh defines the mesh to be rendered
  94755. * @param nodeMaterial defines the node material requesting the update
  94756. * @param defines defines the material defines to update
  94757. * @param useInstances specifies that instances should be used
  94758. */
  94759. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  94760. /**
  94761. * Update defines for shader compilation
  94762. * @param mesh defines the mesh to be rendered
  94763. * @param nodeMaterial defines the node material requesting the update
  94764. * @param defines defines the material defines to update
  94765. * @param useInstances specifies that instances should be used
  94766. * @param subMesh defines which submesh to render
  94767. */
  94768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94769. /**
  94770. * Lets the block try to connect some inputs automatically
  94771. * @param material defines the hosting NodeMaterial
  94772. */
  94773. autoConfigure(material: NodeMaterial): void;
  94774. /**
  94775. * Function called when a block is declared as repeatable content generator
  94776. * @param vertexShaderState defines the current compilation state for the vertex shader
  94777. * @param fragmentShaderState defines the current compilation state for the fragment shader
  94778. * @param mesh defines the mesh to be rendered
  94779. * @param defines defines the material defines to update
  94780. */
  94781. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  94782. /**
  94783. * Checks if the block is ready
  94784. * @param mesh defines the mesh to be rendered
  94785. * @param nodeMaterial defines the node material requesting the update
  94786. * @param defines defines the material defines to update
  94787. * @param useInstances specifies that instances should be used
  94788. * @returns true if the block is ready
  94789. */
  94790. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  94791. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  94792. private _processBuild;
  94793. /**
  94794. * Validates the new name for the block node.
  94795. * @param newName the new name to be given to the node.
  94796. * @returns false if the name is a reserve word, else true.
  94797. */
  94798. validateBlockName(newName: string): boolean;
  94799. /**
  94800. * Compile the current node and generate the shader code
  94801. * @param state defines the current compilation state (uniforms, samplers, current string)
  94802. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  94803. * @returns true if already built
  94804. */
  94805. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  94806. protected _inputRename(name: string): string;
  94807. protected _outputRename(name: string): string;
  94808. protected _dumpPropertiesCode(): string;
  94809. /** @hidden */
  94810. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  94811. /** @hidden */
  94812. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  94813. /**
  94814. * Clone the current block to a new identical block
  94815. * @param scene defines the hosting scene
  94816. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94817. * @returns a copy of the current block
  94818. */
  94819. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  94820. /**
  94821. * Serializes this block in a JSON representation
  94822. * @returns the serialized block object
  94823. */
  94824. serialize(): any;
  94825. /** @hidden */
  94826. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94827. private _deserializePortDisplayNamesAndExposedOnFrame;
  94828. /**
  94829. * Release resources
  94830. */
  94831. dispose(): void;
  94832. }
  94833. }
  94834. declare module BABYLON {
  94835. /**
  94836. * Base class of materials working in push mode in babylon JS
  94837. * @hidden
  94838. */
  94839. export class PushMaterial extends Material {
  94840. protected _activeEffect: Effect;
  94841. protected _normalMatrix: Matrix;
  94842. constructor(name: string, scene: Scene);
  94843. getEffect(): Effect;
  94844. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94845. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  94846. /**
  94847. * Binds the given world matrix to the active effect
  94848. *
  94849. * @param world the matrix to bind
  94850. */
  94851. bindOnlyWorldMatrix(world: Matrix): void;
  94852. /**
  94853. * Binds the given normal matrix to the active effect
  94854. *
  94855. * @param normalMatrix the matrix to bind
  94856. */
  94857. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  94858. bind(world: Matrix, mesh?: Mesh): void;
  94859. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  94860. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  94861. }
  94862. }
  94863. declare module BABYLON {
  94864. /**
  94865. * Root class for all node material optimizers
  94866. */
  94867. export class NodeMaterialOptimizer {
  94868. /**
  94869. * Function used to optimize a NodeMaterial graph
  94870. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  94871. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  94872. */
  94873. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  94874. }
  94875. }
  94876. declare module BABYLON {
  94877. /**
  94878. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  94879. */
  94880. export class TransformBlock extends NodeMaterialBlock {
  94881. /**
  94882. * Defines the value to use to complement W value to transform it to a Vector4
  94883. */
  94884. complementW: number;
  94885. /**
  94886. * Defines the value to use to complement z value to transform it to a Vector4
  94887. */
  94888. complementZ: number;
  94889. /**
  94890. * Creates a new TransformBlock
  94891. * @param name defines the block name
  94892. */
  94893. constructor(name: string);
  94894. /**
  94895. * Gets the current class name
  94896. * @returns the class name
  94897. */
  94898. getClassName(): string;
  94899. /**
  94900. * Gets the vector input
  94901. */
  94902. get vector(): NodeMaterialConnectionPoint;
  94903. /**
  94904. * Gets the output component
  94905. */
  94906. get output(): NodeMaterialConnectionPoint;
  94907. /**
  94908. * Gets the xyz output component
  94909. */
  94910. get xyz(): NodeMaterialConnectionPoint;
  94911. /**
  94912. * Gets the matrix transform input
  94913. */
  94914. get transform(): NodeMaterialConnectionPoint;
  94915. protected _buildBlock(state: NodeMaterialBuildState): this;
  94916. /**
  94917. * Update defines for shader compilation
  94918. * @param mesh defines the mesh to be rendered
  94919. * @param nodeMaterial defines the node material requesting the update
  94920. * @param defines defines the material defines to update
  94921. * @param useInstances specifies that instances should be used
  94922. * @param subMesh defines which submesh to render
  94923. */
  94924. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  94925. serialize(): any;
  94926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  94927. protected _dumpPropertiesCode(): string;
  94928. }
  94929. }
  94930. declare module BABYLON {
  94931. /**
  94932. * Block used to output the vertex position
  94933. */
  94934. export class VertexOutputBlock extends NodeMaterialBlock {
  94935. /**
  94936. * Creates a new VertexOutputBlock
  94937. * @param name defines the block name
  94938. */
  94939. constructor(name: string);
  94940. /**
  94941. * Gets the current class name
  94942. * @returns the class name
  94943. */
  94944. getClassName(): string;
  94945. /**
  94946. * Gets the vector input component
  94947. */
  94948. get vector(): NodeMaterialConnectionPoint;
  94949. protected _buildBlock(state: NodeMaterialBuildState): this;
  94950. }
  94951. }
  94952. declare module BABYLON {
  94953. /**
  94954. * Block used to output the final color
  94955. */
  94956. export class FragmentOutputBlock extends NodeMaterialBlock {
  94957. /**
  94958. * Create a new FragmentOutputBlock
  94959. * @param name defines the block name
  94960. */
  94961. constructor(name: string);
  94962. /**
  94963. * Gets the current class name
  94964. * @returns the class name
  94965. */
  94966. getClassName(): string;
  94967. /**
  94968. * Gets the rgba input component
  94969. */
  94970. get rgba(): NodeMaterialConnectionPoint;
  94971. /**
  94972. * Gets the rgb input component
  94973. */
  94974. get rgb(): NodeMaterialConnectionPoint;
  94975. /**
  94976. * Gets the a input component
  94977. */
  94978. get a(): NodeMaterialConnectionPoint;
  94979. protected _buildBlock(state: NodeMaterialBuildState): this;
  94980. }
  94981. }
  94982. declare module BABYLON {
  94983. /**
  94984. * Block used for the particle ramp gradient section
  94985. */
  94986. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  94987. /**
  94988. * Create a new ParticleRampGradientBlock
  94989. * @param name defines the block name
  94990. */
  94991. constructor(name: string);
  94992. /**
  94993. * Gets the current class name
  94994. * @returns the class name
  94995. */
  94996. getClassName(): string;
  94997. /**
  94998. * Gets the color input component
  94999. */
  95000. get color(): NodeMaterialConnectionPoint;
  95001. /**
  95002. * Gets the rampColor output component
  95003. */
  95004. get rampColor(): NodeMaterialConnectionPoint;
  95005. /**
  95006. * Initialize the block and prepare the context for build
  95007. * @param state defines the state that will be used for the build
  95008. */
  95009. initialize(state: NodeMaterialBuildState): void;
  95010. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  95011. }
  95012. }
  95013. declare module BABYLON {
  95014. /**
  95015. * Block used for the particle blend multiply section
  95016. */
  95017. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  95018. /**
  95019. * Create a new ParticleBlendMultiplyBlock
  95020. * @param name defines the block name
  95021. */
  95022. constructor(name: string);
  95023. /**
  95024. * Gets the current class name
  95025. * @returns the class name
  95026. */
  95027. getClassName(): string;
  95028. /**
  95029. * Gets the color input component
  95030. */
  95031. get color(): NodeMaterialConnectionPoint;
  95032. /**
  95033. * Gets the alphaTexture input component
  95034. */
  95035. get alphaTexture(): NodeMaterialConnectionPoint;
  95036. /**
  95037. * Gets the alphaColor input component
  95038. */
  95039. get alphaColor(): NodeMaterialConnectionPoint;
  95040. /**
  95041. * Gets the blendColor output component
  95042. */
  95043. get blendColor(): NodeMaterialConnectionPoint;
  95044. /**
  95045. * Initialize the block and prepare the context for build
  95046. * @param state defines the state that will be used for the build
  95047. */
  95048. initialize(state: NodeMaterialBuildState): void;
  95049. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  95050. }
  95051. }
  95052. declare module BABYLON {
  95053. /**
  95054. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  95055. */
  95056. export class VectorMergerBlock extends NodeMaterialBlock {
  95057. /**
  95058. * Create a new VectorMergerBlock
  95059. * @param name defines the block name
  95060. */
  95061. constructor(name: string);
  95062. /**
  95063. * Gets the current class name
  95064. * @returns the class name
  95065. */
  95066. getClassName(): string;
  95067. /**
  95068. * Gets the xyz component (input)
  95069. */
  95070. get xyzIn(): NodeMaterialConnectionPoint;
  95071. /**
  95072. * Gets the xy component (input)
  95073. */
  95074. get xyIn(): NodeMaterialConnectionPoint;
  95075. /**
  95076. * Gets the x component (input)
  95077. */
  95078. get x(): NodeMaterialConnectionPoint;
  95079. /**
  95080. * Gets the y component (input)
  95081. */
  95082. get y(): NodeMaterialConnectionPoint;
  95083. /**
  95084. * Gets the z component (input)
  95085. */
  95086. get z(): NodeMaterialConnectionPoint;
  95087. /**
  95088. * Gets the w component (input)
  95089. */
  95090. get w(): NodeMaterialConnectionPoint;
  95091. /**
  95092. * Gets the xyzw component (output)
  95093. */
  95094. get xyzw(): NodeMaterialConnectionPoint;
  95095. /**
  95096. * Gets the xyz component (output)
  95097. */
  95098. get xyzOut(): NodeMaterialConnectionPoint;
  95099. /**
  95100. * Gets the xy component (output)
  95101. */
  95102. get xyOut(): NodeMaterialConnectionPoint;
  95103. /**
  95104. * Gets the xy component (output)
  95105. * @deprecated Please use xyOut instead.
  95106. */
  95107. get xy(): NodeMaterialConnectionPoint;
  95108. /**
  95109. * Gets the xyz component (output)
  95110. * @deprecated Please use xyzOut instead.
  95111. */
  95112. get xyz(): NodeMaterialConnectionPoint;
  95113. protected _buildBlock(state: NodeMaterialBuildState): this;
  95114. }
  95115. }
  95116. declare module BABYLON {
  95117. /**
  95118. * Block used to remap a float from a range to a new one
  95119. */
  95120. export class RemapBlock extends NodeMaterialBlock {
  95121. /**
  95122. * Gets or sets the source range
  95123. */
  95124. sourceRange: Vector2;
  95125. /**
  95126. * Gets or sets the target range
  95127. */
  95128. targetRange: Vector2;
  95129. /**
  95130. * Creates a new RemapBlock
  95131. * @param name defines the block name
  95132. */
  95133. constructor(name: string);
  95134. /**
  95135. * Gets the current class name
  95136. * @returns the class name
  95137. */
  95138. getClassName(): string;
  95139. /**
  95140. * Gets the input component
  95141. */
  95142. get input(): NodeMaterialConnectionPoint;
  95143. /**
  95144. * Gets the source min input component
  95145. */
  95146. get sourceMin(): NodeMaterialConnectionPoint;
  95147. /**
  95148. * Gets the source max input component
  95149. */
  95150. get sourceMax(): NodeMaterialConnectionPoint;
  95151. /**
  95152. * Gets the target min input component
  95153. */
  95154. get targetMin(): NodeMaterialConnectionPoint;
  95155. /**
  95156. * Gets the target max input component
  95157. */
  95158. get targetMax(): NodeMaterialConnectionPoint;
  95159. /**
  95160. * Gets the output component
  95161. */
  95162. get output(): NodeMaterialConnectionPoint;
  95163. protected _buildBlock(state: NodeMaterialBuildState): this;
  95164. protected _dumpPropertiesCode(): string;
  95165. serialize(): any;
  95166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  95167. }
  95168. }
  95169. declare module BABYLON {
  95170. /**
  95171. * Block used to multiply 2 values
  95172. */
  95173. export class MultiplyBlock extends NodeMaterialBlock {
  95174. /**
  95175. * Creates a new MultiplyBlock
  95176. * @param name defines the block name
  95177. */
  95178. constructor(name: string);
  95179. /**
  95180. * Gets the current class name
  95181. * @returns the class name
  95182. */
  95183. getClassName(): string;
  95184. /**
  95185. * Gets the left operand input component
  95186. */
  95187. get left(): NodeMaterialConnectionPoint;
  95188. /**
  95189. * Gets the right operand input component
  95190. */
  95191. get right(): NodeMaterialConnectionPoint;
  95192. /**
  95193. * Gets the output component
  95194. */
  95195. get output(): NodeMaterialConnectionPoint;
  95196. protected _buildBlock(state: NodeMaterialBuildState): this;
  95197. }
  95198. }
  95199. declare module BABYLON {
  95200. /** Interface used by value gradients (color, factor, ...) */
  95201. export interface IValueGradient {
  95202. /**
  95203. * Gets or sets the gradient value (between 0 and 1)
  95204. */
  95205. gradient: number;
  95206. }
  95207. /** Class used to store color4 gradient */
  95208. export class ColorGradient implements IValueGradient {
  95209. /**
  95210. * Gets or sets the gradient value (between 0 and 1)
  95211. */
  95212. gradient: number;
  95213. /**
  95214. * Gets or sets first associated color
  95215. */
  95216. color1: Color4;
  95217. /**
  95218. * Gets or sets second associated color
  95219. */
  95220. color2?: Color4 | undefined;
  95221. /**
  95222. * Creates a new color4 gradient
  95223. * @param gradient gets or sets the gradient value (between 0 and 1)
  95224. * @param color1 gets or sets first associated color
  95225. * @param color2 gets or sets first second color
  95226. */
  95227. constructor(
  95228. /**
  95229. * Gets or sets the gradient value (between 0 and 1)
  95230. */
  95231. gradient: number,
  95232. /**
  95233. * Gets or sets first associated color
  95234. */
  95235. color1: Color4,
  95236. /**
  95237. * Gets or sets second associated color
  95238. */
  95239. color2?: Color4 | undefined);
  95240. /**
  95241. * Will get a color picked randomly between color1 and color2.
  95242. * If color2 is undefined then color1 will be used
  95243. * @param result defines the target Color4 to store the result in
  95244. */
  95245. getColorToRef(result: Color4): void;
  95246. }
  95247. /** Class used to store color 3 gradient */
  95248. export class Color3Gradient implements IValueGradient {
  95249. /**
  95250. * Gets or sets the gradient value (between 0 and 1)
  95251. */
  95252. gradient: number;
  95253. /**
  95254. * Gets or sets the associated color
  95255. */
  95256. color: Color3;
  95257. /**
  95258. * Creates a new color3 gradient
  95259. * @param gradient gets or sets the gradient value (between 0 and 1)
  95260. * @param color gets or sets associated color
  95261. */
  95262. constructor(
  95263. /**
  95264. * Gets or sets the gradient value (between 0 and 1)
  95265. */
  95266. gradient: number,
  95267. /**
  95268. * Gets or sets the associated color
  95269. */
  95270. color: Color3);
  95271. }
  95272. /** Class used to store factor gradient */
  95273. export class FactorGradient implements IValueGradient {
  95274. /**
  95275. * Gets or sets the gradient value (between 0 and 1)
  95276. */
  95277. gradient: number;
  95278. /**
  95279. * Gets or sets first associated factor
  95280. */
  95281. factor1: number;
  95282. /**
  95283. * Gets or sets second associated factor
  95284. */
  95285. factor2?: number | undefined;
  95286. /**
  95287. * Creates a new factor gradient
  95288. * @param gradient gets or sets the gradient value (between 0 and 1)
  95289. * @param factor1 gets or sets first associated factor
  95290. * @param factor2 gets or sets second associated factor
  95291. */
  95292. constructor(
  95293. /**
  95294. * Gets or sets the gradient value (between 0 and 1)
  95295. */
  95296. gradient: number,
  95297. /**
  95298. * Gets or sets first associated factor
  95299. */
  95300. factor1: number,
  95301. /**
  95302. * Gets or sets second associated factor
  95303. */
  95304. factor2?: number | undefined);
  95305. /**
  95306. * Will get a number picked randomly between factor1 and factor2.
  95307. * If factor2 is undefined then factor1 will be used
  95308. * @returns the picked number
  95309. */
  95310. getFactor(): number;
  95311. }
  95312. /**
  95313. * Helper used to simplify some generic gradient tasks
  95314. */
  95315. export class GradientHelper {
  95316. /**
  95317. * Gets the current gradient from an array of IValueGradient
  95318. * @param ratio defines the current ratio to get
  95319. * @param gradients defines the array of IValueGradient
  95320. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  95321. */
  95322. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  95323. }
  95324. }
  95325. declare module BABYLON {
  95326. interface ThinEngine {
  95327. /**
  95328. * Creates a raw texture
  95329. * @param data defines the data to store in the texture
  95330. * @param width defines the width of the texture
  95331. * @param height defines the height of the texture
  95332. * @param format defines the format of the data
  95333. * @param generateMipMaps defines if the engine should generate the mip levels
  95334. * @param invertY defines if data must be stored with Y axis inverted
  95335. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  95336. * @param compression defines the compression used (null by default)
  95337. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95338. * @returns the raw texture inside an InternalTexture
  95339. */
  95340. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  95341. /**
  95342. * Update a raw texture
  95343. * @param texture defines the texture to update
  95344. * @param data defines the data to store in the texture
  95345. * @param format defines the format of the data
  95346. * @param invertY defines if data must be stored with Y axis inverted
  95347. */
  95348. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95349. /**
  95350. * Update a raw texture
  95351. * @param texture defines the texture to update
  95352. * @param data defines the data to store in the texture
  95353. * @param format defines the format of the data
  95354. * @param invertY defines if data must be stored with Y axis inverted
  95355. * @param compression defines the compression used (null by default)
  95356. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95357. */
  95358. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  95359. /**
  95360. * Creates a new raw cube texture
  95361. * @param data defines the array of data to use to create each face
  95362. * @param size defines the size of the textures
  95363. * @param format defines the format of the data
  95364. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95365. * @param generateMipMaps defines if the engine should generate the mip levels
  95366. * @param invertY defines if data must be stored with Y axis inverted
  95367. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95368. * @param compression defines the compression used (null by default)
  95369. * @returns the cube texture as an InternalTexture
  95370. */
  95371. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  95372. /**
  95373. * Update a raw cube texture
  95374. * @param texture defines the texture to udpdate
  95375. * @param data defines the data to store
  95376. * @param format defines the data format
  95377. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95378. * @param invertY defines if data must be stored with Y axis inverted
  95379. */
  95380. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  95381. /**
  95382. * Update a raw cube texture
  95383. * @param texture defines the texture to udpdate
  95384. * @param data defines the data to store
  95385. * @param format defines the data format
  95386. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95387. * @param invertY defines if data must be stored with Y axis inverted
  95388. * @param compression defines the compression used (null by default)
  95389. */
  95390. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  95391. /**
  95392. * Update a raw cube texture
  95393. * @param texture defines the texture to udpdate
  95394. * @param data defines the data to store
  95395. * @param format defines the data format
  95396. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  95397. * @param invertY defines if data must be stored with Y axis inverted
  95398. * @param compression defines the compression used (null by default)
  95399. * @param level defines which level of the texture to update
  95400. */
  95401. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  95402. /**
  95403. * Creates a new raw cube texture from a specified url
  95404. * @param url defines the url where the data is located
  95405. * @param scene defines the current scene
  95406. * @param size defines the size of the textures
  95407. * @param format defines the format of the data
  95408. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95409. * @param noMipmap defines if the engine should avoid generating the mip levels
  95410. * @param callback defines a callback used to extract texture data from loaded data
  95411. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95412. * @param onLoad defines a callback called when texture is loaded
  95413. * @param onError defines a callback called if there is an error
  95414. * @returns the cube texture as an InternalTexture
  95415. */
  95416. 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;
  95417. /**
  95418. * Creates a new raw cube texture from a specified url
  95419. * @param url defines the url where the data is located
  95420. * @param scene defines the current scene
  95421. * @param size defines the size of the textures
  95422. * @param format defines the format of the data
  95423. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  95424. * @param noMipmap defines if the engine should avoid generating the mip levels
  95425. * @param callback defines a callback used to extract texture data from loaded data
  95426. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  95427. * @param onLoad defines a callback called when texture is loaded
  95428. * @param onError defines a callback called if there is an error
  95429. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95430. * @param invertY defines if data must be stored with Y axis inverted
  95431. * @returns the cube texture as an InternalTexture
  95432. */
  95433. 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;
  95434. /**
  95435. * Creates a new raw 3D texture
  95436. * @param data defines the data used to create the texture
  95437. * @param width defines the width of the texture
  95438. * @param height defines the height of the texture
  95439. * @param depth defines the depth of the texture
  95440. * @param format defines the format of the texture
  95441. * @param generateMipMaps defines if the engine must generate mip levels
  95442. * @param invertY defines if data must be stored with Y axis inverted
  95443. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95444. * @param compression defines the compressed used (can be null)
  95445. * @param textureType defines the compressed used (can be null)
  95446. * @returns a new raw 3D texture (stored in an InternalTexture)
  95447. */
  95448. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95449. /**
  95450. * Update a raw 3D texture
  95451. * @param texture defines the texture to update
  95452. * @param data defines the data to store
  95453. * @param format defines the data format
  95454. * @param invertY defines if data must be stored with Y axis inverted
  95455. */
  95456. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95457. /**
  95458. * Update a raw 3D texture
  95459. * @param texture defines the texture to update
  95460. * @param data defines the data to store
  95461. * @param format defines the data format
  95462. * @param invertY defines if data must be stored with Y axis inverted
  95463. * @param compression defines the used compression (can be null)
  95464. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95465. */
  95466. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95467. /**
  95468. * Creates a new raw 2D array texture
  95469. * @param data defines the data used to create the texture
  95470. * @param width defines the width of the texture
  95471. * @param height defines the height of the texture
  95472. * @param depth defines the number of layers of the texture
  95473. * @param format defines the format of the texture
  95474. * @param generateMipMaps defines if the engine must generate mip levels
  95475. * @param invertY defines if data must be stored with Y axis inverted
  95476. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  95477. * @param compression defines the compressed used (can be null)
  95478. * @param textureType defines the compressed used (can be null)
  95479. * @returns a new raw 2D array texture (stored in an InternalTexture)
  95480. */
  95481. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  95482. /**
  95483. * Update a raw 2D array texture
  95484. * @param texture defines the texture to update
  95485. * @param data defines the data to store
  95486. * @param format defines the data format
  95487. * @param invertY defines if data must be stored with Y axis inverted
  95488. */
  95489. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  95490. /**
  95491. * Update a raw 2D array texture
  95492. * @param texture defines the texture to update
  95493. * @param data defines the data to store
  95494. * @param format defines the data format
  95495. * @param invertY defines if data must be stored with Y axis inverted
  95496. * @param compression defines the used compression (can be null)
  95497. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  95498. */
  95499. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  95500. }
  95501. }
  95502. declare module BABYLON {
  95503. /**
  95504. * Raw texture can help creating a texture directly from an array of data.
  95505. * This can be super useful if you either get the data from an uncompressed source or
  95506. * if you wish to create your texture pixel by pixel.
  95507. */
  95508. export class RawTexture extends Texture {
  95509. /**
  95510. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95511. */
  95512. format: number;
  95513. /**
  95514. * Instantiates a new RawTexture.
  95515. * Raw texture can help creating a texture directly from an array of data.
  95516. * This can be super useful if you either get the data from an uncompressed source or
  95517. * if you wish to create your texture pixel by pixel.
  95518. * @param data define the array of data to use to create the texture
  95519. * @param width define the width of the texture
  95520. * @param height define the height of the texture
  95521. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95522. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95523. * @param generateMipMaps define whether mip maps should be generated or not
  95524. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95525. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95526. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95527. */
  95528. constructor(data: ArrayBufferView, width: number, height: number,
  95529. /**
  95530. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  95531. */
  95532. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  95533. /**
  95534. * Updates the texture underlying data.
  95535. * @param data Define the new data of the texture
  95536. */
  95537. update(data: ArrayBufferView): void;
  95538. /**
  95539. * Creates a luminance texture from some data.
  95540. * @param data Define the texture data
  95541. * @param width Define the width of the texture
  95542. * @param height Define the height of the texture
  95543. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95544. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95545. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95546. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95547. * @returns the luminance texture
  95548. */
  95549. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95550. /**
  95551. * Creates a luminance alpha texture from some data.
  95552. * @param data Define the texture data
  95553. * @param width Define the width of the texture
  95554. * @param height Define the height of the texture
  95555. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95556. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95557. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95558. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95559. * @returns the luminance alpha texture
  95560. */
  95561. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95562. /**
  95563. * Creates an alpha texture from some data.
  95564. * @param data Define the texture data
  95565. * @param width Define the width of the texture
  95566. * @param height Define the height of the texture
  95567. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95571. * @returns the alpha texture
  95572. */
  95573. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  95574. /**
  95575. * Creates a RGB texture from some data.
  95576. * @param data Define the texture data
  95577. * @param width Define the width of the texture
  95578. * @param height Define the height of the texture
  95579. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95580. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95581. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95582. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95583. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95584. * @returns the RGB alpha texture
  95585. */
  95586. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95587. /**
  95588. * Creates a RGBA texture from some data.
  95589. * @param data Define the texture data
  95590. * @param width Define the width of the texture
  95591. * @param height Define the height of the texture
  95592. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95593. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95594. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95595. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95596. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95597. * @returns the RGBA texture
  95598. */
  95599. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95600. /**
  95601. * Creates a R texture from some data.
  95602. * @param data Define the texture data
  95603. * @param width Define the width of the texture
  95604. * @param height Define the height of the texture
  95605. * @param sceneOrEngine defines the scene or engine the texture will belong to
  95606. * @param generateMipMaps Define whether or not to create mip maps for the texture
  95607. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  95608. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  95609. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  95610. * @returns the R texture
  95611. */
  95612. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  95613. }
  95614. }
  95615. declare module BABYLON {
  95616. interface ThinEngine {
  95617. /**
  95618. * Update a dynamic index buffer
  95619. * @param indexBuffer defines the target index buffer
  95620. * @param indices defines the data to update
  95621. * @param offset defines the offset in the target index buffer where update should start
  95622. */
  95623. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  95624. /**
  95625. * Updates a dynamic vertex buffer.
  95626. * @param vertexBuffer the vertex buffer to update
  95627. * @param data the data used to update the vertex buffer
  95628. * @param byteOffset the byte offset of the data
  95629. * @param byteLength the byte length of the data
  95630. */
  95631. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  95632. }
  95633. }
  95634. declare module BABYLON {
  95635. interface AbstractScene {
  95636. /**
  95637. * The list of procedural textures added to the scene
  95638. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95639. */
  95640. proceduralTextures: Array<ProceduralTexture>;
  95641. }
  95642. /**
  95643. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  95644. * in a given scene.
  95645. */
  95646. export class ProceduralTextureSceneComponent implements ISceneComponent {
  95647. /**
  95648. * The component name helpfull to identify the component in the list of scene components.
  95649. */
  95650. readonly name: string;
  95651. /**
  95652. * The scene the component belongs to.
  95653. */
  95654. scene: Scene;
  95655. /**
  95656. * Creates a new instance of the component for the given scene
  95657. * @param scene Defines the scene to register the component in
  95658. */
  95659. constructor(scene: Scene);
  95660. /**
  95661. * Registers the component in a given scene
  95662. */
  95663. register(): void;
  95664. /**
  95665. * Rebuilds the elements related to this component in case of
  95666. * context lost for instance.
  95667. */
  95668. rebuild(): void;
  95669. /**
  95670. * Disposes the component and the associated ressources.
  95671. */
  95672. dispose(): void;
  95673. private _beforeClear;
  95674. }
  95675. }
  95676. declare module BABYLON {
  95677. interface ThinEngine {
  95678. /**
  95679. * Creates a new render target cube texture
  95680. * @param size defines the size of the texture
  95681. * @param options defines the options used to create the texture
  95682. * @returns a new render target cube texture stored in an InternalTexture
  95683. */
  95684. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  95685. }
  95686. }
  95687. declare module BABYLON {
  95688. /** @hidden */
  95689. export var proceduralVertexShader: {
  95690. name: string;
  95691. shader: string;
  95692. };
  95693. }
  95694. declare module BABYLON {
  95695. /**
  95696. * 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.
  95697. * This is the base class of any Procedural texture and contains most of the shareable code.
  95698. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95699. */
  95700. export class ProceduralTexture extends Texture {
  95701. /**
  95702. * Define if the texture is enabled or not (disabled texture will not render)
  95703. */
  95704. isEnabled: boolean;
  95705. /**
  95706. * Define if the texture must be cleared before rendering (default is true)
  95707. */
  95708. autoClear: boolean;
  95709. /**
  95710. * Callback called when the texture is generated
  95711. */
  95712. onGenerated: () => void;
  95713. /**
  95714. * Event raised when the texture is generated
  95715. */
  95716. onGeneratedObservable: Observable<ProceduralTexture>;
  95717. /**
  95718. * Event raised before the texture is generated
  95719. */
  95720. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  95721. /**
  95722. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  95723. */
  95724. nodeMaterialSource: Nullable<NodeMaterial>;
  95725. /** @hidden */
  95726. _generateMipMaps: boolean;
  95727. /** @hidden **/
  95728. _effect: Effect;
  95729. /** @hidden */
  95730. _textures: {
  95731. [key: string]: Texture;
  95732. };
  95733. /** @hidden */
  95734. protected _fallbackTexture: Nullable<Texture>;
  95735. private _size;
  95736. private _currentRefreshId;
  95737. private _frameId;
  95738. private _refreshRate;
  95739. private _vertexBuffers;
  95740. private _indexBuffer;
  95741. private _uniforms;
  95742. private _samplers;
  95743. private _fragment;
  95744. private _floats;
  95745. private _ints;
  95746. private _floatsArrays;
  95747. private _colors3;
  95748. private _colors4;
  95749. private _vectors2;
  95750. private _vectors3;
  95751. private _matrices;
  95752. private _fallbackTextureUsed;
  95753. private _fullEngine;
  95754. private _cachedDefines;
  95755. private _contentUpdateId;
  95756. private _contentData;
  95757. /**
  95758. * Instantiates a new procedural texture.
  95759. * 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.
  95760. * This is the base class of any Procedural texture and contains most of the shareable code.
  95761. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  95762. * @param name Define the name of the texture
  95763. * @param size Define the size of the texture to create
  95764. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  95765. * @param scene Define the scene the texture belongs to
  95766. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  95767. * @param generateMipMaps Define if the texture should creates mip maps or not
  95768. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  95769. * @param textureType The FBO internal texture type
  95770. */
  95771. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  95772. /**
  95773. * The effect that is created when initializing the post process.
  95774. * @returns The created effect corresponding the the postprocess.
  95775. */
  95776. getEffect(): Effect;
  95777. /**
  95778. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  95779. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  95780. */
  95781. getContent(): Nullable<ArrayBufferView>;
  95782. private _createIndexBuffer;
  95783. /** @hidden */
  95784. _rebuild(): void;
  95785. /**
  95786. * Resets the texture in order to recreate its associated resources.
  95787. * This can be called in case of context loss
  95788. */
  95789. reset(): void;
  95790. protected _getDefines(): string;
  95791. /**
  95792. * Is the texture ready to be used ? (rendered at least once)
  95793. * @returns true if ready, otherwise, false.
  95794. */
  95795. isReady(): boolean;
  95796. /**
  95797. * Resets the refresh counter of the texture and start bak from scratch.
  95798. * Could be useful to regenerate the texture if it is setup to render only once.
  95799. */
  95800. resetRefreshCounter(): void;
  95801. /**
  95802. * Set the fragment shader to use in order to render the texture.
  95803. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  95804. */
  95805. setFragment(fragment: any): void;
  95806. /**
  95807. * Define the refresh rate of the texture or the rendering frequency.
  95808. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95809. */
  95810. get refreshRate(): number;
  95811. set refreshRate(value: number);
  95812. /** @hidden */
  95813. _shouldRender(): boolean;
  95814. /**
  95815. * Get the size the texture is rendering at.
  95816. * @returns the size (on cube texture it is always squared)
  95817. */
  95818. getRenderSize(): RenderTargetTextureSize;
  95819. /**
  95820. * Resize the texture to new value.
  95821. * @param size Define the new size the texture should have
  95822. * @param generateMipMaps Define whether the new texture should create mip maps
  95823. */
  95824. resize(size: number, generateMipMaps: boolean): void;
  95825. private _checkUniform;
  95826. /**
  95827. * Set a texture in the shader program used to render.
  95828. * @param name Define the name of the uniform samplers as defined in the shader
  95829. * @param texture Define the texture to bind to this sampler
  95830. * @return the texture itself allowing "fluent" like uniform updates
  95831. */
  95832. setTexture(name: string, texture: Texture): ProceduralTexture;
  95833. /**
  95834. * Set a float in the shader.
  95835. * @param name Define the name of the uniform as defined in the shader
  95836. * @param value Define the value to give to the uniform
  95837. * @return the texture itself allowing "fluent" like uniform updates
  95838. */
  95839. setFloat(name: string, value: number): ProceduralTexture;
  95840. /**
  95841. * Set a int in the shader.
  95842. * @param name Define the name of the uniform as defined in the shader
  95843. * @param value Define the value to give to the uniform
  95844. * @return the texture itself allowing "fluent" like uniform updates
  95845. */
  95846. setInt(name: string, value: number): ProceduralTexture;
  95847. /**
  95848. * Set an array of floats in the shader.
  95849. * @param name Define the name of the uniform as defined in the shader
  95850. * @param value Define the value to give to the uniform
  95851. * @return the texture itself allowing "fluent" like uniform updates
  95852. */
  95853. setFloats(name: string, value: number[]): ProceduralTexture;
  95854. /**
  95855. * Set a vec3 in the shader from a Color3.
  95856. * @param name Define the name of the uniform as defined in the shader
  95857. * @param value Define the value to give to the uniform
  95858. * @return the texture itself allowing "fluent" like uniform updates
  95859. */
  95860. setColor3(name: string, value: Color3): ProceduralTexture;
  95861. /**
  95862. * Set a vec4 in the shader from a Color4.
  95863. * @param name Define the name of the uniform as defined in the shader
  95864. * @param value Define the value to give to the uniform
  95865. * @return the texture itself allowing "fluent" like uniform updates
  95866. */
  95867. setColor4(name: string, value: Color4): ProceduralTexture;
  95868. /**
  95869. * Set a vec2 in the shader from a Vector2.
  95870. * @param name Define the name of the uniform as defined in the shader
  95871. * @param value Define the value to give to the uniform
  95872. * @return the texture itself allowing "fluent" like uniform updates
  95873. */
  95874. setVector2(name: string, value: Vector2): ProceduralTexture;
  95875. /**
  95876. * Set a vec3 in the shader from a Vector3.
  95877. * @param name Define the name of the uniform as defined in the shader
  95878. * @param value Define the value to give to the uniform
  95879. * @return the texture itself allowing "fluent" like uniform updates
  95880. */
  95881. setVector3(name: string, value: Vector3): ProceduralTexture;
  95882. /**
  95883. * Set a mat4 in the shader from a MAtrix.
  95884. * @param name Define the name of the uniform as defined in the shader
  95885. * @param value Define the value to give to the uniform
  95886. * @return the texture itself allowing "fluent" like uniform updates
  95887. */
  95888. setMatrix(name: string, value: Matrix): ProceduralTexture;
  95889. /**
  95890. * Render the texture to its associated render target.
  95891. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  95892. */
  95893. render(useCameraPostProcess?: boolean): void;
  95894. /**
  95895. * Clone the texture.
  95896. * @returns the cloned texture
  95897. */
  95898. clone(): ProceduralTexture;
  95899. /**
  95900. * Dispose the texture and release its asoociated resources.
  95901. */
  95902. dispose(): void;
  95903. }
  95904. }
  95905. declare module BABYLON {
  95906. /**
  95907. * This represents the base class for particle system in Babylon.
  95908. * 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.
  95909. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  95910. * @example https://doc.babylonjs.com/babylon101/particles
  95911. */
  95912. export class BaseParticleSystem {
  95913. /**
  95914. * Source color is added to the destination color without alpha affecting the result
  95915. */
  95916. static BLENDMODE_ONEONE: number;
  95917. /**
  95918. * Blend current color and particle color using particle’s alpha
  95919. */
  95920. static BLENDMODE_STANDARD: number;
  95921. /**
  95922. * Add current color and particle color multiplied by particle’s alpha
  95923. */
  95924. static BLENDMODE_ADD: number;
  95925. /**
  95926. * Multiply current color with particle color
  95927. */
  95928. static BLENDMODE_MULTIPLY: number;
  95929. /**
  95930. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  95931. */
  95932. static BLENDMODE_MULTIPLYADD: number;
  95933. /**
  95934. * List of animations used by the particle system.
  95935. */
  95936. animations: Animation[];
  95937. /**
  95938. * Gets or sets the unique id of the particle system
  95939. */
  95940. uniqueId: number;
  95941. /**
  95942. * The id of the Particle system.
  95943. */
  95944. id: string;
  95945. /**
  95946. * The friendly name of the Particle system.
  95947. */
  95948. name: string;
  95949. /**
  95950. * Snippet ID if the particle system was created from the snippet server
  95951. */
  95952. snippetId: string;
  95953. /**
  95954. * The rendering group used by the Particle system to chose when to render.
  95955. */
  95956. renderingGroupId: number;
  95957. /**
  95958. * The emitter represents the Mesh or position we are attaching the particle system to.
  95959. */
  95960. emitter: Nullable<AbstractMesh | Vector3>;
  95961. /**
  95962. * The maximum number of particles to emit per frame
  95963. */
  95964. emitRate: number;
  95965. /**
  95966. * If you want to launch only a few particles at once, that can be done, as well.
  95967. */
  95968. manualEmitCount: number;
  95969. /**
  95970. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95971. */
  95972. updateSpeed: number;
  95973. /**
  95974. * The amount of time the particle system is running (depends of the overall update speed).
  95975. */
  95976. targetStopDuration: number;
  95977. /**
  95978. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95979. */
  95980. disposeOnStop: boolean;
  95981. /**
  95982. * Minimum power of emitting particles.
  95983. */
  95984. minEmitPower: number;
  95985. /**
  95986. * Maximum power of emitting particles.
  95987. */
  95988. maxEmitPower: number;
  95989. /**
  95990. * Minimum life time of emitting particles.
  95991. */
  95992. minLifeTime: number;
  95993. /**
  95994. * Maximum life time of emitting particles.
  95995. */
  95996. maxLifeTime: number;
  95997. /**
  95998. * Minimum Size of emitting particles.
  95999. */
  96000. minSize: number;
  96001. /**
  96002. * Maximum Size of emitting particles.
  96003. */
  96004. maxSize: number;
  96005. /**
  96006. * Minimum scale of emitting particles on X axis.
  96007. */
  96008. minScaleX: number;
  96009. /**
  96010. * Maximum scale of emitting particles on X axis.
  96011. */
  96012. maxScaleX: number;
  96013. /**
  96014. * Minimum scale of emitting particles on Y axis.
  96015. */
  96016. minScaleY: number;
  96017. /**
  96018. * Maximum scale of emitting particles on Y axis.
  96019. */
  96020. maxScaleY: number;
  96021. /**
  96022. * Gets or sets the minimal initial rotation in radians.
  96023. */
  96024. minInitialRotation: number;
  96025. /**
  96026. * Gets or sets the maximal initial rotation in radians.
  96027. */
  96028. maxInitialRotation: number;
  96029. /**
  96030. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  96031. */
  96032. minAngularSpeed: number;
  96033. /**
  96034. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  96035. */
  96036. maxAngularSpeed: number;
  96037. /**
  96038. * The texture used to render each particle. (this can be a spritesheet)
  96039. */
  96040. particleTexture: Nullable<BaseTexture>;
  96041. /**
  96042. * The layer mask we are rendering the particles through.
  96043. */
  96044. layerMask: number;
  96045. /**
  96046. * This can help using your own shader to render the particle system.
  96047. * The according effect will be created
  96048. */
  96049. customShader: any;
  96050. /**
  96051. * By default particle system starts as soon as they are created. This prevents the
  96052. * automatic start to happen and let you decide when to start emitting particles.
  96053. */
  96054. preventAutoStart: boolean;
  96055. private _noiseTexture;
  96056. /**
  96057. * Gets or sets a texture used to add random noise to particle positions
  96058. */
  96059. get noiseTexture(): Nullable<ProceduralTexture>;
  96060. set noiseTexture(value: Nullable<ProceduralTexture>);
  96061. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  96062. noiseStrength: Vector3;
  96063. /**
  96064. * Callback triggered when the particle animation is ending.
  96065. */
  96066. onAnimationEnd: Nullable<() => void>;
  96067. /**
  96068. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  96069. */
  96070. blendMode: number;
  96071. /**
  96072. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  96073. * to override the particles.
  96074. */
  96075. forceDepthWrite: boolean;
  96076. /** 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 */
  96077. preWarmCycles: number;
  96078. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  96079. preWarmStepOffset: number;
  96080. /**
  96081. * 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)
  96082. */
  96083. spriteCellChangeSpeed: number;
  96084. /**
  96085. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  96086. */
  96087. startSpriteCellID: number;
  96088. /**
  96089. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  96090. */
  96091. endSpriteCellID: number;
  96092. /**
  96093. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  96094. */
  96095. spriteCellWidth: number;
  96096. /**
  96097. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  96098. */
  96099. spriteCellHeight: number;
  96100. /**
  96101. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  96102. */
  96103. spriteRandomStartCell: boolean;
  96104. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  96105. translationPivot: Vector2;
  96106. /** @hidden */
  96107. protected _isAnimationSheetEnabled: boolean;
  96108. /**
  96109. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  96110. */
  96111. beginAnimationOnStart: boolean;
  96112. /**
  96113. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  96114. */
  96115. beginAnimationFrom: number;
  96116. /**
  96117. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  96118. */
  96119. beginAnimationTo: number;
  96120. /**
  96121. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  96122. */
  96123. beginAnimationLoop: boolean;
  96124. /**
  96125. * Gets or sets a world offset applied to all particles
  96126. */
  96127. worldOffset: Vector3;
  96128. /**
  96129. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  96130. */
  96131. get isAnimationSheetEnabled(): boolean;
  96132. set isAnimationSheetEnabled(value: boolean);
  96133. /**
  96134. * Get hosting scene
  96135. * @returns the scene
  96136. */
  96137. getScene(): Nullable<Scene>;
  96138. /**
  96139. * You can use gravity if you want to give an orientation to your particles.
  96140. */
  96141. gravity: Vector3;
  96142. protected _colorGradients: Nullable<Array<ColorGradient>>;
  96143. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  96144. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  96145. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  96146. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  96147. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  96148. protected _dragGradients: Nullable<Array<FactorGradient>>;
  96149. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  96150. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  96151. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  96152. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  96153. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  96154. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  96155. /**
  96156. * Defines the delay in milliseconds before starting the system (0 by default)
  96157. */
  96158. startDelay: number;
  96159. /**
  96160. * Gets the current list of drag gradients.
  96161. * You must use addDragGradient and removeDragGradient to udpate this list
  96162. * @returns the list of drag gradients
  96163. */
  96164. getDragGradients(): Nullable<Array<FactorGradient>>;
  96165. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  96166. limitVelocityDamping: number;
  96167. /**
  96168. * Gets the current list of limit velocity gradients.
  96169. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  96170. * @returns the list of limit velocity gradients
  96171. */
  96172. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  96173. /**
  96174. * Gets the current list of color gradients.
  96175. * You must use addColorGradient and removeColorGradient to udpate this list
  96176. * @returns the list of color gradients
  96177. */
  96178. getColorGradients(): Nullable<Array<ColorGradient>>;
  96179. /**
  96180. * Gets the current list of size gradients.
  96181. * You must use addSizeGradient and removeSizeGradient to udpate this list
  96182. * @returns the list of size gradients
  96183. */
  96184. getSizeGradients(): Nullable<Array<FactorGradient>>;
  96185. /**
  96186. * Gets the current list of color remap gradients.
  96187. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  96188. * @returns the list of color remap gradients
  96189. */
  96190. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  96191. /**
  96192. * Gets the current list of alpha remap gradients.
  96193. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  96194. * @returns the list of alpha remap gradients
  96195. */
  96196. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  96197. /**
  96198. * Gets the current list of life time gradients.
  96199. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  96200. * @returns the list of life time gradients
  96201. */
  96202. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  96203. /**
  96204. * Gets the current list of angular speed gradients.
  96205. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  96206. * @returns the list of angular speed gradients
  96207. */
  96208. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  96209. /**
  96210. * Gets the current list of velocity gradients.
  96211. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  96212. * @returns the list of velocity gradients
  96213. */
  96214. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  96215. /**
  96216. * Gets the current list of start size gradients.
  96217. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  96218. * @returns the list of start size gradients
  96219. */
  96220. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  96221. /**
  96222. * Gets the current list of emit rate gradients.
  96223. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  96224. * @returns the list of emit rate gradients
  96225. */
  96226. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  96227. /**
  96228. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96229. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96230. */
  96231. get direction1(): Vector3;
  96232. set direction1(value: Vector3);
  96233. /**
  96234. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  96235. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96236. */
  96237. get direction2(): Vector3;
  96238. set direction2(value: Vector3);
  96239. /**
  96240. * 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.
  96241. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96242. */
  96243. get minEmitBox(): Vector3;
  96244. set minEmitBox(value: Vector3);
  96245. /**
  96246. * 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.
  96247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  96248. */
  96249. get maxEmitBox(): Vector3;
  96250. set maxEmitBox(value: Vector3);
  96251. /**
  96252. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96253. */
  96254. color1: Color4;
  96255. /**
  96256. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  96257. */
  96258. color2: Color4;
  96259. /**
  96260. * Color the particle will have at the end of its lifetime
  96261. */
  96262. colorDead: Color4;
  96263. /**
  96264. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  96265. */
  96266. textureMask: Color4;
  96267. /**
  96268. * The particle emitter type defines the emitter used by the particle system.
  96269. * It can be for example box, sphere, or cone...
  96270. */
  96271. particleEmitterType: IParticleEmitterType;
  96272. /** @hidden */
  96273. _isSubEmitter: boolean;
  96274. /**
  96275. * Gets or sets the billboard mode to use when isBillboardBased = true.
  96276. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  96277. */
  96278. billboardMode: number;
  96279. protected _isBillboardBased: boolean;
  96280. /**
  96281. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  96282. */
  96283. get isBillboardBased(): boolean;
  96284. set isBillboardBased(value: boolean);
  96285. /**
  96286. * The scene the particle system belongs to.
  96287. */
  96288. protected _scene: Nullable<Scene>;
  96289. /**
  96290. * The engine the particle system belongs to.
  96291. */
  96292. protected _engine: ThinEngine;
  96293. /**
  96294. * Local cache of defines for image processing.
  96295. */
  96296. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  96297. /**
  96298. * Default configuration related to image processing available in the standard Material.
  96299. */
  96300. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  96301. /**
  96302. * Gets the image processing configuration used either in this material.
  96303. */
  96304. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  96305. /**
  96306. * Sets the Default image processing configuration used either in the this material.
  96307. *
  96308. * If sets to null, the scene one is in use.
  96309. */
  96310. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  96311. /**
  96312. * Attaches a new image processing configuration to the Standard Material.
  96313. * @param configuration
  96314. */
  96315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  96316. /** @hidden */
  96317. protected _reset(): void;
  96318. /** @hidden */
  96319. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  96320. /**
  96321. * Instantiates a particle system.
  96322. * 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.
  96323. * @param name The name of the particle system
  96324. */
  96325. constructor(name: string);
  96326. /**
  96327. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  96328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96330. * @returns the emitter
  96331. */
  96332. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  96333. /**
  96334. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  96335. * @param radius The radius of the hemisphere to emit from
  96336. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96337. * @returns the emitter
  96338. */
  96339. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  96340. /**
  96341. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  96342. * @param radius The radius of the sphere to emit from
  96343. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  96344. * @returns the emitter
  96345. */
  96346. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  96347. /**
  96348. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  96349. * @param radius The radius of the sphere to emit from
  96350. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  96351. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  96352. * @returns the emitter
  96353. */
  96354. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  96355. /**
  96356. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  96357. * @param radius The radius of the emission cylinder
  96358. * @param height The height of the emission cylinder
  96359. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  96360. * @param directionRandomizer How much to randomize the particle direction [0-1]
  96361. * @returns the emitter
  96362. */
  96363. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  96364. /**
  96365. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  96366. * @param radius The radius of the cylinder to emit from
  96367. * @param height The height of the emission cylinder
  96368. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  96369. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  96370. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  96371. * @returns the emitter
  96372. */
  96373. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  96374. /**
  96375. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  96376. * @param radius The radius of the cone to emit from
  96377. * @param angle The base angle of the cone
  96378. * @returns the emitter
  96379. */
  96380. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  96381. /**
  96382. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  96383. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  96384. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  96385. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96386. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  96387. * @returns the emitter
  96388. */
  96389. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  96390. }
  96391. }
  96392. declare module BABYLON {
  96393. /**
  96394. * Type of sub emitter
  96395. */
  96396. export enum SubEmitterType {
  96397. /**
  96398. * Attached to the particle over it's lifetime
  96399. */
  96400. ATTACHED = 0,
  96401. /**
  96402. * Created when the particle dies
  96403. */
  96404. END = 1
  96405. }
  96406. /**
  96407. * Sub emitter class used to emit particles from an existing particle
  96408. */
  96409. export class SubEmitter {
  96410. /**
  96411. * the particle system to be used by the sub emitter
  96412. */
  96413. particleSystem: ParticleSystem;
  96414. /**
  96415. * Type of the submitter (Default: END)
  96416. */
  96417. type: SubEmitterType;
  96418. /**
  96419. * 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)
  96420. * Note: This only is supported when using an emitter of type Mesh
  96421. */
  96422. inheritDirection: boolean;
  96423. /**
  96424. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  96425. */
  96426. inheritedVelocityAmount: number;
  96427. /**
  96428. * Creates a sub emitter
  96429. * @param particleSystem the particle system to be used by the sub emitter
  96430. */
  96431. constructor(
  96432. /**
  96433. * the particle system to be used by the sub emitter
  96434. */
  96435. particleSystem: ParticleSystem);
  96436. /**
  96437. * Clones the sub emitter
  96438. * @returns the cloned sub emitter
  96439. */
  96440. clone(): SubEmitter;
  96441. /**
  96442. * Serialize current object to a JSON object
  96443. * @returns the serialized object
  96444. */
  96445. serialize(): any;
  96446. /** @hidden */
  96447. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  96448. /**
  96449. * Creates a new SubEmitter from a serialized JSON version
  96450. * @param serializationObject defines the JSON object to read from
  96451. * @param sceneOrEngine defines the hosting scene or the hosting engine
  96452. * @param rootUrl defines the rootUrl for data loading
  96453. * @returns a new SubEmitter
  96454. */
  96455. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  96456. /** Release associated resources */
  96457. dispose(): void;
  96458. }
  96459. }
  96460. declare module BABYLON {
  96461. /** @hidden */
  96462. export var clipPlaneFragmentDeclaration: {
  96463. name: string;
  96464. shader: string;
  96465. };
  96466. }
  96467. declare module BABYLON {
  96468. /** @hidden */
  96469. export var imageProcessingDeclaration: {
  96470. name: string;
  96471. shader: string;
  96472. };
  96473. }
  96474. declare module BABYLON {
  96475. /** @hidden */
  96476. export var imageProcessingFunctions: {
  96477. name: string;
  96478. shader: string;
  96479. };
  96480. }
  96481. declare module BABYLON {
  96482. /** @hidden */
  96483. export var clipPlaneFragment: {
  96484. name: string;
  96485. shader: string;
  96486. };
  96487. }
  96488. declare module BABYLON {
  96489. /** @hidden */
  96490. export var particlesPixelShader: {
  96491. name: string;
  96492. shader: string;
  96493. };
  96494. }
  96495. declare module BABYLON {
  96496. /** @hidden */
  96497. export var clipPlaneVertexDeclaration: {
  96498. name: string;
  96499. shader: string;
  96500. };
  96501. }
  96502. declare module BABYLON {
  96503. /** @hidden */
  96504. export var clipPlaneVertex: {
  96505. name: string;
  96506. shader: string;
  96507. };
  96508. }
  96509. declare module BABYLON {
  96510. /** @hidden */
  96511. export var particlesVertexShader: {
  96512. name: string;
  96513. shader: string;
  96514. };
  96515. }
  96516. declare module BABYLON {
  96517. /**
  96518. * Interface used to define entities containing multiple clip planes
  96519. */
  96520. export interface IClipPlanesHolder {
  96521. /**
  96522. * Gets or sets the active clipplane 1
  96523. */
  96524. clipPlane: Nullable<Plane>;
  96525. /**
  96526. * Gets or sets the active clipplane 2
  96527. */
  96528. clipPlane2: Nullable<Plane>;
  96529. /**
  96530. * Gets or sets the active clipplane 3
  96531. */
  96532. clipPlane3: Nullable<Plane>;
  96533. /**
  96534. * Gets or sets the active clipplane 4
  96535. */
  96536. clipPlane4: Nullable<Plane>;
  96537. /**
  96538. * Gets or sets the active clipplane 5
  96539. */
  96540. clipPlane5: Nullable<Plane>;
  96541. /**
  96542. * Gets or sets the active clipplane 6
  96543. */
  96544. clipPlane6: Nullable<Plane>;
  96545. }
  96546. }
  96547. declare module BABYLON {
  96548. /**
  96549. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  96550. *
  96551. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  96552. *
  96553. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  96554. */
  96555. export class ThinMaterialHelper {
  96556. /**
  96557. * Binds the clip plane information from the holder to the effect.
  96558. * @param effect The effect we are binding the data to
  96559. * @param holder The entity containing the clip plane information
  96560. */
  96561. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  96562. }
  96563. }
  96564. declare module BABYLON {
  96565. interface ThinEngine {
  96566. /**
  96567. * Sets alpha constants used by some alpha blending modes
  96568. * @param r defines the red component
  96569. * @param g defines the green component
  96570. * @param b defines the blue component
  96571. * @param a defines the alpha component
  96572. */
  96573. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  96574. /**
  96575. * Sets the current alpha mode
  96576. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  96577. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  96578. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96579. */
  96580. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96581. /**
  96582. * Gets the current alpha mode
  96583. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  96584. * @returns the current alpha mode
  96585. */
  96586. getAlphaMode(): number;
  96587. /**
  96588. * Sets the current alpha equation
  96589. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  96590. */
  96591. setAlphaEquation(equation: number): void;
  96592. /**
  96593. * Gets the current alpha equation.
  96594. * @returns the current alpha equation
  96595. */
  96596. getAlphaEquation(): number;
  96597. }
  96598. }
  96599. declare module BABYLON {
  96600. /**
  96601. * This represents a particle system in Babylon.
  96602. * 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.
  96603. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  96604. * @example https://doc.babylonjs.com/babylon101/particles
  96605. */
  96606. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  96607. /**
  96608. * Billboard mode will only apply to Y axis
  96609. */
  96610. static readonly BILLBOARDMODE_Y: number;
  96611. /**
  96612. * Billboard mode will apply to all axes
  96613. */
  96614. static readonly BILLBOARDMODE_ALL: number;
  96615. /**
  96616. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  96617. */
  96618. static readonly BILLBOARDMODE_STRETCHED: number;
  96619. /**
  96620. * This function can be defined to provide custom update for active particles.
  96621. * This function will be called instead of regular update (age, position, color, etc.).
  96622. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  96623. */
  96624. updateFunction: (particles: Particle[]) => void;
  96625. private _emitterWorldMatrix;
  96626. /**
  96627. * This function can be defined to specify initial direction for every new particle.
  96628. * It by default use the emitterType defined function
  96629. */
  96630. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96631. /**
  96632. * This function can be defined to specify initial position for every new particle.
  96633. * It by default use the emitterType defined function
  96634. */
  96635. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  96636. /**
  96637. * @hidden
  96638. */
  96639. _inheritedVelocityOffset: Vector3;
  96640. /**
  96641. * An event triggered when the system is disposed
  96642. */
  96643. onDisposeObservable: Observable<IParticleSystem>;
  96644. /**
  96645. * An event triggered when the system is stopped
  96646. */
  96647. onStoppedObservable: Observable<IParticleSystem>;
  96648. private _onDisposeObserver;
  96649. /**
  96650. * Sets a callback that will be triggered when the system is disposed
  96651. */
  96652. set onDispose(callback: () => void);
  96653. private _particles;
  96654. private _epsilon;
  96655. private _capacity;
  96656. private _stockParticles;
  96657. private _newPartsExcess;
  96658. private _vertexData;
  96659. private _vertexBuffer;
  96660. private _vertexBuffers;
  96661. private _spriteBuffer;
  96662. private _indexBuffer;
  96663. private _effect;
  96664. private _customEffect;
  96665. private _cachedDefines;
  96666. private _scaledColorStep;
  96667. private _colorDiff;
  96668. private _scaledDirection;
  96669. private _scaledGravity;
  96670. private _currentRenderId;
  96671. private _alive;
  96672. private _useInstancing;
  96673. private _vertexArrayObject;
  96674. private _started;
  96675. private _stopped;
  96676. private _actualFrame;
  96677. private _scaledUpdateSpeed;
  96678. private _vertexBufferSize;
  96679. /** @hidden */
  96680. _currentEmitRateGradient: Nullable<FactorGradient>;
  96681. /** @hidden */
  96682. _currentEmitRate1: number;
  96683. /** @hidden */
  96684. _currentEmitRate2: number;
  96685. /** @hidden */
  96686. _currentStartSizeGradient: Nullable<FactorGradient>;
  96687. /** @hidden */
  96688. _currentStartSize1: number;
  96689. /** @hidden */
  96690. _currentStartSize2: number;
  96691. private readonly _rawTextureWidth;
  96692. private _rampGradientsTexture;
  96693. private _useRampGradients;
  96694. /** Gets or sets a matrix to use to compute projection */
  96695. defaultProjectionMatrix: Matrix;
  96696. /** Gets or sets a matrix to use to compute view */
  96697. defaultViewMatrix: Matrix;
  96698. /** Gets or sets a boolean indicating that ramp gradients must be used
  96699. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  96700. */
  96701. get useRampGradients(): boolean;
  96702. set useRampGradients(value: boolean);
  96703. /**
  96704. * 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.
  96705. * 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: [])
  96706. */
  96707. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  96708. private _subEmitters;
  96709. /**
  96710. * @hidden
  96711. * If the particle systems emitter should be disposed when the particle system is disposed
  96712. */
  96713. _disposeEmitterOnDispose: boolean;
  96714. /**
  96715. * The current active Sub-systems, this property is used by the root particle system only.
  96716. */
  96717. activeSubSystems: Array<ParticleSystem>;
  96718. /**
  96719. * Specifies if the particles are updated in emitter local space or world space
  96720. */
  96721. isLocal: boolean;
  96722. private _rootParticleSystem;
  96723. /**
  96724. * Gets the current list of active particles
  96725. */
  96726. get particles(): Particle[];
  96727. /**
  96728. * Gets the number of particles active at the same time.
  96729. * @returns The number of active particles.
  96730. */
  96731. getActiveCount(): number;
  96732. /**
  96733. * Returns the string "ParticleSystem"
  96734. * @returns a string containing the class name
  96735. */
  96736. getClassName(): string;
  96737. /**
  96738. * Gets a boolean indicating that the system is stopping
  96739. * @returns true if the system is currently stopping
  96740. */
  96741. isStopping(): boolean;
  96742. /**
  96743. * Gets the custom effect used to render the particles
  96744. * @param blendMode Blend mode for which the effect should be retrieved
  96745. * @returns The effect
  96746. */
  96747. getCustomEffect(blendMode?: number): Nullable<Effect>;
  96748. /**
  96749. * Sets the custom effect used to render the particles
  96750. * @param effect The effect to set
  96751. * @param blendMode Blend mode for which the effect should be set
  96752. */
  96753. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  96754. /** @hidden */
  96755. private _onBeforeDrawParticlesObservable;
  96756. /**
  96757. * Observable that will be called just before the particles are drawn
  96758. */
  96759. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  96760. /**
  96761. * Gets the name of the particle vertex shader
  96762. */
  96763. get vertexShaderName(): string;
  96764. /**
  96765. * Instantiates a particle system.
  96766. * 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.
  96767. * @param name The name of the particle system
  96768. * @param capacity The max number of particles alive at the same time
  96769. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  96770. * @param customEffect a custom effect used to change the way particles are rendered by default
  96771. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  96772. * @param epsilon Offset used to render the particles
  96773. */
  96774. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  96775. private _addFactorGradient;
  96776. private _removeFactorGradient;
  96777. /**
  96778. * Adds a new life time gradient
  96779. * @param gradient defines the gradient to use (between 0 and 1)
  96780. * @param factor defines the life time factor to affect to the specified gradient
  96781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96782. * @returns the current particle system
  96783. */
  96784. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96785. /**
  96786. * Remove a specific life time gradient
  96787. * @param gradient defines the gradient to remove
  96788. * @returns the current particle system
  96789. */
  96790. removeLifeTimeGradient(gradient: number): IParticleSystem;
  96791. /**
  96792. * Adds a new size gradient
  96793. * @param gradient defines the gradient to use (between 0 and 1)
  96794. * @param factor defines the size factor to affect to the specified gradient
  96795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96796. * @returns the current particle system
  96797. */
  96798. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96799. /**
  96800. * Remove a specific size gradient
  96801. * @param gradient defines the gradient to remove
  96802. * @returns the current particle system
  96803. */
  96804. removeSizeGradient(gradient: number): IParticleSystem;
  96805. /**
  96806. * Adds a new color remap gradient
  96807. * @param gradient defines the gradient to use (between 0 and 1)
  96808. * @param min defines the color remap minimal range
  96809. * @param max defines the color remap maximal range
  96810. * @returns the current particle system
  96811. */
  96812. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96813. /**
  96814. * Remove a specific color remap gradient
  96815. * @param gradient defines the gradient to remove
  96816. * @returns the current particle system
  96817. */
  96818. removeColorRemapGradient(gradient: number): IParticleSystem;
  96819. /**
  96820. * Adds a new alpha remap gradient
  96821. * @param gradient defines the gradient to use (between 0 and 1)
  96822. * @param min defines the alpha remap minimal range
  96823. * @param max defines the alpha remap maximal range
  96824. * @returns the current particle system
  96825. */
  96826. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  96827. /**
  96828. * Remove a specific alpha remap gradient
  96829. * @param gradient defines the gradient to remove
  96830. * @returns the current particle system
  96831. */
  96832. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  96833. /**
  96834. * Adds a new angular speed gradient
  96835. * @param gradient defines the gradient to use (between 0 and 1)
  96836. * @param factor defines the angular speed to affect to the specified gradient
  96837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96838. * @returns the current particle system
  96839. */
  96840. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96841. /**
  96842. * Remove a specific angular speed gradient
  96843. * @param gradient defines the gradient to remove
  96844. * @returns the current particle system
  96845. */
  96846. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  96847. /**
  96848. * Adds a new velocity gradient
  96849. * @param gradient defines the gradient to use (between 0 and 1)
  96850. * @param factor defines the velocity to affect to the specified gradient
  96851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96852. * @returns the current particle system
  96853. */
  96854. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96855. /**
  96856. * Remove a specific velocity gradient
  96857. * @param gradient defines the gradient to remove
  96858. * @returns the current particle system
  96859. */
  96860. removeVelocityGradient(gradient: number): IParticleSystem;
  96861. /**
  96862. * Adds a new limit velocity gradient
  96863. * @param gradient defines the gradient to use (between 0 and 1)
  96864. * @param factor defines the limit velocity value to affect to the specified gradient
  96865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96866. * @returns the current particle system
  96867. */
  96868. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96869. /**
  96870. * Remove a specific limit velocity gradient
  96871. * @param gradient defines the gradient to remove
  96872. * @returns the current particle system
  96873. */
  96874. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  96875. /**
  96876. * Adds a new drag gradient
  96877. * @param gradient defines the gradient to use (between 0 and 1)
  96878. * @param factor defines the drag value to affect to the specified gradient
  96879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96880. * @returns the current particle system
  96881. */
  96882. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96883. /**
  96884. * Remove a specific drag gradient
  96885. * @param gradient defines the gradient to remove
  96886. * @returns the current particle system
  96887. */
  96888. removeDragGradient(gradient: number): IParticleSystem;
  96889. /**
  96890. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  96891. * @param gradient defines the gradient to use (between 0 and 1)
  96892. * @param factor defines the emit rate value to affect to the specified gradient
  96893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96894. * @returns the current particle system
  96895. */
  96896. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96897. /**
  96898. * Remove a specific emit rate gradient
  96899. * @param gradient defines the gradient to remove
  96900. * @returns the current particle system
  96901. */
  96902. removeEmitRateGradient(gradient: number): IParticleSystem;
  96903. /**
  96904. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  96905. * @param gradient defines the gradient to use (between 0 and 1)
  96906. * @param factor defines the start size value to affect to the specified gradient
  96907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  96908. * @returns the current particle system
  96909. */
  96910. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  96911. /**
  96912. * Remove a specific start size gradient
  96913. * @param gradient defines the gradient to remove
  96914. * @returns the current particle system
  96915. */
  96916. removeStartSizeGradient(gradient: number): IParticleSystem;
  96917. private _createRampGradientTexture;
  96918. /**
  96919. * Gets the current list of ramp gradients.
  96920. * You must use addRampGradient and removeRampGradient to udpate this list
  96921. * @returns the list of ramp gradients
  96922. */
  96923. getRampGradients(): Nullable<Array<Color3Gradient>>;
  96924. /** Force the system to rebuild all gradients that need to be resync */
  96925. forceRefreshGradients(): void;
  96926. private _syncRampGradientTexture;
  96927. /**
  96928. * Adds a new ramp gradient used to remap particle colors
  96929. * @param gradient defines the gradient to use (between 0 and 1)
  96930. * @param color defines the color to affect to the specified gradient
  96931. * @returns the current particle system
  96932. */
  96933. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  96934. /**
  96935. * Remove a specific ramp gradient
  96936. * @param gradient defines the gradient to remove
  96937. * @returns the current particle system
  96938. */
  96939. removeRampGradient(gradient: number): ParticleSystem;
  96940. /**
  96941. * Adds a new color gradient
  96942. * @param gradient defines the gradient to use (between 0 and 1)
  96943. * @param color1 defines the color to affect to the specified gradient
  96944. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  96945. * @returns this particle system
  96946. */
  96947. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  96948. /**
  96949. * Remove a specific color gradient
  96950. * @param gradient defines the gradient to remove
  96951. * @returns this particle system
  96952. */
  96953. removeColorGradient(gradient: number): IParticleSystem;
  96954. private _fetchR;
  96955. protected _reset(): void;
  96956. private _resetEffect;
  96957. private _createVertexBuffers;
  96958. private _createIndexBuffer;
  96959. /**
  96960. * Gets the maximum number of particles active at the same time.
  96961. * @returns The max number of active particles.
  96962. */
  96963. getCapacity(): number;
  96964. /**
  96965. * Gets whether there are still active particles in the system.
  96966. * @returns True if it is alive, otherwise false.
  96967. */
  96968. isAlive(): boolean;
  96969. /**
  96970. * Gets if the system has been started. (Note: this will still be true after stop is called)
  96971. * @returns True if it has been started, otherwise false.
  96972. */
  96973. isStarted(): boolean;
  96974. private _prepareSubEmitterInternalArray;
  96975. /**
  96976. * Starts the particle system and begins to emit
  96977. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  96978. */
  96979. start(delay?: number): void;
  96980. /**
  96981. * Stops the particle system.
  96982. * @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.
  96983. */
  96984. stop(stopSubEmitters?: boolean): void;
  96985. /**
  96986. * Remove all active particles
  96987. */
  96988. reset(): void;
  96989. /**
  96990. * @hidden (for internal use only)
  96991. */
  96992. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  96993. /**
  96994. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  96995. * Its lifetime will start back at 0.
  96996. */
  96997. recycleParticle: (particle: Particle) => void;
  96998. private _stopSubEmitters;
  96999. private _createParticle;
  97000. private _removeFromRoot;
  97001. private _emitFromParticle;
  97002. private _update;
  97003. /** @hidden */
  97004. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  97005. /** @hidden */
  97006. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  97007. /**
  97008. * Fill the defines array according to the current settings of the particle system
  97009. * @param defines Array to be updated
  97010. * @param blendMode blend mode to take into account when updating the array
  97011. */
  97012. fillDefines(defines: Array<string>, blendMode: number): void;
  97013. /**
  97014. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  97015. * @param uniforms Uniforms array to fill
  97016. * @param attributes Attributes array to fill
  97017. * @param samplers Samplers array to fill
  97018. */
  97019. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  97020. /** @hidden */
  97021. private _getEffect;
  97022. /**
  97023. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  97024. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  97025. */
  97026. animate(preWarmOnly?: boolean): void;
  97027. private _appendParticleVertices;
  97028. /**
  97029. * Rebuilds the particle system.
  97030. */
  97031. rebuild(): void;
  97032. /**
  97033. * Is this system ready to be used/rendered
  97034. * @return true if the system is ready
  97035. */
  97036. isReady(): boolean;
  97037. private _render;
  97038. /**
  97039. * Renders the particle system in its current state.
  97040. * @returns the current number of particles
  97041. */
  97042. render(): number;
  97043. /**
  97044. * Disposes the particle system and free the associated resources
  97045. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  97046. */
  97047. dispose(disposeTexture?: boolean): void;
  97048. /**
  97049. * Clones the particle system.
  97050. * @param name The name of the cloned object
  97051. * @param newEmitter The new emitter to use
  97052. * @returns the cloned particle system
  97053. */
  97054. clone(name: string, newEmitter: any): ParticleSystem;
  97055. /**
  97056. * Serializes the particle system to a JSON object
  97057. * @param serializeTexture defines if the texture must be serialized as well
  97058. * @returns the JSON object
  97059. */
  97060. serialize(serializeTexture?: boolean): any;
  97061. /** @hidden */
  97062. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  97063. /** @hidden */
  97064. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  97065. /**
  97066. * Parses a JSON object to create a particle system.
  97067. * @param parsedParticleSystem The JSON object to parse
  97068. * @param sceneOrEngine The scene or the engine to create the particle system in
  97069. * @param rootUrl The root url to use to load external dependencies like texture
  97070. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  97071. * @returns the Parsed particle system
  97072. */
  97073. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  97074. }
  97075. }
  97076. declare module BABYLON {
  97077. /**
  97078. * A particle represents one of the element emitted by a particle system.
  97079. * This is mainly define by its coordinates, direction, velocity and age.
  97080. */
  97081. export class Particle {
  97082. /**
  97083. * The particle system the particle belongs to.
  97084. */
  97085. particleSystem: ParticleSystem;
  97086. private static _Count;
  97087. /**
  97088. * Unique ID of the particle
  97089. */
  97090. id: number;
  97091. /**
  97092. * The world position of the particle in the scene.
  97093. */
  97094. position: Vector3;
  97095. /**
  97096. * The world direction of the particle in the scene.
  97097. */
  97098. direction: Vector3;
  97099. /**
  97100. * The color of the particle.
  97101. */
  97102. color: Color4;
  97103. /**
  97104. * The color change of the particle per step.
  97105. */
  97106. colorStep: Color4;
  97107. /**
  97108. * Defines how long will the life of the particle be.
  97109. */
  97110. lifeTime: number;
  97111. /**
  97112. * The current age of the particle.
  97113. */
  97114. age: number;
  97115. /**
  97116. * The current size of the particle.
  97117. */
  97118. size: number;
  97119. /**
  97120. * The current scale of the particle.
  97121. */
  97122. scale: Vector2;
  97123. /**
  97124. * The current angle of the particle.
  97125. */
  97126. angle: number;
  97127. /**
  97128. * Defines how fast is the angle changing.
  97129. */
  97130. angularSpeed: number;
  97131. /**
  97132. * Defines the cell index used by the particle to be rendered from a sprite.
  97133. */
  97134. cellIndex: number;
  97135. /**
  97136. * The information required to support color remapping
  97137. */
  97138. remapData: Vector4;
  97139. /** @hidden */
  97140. _randomCellOffset?: number;
  97141. /** @hidden */
  97142. _initialDirection: Nullable<Vector3>;
  97143. /** @hidden */
  97144. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  97145. /** @hidden */
  97146. _initialStartSpriteCellID: number;
  97147. /** @hidden */
  97148. _initialEndSpriteCellID: number;
  97149. /** @hidden */
  97150. _currentColorGradient: Nullable<ColorGradient>;
  97151. /** @hidden */
  97152. _currentColor1: Color4;
  97153. /** @hidden */
  97154. _currentColor2: Color4;
  97155. /** @hidden */
  97156. _currentSizeGradient: Nullable<FactorGradient>;
  97157. /** @hidden */
  97158. _currentSize1: number;
  97159. /** @hidden */
  97160. _currentSize2: number;
  97161. /** @hidden */
  97162. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  97163. /** @hidden */
  97164. _currentAngularSpeed1: number;
  97165. /** @hidden */
  97166. _currentAngularSpeed2: number;
  97167. /** @hidden */
  97168. _currentVelocityGradient: Nullable<FactorGradient>;
  97169. /** @hidden */
  97170. _currentVelocity1: number;
  97171. /** @hidden */
  97172. _currentVelocity2: number;
  97173. /** @hidden */
  97174. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  97175. /** @hidden */
  97176. _currentLimitVelocity1: number;
  97177. /** @hidden */
  97178. _currentLimitVelocity2: number;
  97179. /** @hidden */
  97180. _currentDragGradient: Nullable<FactorGradient>;
  97181. /** @hidden */
  97182. _currentDrag1: number;
  97183. /** @hidden */
  97184. _currentDrag2: number;
  97185. /** @hidden */
  97186. _randomNoiseCoordinates1: Vector3;
  97187. /** @hidden */
  97188. _randomNoiseCoordinates2: Vector3;
  97189. /** @hidden */
  97190. _localPosition?: Vector3;
  97191. /**
  97192. * Creates a new instance Particle
  97193. * @param particleSystem the particle system the particle belongs to
  97194. */
  97195. constructor(
  97196. /**
  97197. * The particle system the particle belongs to.
  97198. */
  97199. particleSystem: ParticleSystem);
  97200. private updateCellInfoFromSystem;
  97201. /**
  97202. * Defines how the sprite cell index is updated for the particle
  97203. */
  97204. updateCellIndex(): void;
  97205. /** @hidden */
  97206. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  97207. /** @hidden */
  97208. _inheritParticleInfoToSubEmitters(): void;
  97209. /** @hidden */
  97210. _reset(): void;
  97211. /**
  97212. * Copy the properties of particle to another one.
  97213. * @param other the particle to copy the information to.
  97214. */
  97215. copyTo(other: Particle): void;
  97216. }
  97217. }
  97218. declare module BABYLON {
  97219. /**
  97220. * Particle emitter represents a volume emitting particles.
  97221. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  97222. */
  97223. export interface IParticleEmitterType {
  97224. /**
  97225. * Called by the particle System when the direction is computed for the created particle.
  97226. * @param worldMatrix is the world matrix of the particle system
  97227. * @param directionToUpdate is the direction vector to update with the result
  97228. * @param particle is the particle we are computed the direction for
  97229. * @param isLocal defines if the direction should be set in local space
  97230. */
  97231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97232. /**
  97233. * Called by the particle System when the position is computed for the created particle.
  97234. * @param worldMatrix is the world matrix of the particle system
  97235. * @param positionToUpdate is the position vector to update with the result
  97236. * @param particle is the particle we are computed the position for
  97237. * @param isLocal defines if the position should be set in local space
  97238. */
  97239. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97240. /**
  97241. * Clones the current emitter and returns a copy of it
  97242. * @returns the new emitter
  97243. */
  97244. clone(): IParticleEmitterType;
  97245. /**
  97246. * Called by the GPUParticleSystem to setup the update shader
  97247. * @param effect defines the update shader
  97248. */
  97249. applyToShader(effect: Effect): void;
  97250. /**
  97251. * Returns a string to use to update the GPU particles update shader
  97252. * @returns the effect defines string
  97253. */
  97254. getEffectDefines(): string;
  97255. /**
  97256. * Returns a string representing the class name
  97257. * @returns a string containing the class name
  97258. */
  97259. getClassName(): string;
  97260. /**
  97261. * Serializes the particle system to a JSON object.
  97262. * @returns the JSON object
  97263. */
  97264. serialize(): any;
  97265. /**
  97266. * Parse properties from a JSON object
  97267. * @param serializationObject defines the JSON object
  97268. * @param scene defines the hosting scene
  97269. */
  97270. parse(serializationObject: any, scene: Nullable<Scene>): void;
  97271. }
  97272. }
  97273. declare module BABYLON {
  97274. /**
  97275. * Particle emitter emitting particles from the inside of a box.
  97276. * It emits the particles randomly between 2 given directions.
  97277. */
  97278. export class BoxParticleEmitter implements IParticleEmitterType {
  97279. /**
  97280. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97281. */
  97282. direction1: Vector3;
  97283. /**
  97284. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97285. */
  97286. direction2: Vector3;
  97287. /**
  97288. * 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.
  97289. */
  97290. minEmitBox: Vector3;
  97291. /**
  97292. * 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.
  97293. */
  97294. maxEmitBox: Vector3;
  97295. /**
  97296. * Creates a new instance BoxParticleEmitter
  97297. */
  97298. constructor();
  97299. /**
  97300. * Called by the particle System when the direction is computed for the created particle.
  97301. * @param worldMatrix is the world matrix of the particle system
  97302. * @param directionToUpdate is the direction vector to update with the result
  97303. * @param particle is the particle we are computed the direction for
  97304. * @param isLocal defines if the direction should be set in local space
  97305. */
  97306. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97307. /**
  97308. * Called by the particle System when the position is computed for the created particle.
  97309. * @param worldMatrix is the world matrix of the particle system
  97310. * @param positionToUpdate is the position vector to update with the result
  97311. * @param particle is the particle we are computed the position for
  97312. * @param isLocal defines if the position should be set in local space
  97313. */
  97314. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97315. /**
  97316. * Clones the current emitter and returns a copy of it
  97317. * @returns the new emitter
  97318. */
  97319. clone(): BoxParticleEmitter;
  97320. /**
  97321. * Called by the GPUParticleSystem to setup the update shader
  97322. * @param effect defines the update shader
  97323. */
  97324. applyToShader(effect: Effect): void;
  97325. /**
  97326. * Returns a string to use to update the GPU particles update shader
  97327. * @returns a string containng the defines string
  97328. */
  97329. getEffectDefines(): string;
  97330. /**
  97331. * Returns the string "BoxParticleEmitter"
  97332. * @returns a string containing the class name
  97333. */
  97334. getClassName(): string;
  97335. /**
  97336. * Serializes the particle system to a JSON object.
  97337. * @returns the JSON object
  97338. */
  97339. serialize(): any;
  97340. /**
  97341. * Parse properties from a JSON object
  97342. * @param serializationObject defines the JSON object
  97343. */
  97344. parse(serializationObject: any): void;
  97345. }
  97346. }
  97347. declare module BABYLON {
  97348. /**
  97349. * Particle emitter emitting particles from the inside of a cone.
  97350. * It emits the particles alongside the cone volume from the base to the particle.
  97351. * The emission direction might be randomized.
  97352. */
  97353. export class ConeParticleEmitter implements IParticleEmitterType {
  97354. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97355. directionRandomizer: number;
  97356. private _radius;
  97357. private _angle;
  97358. private _height;
  97359. /**
  97360. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  97361. */
  97362. radiusRange: number;
  97363. /**
  97364. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  97365. */
  97366. heightRange: number;
  97367. /**
  97368. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  97369. */
  97370. emitFromSpawnPointOnly: boolean;
  97371. /**
  97372. * Gets or sets the radius of the emission cone
  97373. */
  97374. get radius(): number;
  97375. set radius(value: number);
  97376. /**
  97377. * Gets or sets the angle of the emission cone
  97378. */
  97379. get angle(): number;
  97380. set angle(value: number);
  97381. private _buildHeight;
  97382. /**
  97383. * Creates a new instance ConeParticleEmitter
  97384. * @param radius the radius of the emission cone (1 by default)
  97385. * @param angle the cone base angle (PI by default)
  97386. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  97387. */
  97388. constructor(radius?: number, angle?: number,
  97389. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  97390. directionRandomizer?: number);
  97391. /**
  97392. * Called by the particle System when the direction is computed for the created particle.
  97393. * @param worldMatrix is the world matrix of the particle system
  97394. * @param directionToUpdate is the direction vector to update with the result
  97395. * @param particle is the particle we are computed the direction for
  97396. * @param isLocal defines if the direction should be set in local space
  97397. */
  97398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97399. /**
  97400. * Called by the particle System when the position is computed for the created particle.
  97401. * @param worldMatrix is the world matrix of the particle system
  97402. * @param positionToUpdate is the position vector to update with the result
  97403. * @param particle is the particle we are computed the position for
  97404. * @param isLocal defines if the position should be set in local space
  97405. */
  97406. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97407. /**
  97408. * Clones the current emitter and returns a copy of it
  97409. * @returns the new emitter
  97410. */
  97411. clone(): ConeParticleEmitter;
  97412. /**
  97413. * Called by the GPUParticleSystem to setup the update shader
  97414. * @param effect defines the update shader
  97415. */
  97416. applyToShader(effect: Effect): void;
  97417. /**
  97418. * Returns a string to use to update the GPU particles update shader
  97419. * @returns a string containng the defines string
  97420. */
  97421. getEffectDefines(): string;
  97422. /**
  97423. * Returns the string "ConeParticleEmitter"
  97424. * @returns a string containing the class name
  97425. */
  97426. getClassName(): string;
  97427. /**
  97428. * Serializes the particle system to a JSON object.
  97429. * @returns the JSON object
  97430. */
  97431. serialize(): any;
  97432. /**
  97433. * Parse properties from a JSON object
  97434. * @param serializationObject defines the JSON object
  97435. */
  97436. parse(serializationObject: any): void;
  97437. }
  97438. }
  97439. declare module BABYLON {
  97440. /**
  97441. * Particle emitter emitting particles from the inside of a cylinder.
  97442. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  97443. */
  97444. export class CylinderParticleEmitter implements IParticleEmitterType {
  97445. /**
  97446. * The radius of the emission cylinder.
  97447. */
  97448. radius: number;
  97449. /**
  97450. * The height of the emission cylinder.
  97451. */
  97452. height: number;
  97453. /**
  97454. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97455. */
  97456. radiusRange: number;
  97457. /**
  97458. * How much to randomize the particle direction [0-1].
  97459. */
  97460. directionRandomizer: number;
  97461. /**
  97462. * Creates a new instance CylinderParticleEmitter
  97463. * @param radius the radius of the emission cylinder (1 by default)
  97464. * @param height the height of the emission cylinder (1 by default)
  97465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97466. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97467. */
  97468. constructor(
  97469. /**
  97470. * The radius of the emission cylinder.
  97471. */
  97472. radius?: number,
  97473. /**
  97474. * The height of the emission cylinder.
  97475. */
  97476. height?: number,
  97477. /**
  97478. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97479. */
  97480. radiusRange?: number,
  97481. /**
  97482. * How much to randomize the particle direction [0-1].
  97483. */
  97484. directionRandomizer?: number);
  97485. /**
  97486. * Called by the particle System when the direction is computed for the created particle.
  97487. * @param worldMatrix is the world matrix of the particle system
  97488. * @param directionToUpdate is the direction vector to update with the result
  97489. * @param particle is the particle we are computed the direction for
  97490. * @param isLocal defines if the direction should be set in local space
  97491. */
  97492. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97493. /**
  97494. * Called by the particle System when the position is computed for the created particle.
  97495. * @param worldMatrix is the world matrix of the particle system
  97496. * @param positionToUpdate is the position vector to update with the result
  97497. * @param particle is the particle we are computed the position for
  97498. * @param isLocal defines if the position should be set in local space
  97499. */
  97500. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97501. /**
  97502. * Clones the current emitter and returns a copy of it
  97503. * @returns the new emitter
  97504. */
  97505. clone(): CylinderParticleEmitter;
  97506. /**
  97507. * Called by the GPUParticleSystem to setup the update shader
  97508. * @param effect defines the update shader
  97509. */
  97510. applyToShader(effect: Effect): void;
  97511. /**
  97512. * Returns a string to use to update the GPU particles update shader
  97513. * @returns a string containng the defines string
  97514. */
  97515. getEffectDefines(): string;
  97516. /**
  97517. * Returns the string "CylinderParticleEmitter"
  97518. * @returns a string containing the class name
  97519. */
  97520. getClassName(): string;
  97521. /**
  97522. * Serializes the particle system to a JSON object.
  97523. * @returns the JSON object
  97524. */
  97525. serialize(): any;
  97526. /**
  97527. * Parse properties from a JSON object
  97528. * @param serializationObject defines the JSON object
  97529. */
  97530. parse(serializationObject: any): void;
  97531. }
  97532. /**
  97533. * Particle emitter emitting particles from the inside of a cylinder.
  97534. * It emits the particles randomly between two vectors.
  97535. */
  97536. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  97537. /**
  97538. * The min limit of the emission direction.
  97539. */
  97540. direction1: Vector3;
  97541. /**
  97542. * The max limit of the emission direction.
  97543. */
  97544. direction2: Vector3;
  97545. /**
  97546. * Creates a new instance CylinderDirectedParticleEmitter
  97547. * @param radius the radius of the emission cylinder (1 by default)
  97548. * @param height the height of the emission cylinder (1 by default)
  97549. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97550. * @param direction1 the min limit of the emission direction (up vector by default)
  97551. * @param direction2 the max limit of the emission direction (up vector by default)
  97552. */
  97553. constructor(radius?: number, height?: number, radiusRange?: number,
  97554. /**
  97555. * The min limit of the emission direction.
  97556. */
  97557. direction1?: Vector3,
  97558. /**
  97559. * The max limit of the emission direction.
  97560. */
  97561. direction2?: Vector3);
  97562. /**
  97563. * Called by the particle System when the direction is computed for the created particle.
  97564. * @param worldMatrix is the world matrix of the particle system
  97565. * @param directionToUpdate is the direction vector to update with the result
  97566. * @param particle is the particle we are computed the direction for
  97567. */
  97568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97569. /**
  97570. * Clones the current emitter and returns a copy of it
  97571. * @returns the new emitter
  97572. */
  97573. clone(): CylinderDirectedParticleEmitter;
  97574. /**
  97575. * Called by the GPUParticleSystem to setup the update shader
  97576. * @param effect defines the update shader
  97577. */
  97578. applyToShader(effect: Effect): void;
  97579. /**
  97580. * Returns a string to use to update the GPU particles update shader
  97581. * @returns a string containng the defines string
  97582. */
  97583. getEffectDefines(): string;
  97584. /**
  97585. * Returns the string "CylinderDirectedParticleEmitter"
  97586. * @returns a string containing the class name
  97587. */
  97588. getClassName(): string;
  97589. /**
  97590. * Serializes the particle system to a JSON object.
  97591. * @returns the JSON object
  97592. */
  97593. serialize(): any;
  97594. /**
  97595. * Parse properties from a JSON object
  97596. * @param serializationObject defines the JSON object
  97597. */
  97598. parse(serializationObject: any): void;
  97599. }
  97600. }
  97601. declare module BABYLON {
  97602. /**
  97603. * Particle emitter emitting particles from the inside of a hemisphere.
  97604. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  97605. */
  97606. export class HemisphericParticleEmitter implements IParticleEmitterType {
  97607. /**
  97608. * The radius of the emission hemisphere.
  97609. */
  97610. radius: number;
  97611. /**
  97612. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97613. */
  97614. radiusRange: number;
  97615. /**
  97616. * How much to randomize the particle direction [0-1].
  97617. */
  97618. directionRandomizer: number;
  97619. /**
  97620. * Creates a new instance HemisphericParticleEmitter
  97621. * @param radius the radius of the emission hemisphere (1 by default)
  97622. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97623. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97624. */
  97625. constructor(
  97626. /**
  97627. * The radius of the emission hemisphere.
  97628. */
  97629. radius?: number,
  97630. /**
  97631. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97632. */
  97633. radiusRange?: number,
  97634. /**
  97635. * How much to randomize the particle direction [0-1].
  97636. */
  97637. directionRandomizer?: number);
  97638. /**
  97639. * Called by the particle System when the direction is computed for the created particle.
  97640. * @param worldMatrix is the world matrix of the particle system
  97641. * @param directionToUpdate is the direction vector to update with the result
  97642. * @param particle is the particle we are computed the direction for
  97643. * @param isLocal defines if the direction should be set in local space
  97644. */
  97645. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97646. /**
  97647. * Called by the particle System when the position is computed for the created particle.
  97648. * @param worldMatrix is the world matrix of the particle system
  97649. * @param positionToUpdate is the position vector to update with the result
  97650. * @param particle is the particle we are computed the position for
  97651. * @param isLocal defines if the position should be set in local space
  97652. */
  97653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97654. /**
  97655. * Clones the current emitter and returns a copy of it
  97656. * @returns the new emitter
  97657. */
  97658. clone(): HemisphericParticleEmitter;
  97659. /**
  97660. * Called by the GPUParticleSystem to setup the update shader
  97661. * @param effect defines the update shader
  97662. */
  97663. applyToShader(effect: Effect): void;
  97664. /**
  97665. * Returns a string to use to update the GPU particles update shader
  97666. * @returns a string containng the defines string
  97667. */
  97668. getEffectDefines(): string;
  97669. /**
  97670. * Returns the string "HemisphericParticleEmitter"
  97671. * @returns a string containing the class name
  97672. */
  97673. getClassName(): string;
  97674. /**
  97675. * Serializes the particle system to a JSON object.
  97676. * @returns the JSON object
  97677. */
  97678. serialize(): any;
  97679. /**
  97680. * Parse properties from a JSON object
  97681. * @param serializationObject defines the JSON object
  97682. */
  97683. parse(serializationObject: any): void;
  97684. }
  97685. }
  97686. declare module BABYLON {
  97687. /**
  97688. * Particle emitter emitting particles from a point.
  97689. * It emits the particles randomly between 2 given directions.
  97690. */
  97691. export class PointParticleEmitter implements IParticleEmitterType {
  97692. /**
  97693. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97694. */
  97695. direction1: Vector3;
  97696. /**
  97697. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97698. */
  97699. direction2: Vector3;
  97700. /**
  97701. * Creates a new instance PointParticleEmitter
  97702. */
  97703. constructor();
  97704. /**
  97705. * Called by the particle System when the direction is computed for the created particle.
  97706. * @param worldMatrix is the world matrix of the particle system
  97707. * @param directionToUpdate is the direction vector to update with the result
  97708. * @param particle is the particle we are computed the direction for
  97709. * @param isLocal defines if the direction should be set in local space
  97710. */
  97711. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97712. /**
  97713. * Called by the particle System when the position is computed for the created particle.
  97714. * @param worldMatrix is the world matrix of the particle system
  97715. * @param positionToUpdate is the position vector to update with the result
  97716. * @param particle is the particle we are computed the position for
  97717. * @param isLocal defines if the position should be set in local space
  97718. */
  97719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97720. /**
  97721. * Clones the current emitter and returns a copy of it
  97722. * @returns the new emitter
  97723. */
  97724. clone(): PointParticleEmitter;
  97725. /**
  97726. * Called by the GPUParticleSystem to setup the update shader
  97727. * @param effect defines the update shader
  97728. */
  97729. applyToShader(effect: Effect): void;
  97730. /**
  97731. * Returns a string to use to update the GPU particles update shader
  97732. * @returns a string containng the defines string
  97733. */
  97734. getEffectDefines(): string;
  97735. /**
  97736. * Returns the string "PointParticleEmitter"
  97737. * @returns a string containing the class name
  97738. */
  97739. getClassName(): string;
  97740. /**
  97741. * Serializes the particle system to a JSON object.
  97742. * @returns the JSON object
  97743. */
  97744. serialize(): any;
  97745. /**
  97746. * Parse properties from a JSON object
  97747. * @param serializationObject defines the JSON object
  97748. */
  97749. parse(serializationObject: any): void;
  97750. }
  97751. }
  97752. declare module BABYLON {
  97753. /**
  97754. * Particle emitter emitting particles from the inside of a sphere.
  97755. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  97756. */
  97757. export class SphereParticleEmitter implements IParticleEmitterType {
  97758. /**
  97759. * The radius of the emission sphere.
  97760. */
  97761. radius: number;
  97762. /**
  97763. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97764. */
  97765. radiusRange: number;
  97766. /**
  97767. * How much to randomize the particle direction [0-1].
  97768. */
  97769. directionRandomizer: number;
  97770. /**
  97771. * Creates a new instance SphereParticleEmitter
  97772. * @param radius the radius of the emission sphere (1 by default)
  97773. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  97774. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  97775. */
  97776. constructor(
  97777. /**
  97778. * The radius of the emission sphere.
  97779. */
  97780. radius?: number,
  97781. /**
  97782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  97783. */
  97784. radiusRange?: number,
  97785. /**
  97786. * How much to randomize the particle direction [0-1].
  97787. */
  97788. directionRandomizer?: number);
  97789. /**
  97790. * Called by the particle System when the direction is computed for the created particle.
  97791. * @param worldMatrix is the world matrix of the particle system
  97792. * @param directionToUpdate is the direction vector to update with the result
  97793. * @param particle is the particle we are computed the direction for
  97794. * @param isLocal defines if the direction should be set in local space
  97795. */
  97796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97797. /**
  97798. * Called by the particle System when the position is computed for the created particle.
  97799. * @param worldMatrix is the world matrix of the particle system
  97800. * @param positionToUpdate is the position vector to update with the result
  97801. * @param particle is the particle we are computed the position for
  97802. * @param isLocal defines if the position should be set in local space
  97803. */
  97804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97805. /**
  97806. * Clones the current emitter and returns a copy of it
  97807. * @returns the new emitter
  97808. */
  97809. clone(): SphereParticleEmitter;
  97810. /**
  97811. * Called by the GPUParticleSystem to setup the update shader
  97812. * @param effect defines the update shader
  97813. */
  97814. applyToShader(effect: Effect): void;
  97815. /**
  97816. * Returns a string to use to update the GPU particles update shader
  97817. * @returns a string containng the defines string
  97818. */
  97819. getEffectDefines(): string;
  97820. /**
  97821. * Returns the string "SphereParticleEmitter"
  97822. * @returns a string containing the class name
  97823. */
  97824. getClassName(): string;
  97825. /**
  97826. * Serializes the particle system to a JSON object.
  97827. * @returns the JSON object
  97828. */
  97829. serialize(): any;
  97830. /**
  97831. * Parse properties from a JSON object
  97832. * @param serializationObject defines the JSON object
  97833. */
  97834. parse(serializationObject: any): void;
  97835. }
  97836. /**
  97837. * Particle emitter emitting particles from the inside of a sphere.
  97838. * It emits the particles randomly between two vectors.
  97839. */
  97840. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  97841. /**
  97842. * The min limit of the emission direction.
  97843. */
  97844. direction1: Vector3;
  97845. /**
  97846. * The max limit of the emission direction.
  97847. */
  97848. direction2: Vector3;
  97849. /**
  97850. * Creates a new instance SphereDirectedParticleEmitter
  97851. * @param radius the radius of the emission sphere (1 by default)
  97852. * @param direction1 the min limit of the emission direction (up vector by default)
  97853. * @param direction2 the max limit of the emission direction (up vector by default)
  97854. */
  97855. constructor(radius?: number,
  97856. /**
  97857. * The min limit of the emission direction.
  97858. */
  97859. direction1?: Vector3,
  97860. /**
  97861. * The max limit of the emission direction.
  97862. */
  97863. direction2?: Vector3);
  97864. /**
  97865. * Called by the particle System when the direction is computed for the created particle.
  97866. * @param worldMatrix is the world matrix of the particle system
  97867. * @param directionToUpdate is the direction vector to update with the result
  97868. * @param particle is the particle we are computed the direction for
  97869. */
  97870. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  97871. /**
  97872. * Clones the current emitter and returns a copy of it
  97873. * @returns the new emitter
  97874. */
  97875. clone(): SphereDirectedParticleEmitter;
  97876. /**
  97877. * Called by the GPUParticleSystem to setup the update shader
  97878. * @param effect defines the update shader
  97879. */
  97880. applyToShader(effect: Effect): void;
  97881. /**
  97882. * Returns a string to use to update the GPU particles update shader
  97883. * @returns a string containng the defines string
  97884. */
  97885. getEffectDefines(): string;
  97886. /**
  97887. * Returns the string "SphereDirectedParticleEmitter"
  97888. * @returns a string containing the class name
  97889. */
  97890. getClassName(): string;
  97891. /**
  97892. * Serializes the particle system to a JSON object.
  97893. * @returns the JSON object
  97894. */
  97895. serialize(): any;
  97896. /**
  97897. * Parse properties from a JSON object
  97898. * @param serializationObject defines the JSON object
  97899. */
  97900. parse(serializationObject: any): void;
  97901. }
  97902. }
  97903. declare module BABYLON {
  97904. /**
  97905. * Particle emitter emitting particles from a custom list of positions.
  97906. */
  97907. export class CustomParticleEmitter implements IParticleEmitterType {
  97908. /**
  97909. * Gets or sets the position generator that will create the inital position of each particle.
  97910. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97911. */
  97912. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  97913. /**
  97914. * Gets or sets the destination generator that will create the final destination of each particle.
  97915. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  97916. */
  97917. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  97918. /**
  97919. * Creates a new instance CustomParticleEmitter
  97920. */
  97921. constructor();
  97922. /**
  97923. * Called by the particle System when the direction is computed for the created particle.
  97924. * @param worldMatrix is the world matrix of the particle system
  97925. * @param directionToUpdate is the direction vector to update with the result
  97926. * @param particle is the particle we are computed the direction for
  97927. * @param isLocal defines if the direction should be set in local space
  97928. */
  97929. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97930. /**
  97931. * Called by the particle System when the position is computed for the created particle.
  97932. * @param worldMatrix is the world matrix of the particle system
  97933. * @param positionToUpdate is the position vector to update with the result
  97934. * @param particle is the particle we are computed the position for
  97935. * @param isLocal defines if the position should be set in local space
  97936. */
  97937. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  97938. /**
  97939. * Clones the current emitter and returns a copy of it
  97940. * @returns the new emitter
  97941. */
  97942. clone(): CustomParticleEmitter;
  97943. /**
  97944. * Called by the GPUParticleSystem to setup the update shader
  97945. * @param effect defines the update shader
  97946. */
  97947. applyToShader(effect: Effect): void;
  97948. /**
  97949. * Returns a string to use to update the GPU particles update shader
  97950. * @returns a string containng the defines string
  97951. */
  97952. getEffectDefines(): string;
  97953. /**
  97954. * Returns the string "PointParticleEmitter"
  97955. * @returns a string containing the class name
  97956. */
  97957. getClassName(): string;
  97958. /**
  97959. * Serializes the particle system to a JSON object.
  97960. * @returns the JSON object
  97961. */
  97962. serialize(): any;
  97963. /**
  97964. * Parse properties from a JSON object
  97965. * @param serializationObject defines the JSON object
  97966. */
  97967. parse(serializationObject: any): void;
  97968. }
  97969. }
  97970. declare module BABYLON {
  97971. /**
  97972. * Particle emitter emitting particles from the inside of a box.
  97973. * It emits the particles randomly between 2 given directions.
  97974. */
  97975. export class MeshParticleEmitter implements IParticleEmitterType {
  97976. private _indices;
  97977. private _positions;
  97978. private _normals;
  97979. private _storedNormal;
  97980. private _mesh;
  97981. /**
  97982. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97983. */
  97984. direction1: Vector3;
  97985. /**
  97986. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  97987. */
  97988. direction2: Vector3;
  97989. /**
  97990. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  97991. */
  97992. useMeshNormalsForDirection: boolean;
  97993. /** Defines the mesh to use as source */
  97994. get mesh(): Nullable<AbstractMesh>;
  97995. set mesh(value: Nullable<AbstractMesh>);
  97996. /**
  97997. * Creates a new instance MeshParticleEmitter
  97998. * @param mesh defines the mesh to use as source
  97999. */
  98000. constructor(mesh?: Nullable<AbstractMesh>);
  98001. /**
  98002. * Called by the particle System when the direction is computed for the created particle.
  98003. * @param worldMatrix is the world matrix of the particle system
  98004. * @param directionToUpdate is the direction vector to update with the result
  98005. * @param particle is the particle we are computed the direction for
  98006. * @param isLocal defines if the direction should be set in local space
  98007. */
  98008. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98009. /**
  98010. * Called by the particle System when the position is computed for the created particle.
  98011. * @param worldMatrix is the world matrix of the particle system
  98012. * @param positionToUpdate is the position vector to update with the result
  98013. * @param particle is the particle we are computed the position for
  98014. * @param isLocal defines if the position should be set in local space
  98015. */
  98016. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  98017. /**
  98018. * Clones the current emitter and returns a copy of it
  98019. * @returns the new emitter
  98020. */
  98021. clone(): MeshParticleEmitter;
  98022. /**
  98023. * Called by the GPUParticleSystem to setup the update shader
  98024. * @param effect defines the update shader
  98025. */
  98026. applyToShader(effect: Effect): void;
  98027. /**
  98028. * Returns a string to use to update the GPU particles update shader
  98029. * @returns a string containng the defines string
  98030. */
  98031. getEffectDefines(): string;
  98032. /**
  98033. * Returns the string "BoxParticleEmitter"
  98034. * @returns a string containing the class name
  98035. */
  98036. getClassName(): string;
  98037. /**
  98038. * Serializes the particle system to a JSON object.
  98039. * @returns the JSON object
  98040. */
  98041. serialize(): any;
  98042. /**
  98043. * Parse properties from a JSON object
  98044. * @param serializationObject defines the JSON object
  98045. * @param scene defines the hosting scene
  98046. */
  98047. parse(serializationObject: any, scene: Nullable<Scene>): void;
  98048. }
  98049. }
  98050. declare module BABYLON {
  98051. /**
  98052. * Interface representing a particle system in Babylon.js.
  98053. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  98054. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  98055. */
  98056. export interface IParticleSystem {
  98057. /**
  98058. * List of animations used by the particle system.
  98059. */
  98060. animations: Animation[];
  98061. /**
  98062. * The id of the Particle system.
  98063. */
  98064. id: string;
  98065. /**
  98066. * The name of the Particle system.
  98067. */
  98068. name: string;
  98069. /**
  98070. * The emitter represents the Mesh or position we are attaching the particle system to.
  98071. */
  98072. emitter: Nullable<AbstractMesh | Vector3>;
  98073. /**
  98074. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  98075. */
  98076. isBillboardBased: boolean;
  98077. /**
  98078. * The rendering group used by the Particle system to chose when to render.
  98079. */
  98080. renderingGroupId: number;
  98081. /**
  98082. * The layer mask we are rendering the particles through.
  98083. */
  98084. layerMask: number;
  98085. /**
  98086. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  98087. */
  98088. updateSpeed: number;
  98089. /**
  98090. * The amount of time the particle system is running (depends of the overall update speed).
  98091. */
  98092. targetStopDuration: number;
  98093. /**
  98094. * The texture used to render each particle. (this can be a spritesheet)
  98095. */
  98096. particleTexture: Nullable<BaseTexture>;
  98097. /**
  98098. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  98099. */
  98100. blendMode: number;
  98101. /**
  98102. * Minimum life time of emitting particles.
  98103. */
  98104. minLifeTime: number;
  98105. /**
  98106. * Maximum life time of emitting particles.
  98107. */
  98108. maxLifeTime: number;
  98109. /**
  98110. * Minimum Size of emitting particles.
  98111. */
  98112. minSize: number;
  98113. /**
  98114. * Maximum Size of emitting particles.
  98115. */
  98116. maxSize: number;
  98117. /**
  98118. * Minimum scale of emitting particles on X axis.
  98119. */
  98120. minScaleX: number;
  98121. /**
  98122. * Maximum scale of emitting particles on X axis.
  98123. */
  98124. maxScaleX: number;
  98125. /**
  98126. * Minimum scale of emitting particles on Y axis.
  98127. */
  98128. minScaleY: number;
  98129. /**
  98130. * Maximum scale of emitting particles on Y axis.
  98131. */
  98132. maxScaleY: number;
  98133. /**
  98134. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98135. */
  98136. color1: Color4;
  98137. /**
  98138. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  98139. */
  98140. color2: Color4;
  98141. /**
  98142. * Color the particle will have at the end of its lifetime.
  98143. */
  98144. colorDead: Color4;
  98145. /**
  98146. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  98147. */
  98148. emitRate: number;
  98149. /**
  98150. * You can use gravity if you want to give an orientation to your particles.
  98151. */
  98152. gravity: Vector3;
  98153. /**
  98154. * Minimum power of emitting particles.
  98155. */
  98156. minEmitPower: number;
  98157. /**
  98158. * Maximum power of emitting particles.
  98159. */
  98160. maxEmitPower: number;
  98161. /**
  98162. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  98163. */
  98164. minAngularSpeed: number;
  98165. /**
  98166. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  98167. */
  98168. maxAngularSpeed: number;
  98169. /**
  98170. * Gets or sets the minimal initial rotation in radians.
  98171. */
  98172. minInitialRotation: number;
  98173. /**
  98174. * Gets or sets the maximal initial rotation in radians.
  98175. */
  98176. maxInitialRotation: number;
  98177. /**
  98178. * The particle emitter type defines the emitter used by the particle system.
  98179. * It can be for example box, sphere, or cone...
  98180. */
  98181. particleEmitterType: Nullable<IParticleEmitterType>;
  98182. /**
  98183. * Defines the delay in milliseconds before starting the system (0 by default)
  98184. */
  98185. startDelay: number;
  98186. /**
  98187. * 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
  98188. */
  98189. preWarmCycles: number;
  98190. /**
  98191. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  98192. */
  98193. preWarmStepOffset: number;
  98194. /**
  98195. * 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)
  98196. */
  98197. spriteCellChangeSpeed: number;
  98198. /**
  98199. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  98200. */
  98201. startSpriteCellID: number;
  98202. /**
  98203. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  98204. */
  98205. endSpriteCellID: number;
  98206. /**
  98207. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  98208. */
  98209. spriteCellWidth: number;
  98210. /**
  98211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  98212. */
  98213. spriteCellHeight: number;
  98214. /**
  98215. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  98216. */
  98217. spriteRandomStartCell: boolean;
  98218. /**
  98219. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  98220. */
  98221. isAnimationSheetEnabled: boolean;
  98222. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  98223. translationPivot: Vector2;
  98224. /**
  98225. * Gets or sets a texture used to add random noise to particle positions
  98226. */
  98227. noiseTexture: Nullable<BaseTexture>;
  98228. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  98229. noiseStrength: Vector3;
  98230. /**
  98231. * Gets or sets the billboard mode to use when isBillboardBased = true.
  98232. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  98233. */
  98234. billboardMode: number;
  98235. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  98236. limitVelocityDamping: number;
  98237. /**
  98238. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  98239. */
  98240. beginAnimationOnStart: boolean;
  98241. /**
  98242. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  98243. */
  98244. beginAnimationFrom: number;
  98245. /**
  98246. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  98247. */
  98248. beginAnimationTo: number;
  98249. /**
  98250. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  98251. */
  98252. beginAnimationLoop: boolean;
  98253. /**
  98254. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  98255. */
  98256. disposeOnStop: boolean;
  98257. /**
  98258. * Specifies if the particles are updated in emitter local space or world space
  98259. */
  98260. isLocal: boolean;
  98261. /** Snippet ID if the particle system was created from the snippet server */
  98262. snippetId: string;
  98263. /** Gets or sets a matrix to use to compute projection */
  98264. defaultProjectionMatrix: Matrix;
  98265. /**
  98266. * Gets the maximum number of particles active at the same time.
  98267. * @returns The max number of active particles.
  98268. */
  98269. getCapacity(): number;
  98270. /**
  98271. * Gets the number of particles active at the same time.
  98272. * @returns The number of active particles.
  98273. */
  98274. getActiveCount(): number;
  98275. /**
  98276. * Gets if the system has been started. (Note: this will still be true after stop is called)
  98277. * @returns True if it has been started, otherwise false.
  98278. */
  98279. isStarted(): boolean;
  98280. /**
  98281. * Animates the particle system for this frame.
  98282. */
  98283. animate(): void;
  98284. /**
  98285. * Renders the particle system in its current state.
  98286. * @returns the current number of particles
  98287. */
  98288. render(): number;
  98289. /**
  98290. * Dispose the particle system and frees its associated resources.
  98291. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  98292. */
  98293. dispose(disposeTexture?: boolean): void;
  98294. /**
  98295. * An event triggered when the system is disposed
  98296. */
  98297. onDisposeObservable: Observable<IParticleSystem>;
  98298. /**
  98299. * An event triggered when the system is stopped
  98300. */
  98301. onStoppedObservable: Observable<IParticleSystem>;
  98302. /**
  98303. * Clones the particle system.
  98304. * @param name The name of the cloned object
  98305. * @param newEmitter The new emitter to use
  98306. * @returns the cloned particle system
  98307. */
  98308. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  98309. /**
  98310. * Serializes the particle system to a JSON object
  98311. * @param serializeTexture defines if the texture must be serialized as well
  98312. * @returns the JSON object
  98313. */
  98314. serialize(serializeTexture: boolean): any;
  98315. /**
  98316. * Rebuild the particle system
  98317. */
  98318. rebuild(): void;
  98319. /** Force the system to rebuild all gradients that need to be resync */
  98320. forceRefreshGradients(): void;
  98321. /**
  98322. * Starts the particle system and begins to emit
  98323. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  98324. */
  98325. start(delay?: number): void;
  98326. /**
  98327. * Stops the particle system.
  98328. */
  98329. stop(): void;
  98330. /**
  98331. * Remove all active particles
  98332. */
  98333. reset(): void;
  98334. /**
  98335. * Gets a boolean indicating that the system is stopping
  98336. * @returns true if the system is currently stopping
  98337. */
  98338. isStopping(): boolean;
  98339. /**
  98340. * Is this system ready to be used/rendered
  98341. * @return true if the system is ready
  98342. */
  98343. isReady(): boolean;
  98344. /**
  98345. * Returns the string "ParticleSystem"
  98346. * @returns a string containing the class name
  98347. */
  98348. getClassName(): string;
  98349. /**
  98350. * Gets the custom effect used to render the particles
  98351. * @param blendMode Blend mode for which the effect should be retrieved
  98352. * @returns The effect
  98353. */
  98354. getCustomEffect(blendMode: number): Nullable<Effect>;
  98355. /**
  98356. * Sets the custom effect used to render the particles
  98357. * @param effect The effect to set
  98358. * @param blendMode Blend mode for which the effect should be set
  98359. */
  98360. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  98361. /**
  98362. * Fill the defines array according to the current settings of the particle system
  98363. * @param defines Array to be updated
  98364. * @param blendMode blend mode to take into account when updating the array
  98365. */
  98366. fillDefines(defines: Array<string>, blendMode: number): void;
  98367. /**
  98368. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  98369. * @param uniforms Uniforms array to fill
  98370. * @param attributes Attributes array to fill
  98371. * @param samplers Samplers array to fill
  98372. */
  98373. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  98374. /**
  98375. * Observable that will be called just before the particles are drawn
  98376. */
  98377. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  98378. /**
  98379. * Gets the name of the particle vertex shader
  98380. */
  98381. vertexShaderName: string;
  98382. /**
  98383. * Adds a new color gradient
  98384. * @param gradient defines the gradient to use (between 0 and 1)
  98385. * @param color1 defines the color to affect to the specified gradient
  98386. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  98387. * @returns the current particle system
  98388. */
  98389. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  98390. /**
  98391. * Remove a specific color gradient
  98392. * @param gradient defines the gradient to remove
  98393. * @returns the current particle system
  98394. */
  98395. removeColorGradient(gradient: number): IParticleSystem;
  98396. /**
  98397. * Adds a new size gradient
  98398. * @param gradient defines the gradient to use (between 0 and 1)
  98399. * @param factor defines the size factor to affect to the specified gradient
  98400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98401. * @returns the current particle system
  98402. */
  98403. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98404. /**
  98405. * Remove a specific size gradient
  98406. * @param gradient defines the gradient to remove
  98407. * @returns the current particle system
  98408. */
  98409. removeSizeGradient(gradient: number): IParticleSystem;
  98410. /**
  98411. * Gets the current list of color gradients.
  98412. * You must use addColorGradient and removeColorGradient to udpate this list
  98413. * @returns the list of color gradients
  98414. */
  98415. getColorGradients(): Nullable<Array<ColorGradient>>;
  98416. /**
  98417. * Gets the current list of size gradients.
  98418. * You must use addSizeGradient and removeSizeGradient to udpate this list
  98419. * @returns the list of size gradients
  98420. */
  98421. getSizeGradients(): Nullable<Array<FactorGradient>>;
  98422. /**
  98423. * Gets the current list of angular speed gradients.
  98424. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  98425. * @returns the list of angular speed gradients
  98426. */
  98427. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  98428. /**
  98429. * Adds a new angular speed gradient
  98430. * @param gradient defines the gradient to use (between 0 and 1)
  98431. * @param factor defines the angular speed to affect to the specified gradient
  98432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98433. * @returns the current particle system
  98434. */
  98435. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98436. /**
  98437. * Remove a specific angular speed gradient
  98438. * @param gradient defines the gradient to remove
  98439. * @returns the current particle system
  98440. */
  98441. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  98442. /**
  98443. * Gets the current list of velocity gradients.
  98444. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  98445. * @returns the list of velocity gradients
  98446. */
  98447. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  98448. /**
  98449. * Adds a new velocity gradient
  98450. * @param gradient defines the gradient to use (between 0 and 1)
  98451. * @param factor defines the velocity to affect to the specified gradient
  98452. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98453. * @returns the current particle system
  98454. */
  98455. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98456. /**
  98457. * Remove a specific velocity gradient
  98458. * @param gradient defines the gradient to remove
  98459. * @returns the current particle system
  98460. */
  98461. removeVelocityGradient(gradient: number): IParticleSystem;
  98462. /**
  98463. * Gets the current list of limit velocity gradients.
  98464. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  98465. * @returns the list of limit velocity gradients
  98466. */
  98467. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  98468. /**
  98469. * Adds a new limit velocity gradient
  98470. * @param gradient defines the gradient to use (between 0 and 1)
  98471. * @param factor defines the limit velocity to affect to the specified gradient
  98472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98473. * @returns the current particle system
  98474. */
  98475. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98476. /**
  98477. * Remove a specific limit velocity gradient
  98478. * @param gradient defines the gradient to remove
  98479. * @returns the current particle system
  98480. */
  98481. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  98482. /**
  98483. * Adds a new drag gradient
  98484. * @param gradient defines the gradient to use (between 0 and 1)
  98485. * @param factor defines the drag to affect to the specified gradient
  98486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98487. * @returns the current particle system
  98488. */
  98489. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98490. /**
  98491. * Remove a specific drag gradient
  98492. * @param gradient defines the gradient to remove
  98493. * @returns the current particle system
  98494. */
  98495. removeDragGradient(gradient: number): IParticleSystem;
  98496. /**
  98497. * Gets the current list of drag gradients.
  98498. * You must use addDragGradient and removeDragGradient to udpate this list
  98499. * @returns the list of drag gradients
  98500. */
  98501. getDragGradients(): Nullable<Array<FactorGradient>>;
  98502. /**
  98503. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  98504. * @param gradient defines the gradient to use (between 0 and 1)
  98505. * @param factor defines the emit rate to affect to the specified gradient
  98506. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98507. * @returns the current particle system
  98508. */
  98509. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98510. /**
  98511. * Remove a specific emit rate gradient
  98512. * @param gradient defines the gradient to remove
  98513. * @returns the current particle system
  98514. */
  98515. removeEmitRateGradient(gradient: number): IParticleSystem;
  98516. /**
  98517. * Gets the current list of emit rate gradients.
  98518. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  98519. * @returns the list of emit rate gradients
  98520. */
  98521. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  98522. /**
  98523. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  98524. * @param gradient defines the gradient to use (between 0 and 1)
  98525. * @param factor defines the start size to affect to the specified gradient
  98526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98527. * @returns the current particle system
  98528. */
  98529. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98530. /**
  98531. * Remove a specific start size gradient
  98532. * @param gradient defines the gradient to remove
  98533. * @returns the current particle system
  98534. */
  98535. removeStartSizeGradient(gradient: number): IParticleSystem;
  98536. /**
  98537. * Gets the current list of start size gradients.
  98538. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  98539. * @returns the list of start size gradients
  98540. */
  98541. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  98542. /**
  98543. * Adds a new life time gradient
  98544. * @param gradient defines the gradient to use (between 0 and 1)
  98545. * @param factor defines the life time factor to affect to the specified gradient
  98546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  98547. * @returns the current particle system
  98548. */
  98549. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  98550. /**
  98551. * Remove a specific life time gradient
  98552. * @param gradient defines the gradient to remove
  98553. * @returns the current particle system
  98554. */
  98555. removeLifeTimeGradient(gradient: number): IParticleSystem;
  98556. /**
  98557. * Gets the current list of life time gradients.
  98558. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  98559. * @returns the list of life time gradients
  98560. */
  98561. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  98562. /**
  98563. * Gets the current list of color gradients.
  98564. * You must use addColorGradient and removeColorGradient to udpate this list
  98565. * @returns the list of color gradients
  98566. */
  98567. getColorGradients(): Nullable<Array<ColorGradient>>;
  98568. /**
  98569. * Adds a new ramp gradient used to remap particle colors
  98570. * @param gradient defines the gradient to use (between 0 and 1)
  98571. * @param color defines the color to affect to the specified gradient
  98572. * @returns the current particle system
  98573. */
  98574. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  98575. /**
  98576. * Gets the current list of ramp gradients.
  98577. * You must use addRampGradient and removeRampGradient to udpate this list
  98578. * @returns the list of ramp gradients
  98579. */
  98580. getRampGradients(): Nullable<Array<Color3Gradient>>;
  98581. /** Gets or sets a boolean indicating that ramp gradients must be used
  98582. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  98583. */
  98584. useRampGradients: boolean;
  98585. /**
  98586. * Adds a new color remap gradient
  98587. * @param gradient defines the gradient to use (between 0 and 1)
  98588. * @param min defines the color remap minimal range
  98589. * @param max defines the color remap maximal range
  98590. * @returns the current particle system
  98591. */
  98592. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98593. /**
  98594. * Gets the current list of color remap gradients.
  98595. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  98596. * @returns the list of color remap gradients
  98597. */
  98598. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  98599. /**
  98600. * Adds a new alpha remap gradient
  98601. * @param gradient defines the gradient to use (between 0 and 1)
  98602. * @param min defines the alpha remap minimal range
  98603. * @param max defines the alpha remap maximal range
  98604. * @returns the current particle system
  98605. */
  98606. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  98607. /**
  98608. * Gets the current list of alpha remap gradients.
  98609. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  98610. * @returns the list of alpha remap gradients
  98611. */
  98612. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  98613. /**
  98614. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  98615. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98616. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98617. * @returns the emitter
  98618. */
  98619. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  98620. /**
  98621. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  98622. * @param radius The radius of the hemisphere to emit from
  98623. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98624. * @returns the emitter
  98625. */
  98626. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  98627. /**
  98628. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  98629. * @param radius The radius of the sphere to emit from
  98630. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  98631. * @returns the emitter
  98632. */
  98633. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  98634. /**
  98635. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  98636. * @param radius The radius of the sphere to emit from
  98637. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  98638. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  98639. * @returns the emitter
  98640. */
  98641. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98642. /**
  98643. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  98644. * @param radius The radius of the emission cylinder
  98645. * @param height The height of the emission cylinder
  98646. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  98647. * @param directionRandomizer How much to randomize the particle direction [0-1]
  98648. * @returns the emitter
  98649. */
  98650. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  98651. /**
  98652. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  98653. * @param radius The radius of the cylinder to emit from
  98654. * @param height The height of the emission cylinder
  98655. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  98656. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  98657. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  98658. * @returns the emitter
  98659. */
  98660. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  98661. /**
  98662. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  98663. * @param radius The radius of the cone to emit from
  98664. * @param angle The base angle of the cone
  98665. * @returns the emitter
  98666. */
  98667. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  98668. /**
  98669. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  98670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  98671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  98672. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98673. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  98674. * @returns the emitter
  98675. */
  98676. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  98677. /**
  98678. * Get hosting scene
  98679. * @returns the scene
  98680. */
  98681. getScene(): Nullable<Scene>;
  98682. }
  98683. }
  98684. declare module BABYLON {
  98685. /**
  98686. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  98687. */
  98688. export class ColorSplitterBlock extends NodeMaterialBlock {
  98689. /**
  98690. * Create a new ColorSplitterBlock
  98691. * @param name defines the block name
  98692. */
  98693. constructor(name: string);
  98694. /**
  98695. * Gets the current class name
  98696. * @returns the class name
  98697. */
  98698. getClassName(): string;
  98699. /**
  98700. * Gets the rgba component (input)
  98701. */
  98702. get rgba(): NodeMaterialConnectionPoint;
  98703. /**
  98704. * Gets the rgb component (input)
  98705. */
  98706. get rgbIn(): NodeMaterialConnectionPoint;
  98707. /**
  98708. * Gets the rgb component (output)
  98709. */
  98710. get rgbOut(): NodeMaterialConnectionPoint;
  98711. /**
  98712. * Gets the r component (output)
  98713. */
  98714. get r(): NodeMaterialConnectionPoint;
  98715. /**
  98716. * Gets the g component (output)
  98717. */
  98718. get g(): NodeMaterialConnectionPoint;
  98719. /**
  98720. * Gets the b component (output)
  98721. */
  98722. get b(): NodeMaterialConnectionPoint;
  98723. /**
  98724. * Gets the a component (output)
  98725. */
  98726. get a(): NodeMaterialConnectionPoint;
  98727. protected _inputRename(name: string): string;
  98728. protected _outputRename(name: string): string;
  98729. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98730. }
  98731. }
  98732. declare module BABYLON {
  98733. /**
  98734. * Operations supported by the Trigonometry block
  98735. */
  98736. export enum TrigonometryBlockOperations {
  98737. /** Cos */
  98738. Cos = 0,
  98739. /** Sin */
  98740. Sin = 1,
  98741. /** Abs */
  98742. Abs = 2,
  98743. /** Exp */
  98744. Exp = 3,
  98745. /** Exp2 */
  98746. Exp2 = 4,
  98747. /** Round */
  98748. Round = 5,
  98749. /** Floor */
  98750. Floor = 6,
  98751. /** Ceiling */
  98752. Ceiling = 7,
  98753. /** Square root */
  98754. Sqrt = 8,
  98755. /** Log */
  98756. Log = 9,
  98757. /** Tangent */
  98758. Tan = 10,
  98759. /** Arc tangent */
  98760. ArcTan = 11,
  98761. /** Arc cosinus */
  98762. ArcCos = 12,
  98763. /** Arc sinus */
  98764. ArcSin = 13,
  98765. /** Fraction */
  98766. Fract = 14,
  98767. /** Sign */
  98768. Sign = 15,
  98769. /** To radians (from degrees) */
  98770. Radians = 16,
  98771. /** To degrees (from radians) */
  98772. Degrees = 17
  98773. }
  98774. /**
  98775. * Block used to apply trigonometry operation to floats
  98776. */
  98777. export class TrigonometryBlock extends NodeMaterialBlock {
  98778. /**
  98779. * Gets or sets the operation applied by the block
  98780. */
  98781. operation: TrigonometryBlockOperations;
  98782. /**
  98783. * Creates a new TrigonometryBlock
  98784. * @param name defines the block name
  98785. */
  98786. constructor(name: string);
  98787. /**
  98788. * Gets the current class name
  98789. * @returns the class name
  98790. */
  98791. getClassName(): string;
  98792. /**
  98793. * Gets the input component
  98794. */
  98795. get input(): NodeMaterialConnectionPoint;
  98796. /**
  98797. * Gets the output component
  98798. */
  98799. get output(): NodeMaterialConnectionPoint;
  98800. protected _buildBlock(state: NodeMaterialBuildState): this;
  98801. serialize(): any;
  98802. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98803. protected _dumpPropertiesCode(): string;
  98804. }
  98805. }
  98806. declare module BABYLON {
  98807. /**
  98808. * Interface used to configure the node material editor
  98809. */
  98810. export interface INodeMaterialEditorOptions {
  98811. /** Define the URl to load node editor script */
  98812. editorURL?: string;
  98813. }
  98814. /** @hidden */
  98815. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  98816. NORMAL: boolean;
  98817. TANGENT: boolean;
  98818. UV1: boolean;
  98819. /** BONES */
  98820. NUM_BONE_INFLUENCERS: number;
  98821. BonesPerMesh: number;
  98822. BONETEXTURE: boolean;
  98823. /** MORPH TARGETS */
  98824. MORPHTARGETS: boolean;
  98825. MORPHTARGETS_NORMAL: boolean;
  98826. MORPHTARGETS_TANGENT: boolean;
  98827. MORPHTARGETS_UV: boolean;
  98828. NUM_MORPH_INFLUENCERS: number;
  98829. /** IMAGE PROCESSING */
  98830. IMAGEPROCESSING: boolean;
  98831. VIGNETTE: boolean;
  98832. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98833. VIGNETTEBLENDMODEOPAQUE: boolean;
  98834. TONEMAPPING: boolean;
  98835. TONEMAPPING_ACES: boolean;
  98836. CONTRAST: boolean;
  98837. EXPOSURE: boolean;
  98838. COLORCURVES: boolean;
  98839. COLORGRADING: boolean;
  98840. COLORGRADING3D: boolean;
  98841. SAMPLER3DGREENDEPTH: boolean;
  98842. SAMPLER3DBGRMAP: boolean;
  98843. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98844. /** MISC. */
  98845. BUMPDIRECTUV: number;
  98846. constructor();
  98847. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  98848. }
  98849. /**
  98850. * Class used to configure NodeMaterial
  98851. */
  98852. export interface INodeMaterialOptions {
  98853. /**
  98854. * Defines if blocks should emit comments
  98855. */
  98856. emitComments: boolean;
  98857. }
  98858. /**
  98859. * Class used to create a node based material built by assembling shader blocks
  98860. */
  98861. export class NodeMaterial extends PushMaterial {
  98862. private static _BuildIdGenerator;
  98863. private _options;
  98864. private _vertexCompilationState;
  98865. private _fragmentCompilationState;
  98866. private _sharedData;
  98867. private _buildId;
  98868. private _buildWasSuccessful;
  98869. private _cachedWorldViewMatrix;
  98870. private _cachedWorldViewProjectionMatrix;
  98871. private _optimizers;
  98872. private _animationFrame;
  98873. /** Define the Url to load node editor script */
  98874. static EditorURL: string;
  98875. /** Define the Url to load snippets */
  98876. static SnippetUrl: string;
  98877. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  98878. static IgnoreTexturesAtLoadTime: boolean;
  98879. private BJSNODEMATERIALEDITOR;
  98880. /** Get the inspector from bundle or global */
  98881. private _getGlobalNodeMaterialEditor;
  98882. /**
  98883. * Snippet ID if the material was created from the snippet server
  98884. */
  98885. snippetId: string;
  98886. /**
  98887. * Gets or sets data used by visual editor
  98888. * @see https://nme.babylonjs.com
  98889. */
  98890. editorData: any;
  98891. /**
  98892. * 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)
  98893. */
  98894. ignoreAlpha: boolean;
  98895. /**
  98896. * Defines the maximum number of lights that can be used in the material
  98897. */
  98898. maxSimultaneousLights: number;
  98899. /**
  98900. * Observable raised when the material is built
  98901. */
  98902. onBuildObservable: Observable<NodeMaterial>;
  98903. /**
  98904. * Gets or sets the root nodes of the material vertex shader
  98905. */
  98906. _vertexOutputNodes: NodeMaterialBlock[];
  98907. /**
  98908. * Gets or sets the root nodes of the material fragment (pixel) shader
  98909. */
  98910. _fragmentOutputNodes: NodeMaterialBlock[];
  98911. /** Gets or sets options to control the node material overall behavior */
  98912. get options(): INodeMaterialOptions;
  98913. set options(options: INodeMaterialOptions);
  98914. /**
  98915. * Default configuration related to image processing available in the standard Material.
  98916. */
  98917. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98918. /**
  98919. * Gets the image processing configuration used either in this material.
  98920. */
  98921. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  98922. /**
  98923. * Sets the Default image processing configuration used either in the this material.
  98924. *
  98925. * If sets to null, the scene one is in use.
  98926. */
  98927. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  98928. /**
  98929. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  98930. */
  98931. attachedBlocks: NodeMaterialBlock[];
  98932. /**
  98933. * Specifies the mode of the node material
  98934. * @hidden
  98935. */
  98936. _mode: NodeMaterialModes;
  98937. /**
  98938. * Gets the mode property
  98939. */
  98940. get mode(): NodeMaterialModes;
  98941. /**
  98942. * A free comment about the material
  98943. */
  98944. comment: string;
  98945. /**
  98946. * Create a new node based material
  98947. * @param name defines the material name
  98948. * @param scene defines the hosting scene
  98949. * @param options defines creation option
  98950. */
  98951. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  98952. /**
  98953. * Gets the current class name of the material e.g. "NodeMaterial"
  98954. * @returns the class name
  98955. */
  98956. getClassName(): string;
  98957. /**
  98958. * Keep track of the image processing observer to allow dispose and replace.
  98959. */
  98960. private _imageProcessingObserver;
  98961. /**
  98962. * Attaches a new image processing configuration to the Standard Material.
  98963. * @param configuration
  98964. */
  98965. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98966. /**
  98967. * Get a block by its name
  98968. * @param name defines the name of the block to retrieve
  98969. * @returns the required block or null if not found
  98970. */
  98971. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  98972. /**
  98973. * Get a block by its name
  98974. * @param predicate defines the predicate used to find the good candidate
  98975. * @returns the required block or null if not found
  98976. */
  98977. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  98978. /**
  98979. * Get an input block by its name
  98980. * @param predicate defines the predicate used to find the good candidate
  98981. * @returns the required input block or null if not found
  98982. */
  98983. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  98984. /**
  98985. * Gets the list of input blocks attached to this material
  98986. * @returns an array of InputBlocks
  98987. */
  98988. getInputBlocks(): InputBlock[];
  98989. /**
  98990. * Adds a new optimizer to the list of optimizers
  98991. * @param optimizer defines the optimizers to add
  98992. * @returns the current material
  98993. */
  98994. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  98995. /**
  98996. * Remove an optimizer from the list of optimizers
  98997. * @param optimizer defines the optimizers to remove
  98998. * @returns the current material
  98999. */
  99000. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  99001. /**
  99002. * Add a new block to the list of output nodes
  99003. * @param node defines the node to add
  99004. * @returns the current material
  99005. */
  99006. addOutputNode(node: NodeMaterialBlock): this;
  99007. /**
  99008. * Remove a block from the list of root nodes
  99009. * @param node defines the node to remove
  99010. * @returns the current material
  99011. */
  99012. removeOutputNode(node: NodeMaterialBlock): this;
  99013. private _addVertexOutputNode;
  99014. private _removeVertexOutputNode;
  99015. private _addFragmentOutputNode;
  99016. private _removeFragmentOutputNode;
  99017. /**
  99018. * Specifies if the material will require alpha blending
  99019. * @returns a boolean specifying if alpha blending is needed
  99020. */
  99021. needAlphaBlending(): boolean;
  99022. /**
  99023. * Specifies if this material should be rendered in alpha test mode
  99024. * @returns a boolean specifying if an alpha test is needed.
  99025. */
  99026. needAlphaTesting(): boolean;
  99027. private _initializeBlock;
  99028. private _resetDualBlocks;
  99029. /**
  99030. * Remove a block from the current node material
  99031. * @param block defines the block to remove
  99032. */
  99033. removeBlock(block: NodeMaterialBlock): void;
  99034. /**
  99035. * Build the material and generates the inner effect
  99036. * @param verbose defines if the build should log activity
  99037. */
  99038. build(verbose?: boolean): void;
  99039. /**
  99040. * Runs an otpimization phase to try to improve the shader code
  99041. */
  99042. optimize(): void;
  99043. private _prepareDefinesForAttributes;
  99044. /**
  99045. * Create a post process from the material
  99046. * @param camera The camera to apply the render pass to.
  99047. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  99048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  99049. * @param engine The engine which the post process will be applied. (default: current engine)
  99050. * @param reusable If the post process can be reused on the same frame. (default: false)
  99051. * @param textureType Type of textures used when performing the post process. (default: 0)
  99052. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  99053. * @returns the post process created
  99054. */
  99055. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  99056. /**
  99057. * Create the post process effect from the material
  99058. * @param postProcess The post process to create the effect for
  99059. */
  99060. createEffectForPostProcess(postProcess: PostProcess): void;
  99061. private _createEffectForPostProcess;
  99062. /**
  99063. * Create a new procedural texture based on this node material
  99064. * @param size defines the size of the texture
  99065. * @param scene defines the hosting scene
  99066. * @returns the new procedural texture attached to this node material
  99067. */
  99068. createProceduralTexture(size: number | {
  99069. width: number;
  99070. height: number;
  99071. layers?: number;
  99072. }, scene: Scene): Nullable<ProceduralTexture>;
  99073. private _createEffectForParticles;
  99074. private _checkInternals;
  99075. /**
  99076. * Create the effect to be used as the custom effect for a particle system
  99077. * @param particleSystem Particle system to create the effect for
  99078. * @param onCompiled defines a function to call when the effect creation is successful
  99079. * @param onError defines a function to call when the effect creation has failed
  99080. */
  99081. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  99082. private _processDefines;
  99083. /**
  99084. * Get if the submesh is ready to be used and all its information available.
  99085. * Child classes can use it to update shaders
  99086. * @param mesh defines the mesh to check
  99087. * @param subMesh defines which submesh to check
  99088. * @param useInstances specifies that instances should be used
  99089. * @returns a boolean indicating that the submesh is ready or not
  99090. */
  99091. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99092. /**
  99093. * Get a string representing the shaders built by the current node graph
  99094. */
  99095. get compiledShaders(): string;
  99096. /**
  99097. * Binds the world matrix to the material
  99098. * @param world defines the world transformation matrix
  99099. */
  99100. bindOnlyWorldMatrix(world: Matrix): void;
  99101. /**
  99102. * Binds the submesh to this material by preparing the effect and shader to draw
  99103. * @param world defines the world transformation matrix
  99104. * @param mesh defines the mesh containing the submesh
  99105. * @param subMesh defines the submesh to bind the material to
  99106. */
  99107. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99108. /**
  99109. * Gets the active textures from the material
  99110. * @returns an array of textures
  99111. */
  99112. getActiveTextures(): BaseTexture[];
  99113. /**
  99114. * Gets the list of texture blocks
  99115. * @returns an array of texture blocks
  99116. */
  99117. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99118. /**
  99119. * Specifies if the material uses a texture
  99120. * @param texture defines the texture to check against the material
  99121. * @returns a boolean specifying if the material uses the texture
  99122. */
  99123. hasTexture(texture: BaseTexture): boolean;
  99124. /**
  99125. * Disposes the material
  99126. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  99127. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  99128. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  99129. */
  99130. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  99131. /** Creates the node editor window. */
  99132. private _createNodeEditor;
  99133. /**
  99134. * Launch the node material editor
  99135. * @param config Define the configuration of the editor
  99136. * @return a promise fulfilled when the node editor is visible
  99137. */
  99138. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  99139. /**
  99140. * Clear the current material
  99141. */
  99142. clear(): void;
  99143. /**
  99144. * Clear the current material and set it to a default state
  99145. */
  99146. setToDefault(): void;
  99147. /**
  99148. * Clear the current material and set it to a default state for post process
  99149. */
  99150. setToDefaultPostProcess(): void;
  99151. /**
  99152. * Clear the current material and set it to a default state for procedural texture
  99153. */
  99154. setToDefaultProceduralTexture(): void;
  99155. /**
  99156. * Clear the current material and set it to a default state for particle
  99157. */
  99158. setToDefaultParticle(): void;
  99159. /**
  99160. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  99161. * @param url defines the url to load from
  99162. * @returns a promise that will fullfil when the material is fully loaded
  99163. */
  99164. loadAsync(url: string): Promise<void>;
  99165. private _gatherBlocks;
  99166. /**
  99167. * Generate a string containing the code declaration required to create an equivalent of this material
  99168. * @returns a string
  99169. */
  99170. generateCode(): string;
  99171. /**
  99172. * Serializes this material in a JSON representation
  99173. * @returns the serialized material object
  99174. */
  99175. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  99176. private _restoreConnections;
  99177. /**
  99178. * Clear the current graph and load a new one from a serialization object
  99179. * @param source defines the JSON representation of the material
  99180. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99181. * @param merge defines whether or not the source must be merged or replace the current content
  99182. */
  99183. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  99184. /**
  99185. * Makes a duplicate of the current material.
  99186. * @param name - name to use for the new material.
  99187. */
  99188. clone(name: string): NodeMaterial;
  99189. /**
  99190. * Creates a node material from parsed material data
  99191. * @param source defines the JSON representation of the material
  99192. * @param scene defines the hosting scene
  99193. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99194. * @returns a new node material
  99195. */
  99196. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  99197. /**
  99198. * Creates a node material from a snippet saved in a remote file
  99199. * @param name defines the name of the material to create
  99200. * @param url defines the url to load from
  99201. * @param scene defines the hosting scene
  99202. * @returns a promise that will resolve to the new node material
  99203. */
  99204. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  99205. /**
  99206. * Creates a node material from a snippet saved by the node material editor
  99207. * @param snippetId defines the snippet to load
  99208. * @param scene defines the hosting scene
  99209. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99210. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  99211. * @returns a promise that will resolve to the new node material
  99212. */
  99213. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  99214. /**
  99215. * Creates a new node material set to default basic configuration
  99216. * @param name defines the name of the material
  99217. * @param scene defines the hosting scene
  99218. * @returns a new NodeMaterial
  99219. */
  99220. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  99221. }
  99222. }
  99223. declare module BABYLON {
  99224. interface ThinEngine {
  99225. /**
  99226. * Unbind a list of render target textures from the webGL context
  99227. * This is used only when drawBuffer extension or webGL2 are active
  99228. * @param textures defines the render target textures to unbind
  99229. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  99230. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  99231. */
  99232. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  99233. /**
  99234. * Create a multi render target texture
  99235. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  99236. * @param size defines the size of the texture
  99237. * @param options defines the creation options
  99238. * @returns the cube texture as an InternalTexture
  99239. */
  99240. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  99241. /**
  99242. * Update the sample count for a given multiple render target texture
  99243. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  99244. * @param textures defines the textures to update
  99245. * @param samples defines the sample count to set
  99246. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  99247. */
  99248. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  99249. /**
  99250. * Select a subsets of attachments to draw to.
  99251. * @param attachments gl attachments
  99252. */
  99253. bindAttachments(attachments: number[]): void;
  99254. /**
  99255. * Creates a layout object to draw/clear on specific textures in a MRT
  99256. * @param textureStatus textureStatus[i] indicates if the i-th is active
  99257. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  99258. */
  99259. buildTextureLayout(textureStatus: boolean[]): number[];
  99260. /**
  99261. * Restores the webgl state to only draw on the main color attachment
  99262. */
  99263. restoreSingleAttachment(): void;
  99264. }
  99265. }
  99266. declare module BABYLON {
  99267. /**
  99268. * Creation options of the multi render target texture.
  99269. */
  99270. export interface IMultiRenderTargetOptions {
  99271. /**
  99272. * Define if the texture needs to create mip maps after render.
  99273. */
  99274. generateMipMaps?: boolean;
  99275. /**
  99276. * Define the types of all the draw buffers we want to create
  99277. */
  99278. types?: number[];
  99279. /**
  99280. * Define the sampling modes of all the draw buffers we want to create
  99281. */
  99282. samplingModes?: number[];
  99283. /**
  99284. * Define if a depth buffer is required
  99285. */
  99286. generateDepthBuffer?: boolean;
  99287. /**
  99288. * Define if a stencil buffer is required
  99289. */
  99290. generateStencilBuffer?: boolean;
  99291. /**
  99292. * Define if a depth texture is required instead of a depth buffer
  99293. */
  99294. generateDepthTexture?: boolean;
  99295. /**
  99296. * Define the number of desired draw buffers
  99297. */
  99298. textureCount?: number;
  99299. /**
  99300. * Define if aspect ratio should be adapted to the texture or stay the scene one
  99301. */
  99302. doNotChangeAspectRatio?: boolean;
  99303. /**
  99304. * Define the default type of the buffers we are creating
  99305. */
  99306. defaultType?: number;
  99307. }
  99308. /**
  99309. * A multi render target, like a render target provides the ability to render to a texture.
  99310. * Unlike the render target, it can render to several draw buffers in one draw.
  99311. * This is specially interesting in deferred rendering or for any effects requiring more than
  99312. * just one color from a single pass.
  99313. */
  99314. export class MultiRenderTarget extends RenderTargetTexture {
  99315. private _internalTextures;
  99316. private _textures;
  99317. private _multiRenderTargetOptions;
  99318. private _count;
  99319. /**
  99320. * Get if draw buffers are currently supported by the used hardware and browser.
  99321. */
  99322. get isSupported(): boolean;
  99323. /**
  99324. * Get the list of textures generated by the multi render target.
  99325. */
  99326. get textures(): Texture[];
  99327. /**
  99328. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  99329. */
  99330. get count(): number;
  99331. /**
  99332. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  99333. */
  99334. get depthTexture(): Texture;
  99335. /**
  99336. * Set the wrapping mode on U of all the textures we are rendering to.
  99337. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99338. */
  99339. set wrapU(wrap: number);
  99340. /**
  99341. * Set the wrapping mode on V of all the textures we are rendering to.
  99342. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  99343. */
  99344. set wrapV(wrap: number);
  99345. /**
  99346. * Instantiate a new multi render target texture.
  99347. * A multi render target, like a render target provides the ability to render to a texture.
  99348. * Unlike the render target, it can render to several draw buffers in one draw.
  99349. * This is specially interesting in deferred rendering or for any effects requiring more than
  99350. * just one color from a single pass.
  99351. * @param name Define the name of the texture
  99352. * @param size Define the size of the buffers to render to
  99353. * @param count Define the number of target we are rendering into
  99354. * @param scene Define the scene the texture belongs to
  99355. * @param options Define the options used to create the multi render target
  99356. */
  99357. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  99358. private _initTypes;
  99359. /** @hidden */
  99360. _rebuild(forceFullRebuild?: boolean): void;
  99361. private _createInternalTextures;
  99362. private _createTextures;
  99363. /**
  99364. * Replaces a texture within the MRT.
  99365. * @param texture The new texture to insert in the MRT
  99366. * @param index The index of the texture to replace
  99367. */
  99368. replaceTexture(texture: Texture, index: number): void;
  99369. /**
  99370. * Define the number of samples used if MSAA is enabled.
  99371. */
  99372. get samples(): number;
  99373. set samples(value: number);
  99374. /**
  99375. * Resize all the textures in the multi render target.
  99376. * Be careful as it will recreate all the data in the new texture.
  99377. * @param size Define the new size
  99378. */
  99379. resize(size: any): void;
  99380. /**
  99381. * Changes the number of render targets in this MRT
  99382. * Be careful as it will recreate all the data in the new texture.
  99383. * @param count new texture count
  99384. * @param options Specifies texture types and sampling modes for new textures
  99385. */
  99386. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  99387. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  99388. /**
  99389. * Dispose the render targets and their associated resources
  99390. */
  99391. dispose(): void;
  99392. /**
  99393. * Release all the underlying texture used as draw buffers.
  99394. */
  99395. releaseInternalTextures(): void;
  99396. }
  99397. }
  99398. declare module BABYLON {
  99399. /** @hidden */
  99400. export var imageProcessingPixelShader: {
  99401. name: string;
  99402. shader: string;
  99403. };
  99404. }
  99405. declare module BABYLON {
  99406. /**
  99407. * ImageProcessingPostProcess
  99408. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  99409. */
  99410. export class ImageProcessingPostProcess extends PostProcess {
  99411. /**
  99412. * Default configuration related to image processing available in the PBR Material.
  99413. */
  99414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99415. /**
  99416. * Gets the image processing configuration used either in this material.
  99417. */
  99418. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99419. /**
  99420. * Sets the Default image processing configuration used either in the this material.
  99421. *
  99422. * If sets to null, the scene one is in use.
  99423. */
  99424. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99425. /**
  99426. * Keep track of the image processing observer to allow dispose and replace.
  99427. */
  99428. private _imageProcessingObserver;
  99429. /**
  99430. * Attaches a new image processing configuration to the PBR Material.
  99431. * @param configuration
  99432. */
  99433. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  99434. /**
  99435. * If the post process is supported.
  99436. */
  99437. get isSupported(): boolean;
  99438. /**
  99439. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99440. */
  99441. get colorCurves(): Nullable<ColorCurves>;
  99442. /**
  99443. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  99444. */
  99445. set colorCurves(value: Nullable<ColorCurves>);
  99446. /**
  99447. * Gets wether the color curves effect is enabled.
  99448. */
  99449. get colorCurvesEnabled(): boolean;
  99450. /**
  99451. * Sets wether the color curves effect is enabled.
  99452. */
  99453. set colorCurvesEnabled(value: boolean);
  99454. /**
  99455. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99456. */
  99457. get colorGradingTexture(): Nullable<BaseTexture>;
  99458. /**
  99459. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  99460. */
  99461. set colorGradingTexture(value: Nullable<BaseTexture>);
  99462. /**
  99463. * Gets wether the color grading effect is enabled.
  99464. */
  99465. get colorGradingEnabled(): boolean;
  99466. /**
  99467. * Gets wether the color grading effect is enabled.
  99468. */
  99469. set colorGradingEnabled(value: boolean);
  99470. /**
  99471. * Gets exposure used in the effect.
  99472. */
  99473. get exposure(): number;
  99474. /**
  99475. * Sets exposure used in the effect.
  99476. */
  99477. set exposure(value: number);
  99478. /**
  99479. * Gets wether tonemapping is enabled or not.
  99480. */
  99481. get toneMappingEnabled(): boolean;
  99482. /**
  99483. * Sets wether tonemapping is enabled or not
  99484. */
  99485. set toneMappingEnabled(value: boolean);
  99486. /**
  99487. * Gets the type of tone mapping effect.
  99488. */
  99489. get toneMappingType(): number;
  99490. /**
  99491. * Sets the type of tone mapping effect.
  99492. */
  99493. set toneMappingType(value: number);
  99494. /**
  99495. * Gets contrast used in the effect.
  99496. */
  99497. get contrast(): number;
  99498. /**
  99499. * Sets contrast used in the effect.
  99500. */
  99501. set contrast(value: number);
  99502. /**
  99503. * Gets Vignette stretch size.
  99504. */
  99505. get vignetteStretch(): number;
  99506. /**
  99507. * Sets Vignette stretch size.
  99508. */
  99509. set vignetteStretch(value: number);
  99510. /**
  99511. * Gets Vignette centre X Offset.
  99512. */
  99513. get vignetteCentreX(): number;
  99514. /**
  99515. * Sets Vignette centre X Offset.
  99516. */
  99517. set vignetteCentreX(value: number);
  99518. /**
  99519. * Gets Vignette centre Y Offset.
  99520. */
  99521. get vignetteCentreY(): number;
  99522. /**
  99523. * Sets Vignette centre Y Offset.
  99524. */
  99525. set vignetteCentreY(value: number);
  99526. /**
  99527. * Gets Vignette weight or intensity of the vignette effect.
  99528. */
  99529. get vignetteWeight(): number;
  99530. /**
  99531. * Sets Vignette weight or intensity of the vignette effect.
  99532. */
  99533. set vignetteWeight(value: number);
  99534. /**
  99535. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99536. * if vignetteEnabled is set to true.
  99537. */
  99538. get vignetteColor(): Color4;
  99539. /**
  99540. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  99541. * if vignetteEnabled is set to true.
  99542. */
  99543. set vignetteColor(value: Color4);
  99544. /**
  99545. * Gets Camera field of view used by the Vignette effect.
  99546. */
  99547. get vignetteCameraFov(): number;
  99548. /**
  99549. * Sets Camera field of view used by the Vignette effect.
  99550. */
  99551. set vignetteCameraFov(value: number);
  99552. /**
  99553. * Gets the vignette blend mode allowing different kind of effect.
  99554. */
  99555. get vignetteBlendMode(): number;
  99556. /**
  99557. * Sets the vignette blend mode allowing different kind of effect.
  99558. */
  99559. set vignetteBlendMode(value: number);
  99560. /**
  99561. * Gets wether the vignette effect is enabled.
  99562. */
  99563. get vignetteEnabled(): boolean;
  99564. /**
  99565. * Sets wether the vignette effect is enabled.
  99566. */
  99567. set vignetteEnabled(value: boolean);
  99568. private _fromLinearSpace;
  99569. /**
  99570. * Gets wether the input of the processing is in Gamma or Linear Space.
  99571. */
  99572. get fromLinearSpace(): boolean;
  99573. /**
  99574. * Sets wether the input of the processing is in Gamma or Linear Space.
  99575. */
  99576. set fromLinearSpace(value: boolean);
  99577. /**
  99578. * Defines cache preventing GC.
  99579. */
  99580. private _defines;
  99581. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  99582. /**
  99583. * "ImageProcessingPostProcess"
  99584. * @returns "ImageProcessingPostProcess"
  99585. */
  99586. getClassName(): string;
  99587. /**
  99588. * @hidden
  99589. */
  99590. _updateParameters(): void;
  99591. dispose(camera?: Camera): void;
  99592. }
  99593. }
  99594. declare module BABYLON {
  99595. /**
  99596. * Interface for defining prepass effects in the prepass post-process pipeline
  99597. */
  99598. export interface PrePassEffectConfiguration {
  99599. /**
  99600. * Name of the effect
  99601. */
  99602. name: string;
  99603. /**
  99604. * Post process to attach for this effect
  99605. */
  99606. postProcess?: PostProcess;
  99607. /**
  99608. * Textures required in the MRT
  99609. */
  99610. texturesRequired: number[];
  99611. /**
  99612. * Is the effect enabled
  99613. */
  99614. enabled: boolean;
  99615. /**
  99616. * Disposes the effect configuration
  99617. */
  99618. dispose?: () => void;
  99619. /**
  99620. * Creates the associated post process
  99621. */
  99622. createPostProcess?: () => PostProcess;
  99623. }
  99624. }
  99625. declare module BABYLON {
  99626. /**
  99627. * Options to be used when creating a FresnelParameters.
  99628. */
  99629. export type IFresnelParametersCreationOptions = {
  99630. /**
  99631. * Define the color used on edges (grazing angle)
  99632. */
  99633. leftColor?: Color3;
  99634. /**
  99635. * Define the color used on center
  99636. */
  99637. rightColor?: Color3;
  99638. /**
  99639. * Define bias applied to computed fresnel term
  99640. */
  99641. bias?: number;
  99642. /**
  99643. * Defined the power exponent applied to fresnel term
  99644. */
  99645. power?: number;
  99646. /**
  99647. * Define if the fresnel effect is enable or not.
  99648. */
  99649. isEnabled?: boolean;
  99650. };
  99651. /**
  99652. * Serialized format for FresnelParameters.
  99653. */
  99654. export type IFresnelParametersSerialized = {
  99655. /**
  99656. * Define the color used on edges (grazing angle) [as an array]
  99657. */
  99658. leftColor: number[];
  99659. /**
  99660. * Define the color used on center [as an array]
  99661. */
  99662. rightColor: number[];
  99663. /**
  99664. * Define bias applied to computed fresnel term
  99665. */
  99666. bias: number;
  99667. /**
  99668. * Defined the power exponent applied to fresnel term
  99669. */
  99670. power?: number;
  99671. /**
  99672. * Define if the fresnel effect is enable or not.
  99673. */
  99674. isEnabled: boolean;
  99675. };
  99676. /**
  99677. * This represents all the required information to add a fresnel effect on a material:
  99678. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99679. */
  99680. export class FresnelParameters {
  99681. private _isEnabled;
  99682. /**
  99683. * Define if the fresnel effect is enable or not.
  99684. */
  99685. get isEnabled(): boolean;
  99686. set isEnabled(value: boolean);
  99687. /**
  99688. * Define the color used on edges (grazing angle)
  99689. */
  99690. leftColor: Color3;
  99691. /**
  99692. * Define the color used on center
  99693. */
  99694. rightColor: Color3;
  99695. /**
  99696. * Define bias applied to computed fresnel term
  99697. */
  99698. bias: number;
  99699. /**
  99700. * Defined the power exponent applied to fresnel term
  99701. */
  99702. power: number;
  99703. /**
  99704. * Creates a new FresnelParameters object.
  99705. *
  99706. * @param options provide your own settings to optionally to override defaults
  99707. */
  99708. constructor(options?: IFresnelParametersCreationOptions);
  99709. /**
  99710. * Clones the current fresnel and its valuues
  99711. * @returns a clone fresnel configuration
  99712. */
  99713. clone(): FresnelParameters;
  99714. /**
  99715. * Determines equality between FresnelParameters objects
  99716. * @param otherFresnelParameters defines the second operand
  99717. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  99718. */
  99719. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  99720. /**
  99721. * Serializes the current fresnel parameters to a JSON representation.
  99722. * @return the JSON serialization
  99723. */
  99724. serialize(): IFresnelParametersSerialized;
  99725. /**
  99726. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99727. * @param parsedFresnelParameters Define the JSON representation
  99728. * @returns the parsed parameters
  99729. */
  99730. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  99731. }
  99732. }
  99733. declare module BABYLON {
  99734. /**
  99735. * This groups all the flags used to control the materials channel.
  99736. */
  99737. export class MaterialFlags {
  99738. private static _DiffuseTextureEnabled;
  99739. /**
  99740. * Are diffuse textures enabled in the application.
  99741. */
  99742. static get DiffuseTextureEnabled(): boolean;
  99743. static set DiffuseTextureEnabled(value: boolean);
  99744. private static _DetailTextureEnabled;
  99745. /**
  99746. * Are detail textures enabled in the application.
  99747. */
  99748. static get DetailTextureEnabled(): boolean;
  99749. static set DetailTextureEnabled(value: boolean);
  99750. private static _AmbientTextureEnabled;
  99751. /**
  99752. * Are ambient textures enabled in the application.
  99753. */
  99754. static get AmbientTextureEnabled(): boolean;
  99755. static set AmbientTextureEnabled(value: boolean);
  99756. private static _OpacityTextureEnabled;
  99757. /**
  99758. * Are opacity textures enabled in the application.
  99759. */
  99760. static get OpacityTextureEnabled(): boolean;
  99761. static set OpacityTextureEnabled(value: boolean);
  99762. private static _ReflectionTextureEnabled;
  99763. /**
  99764. * Are reflection textures enabled in the application.
  99765. */
  99766. static get ReflectionTextureEnabled(): boolean;
  99767. static set ReflectionTextureEnabled(value: boolean);
  99768. private static _EmissiveTextureEnabled;
  99769. /**
  99770. * Are emissive textures enabled in the application.
  99771. */
  99772. static get EmissiveTextureEnabled(): boolean;
  99773. static set EmissiveTextureEnabled(value: boolean);
  99774. private static _SpecularTextureEnabled;
  99775. /**
  99776. * Are specular textures enabled in the application.
  99777. */
  99778. static get SpecularTextureEnabled(): boolean;
  99779. static set SpecularTextureEnabled(value: boolean);
  99780. private static _BumpTextureEnabled;
  99781. /**
  99782. * Are bump textures enabled in the application.
  99783. */
  99784. static get BumpTextureEnabled(): boolean;
  99785. static set BumpTextureEnabled(value: boolean);
  99786. private static _LightmapTextureEnabled;
  99787. /**
  99788. * Are lightmap textures enabled in the application.
  99789. */
  99790. static get LightmapTextureEnabled(): boolean;
  99791. static set LightmapTextureEnabled(value: boolean);
  99792. private static _RefractionTextureEnabled;
  99793. /**
  99794. * Are refraction textures enabled in the application.
  99795. */
  99796. static get RefractionTextureEnabled(): boolean;
  99797. static set RefractionTextureEnabled(value: boolean);
  99798. private static _ColorGradingTextureEnabled;
  99799. /**
  99800. * Are color grading textures enabled in the application.
  99801. */
  99802. static get ColorGradingTextureEnabled(): boolean;
  99803. static set ColorGradingTextureEnabled(value: boolean);
  99804. private static _FresnelEnabled;
  99805. /**
  99806. * Are fresnels enabled in the application.
  99807. */
  99808. static get FresnelEnabled(): boolean;
  99809. static set FresnelEnabled(value: boolean);
  99810. private static _ClearCoatTextureEnabled;
  99811. /**
  99812. * Are clear coat textures enabled in the application.
  99813. */
  99814. static get ClearCoatTextureEnabled(): boolean;
  99815. static set ClearCoatTextureEnabled(value: boolean);
  99816. private static _ClearCoatBumpTextureEnabled;
  99817. /**
  99818. * Are clear coat bump textures enabled in the application.
  99819. */
  99820. static get ClearCoatBumpTextureEnabled(): boolean;
  99821. static set ClearCoatBumpTextureEnabled(value: boolean);
  99822. private static _ClearCoatTintTextureEnabled;
  99823. /**
  99824. * Are clear coat tint textures enabled in the application.
  99825. */
  99826. static get ClearCoatTintTextureEnabled(): boolean;
  99827. static set ClearCoatTintTextureEnabled(value: boolean);
  99828. private static _SheenTextureEnabled;
  99829. /**
  99830. * Are sheen textures enabled in the application.
  99831. */
  99832. static get SheenTextureEnabled(): boolean;
  99833. static set SheenTextureEnabled(value: boolean);
  99834. private static _AnisotropicTextureEnabled;
  99835. /**
  99836. * Are anisotropic textures enabled in the application.
  99837. */
  99838. static get AnisotropicTextureEnabled(): boolean;
  99839. static set AnisotropicTextureEnabled(value: boolean);
  99840. private static _ThicknessTextureEnabled;
  99841. /**
  99842. * Are thickness textures enabled in the application.
  99843. */
  99844. static get ThicknessTextureEnabled(): boolean;
  99845. static set ThicknessTextureEnabled(value: boolean);
  99846. }
  99847. }
  99848. declare module BABYLON {
  99849. /** @hidden */
  99850. export var defaultFragmentDeclaration: {
  99851. name: string;
  99852. shader: string;
  99853. };
  99854. }
  99855. declare module BABYLON {
  99856. /** @hidden */
  99857. export var defaultUboDeclaration: {
  99858. name: string;
  99859. shader: string;
  99860. };
  99861. }
  99862. declare module BABYLON {
  99863. /** @hidden */
  99864. export var prePassDeclaration: {
  99865. name: string;
  99866. shader: string;
  99867. };
  99868. }
  99869. declare module BABYLON {
  99870. /** @hidden */
  99871. export var lightFragmentDeclaration: {
  99872. name: string;
  99873. shader: string;
  99874. };
  99875. }
  99876. declare module BABYLON {
  99877. /** @hidden */
  99878. export var lightUboDeclaration: {
  99879. name: string;
  99880. shader: string;
  99881. };
  99882. }
  99883. declare module BABYLON {
  99884. /** @hidden */
  99885. export var lightsFragmentFunctions: {
  99886. name: string;
  99887. shader: string;
  99888. };
  99889. }
  99890. declare module BABYLON {
  99891. /** @hidden */
  99892. export var shadowsFragmentFunctions: {
  99893. name: string;
  99894. shader: string;
  99895. };
  99896. }
  99897. declare module BABYLON {
  99898. /** @hidden */
  99899. export var fresnelFunction: {
  99900. name: string;
  99901. shader: string;
  99902. };
  99903. }
  99904. declare module BABYLON {
  99905. /** @hidden */
  99906. export var bumpFragmentMainFunctions: {
  99907. name: string;
  99908. shader: string;
  99909. };
  99910. }
  99911. declare module BABYLON {
  99912. /** @hidden */
  99913. export var bumpFragmentFunctions: {
  99914. name: string;
  99915. shader: string;
  99916. };
  99917. }
  99918. declare module BABYLON {
  99919. /** @hidden */
  99920. export var logDepthDeclaration: {
  99921. name: string;
  99922. shader: string;
  99923. };
  99924. }
  99925. declare module BABYLON {
  99926. /** @hidden */
  99927. export var fogFragmentDeclaration: {
  99928. name: string;
  99929. shader: string;
  99930. };
  99931. }
  99932. declare module BABYLON {
  99933. /** @hidden */
  99934. export var bumpFragment: {
  99935. name: string;
  99936. shader: string;
  99937. };
  99938. }
  99939. declare module BABYLON {
  99940. /** @hidden */
  99941. export var depthPrePass: {
  99942. name: string;
  99943. shader: string;
  99944. };
  99945. }
  99946. declare module BABYLON {
  99947. /** @hidden */
  99948. export var lightFragment: {
  99949. name: string;
  99950. shader: string;
  99951. };
  99952. }
  99953. declare module BABYLON {
  99954. /** @hidden */
  99955. export var logDepthFragment: {
  99956. name: string;
  99957. shader: string;
  99958. };
  99959. }
  99960. declare module BABYLON {
  99961. /** @hidden */
  99962. export var fogFragment: {
  99963. name: string;
  99964. shader: string;
  99965. };
  99966. }
  99967. declare module BABYLON {
  99968. /** @hidden */
  99969. export var defaultPixelShader: {
  99970. name: string;
  99971. shader: string;
  99972. };
  99973. }
  99974. declare module BABYLON {
  99975. /** @hidden */
  99976. export var defaultVertexDeclaration: {
  99977. name: string;
  99978. shader: string;
  99979. };
  99980. }
  99981. declare module BABYLON {
  99982. /** @hidden */
  99983. export var bonesDeclaration: {
  99984. name: string;
  99985. shader: string;
  99986. };
  99987. }
  99988. declare module BABYLON {
  99989. /** @hidden */
  99990. export var instancesDeclaration: {
  99991. name: string;
  99992. shader: string;
  99993. };
  99994. }
  99995. declare module BABYLON {
  99996. /** @hidden */
  99997. export var prePassVertexDeclaration: {
  99998. name: string;
  99999. shader: string;
  100000. };
  100001. }
  100002. declare module BABYLON {
  100003. /** @hidden */
  100004. export var bumpVertexDeclaration: {
  100005. name: string;
  100006. shader: string;
  100007. };
  100008. }
  100009. declare module BABYLON {
  100010. /** @hidden */
  100011. export var fogVertexDeclaration: {
  100012. name: string;
  100013. shader: string;
  100014. };
  100015. }
  100016. declare module BABYLON {
  100017. /** @hidden */
  100018. export var morphTargetsVertexGlobalDeclaration: {
  100019. name: string;
  100020. shader: string;
  100021. };
  100022. }
  100023. declare module BABYLON {
  100024. /** @hidden */
  100025. export var morphTargetsVertexDeclaration: {
  100026. name: string;
  100027. shader: string;
  100028. };
  100029. }
  100030. declare module BABYLON {
  100031. /** @hidden */
  100032. export var morphTargetsVertex: {
  100033. name: string;
  100034. shader: string;
  100035. };
  100036. }
  100037. declare module BABYLON {
  100038. /** @hidden */
  100039. export var instancesVertex: {
  100040. name: string;
  100041. shader: string;
  100042. };
  100043. }
  100044. declare module BABYLON {
  100045. /** @hidden */
  100046. export var bonesVertex: {
  100047. name: string;
  100048. shader: string;
  100049. };
  100050. }
  100051. declare module BABYLON {
  100052. /** @hidden */
  100053. export var prePassVertex: {
  100054. name: string;
  100055. shader: string;
  100056. };
  100057. }
  100058. declare module BABYLON {
  100059. /** @hidden */
  100060. export var bumpVertex: {
  100061. name: string;
  100062. shader: string;
  100063. };
  100064. }
  100065. declare module BABYLON {
  100066. /** @hidden */
  100067. export var fogVertex: {
  100068. name: string;
  100069. shader: string;
  100070. };
  100071. }
  100072. declare module BABYLON {
  100073. /** @hidden */
  100074. export var shadowsVertex: {
  100075. name: string;
  100076. shader: string;
  100077. };
  100078. }
  100079. declare module BABYLON {
  100080. /** @hidden */
  100081. export var pointCloudVertex: {
  100082. name: string;
  100083. shader: string;
  100084. };
  100085. }
  100086. declare module BABYLON {
  100087. /** @hidden */
  100088. export var logDepthVertex: {
  100089. name: string;
  100090. shader: string;
  100091. };
  100092. }
  100093. declare module BABYLON {
  100094. /** @hidden */
  100095. export var defaultVertexShader: {
  100096. name: string;
  100097. shader: string;
  100098. };
  100099. }
  100100. declare module BABYLON {
  100101. /**
  100102. * @hidden
  100103. */
  100104. export interface IMaterialDetailMapDefines {
  100105. DETAIL: boolean;
  100106. DETAILDIRECTUV: number;
  100107. DETAIL_NORMALBLENDMETHOD: number;
  100108. /** @hidden */
  100109. _areTexturesDirty: boolean;
  100110. }
  100111. /**
  100112. * Define the code related to the detail map parameters of a material
  100113. *
  100114. * Inspired from:
  100115. * 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
  100116. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  100117. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  100118. */
  100119. export class DetailMapConfiguration {
  100120. private _texture;
  100121. /**
  100122. * The detail texture of the material.
  100123. */
  100124. texture: Nullable<BaseTexture>;
  100125. /**
  100126. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  100127. * Bigger values mean stronger blending
  100128. */
  100129. diffuseBlendLevel: number;
  100130. /**
  100131. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  100132. * Bigger values mean stronger blending. Only used with PBR materials
  100133. */
  100134. roughnessBlendLevel: number;
  100135. /**
  100136. * Defines how strong the bump effect from the detail map is
  100137. * Bigger values mean stronger effect
  100138. */
  100139. bumpLevel: number;
  100140. private _normalBlendMethod;
  100141. /**
  100142. * The method used to blend the bump and detail normals together
  100143. */
  100144. normalBlendMethod: number;
  100145. private _isEnabled;
  100146. /**
  100147. * Enable or disable the detail map on this material
  100148. */
  100149. isEnabled: boolean;
  100150. /** @hidden */
  100151. private _internalMarkAllSubMeshesAsTexturesDirty;
  100152. /** @hidden */
  100153. _markAllSubMeshesAsTexturesDirty(): void;
  100154. /**
  100155. * Instantiate a new detail map
  100156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  100157. */
  100158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  100159. /**
  100160. * Gets whether the submesh is ready to be used or not.
  100161. * @param defines the list of "defines" to update.
  100162. * @param scene defines the scene the material belongs to.
  100163. * @returns - boolean indicating that the submesh is ready or not.
  100164. */
  100165. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  100166. /**
  100167. * Update the defines for detail map usage
  100168. * @param defines the list of "defines" to update.
  100169. * @param scene defines the scene the material belongs to.
  100170. */
  100171. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  100172. /**
  100173. * Binds the material data.
  100174. * @param uniformBuffer defines the Uniform buffer to fill in.
  100175. * @param scene defines the scene the material belongs to.
  100176. * @param isFrozen defines whether the material is frozen or not.
  100177. */
  100178. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  100179. /**
  100180. * Checks to see if a texture is used in the material.
  100181. * @param texture - Base texture to use.
  100182. * @returns - Boolean specifying if a texture is used in the material.
  100183. */
  100184. hasTexture(texture: BaseTexture): boolean;
  100185. /**
  100186. * Returns an array of the actively used textures.
  100187. * @param activeTextures Array of BaseTextures
  100188. */
  100189. getActiveTextures(activeTextures: BaseTexture[]): void;
  100190. /**
  100191. * Returns the animatable textures.
  100192. * @param animatables Array of animatable textures.
  100193. */
  100194. getAnimatables(animatables: IAnimatable[]): void;
  100195. /**
  100196. * Disposes the resources of the material.
  100197. * @param forceDisposeTextures - Forces the disposal of all textures.
  100198. */
  100199. dispose(forceDisposeTextures?: boolean): void;
  100200. /**
  100201. * Get the current class name useful for serialization or dynamic coding.
  100202. * @returns "DetailMap"
  100203. */
  100204. getClassName(): string;
  100205. /**
  100206. * Add the required uniforms to the current list.
  100207. * @param uniforms defines the current uniform list.
  100208. */
  100209. static AddUniforms(uniforms: string[]): void;
  100210. /**
  100211. * Add the required samplers to the current list.
  100212. * @param samplers defines the current sampler list.
  100213. */
  100214. static AddSamplers(samplers: string[]): void;
  100215. /**
  100216. * Add the required uniforms to the current buffer.
  100217. * @param uniformBuffer defines the current uniform buffer.
  100218. */
  100219. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  100220. /**
  100221. * Makes a duplicate of the current instance into another one.
  100222. * @param detailMap define the instance where to copy the info
  100223. */
  100224. copyTo(detailMap: DetailMapConfiguration): void;
  100225. /**
  100226. * Serializes this detail map instance
  100227. * @returns - An object with the serialized instance.
  100228. */
  100229. serialize(): any;
  100230. /**
  100231. * Parses a detail map setting from a serialized object.
  100232. * @param source - Serialized object.
  100233. * @param scene Defines the scene we are parsing for
  100234. * @param rootUrl Defines the rootUrl to load from
  100235. */
  100236. parse(source: any, scene: Scene, rootUrl: string): void;
  100237. }
  100238. }
  100239. declare module BABYLON {
  100240. /** @hidden */
  100241. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  100242. MAINUV1: boolean;
  100243. MAINUV2: boolean;
  100244. DIFFUSE: boolean;
  100245. DIFFUSEDIRECTUV: number;
  100246. DETAIL: boolean;
  100247. DETAILDIRECTUV: number;
  100248. DETAIL_NORMALBLENDMETHOD: number;
  100249. AMBIENT: boolean;
  100250. AMBIENTDIRECTUV: number;
  100251. OPACITY: boolean;
  100252. OPACITYDIRECTUV: number;
  100253. OPACITYRGB: boolean;
  100254. REFLECTION: boolean;
  100255. EMISSIVE: boolean;
  100256. EMISSIVEDIRECTUV: number;
  100257. SPECULAR: boolean;
  100258. SPECULARDIRECTUV: number;
  100259. BUMP: boolean;
  100260. BUMPDIRECTUV: number;
  100261. PARALLAX: boolean;
  100262. PARALLAXOCCLUSION: boolean;
  100263. SPECULAROVERALPHA: boolean;
  100264. CLIPPLANE: boolean;
  100265. CLIPPLANE2: boolean;
  100266. CLIPPLANE3: boolean;
  100267. CLIPPLANE4: boolean;
  100268. CLIPPLANE5: boolean;
  100269. CLIPPLANE6: boolean;
  100270. ALPHATEST: boolean;
  100271. DEPTHPREPASS: boolean;
  100272. ALPHAFROMDIFFUSE: boolean;
  100273. POINTSIZE: boolean;
  100274. FOG: boolean;
  100275. SPECULARTERM: boolean;
  100276. DIFFUSEFRESNEL: boolean;
  100277. OPACITYFRESNEL: boolean;
  100278. REFLECTIONFRESNEL: boolean;
  100279. REFRACTIONFRESNEL: boolean;
  100280. EMISSIVEFRESNEL: boolean;
  100281. FRESNEL: boolean;
  100282. NORMAL: boolean;
  100283. UV1: boolean;
  100284. UV2: boolean;
  100285. VERTEXCOLOR: boolean;
  100286. VERTEXALPHA: boolean;
  100287. NUM_BONE_INFLUENCERS: number;
  100288. BonesPerMesh: number;
  100289. BONETEXTURE: boolean;
  100290. BONES_VELOCITY_ENABLED: boolean;
  100291. INSTANCES: boolean;
  100292. THIN_INSTANCES: boolean;
  100293. GLOSSINESS: boolean;
  100294. ROUGHNESS: boolean;
  100295. EMISSIVEASILLUMINATION: boolean;
  100296. LINKEMISSIVEWITHDIFFUSE: boolean;
  100297. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100298. LIGHTMAP: boolean;
  100299. LIGHTMAPDIRECTUV: number;
  100300. OBJECTSPACE_NORMALMAP: boolean;
  100301. USELIGHTMAPASSHADOWMAP: boolean;
  100302. REFLECTIONMAP_3D: boolean;
  100303. REFLECTIONMAP_SPHERICAL: boolean;
  100304. REFLECTIONMAP_PLANAR: boolean;
  100305. REFLECTIONMAP_CUBIC: boolean;
  100306. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100307. REFLECTIONMAP_PROJECTION: boolean;
  100308. REFLECTIONMAP_SKYBOX: boolean;
  100309. REFLECTIONMAP_EXPLICIT: boolean;
  100310. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100311. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100312. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100313. INVERTCUBICMAP: boolean;
  100314. LOGARITHMICDEPTH: boolean;
  100315. REFRACTION: boolean;
  100316. REFRACTIONMAP_3D: boolean;
  100317. REFLECTIONOVERALPHA: boolean;
  100318. TWOSIDEDLIGHTING: boolean;
  100319. SHADOWFLOAT: boolean;
  100320. MORPHTARGETS: boolean;
  100321. MORPHTARGETS_NORMAL: boolean;
  100322. MORPHTARGETS_TANGENT: boolean;
  100323. MORPHTARGETS_UV: boolean;
  100324. NUM_MORPH_INFLUENCERS: number;
  100325. NONUNIFORMSCALING: boolean;
  100326. PREMULTIPLYALPHA: boolean;
  100327. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100328. ALPHABLEND: boolean;
  100329. PREPASS: boolean;
  100330. PREPASS_IRRADIANCE: boolean;
  100331. PREPASS_IRRADIANCE_INDEX: number;
  100332. PREPASS_ALBEDO: boolean;
  100333. PREPASS_ALBEDO_INDEX: number;
  100334. PREPASS_DEPTHNORMAL: boolean;
  100335. PREPASS_DEPTHNORMAL_INDEX: number;
  100336. PREPASS_POSITION: boolean;
  100337. PREPASS_POSITION_INDEX: number;
  100338. PREPASS_VELOCITY: boolean;
  100339. PREPASS_VELOCITY_INDEX: number;
  100340. PREPASS_REFLECTIVITY: boolean;
  100341. PREPASS_REFLECTIVITY_INDEX: number;
  100342. SCENE_MRT_COUNT: number;
  100343. RGBDLIGHTMAP: boolean;
  100344. RGBDREFLECTION: boolean;
  100345. RGBDREFRACTION: boolean;
  100346. IMAGEPROCESSING: boolean;
  100347. VIGNETTE: boolean;
  100348. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100349. VIGNETTEBLENDMODEOPAQUE: boolean;
  100350. TONEMAPPING: boolean;
  100351. TONEMAPPING_ACES: boolean;
  100352. CONTRAST: boolean;
  100353. COLORCURVES: boolean;
  100354. COLORGRADING: boolean;
  100355. COLORGRADING3D: boolean;
  100356. SAMPLER3DGREENDEPTH: boolean;
  100357. SAMPLER3DBGRMAP: boolean;
  100358. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100359. MULTIVIEW: boolean;
  100360. /**
  100361. * If the reflection texture on this material is in linear color space
  100362. * @hidden
  100363. */
  100364. IS_REFLECTION_LINEAR: boolean;
  100365. /**
  100366. * If the refraction texture on this material is in linear color space
  100367. * @hidden
  100368. */
  100369. IS_REFRACTION_LINEAR: boolean;
  100370. EXPOSURE: boolean;
  100371. constructor();
  100372. setReflectionMode(modeToEnable: string): void;
  100373. }
  100374. /**
  100375. * This is the default material used in Babylon. It is the best trade off between quality
  100376. * and performances.
  100377. * @see https://doc.babylonjs.com/babylon101/materials
  100378. */
  100379. export class StandardMaterial extends PushMaterial {
  100380. private _diffuseTexture;
  100381. /**
  100382. * The basic texture of the material as viewed under a light.
  100383. */
  100384. diffuseTexture: Nullable<BaseTexture>;
  100385. private _ambientTexture;
  100386. /**
  100387. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100388. */
  100389. ambientTexture: Nullable<BaseTexture>;
  100390. private _opacityTexture;
  100391. /**
  100392. * Define the transparency of the material from a texture.
  100393. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100394. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100395. */
  100396. opacityTexture: Nullable<BaseTexture>;
  100397. private _reflectionTexture;
  100398. /**
  100399. * Define the texture used to display the reflection.
  100400. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100401. */
  100402. reflectionTexture: Nullable<BaseTexture>;
  100403. private _emissiveTexture;
  100404. /**
  100405. * Define texture of the material as if self lit.
  100406. * This will be mixed in the final result even in the absence of light.
  100407. */
  100408. emissiveTexture: Nullable<BaseTexture>;
  100409. private _specularTexture;
  100410. /**
  100411. * Define how the color and intensity of the highlight given by the light in the material.
  100412. */
  100413. specularTexture: Nullable<BaseTexture>;
  100414. private _bumpTexture;
  100415. /**
  100416. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100417. * 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.
  100418. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  100419. */
  100420. bumpTexture: Nullable<BaseTexture>;
  100421. private _lightmapTexture;
  100422. /**
  100423. * Complex lighting can be computationally expensive to compute at runtime.
  100424. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100425. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  100426. */
  100427. lightmapTexture: Nullable<BaseTexture>;
  100428. private _refractionTexture;
  100429. /**
  100430. * Define the texture used to display the refraction.
  100431. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100432. */
  100433. refractionTexture: Nullable<BaseTexture>;
  100434. /**
  100435. * The color of the material lit by the environmental background lighting.
  100436. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  100437. */
  100438. ambientColor: Color3;
  100439. /**
  100440. * The basic color of the material as viewed under a light.
  100441. */
  100442. diffuseColor: Color3;
  100443. /**
  100444. * Define how the color and intensity of the highlight given by the light in the material.
  100445. */
  100446. specularColor: Color3;
  100447. /**
  100448. * Define the color of the material as if self lit.
  100449. * This will be mixed in the final result even in the absence of light.
  100450. */
  100451. emissiveColor: Color3;
  100452. /**
  100453. * Defines how sharp are the highlights in the material.
  100454. * The bigger the value the sharper giving a more glossy feeling to the result.
  100455. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  100456. */
  100457. specularPower: number;
  100458. private _useAlphaFromDiffuseTexture;
  100459. /**
  100460. * Does the transparency come from the diffuse texture alpha channel.
  100461. */
  100462. useAlphaFromDiffuseTexture: boolean;
  100463. private _useEmissiveAsIllumination;
  100464. /**
  100465. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  100466. */
  100467. useEmissiveAsIllumination: boolean;
  100468. private _linkEmissiveWithDiffuse;
  100469. /**
  100470. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  100471. * the emissive level when the final color is close to one.
  100472. */
  100473. linkEmissiveWithDiffuse: boolean;
  100474. private _useSpecularOverAlpha;
  100475. /**
  100476. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  100477. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  100478. */
  100479. useSpecularOverAlpha: boolean;
  100480. private _useReflectionOverAlpha;
  100481. /**
  100482. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  100483. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  100484. */
  100485. useReflectionOverAlpha: boolean;
  100486. private _disableLighting;
  100487. /**
  100488. * Does lights from the scene impacts this material.
  100489. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  100490. */
  100491. disableLighting: boolean;
  100492. private _useObjectSpaceNormalMap;
  100493. /**
  100494. * Allows using an object space normal map (instead of tangent space).
  100495. */
  100496. useObjectSpaceNormalMap: boolean;
  100497. private _useParallax;
  100498. /**
  100499. * Is parallax enabled or not.
  100500. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100501. */
  100502. useParallax: boolean;
  100503. private _useParallaxOcclusion;
  100504. /**
  100505. * Is parallax occlusion enabled or not.
  100506. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  100507. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  100508. */
  100509. useParallaxOcclusion: boolean;
  100510. /**
  100511. * 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.
  100512. */
  100513. parallaxScaleBias: number;
  100514. private _roughness;
  100515. /**
  100516. * Helps to define how blurry the reflections should appears in the material.
  100517. */
  100518. roughness: number;
  100519. /**
  100520. * In case of refraction, define the value of the index of refraction.
  100521. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100522. */
  100523. indexOfRefraction: number;
  100524. /**
  100525. * Invert the refraction texture alongside the y axis.
  100526. * It can be useful with procedural textures or probe for instance.
  100527. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100528. */
  100529. invertRefractionY: boolean;
  100530. /**
  100531. * Defines the alpha limits in alpha test mode.
  100532. */
  100533. alphaCutOff: number;
  100534. private _useLightmapAsShadowmap;
  100535. /**
  100536. * In case of light mapping, define whether the map contains light or shadow informations.
  100537. */
  100538. useLightmapAsShadowmap: boolean;
  100539. private _diffuseFresnelParameters;
  100540. /**
  100541. * Define the diffuse fresnel parameters of the material.
  100542. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100543. */
  100544. diffuseFresnelParameters: FresnelParameters;
  100545. private _opacityFresnelParameters;
  100546. /**
  100547. * Define the opacity fresnel parameters of the material.
  100548. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100549. */
  100550. opacityFresnelParameters: FresnelParameters;
  100551. private _reflectionFresnelParameters;
  100552. /**
  100553. * Define the reflection fresnel parameters of the material.
  100554. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100555. */
  100556. reflectionFresnelParameters: FresnelParameters;
  100557. private _refractionFresnelParameters;
  100558. /**
  100559. * Define the refraction fresnel parameters of the material.
  100560. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100561. */
  100562. refractionFresnelParameters: FresnelParameters;
  100563. private _emissiveFresnelParameters;
  100564. /**
  100565. * Define the emissive fresnel parameters of the material.
  100566. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100567. */
  100568. emissiveFresnelParameters: FresnelParameters;
  100569. private _useReflectionFresnelFromSpecular;
  100570. /**
  100571. * If true automatically deducts the fresnels values from the material specularity.
  100572. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100573. */
  100574. useReflectionFresnelFromSpecular: boolean;
  100575. private _useGlossinessFromSpecularMapAlpha;
  100576. /**
  100577. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  100578. */
  100579. useGlossinessFromSpecularMapAlpha: boolean;
  100580. private _maxSimultaneousLights;
  100581. /**
  100582. * Defines the maximum number of lights that can be used in the material
  100583. */
  100584. maxSimultaneousLights: number;
  100585. private _invertNormalMapX;
  100586. /**
  100587. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  100588. */
  100589. invertNormalMapX: boolean;
  100590. private _invertNormalMapY;
  100591. /**
  100592. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  100593. */
  100594. invertNormalMapY: boolean;
  100595. private _twoSidedLighting;
  100596. /**
  100597. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  100598. */
  100599. twoSidedLighting: boolean;
  100600. /**
  100601. * Default configuration related to image processing available in the standard Material.
  100602. */
  100603. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100604. /**
  100605. * Gets the image processing configuration used either in this material.
  100606. */
  100607. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100608. /**
  100609. * Sets the Default image processing configuration used either in the this material.
  100610. *
  100611. * If sets to null, the scene one is in use.
  100612. */
  100613. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100614. /**
  100615. * Keep track of the image processing observer to allow dispose and replace.
  100616. */
  100617. private _imageProcessingObserver;
  100618. /**
  100619. * Attaches a new image processing configuration to the Standard Material.
  100620. * @param configuration
  100621. */
  100622. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100623. /**
  100624. * Defines additionnal PrePass parameters for the material.
  100625. */
  100626. readonly prePassConfiguration: PrePassConfiguration;
  100627. /**
  100628. * Gets wether the color curves effect is enabled.
  100629. */
  100630. get cameraColorCurvesEnabled(): boolean;
  100631. /**
  100632. * Sets wether the color curves effect is enabled.
  100633. */
  100634. set cameraColorCurvesEnabled(value: boolean);
  100635. /**
  100636. * Gets wether the color grading effect is enabled.
  100637. */
  100638. get cameraColorGradingEnabled(): boolean;
  100639. /**
  100640. * Gets wether the color grading effect is enabled.
  100641. */
  100642. set cameraColorGradingEnabled(value: boolean);
  100643. /**
  100644. * Gets wether tonemapping is enabled or not.
  100645. */
  100646. get cameraToneMappingEnabled(): boolean;
  100647. /**
  100648. * Sets wether tonemapping is enabled or not
  100649. */
  100650. set cameraToneMappingEnabled(value: boolean);
  100651. /**
  100652. * The camera exposure used on this material.
  100653. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100654. * This corresponds to a photographic exposure.
  100655. */
  100656. get cameraExposure(): number;
  100657. /**
  100658. * The camera exposure used on this material.
  100659. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  100660. * This corresponds to a photographic exposure.
  100661. */
  100662. set cameraExposure(value: number);
  100663. /**
  100664. * Gets The camera contrast used on this material.
  100665. */
  100666. get cameraContrast(): number;
  100667. /**
  100668. * Sets The camera contrast used on this material.
  100669. */
  100670. set cameraContrast(value: number);
  100671. /**
  100672. * Gets the Color Grading 2D Lookup Texture.
  100673. */
  100674. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100675. /**
  100676. * Sets the Color Grading 2D Lookup Texture.
  100677. */
  100678. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100679. /**
  100680. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100681. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100682. * 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;
  100683. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100684. */
  100685. get cameraColorCurves(): Nullable<ColorCurves>;
  100686. /**
  100687. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100688. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100689. * 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;
  100690. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100691. */
  100692. set cameraColorCurves(value: Nullable<ColorCurves>);
  100693. /**
  100694. * Can this material render to several textures at once
  100695. */
  100696. get canRenderToMRT(): boolean;
  100697. /**
  100698. * Defines the detail map parameters for the material.
  100699. */
  100700. readonly detailMap: DetailMapConfiguration;
  100701. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100702. protected _worldViewProjectionMatrix: Matrix;
  100703. protected _globalAmbientColor: Color3;
  100704. protected _useLogarithmicDepth: boolean;
  100705. protected _rebuildInParallel: boolean;
  100706. /**
  100707. * Instantiates a new standard material.
  100708. * This is the default material used in Babylon. It is the best trade off between quality
  100709. * and performances.
  100710. * @see https://doc.babylonjs.com/babylon101/materials
  100711. * @param name Define the name of the material in the scene
  100712. * @param scene Define the scene the material belong to
  100713. */
  100714. constructor(name: string, scene: Scene);
  100715. /**
  100716. * Gets a boolean indicating that current material needs to register RTT
  100717. */
  100718. get hasRenderTargetTextures(): boolean;
  100719. /**
  100720. * Gets the current class name of the material e.g. "StandardMaterial"
  100721. * Mainly use in serialization.
  100722. * @returns the class name
  100723. */
  100724. getClassName(): string;
  100725. /**
  100726. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100727. * You can try switching to logarithmic depth.
  100728. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100729. */
  100730. get useLogarithmicDepth(): boolean;
  100731. set useLogarithmicDepth(value: boolean);
  100732. /**
  100733. * Specifies if the material will require alpha blending
  100734. * @returns a boolean specifying if alpha blending is needed
  100735. */
  100736. needAlphaBlending(): boolean;
  100737. /**
  100738. * Specifies if this material should be rendered in alpha test mode
  100739. * @returns a boolean specifying if an alpha test is needed.
  100740. */
  100741. needAlphaTesting(): boolean;
  100742. /**
  100743. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  100744. */
  100745. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100746. /**
  100747. * Specifies whether or not there is a usable alpha channel for transparency.
  100748. */
  100749. protected _hasAlphaChannel(): boolean;
  100750. /**
  100751. * Get the texture used for alpha test purpose.
  100752. * @returns the diffuse texture in case of the standard material.
  100753. */
  100754. getAlphaTestTexture(): Nullable<BaseTexture>;
  100755. /**
  100756. * Get if the submesh is ready to be used and all its information available.
  100757. * Child classes can use it to update shaders
  100758. * @param mesh defines the mesh to check
  100759. * @param subMesh defines which submesh to check
  100760. * @param useInstances specifies that instances should be used
  100761. * @returns a boolean indicating that the submesh is ready or not
  100762. */
  100763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100764. /**
  100765. * Builds the material UBO layouts.
  100766. * Used internally during the effect preparation.
  100767. */
  100768. buildUniformLayout(): void;
  100769. /**
  100770. * Unbinds the material from the mesh
  100771. */
  100772. unbind(): void;
  100773. /**
  100774. * Binds the submesh to this material by preparing the effect and shader to draw
  100775. * @param world defines the world transformation matrix
  100776. * @param mesh defines the mesh containing the submesh
  100777. * @param subMesh defines the submesh to bind the material to
  100778. */
  100779. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100780. /**
  100781. * Get the list of animatables in the material.
  100782. * @returns the list of animatables object used in the material
  100783. */
  100784. getAnimatables(): IAnimatable[];
  100785. /**
  100786. * Gets the active textures from the material
  100787. * @returns an array of textures
  100788. */
  100789. getActiveTextures(): BaseTexture[];
  100790. /**
  100791. * Specifies if the material uses a texture
  100792. * @param texture defines the texture to check against the material
  100793. * @returns a boolean specifying if the material uses the texture
  100794. */
  100795. hasTexture(texture: BaseTexture): boolean;
  100796. /**
  100797. * Disposes the material
  100798. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100799. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100800. */
  100801. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100802. /**
  100803. * Makes a duplicate of the material, and gives it a new name
  100804. * @param name defines the new name for the duplicated material
  100805. * @returns the cloned material
  100806. */
  100807. clone(name: string): StandardMaterial;
  100808. /**
  100809. * Serializes this material in a JSON representation
  100810. * @returns the serialized material object
  100811. */
  100812. serialize(): any;
  100813. /**
  100814. * Creates a standard material from parsed material data
  100815. * @param source defines the JSON representation of the material
  100816. * @param scene defines the hosting scene
  100817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100818. * @returns a new standard material
  100819. */
  100820. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100821. /**
  100822. * Are diffuse textures enabled in the application.
  100823. */
  100824. static get DiffuseTextureEnabled(): boolean;
  100825. static set DiffuseTextureEnabled(value: boolean);
  100826. /**
  100827. * Are detail textures enabled in the application.
  100828. */
  100829. static get DetailTextureEnabled(): boolean;
  100830. static set DetailTextureEnabled(value: boolean);
  100831. /**
  100832. * Are ambient textures enabled in the application.
  100833. */
  100834. static get AmbientTextureEnabled(): boolean;
  100835. static set AmbientTextureEnabled(value: boolean);
  100836. /**
  100837. * Are opacity textures enabled in the application.
  100838. */
  100839. static get OpacityTextureEnabled(): boolean;
  100840. static set OpacityTextureEnabled(value: boolean);
  100841. /**
  100842. * Are reflection textures enabled in the application.
  100843. */
  100844. static get ReflectionTextureEnabled(): boolean;
  100845. static set ReflectionTextureEnabled(value: boolean);
  100846. /**
  100847. * Are emissive textures enabled in the application.
  100848. */
  100849. static get EmissiveTextureEnabled(): boolean;
  100850. static set EmissiveTextureEnabled(value: boolean);
  100851. /**
  100852. * Are specular textures enabled in the application.
  100853. */
  100854. static get SpecularTextureEnabled(): boolean;
  100855. static set SpecularTextureEnabled(value: boolean);
  100856. /**
  100857. * Are bump textures enabled in the application.
  100858. */
  100859. static get BumpTextureEnabled(): boolean;
  100860. static set BumpTextureEnabled(value: boolean);
  100861. /**
  100862. * Are lightmap textures enabled in the application.
  100863. */
  100864. static get LightmapTextureEnabled(): boolean;
  100865. static set LightmapTextureEnabled(value: boolean);
  100866. /**
  100867. * Are refraction textures enabled in the application.
  100868. */
  100869. static get RefractionTextureEnabled(): boolean;
  100870. static set RefractionTextureEnabled(value: boolean);
  100871. /**
  100872. * Are color grading textures enabled in the application.
  100873. */
  100874. static get ColorGradingTextureEnabled(): boolean;
  100875. static set ColorGradingTextureEnabled(value: boolean);
  100876. /**
  100877. * Are fresnels enabled in the application.
  100878. */
  100879. static get FresnelEnabled(): boolean;
  100880. static set FresnelEnabled(value: boolean);
  100881. }
  100882. }
  100883. declare module BABYLON {
  100884. /** @hidden */
  100885. export var rgbdDecodePixelShader: {
  100886. name: string;
  100887. shader: string;
  100888. };
  100889. }
  100890. declare module BABYLON {
  100891. /**
  100892. * Class used to host RGBD texture specific utilities
  100893. */
  100894. export class RGBDTextureTools {
  100895. /**
  100896. * Expand the RGBD Texture from RGBD to Half Float if possible.
  100897. * @param texture the texture to expand.
  100898. */
  100899. static ExpandRGBDTexture(texture: Texture): void;
  100900. }
  100901. }
  100902. declare module BABYLON {
  100903. /**
  100904. * Class used to host texture specific utilities
  100905. */
  100906. export class BRDFTextureTools {
  100907. /**
  100908. * Prevents texture cache collision
  100909. */
  100910. private static _instanceNumber;
  100911. /**
  100912. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  100913. * @param scene defines the hosting scene
  100914. * @returns the environment BRDF texture
  100915. */
  100916. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  100917. private static _environmentBRDFBase64Texture;
  100918. }
  100919. }
  100920. declare module BABYLON {
  100921. /**
  100922. * @hidden
  100923. */
  100924. export interface IMaterialClearCoatDefines {
  100925. CLEARCOAT: boolean;
  100926. CLEARCOAT_DEFAULTIOR: boolean;
  100927. CLEARCOAT_TEXTURE: boolean;
  100928. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  100929. CLEARCOAT_TEXTUREDIRECTUV: number;
  100930. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  100931. CLEARCOAT_BUMP: boolean;
  100932. CLEARCOAT_BUMPDIRECTUV: number;
  100933. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  100934. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  100935. CLEARCOAT_REMAP_F0: boolean;
  100936. CLEARCOAT_TINT: boolean;
  100937. CLEARCOAT_TINT_TEXTURE: boolean;
  100938. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  100939. /** @hidden */
  100940. _areTexturesDirty: boolean;
  100941. }
  100942. /**
  100943. * Define the code related to the clear coat parameters of the pbr material.
  100944. */
  100945. export class PBRClearCoatConfiguration {
  100946. /**
  100947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100948. * The default fits with a polyurethane material.
  100949. * @hidden
  100950. */
  100951. static readonly _DefaultIndexOfRefraction: number;
  100952. private _isEnabled;
  100953. /**
  100954. * Defines if the clear coat is enabled in the material.
  100955. */
  100956. isEnabled: boolean;
  100957. /**
  100958. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  100959. */
  100960. intensity: number;
  100961. /**
  100962. * Defines the clear coat layer roughness.
  100963. */
  100964. roughness: number;
  100965. private _indexOfRefraction;
  100966. /**
  100967. * Defines the index of refraction of the clear coat.
  100968. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  100969. * The default fits with a polyurethane material.
  100970. * Changing the default value is more performance intensive.
  100971. */
  100972. indexOfRefraction: number;
  100973. private _texture;
  100974. /**
  100975. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  100976. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  100977. * if textureRoughness is not empty, else no texture roughness is used
  100978. */
  100979. texture: Nullable<BaseTexture>;
  100980. private _useRoughnessFromMainTexture;
  100981. /**
  100982. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  100983. * If false, the green channel from textureRoughness is used for roughness
  100984. */
  100985. useRoughnessFromMainTexture: boolean;
  100986. private _textureRoughness;
  100987. /**
  100988. * Stores the clear coat roughness in a texture (green channel)
  100989. * Not used if useRoughnessFromMainTexture is true
  100990. */
  100991. textureRoughness: Nullable<BaseTexture>;
  100992. private _remapF0OnInterfaceChange;
  100993. /**
  100994. * Defines if the F0 value should be remapped to account for the interface change in the material.
  100995. */
  100996. remapF0OnInterfaceChange: boolean;
  100997. private _bumpTexture;
  100998. /**
  100999. * Define the clear coat specific bump texture.
  101000. */
  101001. bumpTexture: Nullable<BaseTexture>;
  101002. private _isTintEnabled;
  101003. /**
  101004. * Defines if the clear coat tint is enabled in the material.
  101005. */
  101006. isTintEnabled: boolean;
  101007. /**
  101008. * Defines the clear coat tint of the material.
  101009. * This is only use if tint is enabled
  101010. */
  101011. tintColor: Color3;
  101012. /**
  101013. * Defines the distance at which the tint color should be found in the
  101014. * clear coat media.
  101015. * This is only use if tint is enabled
  101016. */
  101017. tintColorAtDistance: number;
  101018. /**
  101019. * Defines the clear coat layer thickness.
  101020. * This is only use if tint is enabled
  101021. */
  101022. tintThickness: number;
  101023. private _tintTexture;
  101024. /**
  101025. * Stores the clear tint values in a texture.
  101026. * rgb is tint
  101027. * a is a thickness factor
  101028. */
  101029. tintTexture: Nullable<BaseTexture>;
  101030. /** @hidden */
  101031. private _internalMarkAllSubMeshesAsTexturesDirty;
  101032. /** @hidden */
  101033. _markAllSubMeshesAsTexturesDirty(): void;
  101034. /**
  101035. * Instantiate a new istance of clear coat configuration.
  101036. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101037. */
  101038. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101039. /**
  101040. * Gets wehter the submesh is ready to be used or not.
  101041. * @param defines the list of "defines" to update.
  101042. * @param scene defines the scene the material belongs to.
  101043. * @param engine defines the engine the material belongs to.
  101044. * @param disableBumpMap defines wether the material disables bump or not.
  101045. * @returns - boolean indicating that the submesh is ready or not.
  101046. */
  101047. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  101048. /**
  101049. * Checks to see if a texture is used in the material.
  101050. * @param defines the list of "defines" to update.
  101051. * @param scene defines the scene to the material belongs to.
  101052. */
  101053. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  101054. /**
  101055. * Binds the material data.
  101056. * @param uniformBuffer defines the Uniform buffer to fill in.
  101057. * @param scene defines the scene the material belongs to.
  101058. * @param engine defines the engine the material belongs to.
  101059. * @param disableBumpMap defines wether the material disables bump or not.
  101060. * @param isFrozen defines wether the material is frozen or not.
  101061. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  101062. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  101063. * @param subMesh the submesh to bind data for
  101064. */
  101065. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  101066. /**
  101067. * Checks to see if a texture is used in the material.
  101068. * @param texture - Base texture to use.
  101069. * @returns - Boolean specifying if a texture is used in the material.
  101070. */
  101071. hasTexture(texture: BaseTexture): boolean;
  101072. /**
  101073. * Returns an array of the actively used textures.
  101074. * @param activeTextures Array of BaseTextures
  101075. */
  101076. getActiveTextures(activeTextures: BaseTexture[]): void;
  101077. /**
  101078. * Returns the animatable textures.
  101079. * @param animatables Array of animatable textures.
  101080. */
  101081. getAnimatables(animatables: IAnimatable[]): void;
  101082. /**
  101083. * Disposes the resources of the material.
  101084. * @param forceDisposeTextures - Forces the disposal of all textures.
  101085. */
  101086. dispose(forceDisposeTextures?: boolean): void;
  101087. /**
  101088. * Get the current class name of the texture useful for serialization or dynamic coding.
  101089. * @returns "PBRClearCoatConfiguration"
  101090. */
  101091. getClassName(): string;
  101092. /**
  101093. * Add fallbacks to the effect fallbacks list.
  101094. * @param defines defines the Base texture to use.
  101095. * @param fallbacks defines the current fallback list.
  101096. * @param currentRank defines the current fallback rank.
  101097. * @returns the new fallback rank.
  101098. */
  101099. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101100. /**
  101101. * Add the required uniforms to the current list.
  101102. * @param uniforms defines the current uniform list.
  101103. */
  101104. static AddUniforms(uniforms: string[]): void;
  101105. /**
  101106. * Add the required samplers to the current list.
  101107. * @param samplers defines the current sampler list.
  101108. */
  101109. static AddSamplers(samplers: string[]): void;
  101110. /**
  101111. * Add the required uniforms to the current buffer.
  101112. * @param uniformBuffer defines the current uniform buffer.
  101113. */
  101114. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101115. /**
  101116. * Makes a duplicate of the current configuration into another one.
  101117. * @param clearCoatConfiguration define the config where to copy the info
  101118. */
  101119. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  101120. /**
  101121. * Serializes this clear coat configuration.
  101122. * @returns - An object with the serialized config.
  101123. */
  101124. serialize(): any;
  101125. /**
  101126. * Parses a anisotropy Configuration from a serialized object.
  101127. * @param source - Serialized object.
  101128. * @param scene Defines the scene we are parsing for
  101129. * @param rootUrl Defines the rootUrl to load from
  101130. */
  101131. parse(source: any, scene: Scene, rootUrl: string): void;
  101132. }
  101133. }
  101134. declare module BABYLON {
  101135. /**
  101136. * @hidden
  101137. */
  101138. export interface IMaterialAnisotropicDefines {
  101139. ANISOTROPIC: boolean;
  101140. ANISOTROPIC_TEXTURE: boolean;
  101141. ANISOTROPIC_TEXTUREDIRECTUV: number;
  101142. MAINUV1: boolean;
  101143. _areTexturesDirty: boolean;
  101144. _needUVs: boolean;
  101145. }
  101146. /**
  101147. * Define the code related to the anisotropic parameters of the pbr material.
  101148. */
  101149. export class PBRAnisotropicConfiguration {
  101150. private _isEnabled;
  101151. /**
  101152. * Defines if the anisotropy is enabled in the material.
  101153. */
  101154. isEnabled: boolean;
  101155. /**
  101156. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  101157. */
  101158. intensity: number;
  101159. /**
  101160. * Defines if the effect is along the tangents, bitangents or in between.
  101161. * By default, the effect is "strectching" the highlights along the tangents.
  101162. */
  101163. direction: Vector2;
  101164. private _texture;
  101165. /**
  101166. * Stores the anisotropy values in a texture.
  101167. * rg is direction (like normal from -1 to 1)
  101168. * b is a intensity
  101169. */
  101170. texture: Nullable<BaseTexture>;
  101171. /** @hidden */
  101172. private _internalMarkAllSubMeshesAsTexturesDirty;
  101173. /** @hidden */
  101174. _markAllSubMeshesAsTexturesDirty(): void;
  101175. /**
  101176. * Instantiate a new istance of anisotropy configuration.
  101177. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101178. */
  101179. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101180. /**
  101181. * Specifies that the submesh is ready to be used.
  101182. * @param defines the list of "defines" to update.
  101183. * @param scene defines the scene the material belongs to.
  101184. * @returns - boolean indicating that the submesh is ready or not.
  101185. */
  101186. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  101187. /**
  101188. * Checks to see if a texture is used in the material.
  101189. * @param defines the list of "defines" to update.
  101190. * @param mesh the mesh we are preparing the defines for.
  101191. * @param scene defines the scene the material belongs to.
  101192. */
  101193. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  101194. /**
  101195. * Binds the material data.
  101196. * @param uniformBuffer defines the Uniform buffer to fill in.
  101197. * @param scene defines the scene the material belongs to.
  101198. * @param isFrozen defines wether the material is frozen or not.
  101199. */
  101200. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  101201. /**
  101202. * Checks to see if a texture is used in the material.
  101203. * @param texture - Base texture to use.
  101204. * @returns - Boolean specifying if a texture is used in the material.
  101205. */
  101206. hasTexture(texture: BaseTexture): boolean;
  101207. /**
  101208. * Returns an array of the actively used textures.
  101209. * @param activeTextures Array of BaseTextures
  101210. */
  101211. getActiveTextures(activeTextures: BaseTexture[]): void;
  101212. /**
  101213. * Returns the animatable textures.
  101214. * @param animatables Array of animatable textures.
  101215. */
  101216. getAnimatables(animatables: IAnimatable[]): void;
  101217. /**
  101218. * Disposes the resources of the material.
  101219. * @param forceDisposeTextures - Forces the disposal of all textures.
  101220. */
  101221. dispose(forceDisposeTextures?: boolean): void;
  101222. /**
  101223. * Get the current class name of the texture useful for serialization or dynamic coding.
  101224. * @returns "PBRAnisotropicConfiguration"
  101225. */
  101226. getClassName(): string;
  101227. /**
  101228. * Add fallbacks to the effect fallbacks list.
  101229. * @param defines defines the Base texture to use.
  101230. * @param fallbacks defines the current fallback list.
  101231. * @param currentRank defines the current fallback rank.
  101232. * @returns the new fallback rank.
  101233. */
  101234. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101235. /**
  101236. * Add the required uniforms to the current list.
  101237. * @param uniforms defines the current uniform list.
  101238. */
  101239. static AddUniforms(uniforms: string[]): void;
  101240. /**
  101241. * Add the required uniforms to the current buffer.
  101242. * @param uniformBuffer defines the current uniform buffer.
  101243. */
  101244. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101245. /**
  101246. * Add the required samplers to the current list.
  101247. * @param samplers defines the current sampler list.
  101248. */
  101249. static AddSamplers(samplers: string[]): void;
  101250. /**
  101251. * Makes a duplicate of the current configuration into another one.
  101252. * @param anisotropicConfiguration define the config where to copy the info
  101253. */
  101254. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  101255. /**
  101256. * Serializes this anisotropy configuration.
  101257. * @returns - An object with the serialized config.
  101258. */
  101259. serialize(): any;
  101260. /**
  101261. * Parses a anisotropy Configuration from a serialized object.
  101262. * @param source - Serialized object.
  101263. * @param scene Defines the scene we are parsing for
  101264. * @param rootUrl Defines the rootUrl to load from
  101265. */
  101266. parse(source: any, scene: Scene, rootUrl: string): void;
  101267. }
  101268. }
  101269. declare module BABYLON {
  101270. /**
  101271. * @hidden
  101272. */
  101273. export interface IMaterialBRDFDefines {
  101274. BRDF_V_HEIGHT_CORRELATED: boolean;
  101275. MS_BRDF_ENERGY_CONSERVATION: boolean;
  101276. SPHERICAL_HARMONICS: boolean;
  101277. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  101278. /** @hidden */
  101279. _areMiscDirty: boolean;
  101280. }
  101281. /**
  101282. * Define the code related to the BRDF parameters of the pbr material.
  101283. */
  101284. export class PBRBRDFConfiguration {
  101285. /**
  101286. * Default value used for the energy conservation.
  101287. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101288. */
  101289. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  101290. /**
  101291. * Default value used for the Smith Visibility Height Correlated mode.
  101292. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  101293. */
  101294. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  101295. /**
  101296. * Default value used for the IBL diffuse part.
  101297. * This can help switching back to the polynomials mode globally which is a tiny bit
  101298. * less GPU intensive at the drawback of a lower quality.
  101299. */
  101300. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  101301. /**
  101302. * Default value used for activating energy conservation for the specular workflow.
  101303. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101304. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101305. */
  101306. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  101307. private _useEnergyConservation;
  101308. /**
  101309. * Defines if the material uses energy conservation.
  101310. */
  101311. useEnergyConservation: boolean;
  101312. private _useSmithVisibilityHeightCorrelated;
  101313. /**
  101314. * LEGACY Mode set to false
  101315. * Defines if the material uses height smith correlated visibility term.
  101316. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  101317. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  101318. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  101319. * Not relying on height correlated will also disable energy conservation.
  101320. */
  101321. useSmithVisibilityHeightCorrelated: boolean;
  101322. private _useSphericalHarmonics;
  101323. /**
  101324. * LEGACY Mode set to false
  101325. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  101326. * diffuse part of the IBL.
  101327. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  101328. * to the ground truth.
  101329. */
  101330. useSphericalHarmonics: boolean;
  101331. private _useSpecularGlossinessInputEnergyConservation;
  101332. /**
  101333. * Defines if the material uses energy conservation, when the specular workflow is active.
  101334. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  101335. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  101336. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  101337. */
  101338. useSpecularGlossinessInputEnergyConservation: boolean;
  101339. /** @hidden */
  101340. private _internalMarkAllSubMeshesAsMiscDirty;
  101341. /** @hidden */
  101342. _markAllSubMeshesAsMiscDirty(): void;
  101343. /**
  101344. * Instantiate a new istance of clear coat configuration.
  101345. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  101346. */
  101347. constructor(markAllSubMeshesAsMiscDirty: () => void);
  101348. /**
  101349. * Checks to see if a texture is used in the material.
  101350. * @param defines the list of "defines" to update.
  101351. */
  101352. prepareDefines(defines: IMaterialBRDFDefines): void;
  101353. /**
  101354. * Get the current class name of the texture useful for serialization or dynamic coding.
  101355. * @returns "PBRClearCoatConfiguration"
  101356. */
  101357. getClassName(): string;
  101358. /**
  101359. * Makes a duplicate of the current configuration into another one.
  101360. * @param brdfConfiguration define the config where to copy the info
  101361. */
  101362. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  101363. /**
  101364. * Serializes this BRDF configuration.
  101365. * @returns - An object with the serialized config.
  101366. */
  101367. serialize(): any;
  101368. /**
  101369. * Parses a anisotropy Configuration from a serialized object.
  101370. * @param source - Serialized object.
  101371. * @param scene Defines the scene we are parsing for
  101372. * @param rootUrl Defines the rootUrl to load from
  101373. */
  101374. parse(source: any, scene: Scene, rootUrl: string): void;
  101375. }
  101376. }
  101377. declare module BABYLON {
  101378. /**
  101379. * @hidden
  101380. */
  101381. export interface IMaterialSheenDefines {
  101382. SHEEN: boolean;
  101383. SHEEN_TEXTURE: boolean;
  101384. SHEEN_TEXTURE_ROUGHNESS: boolean;
  101385. SHEEN_TEXTUREDIRECTUV: number;
  101386. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  101387. SHEEN_LINKWITHALBEDO: boolean;
  101388. SHEEN_ROUGHNESS: boolean;
  101389. SHEEN_ALBEDOSCALING: boolean;
  101390. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  101391. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  101392. /** @hidden */
  101393. _areTexturesDirty: boolean;
  101394. }
  101395. /**
  101396. * Define the code related to the Sheen parameters of the pbr material.
  101397. */
  101398. export class PBRSheenConfiguration {
  101399. private _isEnabled;
  101400. /**
  101401. * Defines if the material uses sheen.
  101402. */
  101403. isEnabled: boolean;
  101404. private _linkSheenWithAlbedo;
  101405. /**
  101406. * Defines if the sheen is linked to the sheen color.
  101407. */
  101408. linkSheenWithAlbedo: boolean;
  101409. /**
  101410. * Defines the sheen intensity.
  101411. */
  101412. intensity: number;
  101413. /**
  101414. * Defines the sheen color.
  101415. */
  101416. color: Color3;
  101417. private _texture;
  101418. /**
  101419. * Stores the sheen tint values in a texture.
  101420. * rgb is tint
  101421. * a is a intensity or roughness if the roughness property has been defined and useRoughnessFromTexture is true (in that case, textureRoughness won't be used)
  101422. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  101423. */
  101424. texture: Nullable<BaseTexture>;
  101425. private _useRoughnessFromMainTexture;
  101426. /**
  101427. * Indicates that the alpha channel of the texture property will be used for roughness.
  101428. * Has no effect if the roughness (and texture!) property is not defined
  101429. */
  101430. useRoughnessFromMainTexture: boolean;
  101431. private _roughness;
  101432. /**
  101433. * Defines the sheen roughness.
  101434. * It is not taken into account if linkSheenWithAlbedo is true.
  101435. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  101436. */
  101437. roughness: Nullable<number>;
  101438. private _textureRoughness;
  101439. /**
  101440. * Stores the sheen roughness in a texture.
  101441. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  101442. */
  101443. textureRoughness: Nullable<BaseTexture>;
  101444. private _albedoScaling;
  101445. /**
  101446. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  101447. * It allows the strength of the sheen effect to not depend on the base color of the material,
  101448. * making it easier to setup and tweak the effect
  101449. */
  101450. albedoScaling: boolean;
  101451. /** @hidden */
  101452. private _internalMarkAllSubMeshesAsTexturesDirty;
  101453. /** @hidden */
  101454. _markAllSubMeshesAsTexturesDirty(): void;
  101455. /**
  101456. * Instantiate a new istance of clear coat configuration.
  101457. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101458. */
  101459. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  101460. /**
  101461. * Specifies that the submesh is ready to be used.
  101462. * @param defines the list of "defines" to update.
  101463. * @param scene defines the scene the material belongs to.
  101464. * @returns - boolean indicating that the submesh is ready or not.
  101465. */
  101466. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  101467. /**
  101468. * Checks to see if a texture is used in the material.
  101469. * @param defines the list of "defines" to update.
  101470. * @param scene defines the scene the material belongs to.
  101471. */
  101472. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  101473. /**
  101474. * Binds the material data.
  101475. * @param uniformBuffer defines the Uniform buffer to fill in.
  101476. * @param scene defines the scene the material belongs to.
  101477. * @param isFrozen defines wether the material is frozen or not.
  101478. * @param subMesh the submesh to bind data for
  101479. */
  101480. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  101481. /**
  101482. * Checks to see if a texture is used in the material.
  101483. * @param texture - Base texture to use.
  101484. * @returns - Boolean specifying if a texture is used in the material.
  101485. */
  101486. hasTexture(texture: BaseTexture): boolean;
  101487. /**
  101488. * Returns an array of the actively used textures.
  101489. * @param activeTextures Array of BaseTextures
  101490. */
  101491. getActiveTextures(activeTextures: BaseTexture[]): void;
  101492. /**
  101493. * Returns the animatable textures.
  101494. * @param animatables Array of animatable textures.
  101495. */
  101496. getAnimatables(animatables: IAnimatable[]): void;
  101497. /**
  101498. * Disposes the resources of the material.
  101499. * @param forceDisposeTextures - Forces the disposal of all textures.
  101500. */
  101501. dispose(forceDisposeTextures?: boolean): void;
  101502. /**
  101503. * Get the current class name of the texture useful for serialization or dynamic coding.
  101504. * @returns "PBRSheenConfiguration"
  101505. */
  101506. getClassName(): string;
  101507. /**
  101508. * Add fallbacks to the effect fallbacks list.
  101509. * @param defines defines the Base texture to use.
  101510. * @param fallbacks defines the current fallback list.
  101511. * @param currentRank defines the current fallback rank.
  101512. * @returns the new fallback rank.
  101513. */
  101514. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101515. /**
  101516. * Add the required uniforms to the current list.
  101517. * @param uniforms defines the current uniform list.
  101518. */
  101519. static AddUniforms(uniforms: string[]): void;
  101520. /**
  101521. * Add the required uniforms to the current buffer.
  101522. * @param uniformBuffer defines the current uniform buffer.
  101523. */
  101524. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101525. /**
  101526. * Add the required samplers to the current list.
  101527. * @param samplers defines the current sampler list.
  101528. */
  101529. static AddSamplers(samplers: string[]): void;
  101530. /**
  101531. * Makes a duplicate of the current configuration into another one.
  101532. * @param sheenConfiguration define the config where to copy the info
  101533. */
  101534. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  101535. /**
  101536. * Serializes this BRDF configuration.
  101537. * @returns - An object with the serialized config.
  101538. */
  101539. serialize(): any;
  101540. /**
  101541. * Parses a anisotropy Configuration from a serialized object.
  101542. * @param source - Serialized object.
  101543. * @param scene Defines the scene we are parsing for
  101544. * @param rootUrl Defines the rootUrl to load from
  101545. */
  101546. parse(source: any, scene: Scene, rootUrl: string): void;
  101547. }
  101548. }
  101549. declare module BABYLON {
  101550. /**
  101551. * @hidden
  101552. */
  101553. export interface IMaterialSubSurfaceDefines {
  101554. SUBSURFACE: boolean;
  101555. SS_REFRACTION: boolean;
  101556. SS_TRANSLUCENCY: boolean;
  101557. SS_SCATTERING: boolean;
  101558. SS_THICKNESSANDMASK_TEXTURE: boolean;
  101559. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  101560. SS_REFRACTIONMAP_3D: boolean;
  101561. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  101562. SS_LODINREFRACTIONALPHA: boolean;
  101563. SS_GAMMAREFRACTION: boolean;
  101564. SS_RGBDREFRACTION: boolean;
  101565. SS_LINEARSPECULARREFRACTION: boolean;
  101566. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  101567. SS_ALBEDOFORREFRACTIONTINT: boolean;
  101568. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  101569. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  101570. /** @hidden */
  101571. _areTexturesDirty: boolean;
  101572. }
  101573. /**
  101574. * Define the code related to the sub surface parameters of the pbr material.
  101575. */
  101576. export class PBRSubSurfaceConfiguration {
  101577. private _isRefractionEnabled;
  101578. /**
  101579. * Defines if the refraction is enabled in the material.
  101580. */
  101581. isRefractionEnabled: boolean;
  101582. private _isTranslucencyEnabled;
  101583. /**
  101584. * Defines if the translucency is enabled in the material.
  101585. */
  101586. isTranslucencyEnabled: boolean;
  101587. private _isScatteringEnabled;
  101588. /**
  101589. * Defines if the sub surface scattering is enabled in the material.
  101590. */
  101591. isScatteringEnabled: boolean;
  101592. private _scatteringDiffusionProfileIndex;
  101593. /**
  101594. * Diffusion profile for subsurface scattering.
  101595. * Useful for better scattering in the skins or foliages.
  101596. */
  101597. get scatteringDiffusionProfile(): Nullable<Color3>;
  101598. set scatteringDiffusionProfile(c: Nullable<Color3>);
  101599. /**
  101600. * Defines the refraction intensity of the material.
  101601. * The refraction when enabled replaces the Diffuse part of the material.
  101602. * The intensity helps transitionning between diffuse and refraction.
  101603. */
  101604. refractionIntensity: number;
  101605. /**
  101606. * Defines the translucency intensity of the material.
  101607. * When translucency has been enabled, this defines how much of the "translucency"
  101608. * is addded to the diffuse part of the material.
  101609. */
  101610. translucencyIntensity: number;
  101611. /**
  101612. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  101613. */
  101614. useAlbedoToTintRefraction: boolean;
  101615. private _thicknessTexture;
  101616. /**
  101617. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  101618. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  101619. * 0 would mean minimumThickness
  101620. * 1 would mean maximumThickness
  101621. * The other channels might be use as a mask to vary the different effects intensity.
  101622. */
  101623. thicknessTexture: Nullable<BaseTexture>;
  101624. private _refractionTexture;
  101625. /**
  101626. * Defines the texture to use for refraction.
  101627. */
  101628. refractionTexture: Nullable<BaseTexture>;
  101629. private _indexOfRefraction;
  101630. /**
  101631. * Index of refraction of the material base layer.
  101632. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101633. *
  101634. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  101635. *
  101636. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  101637. */
  101638. indexOfRefraction: number;
  101639. private _volumeIndexOfRefraction;
  101640. /**
  101641. * Index of refraction of the material's volume.
  101642. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  101643. *
  101644. * This ONLY impacts refraction. If not provided or given a non-valid value,
  101645. * the volume will use the same IOR as the surface.
  101646. */
  101647. get volumeIndexOfRefraction(): number;
  101648. set volumeIndexOfRefraction(value: number);
  101649. private _invertRefractionY;
  101650. /**
  101651. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101652. */
  101653. invertRefractionY: boolean;
  101654. private _linkRefractionWithTransparency;
  101655. /**
  101656. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101657. * Materials half opaque for instance using refraction could benefit from this control.
  101658. */
  101659. linkRefractionWithTransparency: boolean;
  101660. /**
  101661. * Defines the minimum thickness stored in the thickness map.
  101662. * If no thickness map is defined, this value will be used to simulate thickness.
  101663. */
  101664. minimumThickness: number;
  101665. /**
  101666. * Defines the maximum thickness stored in the thickness map.
  101667. */
  101668. maximumThickness: number;
  101669. /**
  101670. * Defines the volume tint of the material.
  101671. * This is used for both translucency and scattering.
  101672. */
  101673. tintColor: Color3;
  101674. /**
  101675. * Defines the distance at which the tint color should be found in the media.
  101676. * This is used for refraction only.
  101677. */
  101678. tintColorAtDistance: number;
  101679. /**
  101680. * Defines how far each channel transmit through the media.
  101681. * It is defined as a color to simplify it selection.
  101682. */
  101683. diffusionDistance: Color3;
  101684. private _useMaskFromThicknessTexture;
  101685. /**
  101686. * Stores the intensity of the different subsurface effects in the thickness texture.
  101687. * * the green channel is the translucency intensity.
  101688. * * the blue channel is the scattering intensity.
  101689. * * the alpha channel is the refraction intensity.
  101690. */
  101691. useMaskFromThicknessTexture: boolean;
  101692. private _scene;
  101693. private _useMaskFromThicknessTextureGltf;
  101694. /**
  101695. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  101696. * matches the channel-packing that is used by glTF.
  101697. * * the red channel is the transmission/translucency intensity.
  101698. * * the green channel is the thickness.
  101699. */
  101700. useMaskFromThicknessTextureGltf: boolean;
  101701. /** @hidden */
  101702. private _internalMarkAllSubMeshesAsTexturesDirty;
  101703. private _internalMarkScenePrePassDirty;
  101704. /** @hidden */
  101705. _markAllSubMeshesAsTexturesDirty(): void;
  101706. /** @hidden */
  101707. _markScenePrePassDirty(): void;
  101708. /**
  101709. * Instantiate a new istance of sub surface configuration.
  101710. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  101711. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  101712. * @param scene The scene
  101713. */
  101714. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  101715. /**
  101716. * Gets wehter the submesh is ready to be used or not.
  101717. * @param defines the list of "defines" to update.
  101718. * @param scene defines the scene the material belongs to.
  101719. * @returns - boolean indicating that the submesh is ready or not.
  101720. */
  101721. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  101722. /**
  101723. * Checks to see if a texture is used in the material.
  101724. * @param defines the list of "defines" to update.
  101725. * @param scene defines the scene to the material belongs to.
  101726. */
  101727. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  101728. /**
  101729. * Binds the material data.
  101730. * @param uniformBuffer defines the Uniform buffer to fill in.
  101731. * @param scene defines the scene the material belongs to.
  101732. * @param engine defines the engine the material belongs to.
  101733. * @param isFrozen defines whether the material is frozen or not.
  101734. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  101735. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  101736. */
  101737. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  101738. /**
  101739. * Unbinds the material from the mesh.
  101740. * @param activeEffect defines the effect that should be unbound from.
  101741. * @returns true if unbound, otherwise false
  101742. */
  101743. unbind(activeEffect: Effect): boolean;
  101744. /**
  101745. * Returns the texture used for refraction or null if none is used.
  101746. * @param scene defines the scene the material belongs to.
  101747. * @returns - Refraction texture if present. If no refraction texture and refraction
  101748. * is linked with transparency, returns environment texture. Otherwise, returns null.
  101749. */
  101750. private _getRefractionTexture;
  101751. /**
  101752. * Returns true if alpha blending should be disabled.
  101753. */
  101754. get disableAlphaBlending(): boolean;
  101755. /**
  101756. * Fills the list of render target textures.
  101757. * @param renderTargets the list of render targets to update
  101758. */
  101759. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  101760. /**
  101761. * Checks to see if a texture is used in the material.
  101762. * @param texture - Base texture to use.
  101763. * @returns - Boolean specifying if a texture is used in the material.
  101764. */
  101765. hasTexture(texture: BaseTexture): boolean;
  101766. /**
  101767. * Gets a boolean indicating that current material needs to register RTT
  101768. * @returns true if this uses a render target otherwise false.
  101769. */
  101770. hasRenderTargetTextures(): boolean;
  101771. /**
  101772. * Returns an array of the actively used textures.
  101773. * @param activeTextures Array of BaseTextures
  101774. */
  101775. getActiveTextures(activeTextures: BaseTexture[]): void;
  101776. /**
  101777. * Returns the animatable textures.
  101778. * @param animatables Array of animatable textures.
  101779. */
  101780. getAnimatables(animatables: IAnimatable[]): void;
  101781. /**
  101782. * Disposes the resources of the material.
  101783. * @param forceDisposeTextures - Forces the disposal of all textures.
  101784. */
  101785. dispose(forceDisposeTextures?: boolean): void;
  101786. /**
  101787. * Get the current class name of the texture useful for serialization or dynamic coding.
  101788. * @returns "PBRSubSurfaceConfiguration"
  101789. */
  101790. getClassName(): string;
  101791. /**
  101792. * Add fallbacks to the effect fallbacks list.
  101793. * @param defines defines the Base texture to use.
  101794. * @param fallbacks defines the current fallback list.
  101795. * @param currentRank defines the current fallback rank.
  101796. * @returns the new fallback rank.
  101797. */
  101798. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  101799. /**
  101800. * Add the required uniforms to the current list.
  101801. * @param uniforms defines the current uniform list.
  101802. */
  101803. static AddUniforms(uniforms: string[]): void;
  101804. /**
  101805. * Add the required samplers to the current list.
  101806. * @param samplers defines the current sampler list.
  101807. */
  101808. static AddSamplers(samplers: string[]): void;
  101809. /**
  101810. * Add the required uniforms to the current buffer.
  101811. * @param uniformBuffer defines the current uniform buffer.
  101812. */
  101813. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  101814. /**
  101815. * Makes a duplicate of the current configuration into another one.
  101816. * @param configuration define the config where to copy the info
  101817. */
  101818. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  101819. /**
  101820. * Serializes this Sub Surface configuration.
  101821. * @returns - An object with the serialized config.
  101822. */
  101823. serialize(): any;
  101824. /**
  101825. * Parses a anisotropy Configuration from a serialized object.
  101826. * @param source - Serialized object.
  101827. * @param scene Defines the scene we are parsing for
  101828. * @param rootUrl Defines the rootUrl to load from
  101829. */
  101830. parse(source: any, scene: Scene, rootUrl: string): void;
  101831. }
  101832. }
  101833. declare module BABYLON {
  101834. /**
  101835. * Class representing spherical harmonics coefficients to the 3rd degree
  101836. */
  101837. export class SphericalHarmonics {
  101838. /**
  101839. * Defines whether or not the harmonics have been prescaled for rendering.
  101840. */
  101841. preScaled: boolean;
  101842. /**
  101843. * The l0,0 coefficients of the spherical harmonics
  101844. */
  101845. l00: Vector3;
  101846. /**
  101847. * The l1,-1 coefficients of the spherical harmonics
  101848. */
  101849. l1_1: Vector3;
  101850. /**
  101851. * The l1,0 coefficients of the spherical harmonics
  101852. */
  101853. l10: Vector3;
  101854. /**
  101855. * The l1,1 coefficients of the spherical harmonics
  101856. */
  101857. l11: Vector3;
  101858. /**
  101859. * The l2,-2 coefficients of the spherical harmonics
  101860. */
  101861. l2_2: Vector3;
  101862. /**
  101863. * The l2,-1 coefficients of the spherical harmonics
  101864. */
  101865. l2_1: Vector3;
  101866. /**
  101867. * The l2,0 coefficients of the spherical harmonics
  101868. */
  101869. l20: Vector3;
  101870. /**
  101871. * The l2,1 coefficients of the spherical harmonics
  101872. */
  101873. l21: Vector3;
  101874. /**
  101875. * The l2,2 coefficients of the spherical harmonics
  101876. */
  101877. l22: Vector3;
  101878. /**
  101879. * Adds a light to the spherical harmonics
  101880. * @param direction the direction of the light
  101881. * @param color the color of the light
  101882. * @param deltaSolidAngle the delta solid angle of the light
  101883. */
  101884. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  101885. /**
  101886. * Scales the spherical harmonics by the given amount
  101887. * @param scale the amount to scale
  101888. */
  101889. scaleInPlace(scale: number): void;
  101890. /**
  101891. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  101892. *
  101893. * ```
  101894. * E_lm = A_l * L_lm
  101895. * ```
  101896. *
  101897. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  101898. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  101899. * the scaling factors are given in equation 9.
  101900. */
  101901. convertIncidentRadianceToIrradiance(): void;
  101902. /**
  101903. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  101904. *
  101905. * ```
  101906. * L = (1/pi) * E * rho
  101907. * ```
  101908. *
  101909. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  101910. */
  101911. convertIrradianceToLambertianRadiance(): void;
  101912. /**
  101913. * Integrates the reconstruction coefficients directly in to the SH preventing further
  101914. * required operations at run time.
  101915. *
  101916. * This is simply done by scaling back the SH with Ylm constants parameter.
  101917. * The trigonometric part being applied by the shader at run time.
  101918. */
  101919. preScaleForRendering(): void;
  101920. /**
  101921. * Constructs a spherical harmonics from an array.
  101922. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  101923. * @returns the spherical harmonics
  101924. */
  101925. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  101926. /**
  101927. * Gets the spherical harmonics from polynomial
  101928. * @param polynomial the spherical polynomial
  101929. * @returns the spherical harmonics
  101930. */
  101931. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  101932. }
  101933. /**
  101934. * Class representing spherical polynomial coefficients to the 3rd degree
  101935. */
  101936. export class SphericalPolynomial {
  101937. private _harmonics;
  101938. /**
  101939. * The spherical harmonics used to create the polynomials.
  101940. */
  101941. get preScaledHarmonics(): SphericalHarmonics;
  101942. /**
  101943. * The x coefficients of the spherical polynomial
  101944. */
  101945. x: Vector3;
  101946. /**
  101947. * The y coefficients of the spherical polynomial
  101948. */
  101949. y: Vector3;
  101950. /**
  101951. * The z coefficients of the spherical polynomial
  101952. */
  101953. z: Vector3;
  101954. /**
  101955. * The xx coefficients of the spherical polynomial
  101956. */
  101957. xx: Vector3;
  101958. /**
  101959. * The yy coefficients of the spherical polynomial
  101960. */
  101961. yy: Vector3;
  101962. /**
  101963. * The zz coefficients of the spherical polynomial
  101964. */
  101965. zz: Vector3;
  101966. /**
  101967. * The xy coefficients of the spherical polynomial
  101968. */
  101969. xy: Vector3;
  101970. /**
  101971. * The yz coefficients of the spherical polynomial
  101972. */
  101973. yz: Vector3;
  101974. /**
  101975. * The zx coefficients of the spherical polynomial
  101976. */
  101977. zx: Vector3;
  101978. /**
  101979. * Adds an ambient color to the spherical polynomial
  101980. * @param color the color to add
  101981. */
  101982. addAmbient(color: Color3): void;
  101983. /**
  101984. * Scales the spherical polynomial by the given amount
  101985. * @param scale the amount to scale
  101986. */
  101987. scaleInPlace(scale: number): void;
  101988. /**
  101989. * Gets the spherical polynomial from harmonics
  101990. * @param harmonics the spherical harmonics
  101991. * @returns the spherical polynomial
  101992. */
  101993. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  101994. /**
  101995. * Constructs a spherical polynomial from an array.
  101996. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  101997. * @returns the spherical polynomial
  101998. */
  101999. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  102000. }
  102001. }
  102002. declare module BABYLON {
  102003. /**
  102004. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  102005. */
  102006. export interface CubeMapInfo {
  102007. /**
  102008. * The pixel array for the front face.
  102009. * This is stored in format, left to right, up to down format.
  102010. */
  102011. front: Nullable<ArrayBufferView>;
  102012. /**
  102013. * The pixel array for the back face.
  102014. * This is stored in format, left to right, up to down format.
  102015. */
  102016. back: Nullable<ArrayBufferView>;
  102017. /**
  102018. * The pixel array for the left face.
  102019. * This is stored in format, left to right, up to down format.
  102020. */
  102021. left: Nullable<ArrayBufferView>;
  102022. /**
  102023. * The pixel array for the right face.
  102024. * This is stored in format, left to right, up to down format.
  102025. */
  102026. right: Nullable<ArrayBufferView>;
  102027. /**
  102028. * The pixel array for the up face.
  102029. * This is stored in format, left to right, up to down format.
  102030. */
  102031. up: Nullable<ArrayBufferView>;
  102032. /**
  102033. * The pixel array for the down face.
  102034. * This is stored in format, left to right, up to down format.
  102035. */
  102036. down: Nullable<ArrayBufferView>;
  102037. /**
  102038. * The size of the cubemap stored.
  102039. *
  102040. * Each faces will be size * size pixels.
  102041. */
  102042. size: number;
  102043. /**
  102044. * The format of the texture.
  102045. *
  102046. * RGBA, RGB.
  102047. */
  102048. format: number;
  102049. /**
  102050. * The type of the texture data.
  102051. *
  102052. * UNSIGNED_INT, FLOAT.
  102053. */
  102054. type: number;
  102055. /**
  102056. * Specifies whether the texture is in gamma space.
  102057. */
  102058. gammaSpace: boolean;
  102059. }
  102060. /**
  102061. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  102062. */
  102063. export class PanoramaToCubeMapTools {
  102064. private static FACE_LEFT;
  102065. private static FACE_RIGHT;
  102066. private static FACE_FRONT;
  102067. private static FACE_BACK;
  102068. private static FACE_DOWN;
  102069. private static FACE_UP;
  102070. /**
  102071. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  102072. *
  102073. * @param float32Array The source data.
  102074. * @param inputWidth The width of the input panorama.
  102075. * @param inputHeight The height of the input panorama.
  102076. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  102077. * @return The cubemap data
  102078. */
  102079. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  102080. private static CreateCubemapTexture;
  102081. private static CalcProjectionSpherical;
  102082. }
  102083. }
  102084. declare module BABYLON {
  102085. /**
  102086. * Helper class dealing with the extraction of spherical polynomial dataArray
  102087. * from a cube map.
  102088. */
  102089. export class CubeMapToSphericalPolynomialTools {
  102090. private static FileFaces;
  102091. /**
  102092. * Converts a texture to the according Spherical Polynomial data.
  102093. * This extracts the first 3 orders only as they are the only one used in the lighting.
  102094. *
  102095. * @param texture The texture to extract the information from.
  102096. * @return The Spherical Polynomial data.
  102097. */
  102098. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  102099. /**
  102100. * Converts a cubemap to the according Spherical Polynomial data.
  102101. * This extracts the first 3 orders only as they are the only one used in the lighting.
  102102. *
  102103. * @param cubeInfo The Cube map to extract the information from.
  102104. * @return The Spherical Polynomial data.
  102105. */
  102106. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  102107. }
  102108. }
  102109. declare module BABYLON {
  102110. interface BaseTexture {
  102111. /**
  102112. * Get the polynomial representation of the texture data.
  102113. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  102114. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  102115. */
  102116. sphericalPolynomial: Nullable<SphericalPolynomial>;
  102117. }
  102118. }
  102119. declare module BABYLON {
  102120. /** @hidden */
  102121. export var pbrFragmentDeclaration: {
  102122. name: string;
  102123. shader: string;
  102124. };
  102125. }
  102126. declare module BABYLON {
  102127. /** @hidden */
  102128. export var pbrUboDeclaration: {
  102129. name: string;
  102130. shader: string;
  102131. };
  102132. }
  102133. declare module BABYLON {
  102134. /** @hidden */
  102135. export var pbrFragmentExtraDeclaration: {
  102136. name: string;
  102137. shader: string;
  102138. };
  102139. }
  102140. declare module BABYLON {
  102141. /** @hidden */
  102142. export var pbrFragmentSamplersDeclaration: {
  102143. name: string;
  102144. shader: string;
  102145. };
  102146. }
  102147. declare module BABYLON {
  102148. /** @hidden */
  102149. export var subSurfaceScatteringFunctions: {
  102150. name: string;
  102151. shader: string;
  102152. };
  102153. }
  102154. declare module BABYLON {
  102155. /** @hidden */
  102156. export var importanceSampling: {
  102157. name: string;
  102158. shader: string;
  102159. };
  102160. }
  102161. declare module BABYLON {
  102162. /** @hidden */
  102163. export var pbrHelperFunctions: {
  102164. name: string;
  102165. shader: string;
  102166. };
  102167. }
  102168. declare module BABYLON {
  102169. /** @hidden */
  102170. export var harmonicsFunctions: {
  102171. name: string;
  102172. shader: string;
  102173. };
  102174. }
  102175. declare module BABYLON {
  102176. /** @hidden */
  102177. export var pbrDirectLightingSetupFunctions: {
  102178. name: string;
  102179. shader: string;
  102180. };
  102181. }
  102182. declare module BABYLON {
  102183. /** @hidden */
  102184. export var pbrDirectLightingFalloffFunctions: {
  102185. name: string;
  102186. shader: string;
  102187. };
  102188. }
  102189. declare module BABYLON {
  102190. /** @hidden */
  102191. export var pbrBRDFFunctions: {
  102192. name: string;
  102193. shader: string;
  102194. };
  102195. }
  102196. declare module BABYLON {
  102197. /** @hidden */
  102198. export var hdrFilteringFunctions: {
  102199. name: string;
  102200. shader: string;
  102201. };
  102202. }
  102203. declare module BABYLON {
  102204. /** @hidden */
  102205. export var pbrDirectLightingFunctions: {
  102206. name: string;
  102207. shader: string;
  102208. };
  102209. }
  102210. declare module BABYLON {
  102211. /** @hidden */
  102212. export var pbrIBLFunctions: {
  102213. name: string;
  102214. shader: string;
  102215. };
  102216. }
  102217. declare module BABYLON {
  102218. /** @hidden */
  102219. export var pbrBlockAlbedoOpacity: {
  102220. name: string;
  102221. shader: string;
  102222. };
  102223. }
  102224. declare module BABYLON {
  102225. /** @hidden */
  102226. export var pbrBlockReflectivity: {
  102227. name: string;
  102228. shader: string;
  102229. };
  102230. }
  102231. declare module BABYLON {
  102232. /** @hidden */
  102233. export var pbrBlockAmbientOcclusion: {
  102234. name: string;
  102235. shader: string;
  102236. };
  102237. }
  102238. declare module BABYLON {
  102239. /** @hidden */
  102240. export var pbrBlockAlphaFresnel: {
  102241. name: string;
  102242. shader: string;
  102243. };
  102244. }
  102245. declare module BABYLON {
  102246. /** @hidden */
  102247. export var pbrBlockAnisotropic: {
  102248. name: string;
  102249. shader: string;
  102250. };
  102251. }
  102252. declare module BABYLON {
  102253. /** @hidden */
  102254. export var pbrBlockReflection: {
  102255. name: string;
  102256. shader: string;
  102257. };
  102258. }
  102259. declare module BABYLON {
  102260. /** @hidden */
  102261. export var pbrBlockSheen: {
  102262. name: string;
  102263. shader: string;
  102264. };
  102265. }
  102266. declare module BABYLON {
  102267. /** @hidden */
  102268. export var pbrBlockClearcoat: {
  102269. name: string;
  102270. shader: string;
  102271. };
  102272. }
  102273. declare module BABYLON {
  102274. /** @hidden */
  102275. export var pbrBlockSubSurface: {
  102276. name: string;
  102277. shader: string;
  102278. };
  102279. }
  102280. declare module BABYLON {
  102281. /** @hidden */
  102282. export var pbrBlockNormalGeometric: {
  102283. name: string;
  102284. shader: string;
  102285. };
  102286. }
  102287. declare module BABYLON {
  102288. /** @hidden */
  102289. export var pbrBlockNormalFinal: {
  102290. name: string;
  102291. shader: string;
  102292. };
  102293. }
  102294. declare module BABYLON {
  102295. /** @hidden */
  102296. export var pbrBlockLightmapInit: {
  102297. name: string;
  102298. shader: string;
  102299. };
  102300. }
  102301. declare module BABYLON {
  102302. /** @hidden */
  102303. export var pbrBlockGeometryInfo: {
  102304. name: string;
  102305. shader: string;
  102306. };
  102307. }
  102308. declare module BABYLON {
  102309. /** @hidden */
  102310. export var pbrBlockReflectance0: {
  102311. name: string;
  102312. shader: string;
  102313. };
  102314. }
  102315. declare module BABYLON {
  102316. /** @hidden */
  102317. export var pbrBlockReflectance: {
  102318. name: string;
  102319. shader: string;
  102320. };
  102321. }
  102322. declare module BABYLON {
  102323. /** @hidden */
  102324. export var pbrBlockDirectLighting: {
  102325. name: string;
  102326. shader: string;
  102327. };
  102328. }
  102329. declare module BABYLON {
  102330. /** @hidden */
  102331. export var pbrBlockFinalLitComponents: {
  102332. name: string;
  102333. shader: string;
  102334. };
  102335. }
  102336. declare module BABYLON {
  102337. /** @hidden */
  102338. export var pbrBlockFinalUnlitComponents: {
  102339. name: string;
  102340. shader: string;
  102341. };
  102342. }
  102343. declare module BABYLON {
  102344. /** @hidden */
  102345. export var pbrBlockFinalColorComposition: {
  102346. name: string;
  102347. shader: string;
  102348. };
  102349. }
  102350. declare module BABYLON {
  102351. /** @hidden */
  102352. export var pbrBlockImageProcessing: {
  102353. name: string;
  102354. shader: string;
  102355. };
  102356. }
  102357. declare module BABYLON {
  102358. /** @hidden */
  102359. export var pbrDebug: {
  102360. name: string;
  102361. shader: string;
  102362. };
  102363. }
  102364. declare module BABYLON {
  102365. /** @hidden */
  102366. export var pbrPixelShader: {
  102367. name: string;
  102368. shader: string;
  102369. };
  102370. }
  102371. declare module BABYLON {
  102372. /** @hidden */
  102373. export var pbrVertexDeclaration: {
  102374. name: string;
  102375. shader: string;
  102376. };
  102377. }
  102378. declare module BABYLON {
  102379. /** @hidden */
  102380. export var pbrVertexShader: {
  102381. name: string;
  102382. shader: string;
  102383. };
  102384. }
  102385. declare module BABYLON {
  102386. /**
  102387. * Manages the defines for the PBR Material.
  102388. * @hidden
  102389. */
  102390. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  102391. PBR: boolean;
  102392. NUM_SAMPLES: string;
  102393. REALTIME_FILTERING: boolean;
  102394. MAINUV1: boolean;
  102395. MAINUV2: boolean;
  102396. UV1: boolean;
  102397. UV2: boolean;
  102398. ALBEDO: boolean;
  102399. GAMMAALBEDO: boolean;
  102400. ALBEDODIRECTUV: number;
  102401. VERTEXCOLOR: boolean;
  102402. DETAIL: boolean;
  102403. DETAILDIRECTUV: number;
  102404. DETAIL_NORMALBLENDMETHOD: number;
  102405. AMBIENT: boolean;
  102406. AMBIENTDIRECTUV: number;
  102407. AMBIENTINGRAYSCALE: boolean;
  102408. OPACITY: boolean;
  102409. VERTEXALPHA: boolean;
  102410. OPACITYDIRECTUV: number;
  102411. OPACITYRGB: boolean;
  102412. ALPHATEST: boolean;
  102413. DEPTHPREPASS: boolean;
  102414. ALPHABLEND: boolean;
  102415. ALPHAFROMALBEDO: boolean;
  102416. ALPHATESTVALUE: string;
  102417. SPECULAROVERALPHA: boolean;
  102418. RADIANCEOVERALPHA: boolean;
  102419. ALPHAFRESNEL: boolean;
  102420. LINEARALPHAFRESNEL: boolean;
  102421. PREMULTIPLYALPHA: boolean;
  102422. EMISSIVE: boolean;
  102423. EMISSIVEDIRECTUV: number;
  102424. REFLECTIVITY: boolean;
  102425. REFLECTIVITYDIRECTUV: number;
  102426. SPECULARTERM: boolean;
  102427. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  102428. MICROSURFACEAUTOMATIC: boolean;
  102429. LODBASEDMICROSFURACE: boolean;
  102430. MICROSURFACEMAP: boolean;
  102431. MICROSURFACEMAPDIRECTUV: number;
  102432. METALLICWORKFLOW: boolean;
  102433. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  102434. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  102435. METALLNESSSTOREINMETALMAPBLUE: boolean;
  102436. AOSTOREINMETALMAPRED: boolean;
  102437. METALLIC_REFLECTANCE: boolean;
  102438. METALLIC_REFLECTANCEDIRECTUV: number;
  102439. ENVIRONMENTBRDF: boolean;
  102440. ENVIRONMENTBRDF_RGBD: boolean;
  102441. NORMAL: boolean;
  102442. TANGENT: boolean;
  102443. BUMP: boolean;
  102444. BUMPDIRECTUV: number;
  102445. OBJECTSPACE_NORMALMAP: boolean;
  102446. PARALLAX: boolean;
  102447. PARALLAXOCCLUSION: boolean;
  102448. NORMALXYSCALE: boolean;
  102449. LIGHTMAP: boolean;
  102450. LIGHTMAPDIRECTUV: number;
  102451. USELIGHTMAPASSHADOWMAP: boolean;
  102452. GAMMALIGHTMAP: boolean;
  102453. RGBDLIGHTMAP: boolean;
  102454. REFLECTION: boolean;
  102455. REFLECTIONMAP_3D: boolean;
  102456. REFLECTIONMAP_SPHERICAL: boolean;
  102457. REFLECTIONMAP_PLANAR: boolean;
  102458. REFLECTIONMAP_CUBIC: boolean;
  102459. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  102460. REFLECTIONMAP_PROJECTION: boolean;
  102461. REFLECTIONMAP_SKYBOX: boolean;
  102462. REFLECTIONMAP_EXPLICIT: boolean;
  102463. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  102464. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  102465. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  102466. INVERTCUBICMAP: boolean;
  102467. USESPHERICALFROMREFLECTIONMAP: boolean;
  102468. USEIRRADIANCEMAP: boolean;
  102469. SPHERICAL_HARMONICS: boolean;
  102470. USESPHERICALINVERTEX: boolean;
  102471. REFLECTIONMAP_OPPOSITEZ: boolean;
  102472. LODINREFLECTIONALPHA: boolean;
  102473. GAMMAREFLECTION: boolean;
  102474. RGBDREFLECTION: boolean;
  102475. LINEARSPECULARREFLECTION: boolean;
  102476. RADIANCEOCCLUSION: boolean;
  102477. HORIZONOCCLUSION: boolean;
  102478. INSTANCES: boolean;
  102479. THIN_INSTANCES: boolean;
  102480. PREPASS: boolean;
  102481. PREPASS_IRRADIANCE: boolean;
  102482. PREPASS_IRRADIANCE_INDEX: number;
  102483. PREPASS_ALBEDO: boolean;
  102484. PREPASS_ALBEDO_INDEX: number;
  102485. PREPASS_DEPTHNORMAL: boolean;
  102486. PREPASS_DEPTHNORMAL_INDEX: number;
  102487. PREPASS_POSITION: boolean;
  102488. PREPASS_POSITION_INDEX: number;
  102489. PREPASS_VELOCITY: boolean;
  102490. PREPASS_VELOCITY_INDEX: number;
  102491. PREPASS_REFLECTIVITY: boolean;
  102492. PREPASS_REFLECTIVITY_INDEX: number;
  102493. SCENE_MRT_COUNT: number;
  102494. NUM_BONE_INFLUENCERS: number;
  102495. BonesPerMesh: number;
  102496. BONETEXTURE: boolean;
  102497. BONES_VELOCITY_ENABLED: boolean;
  102498. NONUNIFORMSCALING: boolean;
  102499. MORPHTARGETS: boolean;
  102500. MORPHTARGETS_NORMAL: boolean;
  102501. MORPHTARGETS_TANGENT: boolean;
  102502. MORPHTARGETS_UV: boolean;
  102503. NUM_MORPH_INFLUENCERS: number;
  102504. IMAGEPROCESSING: boolean;
  102505. VIGNETTE: boolean;
  102506. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102507. VIGNETTEBLENDMODEOPAQUE: boolean;
  102508. TONEMAPPING: boolean;
  102509. TONEMAPPING_ACES: boolean;
  102510. CONTRAST: boolean;
  102511. COLORCURVES: boolean;
  102512. COLORGRADING: boolean;
  102513. COLORGRADING3D: boolean;
  102514. SAMPLER3DGREENDEPTH: boolean;
  102515. SAMPLER3DBGRMAP: boolean;
  102516. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102517. EXPOSURE: boolean;
  102518. MULTIVIEW: boolean;
  102519. USEPHYSICALLIGHTFALLOFF: boolean;
  102520. USEGLTFLIGHTFALLOFF: boolean;
  102521. TWOSIDEDLIGHTING: boolean;
  102522. SHADOWFLOAT: boolean;
  102523. CLIPPLANE: boolean;
  102524. CLIPPLANE2: boolean;
  102525. CLIPPLANE3: boolean;
  102526. CLIPPLANE4: boolean;
  102527. CLIPPLANE5: boolean;
  102528. CLIPPLANE6: boolean;
  102529. POINTSIZE: boolean;
  102530. FOG: boolean;
  102531. LOGARITHMICDEPTH: boolean;
  102532. FORCENORMALFORWARD: boolean;
  102533. SPECULARAA: boolean;
  102534. CLEARCOAT: boolean;
  102535. CLEARCOAT_DEFAULTIOR: boolean;
  102536. CLEARCOAT_TEXTURE: boolean;
  102537. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  102538. CLEARCOAT_TEXTUREDIRECTUV: number;
  102539. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  102540. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102541. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102542. CLEARCOAT_BUMP: boolean;
  102543. CLEARCOAT_BUMPDIRECTUV: number;
  102544. CLEARCOAT_REMAP_F0: boolean;
  102545. CLEARCOAT_TINT: boolean;
  102546. CLEARCOAT_TINT_TEXTURE: boolean;
  102547. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  102548. ANISOTROPIC: boolean;
  102549. ANISOTROPIC_TEXTURE: boolean;
  102550. ANISOTROPIC_TEXTUREDIRECTUV: number;
  102551. BRDF_V_HEIGHT_CORRELATED: boolean;
  102552. MS_BRDF_ENERGY_CONSERVATION: boolean;
  102553. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  102554. SHEEN: boolean;
  102555. SHEEN_TEXTURE: boolean;
  102556. SHEEN_TEXTURE_ROUGHNESS: boolean;
  102557. SHEEN_TEXTUREDIRECTUV: number;
  102558. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  102559. SHEEN_LINKWITHALBEDO: boolean;
  102560. SHEEN_ROUGHNESS: boolean;
  102561. SHEEN_ALBEDOSCALING: boolean;
  102562. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  102563. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  102564. SUBSURFACE: boolean;
  102565. SS_REFRACTION: boolean;
  102566. SS_TRANSLUCENCY: boolean;
  102567. SS_SCATTERING: boolean;
  102568. SS_THICKNESSANDMASK_TEXTURE: boolean;
  102569. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  102570. SS_REFRACTIONMAP_3D: boolean;
  102571. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  102572. SS_LODINREFRACTIONALPHA: boolean;
  102573. SS_GAMMAREFRACTION: boolean;
  102574. SS_RGBDREFRACTION: boolean;
  102575. SS_LINEARSPECULARREFRACTION: boolean;
  102576. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  102577. SS_ALBEDOFORREFRACTIONTINT: boolean;
  102578. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  102579. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  102580. UNLIT: boolean;
  102581. DEBUGMODE: number;
  102582. /**
  102583. * Initializes the PBR Material defines.
  102584. */
  102585. constructor();
  102586. /**
  102587. * Resets the PBR Material defines.
  102588. */
  102589. reset(): void;
  102590. }
  102591. /**
  102592. * The Physically based material base class of BJS.
  102593. *
  102594. * This offers the main features of a standard PBR material.
  102595. * For more information, please refer to the documentation :
  102596. * https://doc.babylonjs.com/how_to/physically_based_rendering
  102597. */
  102598. export abstract class PBRBaseMaterial extends PushMaterial {
  102599. /**
  102600. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102601. */
  102602. static readonly PBRMATERIAL_OPAQUE: number;
  102603. /**
  102604. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102605. */
  102606. static readonly PBRMATERIAL_ALPHATEST: number;
  102607. /**
  102608. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102609. */
  102610. static readonly PBRMATERIAL_ALPHABLEND: number;
  102611. /**
  102612. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102613. * They are also discarded below the alpha cutoff threshold to improve performances.
  102614. */
  102615. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  102616. /**
  102617. * Defines the default value of how much AO map is occluding the analytical lights
  102618. * (point spot...).
  102619. */
  102620. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  102621. /**
  102622. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  102623. */
  102624. static readonly LIGHTFALLOFF_PHYSICAL: number;
  102625. /**
  102626. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  102627. * to enhance interoperability with other engines.
  102628. */
  102629. static readonly LIGHTFALLOFF_GLTF: number;
  102630. /**
  102631. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  102632. * to enhance interoperability with other materials.
  102633. */
  102634. static readonly LIGHTFALLOFF_STANDARD: number;
  102635. /**
  102636. * Intensity of the direct lights e.g. the four lights available in your scene.
  102637. * This impacts both the direct diffuse and specular highlights.
  102638. */
  102639. protected _directIntensity: number;
  102640. /**
  102641. * Intensity of the emissive part of the material.
  102642. * This helps controlling the emissive effect without modifying the emissive color.
  102643. */
  102644. protected _emissiveIntensity: number;
  102645. /**
  102646. * Intensity of the environment e.g. how much the environment will light the object
  102647. * either through harmonics for rough material or through the refelction for shiny ones.
  102648. */
  102649. protected _environmentIntensity: number;
  102650. /**
  102651. * This is a special control allowing the reduction of the specular highlights coming from the
  102652. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  102653. */
  102654. protected _specularIntensity: number;
  102655. /**
  102656. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  102657. */
  102658. private _lightingInfos;
  102659. /**
  102660. * Debug Control allowing disabling the bump map on this material.
  102661. */
  102662. protected _disableBumpMap: boolean;
  102663. /**
  102664. * AKA Diffuse Texture in standard nomenclature.
  102665. */
  102666. protected _albedoTexture: Nullable<BaseTexture>;
  102667. /**
  102668. * AKA Occlusion Texture in other nomenclature.
  102669. */
  102670. protected _ambientTexture: Nullable<BaseTexture>;
  102671. /**
  102672. * AKA Occlusion Texture Intensity in other nomenclature.
  102673. */
  102674. protected _ambientTextureStrength: number;
  102675. /**
  102676. * Defines how much the AO map is occluding the analytical lights (point spot...).
  102677. * 1 means it completely occludes it
  102678. * 0 mean it has no impact
  102679. */
  102680. protected _ambientTextureImpactOnAnalyticalLights: number;
  102681. /**
  102682. * Stores the alpha values in a texture.
  102683. */
  102684. protected _opacityTexture: Nullable<BaseTexture>;
  102685. /**
  102686. * Stores the reflection values in a texture.
  102687. */
  102688. protected _reflectionTexture: Nullable<BaseTexture>;
  102689. /**
  102690. * Stores the emissive values in a texture.
  102691. */
  102692. protected _emissiveTexture: Nullable<BaseTexture>;
  102693. /**
  102694. * AKA Specular texture in other nomenclature.
  102695. */
  102696. protected _reflectivityTexture: Nullable<BaseTexture>;
  102697. /**
  102698. * Used to switch from specular/glossiness to metallic/roughness workflow.
  102699. */
  102700. protected _metallicTexture: Nullable<BaseTexture>;
  102701. /**
  102702. * Specifies the metallic scalar of the metallic/roughness workflow.
  102703. * Can also be used to scale the metalness values of the metallic texture.
  102704. */
  102705. protected _metallic: Nullable<number>;
  102706. /**
  102707. * Specifies the roughness scalar of the metallic/roughness workflow.
  102708. * Can also be used to scale the roughness values of the metallic texture.
  102709. */
  102710. protected _roughness: Nullable<number>;
  102711. /**
  102712. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  102713. * By default the indexOfrefraction is used to compute F0;
  102714. *
  102715. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  102716. *
  102717. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  102718. * F90 = metallicReflectanceColor;
  102719. */
  102720. protected _metallicF0Factor: number;
  102721. /**
  102722. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  102723. * By default the F90 is always 1;
  102724. *
  102725. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  102726. *
  102727. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  102728. * F90 = metallicReflectanceColor;
  102729. */
  102730. protected _metallicReflectanceColor: Color3;
  102731. /**
  102732. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  102733. * This is multiply against the scalar values defined in the material.
  102734. */
  102735. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  102736. /**
  102737. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  102738. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  102739. */
  102740. protected _microSurfaceTexture: Nullable<BaseTexture>;
  102741. /**
  102742. * Stores surface normal data used to displace a mesh in a texture.
  102743. */
  102744. protected _bumpTexture: Nullable<BaseTexture>;
  102745. /**
  102746. * Stores the pre-calculated light information of a mesh in a texture.
  102747. */
  102748. protected _lightmapTexture: Nullable<BaseTexture>;
  102749. /**
  102750. * The color of a material in ambient lighting.
  102751. */
  102752. protected _ambientColor: Color3;
  102753. /**
  102754. * AKA Diffuse Color in other nomenclature.
  102755. */
  102756. protected _albedoColor: Color3;
  102757. /**
  102758. * AKA Specular Color in other nomenclature.
  102759. */
  102760. protected _reflectivityColor: Color3;
  102761. /**
  102762. * The color applied when light is reflected from a material.
  102763. */
  102764. protected _reflectionColor: Color3;
  102765. /**
  102766. * The color applied when light is emitted from a material.
  102767. */
  102768. protected _emissiveColor: Color3;
  102769. /**
  102770. * AKA Glossiness in other nomenclature.
  102771. */
  102772. protected _microSurface: number;
  102773. /**
  102774. * Specifies that the material will use the light map as a show map.
  102775. */
  102776. protected _useLightmapAsShadowmap: boolean;
  102777. /**
  102778. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  102779. * makes the reflect vector face the model (under horizon).
  102780. */
  102781. protected _useHorizonOcclusion: boolean;
  102782. /**
  102783. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  102784. * too much the area relying on ambient texture to define their ambient occlusion.
  102785. */
  102786. protected _useRadianceOcclusion: boolean;
  102787. /**
  102788. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  102789. */
  102790. protected _useAlphaFromAlbedoTexture: boolean;
  102791. /**
  102792. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  102793. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  102794. */
  102795. protected _useSpecularOverAlpha: boolean;
  102796. /**
  102797. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  102798. */
  102799. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  102800. /**
  102801. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  102802. */
  102803. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  102804. /**
  102805. * Specifies if the metallic texture contains the roughness information in its green channel.
  102806. */
  102807. protected _useRoughnessFromMetallicTextureGreen: boolean;
  102808. /**
  102809. * Specifies if the metallic texture contains the metallness information in its blue channel.
  102810. */
  102811. protected _useMetallnessFromMetallicTextureBlue: boolean;
  102812. /**
  102813. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  102814. */
  102815. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  102816. /**
  102817. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  102818. */
  102819. protected _useAmbientInGrayScale: boolean;
  102820. /**
  102821. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  102822. * The material will try to infer what glossiness each pixel should be.
  102823. */
  102824. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  102825. /**
  102826. * Defines the falloff type used in this material.
  102827. * It by default is Physical.
  102828. */
  102829. protected _lightFalloff: number;
  102830. /**
  102831. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  102832. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  102833. */
  102834. protected _useRadianceOverAlpha: boolean;
  102835. /**
  102836. * Allows using an object space normal map (instead of tangent space).
  102837. */
  102838. protected _useObjectSpaceNormalMap: boolean;
  102839. /**
  102840. * Allows using the bump map in parallax mode.
  102841. */
  102842. protected _useParallax: boolean;
  102843. /**
  102844. * Allows using the bump map in parallax occlusion mode.
  102845. */
  102846. protected _useParallaxOcclusion: boolean;
  102847. /**
  102848. * Controls the scale bias of the parallax mode.
  102849. */
  102850. protected _parallaxScaleBias: number;
  102851. /**
  102852. * If sets to true, disables all the lights affecting the material.
  102853. */
  102854. protected _disableLighting: boolean;
  102855. /**
  102856. * Number of Simultaneous lights allowed on the material.
  102857. */
  102858. protected _maxSimultaneousLights: number;
  102859. /**
  102860. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  102861. */
  102862. protected _invertNormalMapX: boolean;
  102863. /**
  102864. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  102865. */
  102866. protected _invertNormalMapY: boolean;
  102867. /**
  102868. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102869. */
  102870. protected _twoSidedLighting: boolean;
  102871. /**
  102872. * Defines the alpha limits in alpha test mode.
  102873. */
  102874. protected _alphaCutOff: number;
  102875. /**
  102876. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102877. */
  102878. protected _forceAlphaTest: boolean;
  102879. /**
  102880. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102881. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  102882. */
  102883. protected _useAlphaFresnel: boolean;
  102884. /**
  102885. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  102886. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  102887. */
  102888. protected _useLinearAlphaFresnel: boolean;
  102889. /**
  102890. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  102891. * from cos thetav and roughness:
  102892. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  102893. */
  102894. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  102895. /**
  102896. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  102897. */
  102898. protected _forceIrradianceInFragment: boolean;
  102899. private _realTimeFiltering;
  102900. /**
  102901. * Enables realtime filtering on the texture.
  102902. */
  102903. get realTimeFiltering(): boolean;
  102904. set realTimeFiltering(b: boolean);
  102905. private _realTimeFilteringQuality;
  102906. /**
  102907. * Quality switch for realtime filtering
  102908. */
  102909. get realTimeFilteringQuality(): number;
  102910. set realTimeFilteringQuality(n: number);
  102911. /**
  102912. * Can this material render to several textures at once
  102913. */
  102914. get canRenderToMRT(): boolean;
  102915. /**
  102916. * Force normal to face away from face.
  102917. */
  102918. protected _forceNormalForward: boolean;
  102919. /**
  102920. * Enables specular anti aliasing in the PBR shader.
  102921. * It will both interacts on the Geometry for analytical and IBL lighting.
  102922. * It also prefilter the roughness map based on the bump values.
  102923. */
  102924. protected _enableSpecularAntiAliasing: boolean;
  102925. /**
  102926. * Default configuration related to image processing available in the PBR Material.
  102927. */
  102928. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102929. /**
  102930. * Keep track of the image processing observer to allow dispose and replace.
  102931. */
  102932. private _imageProcessingObserver;
  102933. /**
  102934. * Attaches a new image processing configuration to the PBR Material.
  102935. * @param configuration
  102936. */
  102937. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102938. /**
  102939. * Stores the available render targets.
  102940. */
  102941. private _renderTargets;
  102942. /**
  102943. * Sets the global ambient color for the material used in lighting calculations.
  102944. */
  102945. private _globalAmbientColor;
  102946. /**
  102947. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  102948. */
  102949. private _useLogarithmicDepth;
  102950. /**
  102951. * If set to true, no lighting calculations will be applied.
  102952. */
  102953. private _unlit;
  102954. private _debugMode;
  102955. /**
  102956. * @hidden
  102957. * This is reserved for the inspector.
  102958. * Defines the material debug mode.
  102959. * It helps seeing only some components of the material while troubleshooting.
  102960. */
  102961. debugMode: number;
  102962. /**
  102963. * @hidden
  102964. * This is reserved for the inspector.
  102965. * Specify from where on screen the debug mode should start.
  102966. * The value goes from -1 (full screen) to 1 (not visible)
  102967. * It helps with side by side comparison against the final render
  102968. * This defaults to -1
  102969. */
  102970. private debugLimit;
  102971. /**
  102972. * @hidden
  102973. * This is reserved for the inspector.
  102974. * As the default viewing range might not be enough (if the ambient is really small for instance)
  102975. * You can use the factor to better multiply the final value.
  102976. */
  102977. private debugFactor;
  102978. /**
  102979. * Defines the clear coat layer parameters for the material.
  102980. */
  102981. readonly clearCoat: PBRClearCoatConfiguration;
  102982. /**
  102983. * Defines the anisotropic parameters for the material.
  102984. */
  102985. readonly anisotropy: PBRAnisotropicConfiguration;
  102986. /**
  102987. * Defines the BRDF parameters for the material.
  102988. */
  102989. readonly brdf: PBRBRDFConfiguration;
  102990. /**
  102991. * Defines the Sheen parameters for the material.
  102992. */
  102993. readonly sheen: PBRSheenConfiguration;
  102994. /**
  102995. * Defines the SubSurface parameters for the material.
  102996. */
  102997. readonly subSurface: PBRSubSurfaceConfiguration;
  102998. /**
  102999. * Defines additionnal PrePass parameters for the material.
  103000. */
  103001. readonly prePassConfiguration: PrePassConfiguration;
  103002. /**
  103003. * Defines the detail map parameters for the material.
  103004. */
  103005. readonly detailMap: DetailMapConfiguration;
  103006. protected _rebuildInParallel: boolean;
  103007. /**
  103008. * Instantiates a new PBRMaterial instance.
  103009. *
  103010. * @param name The material name
  103011. * @param scene The scene the material will be use in.
  103012. */
  103013. constructor(name: string, scene: Scene);
  103014. /**
  103015. * Gets a boolean indicating that current material needs to register RTT
  103016. */
  103017. get hasRenderTargetTextures(): boolean;
  103018. /**
  103019. * Gets the name of the material class.
  103020. */
  103021. getClassName(): string;
  103022. /**
  103023. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103024. */
  103025. get useLogarithmicDepth(): boolean;
  103026. /**
  103027. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  103028. */
  103029. set useLogarithmicDepth(value: boolean);
  103030. /**
  103031. * Returns true if alpha blending should be disabled.
  103032. */
  103033. protected get _disableAlphaBlending(): boolean;
  103034. /**
  103035. * Specifies whether or not this material should be rendered in alpha blend mode.
  103036. */
  103037. needAlphaBlending(): boolean;
  103038. /**
  103039. * Specifies whether or not this material should be rendered in alpha test mode.
  103040. */
  103041. needAlphaTesting(): boolean;
  103042. /**
  103043. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  103044. */
  103045. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  103046. /**
  103047. * Specifies whether or not there is a usable alpha channel for transparency.
  103048. */
  103049. protected _hasAlphaChannel(): boolean;
  103050. /**
  103051. * Gets the texture used for the alpha test.
  103052. */
  103053. getAlphaTestTexture(): Nullable<BaseTexture>;
  103054. /**
  103055. * Specifies that the submesh is ready to be used.
  103056. * @param mesh - BJS mesh.
  103057. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  103058. * @param useInstances - Specifies that instances should be used.
  103059. * @returns - boolean indicating that the submesh is ready or not.
  103060. */
  103061. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103062. /**
  103063. * Specifies if the material uses metallic roughness workflow.
  103064. * @returns boolean specifiying if the material uses metallic roughness workflow.
  103065. */
  103066. isMetallicWorkflow(): boolean;
  103067. private _prepareEffect;
  103068. private _prepareDefines;
  103069. /**
  103070. * Force shader compilation
  103071. */
  103072. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  103073. /**
  103074. * Initializes the uniform buffer layout for the shader.
  103075. */
  103076. buildUniformLayout(): void;
  103077. /**
  103078. * Unbinds the material from the mesh
  103079. */
  103080. unbind(): void;
  103081. /**
  103082. * Binds the submesh data.
  103083. * @param world - The world matrix.
  103084. * @param mesh - The BJS mesh.
  103085. * @param subMesh - A submesh of the BJS mesh.
  103086. */
  103087. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103088. /**
  103089. * Returns the animatable textures.
  103090. * @returns - Array of animatable textures.
  103091. */
  103092. getAnimatables(): IAnimatable[];
  103093. /**
  103094. * Returns the texture used for reflections.
  103095. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  103096. */
  103097. private _getReflectionTexture;
  103098. /**
  103099. * Returns an array of the actively used textures.
  103100. * @returns - Array of BaseTextures
  103101. */
  103102. getActiveTextures(): BaseTexture[];
  103103. /**
  103104. * Checks to see if a texture is used in the material.
  103105. * @param texture - Base texture to use.
  103106. * @returns - Boolean specifying if a texture is used in the material.
  103107. */
  103108. hasTexture(texture: BaseTexture): boolean;
  103109. /**
  103110. * Sets the required values to the prepass renderer.
  103111. * @param prePassRenderer defines the prepass renderer to setup
  103112. */
  103113. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  103114. /**
  103115. * Disposes the resources of the material.
  103116. * @param forceDisposeEffect - Forces the disposal of effects.
  103117. * @param forceDisposeTextures - Forces the disposal of all textures.
  103118. */
  103119. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103120. }
  103121. }
  103122. declare module BABYLON {
  103123. /**
  103124. * The Physically based material of BJS.
  103125. *
  103126. * This offers the main features of a standard PBR material.
  103127. * For more information, please refer to the documentation :
  103128. * https://doc.babylonjs.com/how_to/physically_based_rendering
  103129. */
  103130. export class PBRMaterial extends PBRBaseMaterial {
  103131. /**
  103132. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  103133. */
  103134. static readonly PBRMATERIAL_OPAQUE: number;
  103135. /**
  103136. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  103137. */
  103138. static readonly PBRMATERIAL_ALPHATEST: number;
  103139. /**
  103140. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103141. */
  103142. static readonly PBRMATERIAL_ALPHABLEND: number;
  103143. /**
  103144. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  103145. * They are also discarded below the alpha cutoff threshold to improve performances.
  103146. */
  103147. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  103148. /**
  103149. * Defines the default value of how much AO map is occluding the analytical lights
  103150. * (point spot...).
  103151. */
  103152. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  103153. /**
  103154. * Intensity of the direct lights e.g. the four lights available in your scene.
  103155. * This impacts both the direct diffuse and specular highlights.
  103156. */
  103157. directIntensity: number;
  103158. /**
  103159. * Intensity of the emissive part of the material.
  103160. * This helps controlling the emissive effect without modifying the emissive color.
  103161. */
  103162. emissiveIntensity: number;
  103163. /**
  103164. * Intensity of the environment e.g. how much the environment will light the object
  103165. * either through harmonics for rough material or through the refelction for shiny ones.
  103166. */
  103167. environmentIntensity: number;
  103168. /**
  103169. * This is a special control allowing the reduction of the specular highlights coming from the
  103170. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  103171. */
  103172. specularIntensity: number;
  103173. /**
  103174. * Debug Control allowing disabling the bump map on this material.
  103175. */
  103176. disableBumpMap: boolean;
  103177. /**
  103178. * AKA Diffuse Texture in standard nomenclature.
  103179. */
  103180. albedoTexture: BaseTexture;
  103181. /**
  103182. * AKA Occlusion Texture in other nomenclature.
  103183. */
  103184. ambientTexture: BaseTexture;
  103185. /**
  103186. * AKA Occlusion Texture Intensity in other nomenclature.
  103187. */
  103188. ambientTextureStrength: number;
  103189. /**
  103190. * Defines how much the AO map is occluding the analytical lights (point spot...).
  103191. * 1 means it completely occludes it
  103192. * 0 mean it has no impact
  103193. */
  103194. ambientTextureImpactOnAnalyticalLights: number;
  103195. /**
  103196. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  103197. */
  103198. opacityTexture: BaseTexture;
  103199. /**
  103200. * Stores the reflection values in a texture.
  103201. */
  103202. reflectionTexture: Nullable<BaseTexture>;
  103203. /**
  103204. * Stores the emissive values in a texture.
  103205. */
  103206. emissiveTexture: BaseTexture;
  103207. /**
  103208. * AKA Specular texture in other nomenclature.
  103209. */
  103210. reflectivityTexture: BaseTexture;
  103211. /**
  103212. * Used to switch from specular/glossiness to metallic/roughness workflow.
  103213. */
  103214. metallicTexture: BaseTexture;
  103215. /**
  103216. * Specifies the metallic scalar of the metallic/roughness workflow.
  103217. * Can also be used to scale the metalness values of the metallic texture.
  103218. */
  103219. metallic: Nullable<number>;
  103220. /**
  103221. * Specifies the roughness scalar of the metallic/roughness workflow.
  103222. * Can also be used to scale the roughness values of the metallic texture.
  103223. */
  103224. roughness: Nullable<number>;
  103225. /**
  103226. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  103227. * By default the indexOfrefraction is used to compute F0;
  103228. *
  103229. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  103230. *
  103231. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  103232. * F90 = metallicReflectanceColor;
  103233. */
  103234. metallicF0Factor: number;
  103235. /**
  103236. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  103237. * By default the F90 is always 1;
  103238. *
  103239. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  103240. *
  103241. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  103242. * F90 = metallicReflectanceColor;
  103243. */
  103244. metallicReflectanceColor: Color3;
  103245. /**
  103246. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  103247. * This is multiply against the scalar values defined in the material.
  103248. */
  103249. metallicReflectanceTexture: Nullable<BaseTexture>;
  103250. /**
  103251. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  103252. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  103253. */
  103254. microSurfaceTexture: BaseTexture;
  103255. /**
  103256. * Stores surface normal data used to displace a mesh in a texture.
  103257. */
  103258. bumpTexture: BaseTexture;
  103259. /**
  103260. * Stores the pre-calculated light information of a mesh in a texture.
  103261. */
  103262. lightmapTexture: BaseTexture;
  103263. /**
  103264. * Stores the refracted light information in a texture.
  103265. */
  103266. get refractionTexture(): Nullable<BaseTexture>;
  103267. set refractionTexture(value: Nullable<BaseTexture>);
  103268. /**
  103269. * The color of a material in ambient lighting.
  103270. */
  103271. ambientColor: Color3;
  103272. /**
  103273. * AKA Diffuse Color in other nomenclature.
  103274. */
  103275. albedoColor: Color3;
  103276. /**
  103277. * AKA Specular Color in other nomenclature.
  103278. */
  103279. reflectivityColor: Color3;
  103280. /**
  103281. * The color reflected from the material.
  103282. */
  103283. reflectionColor: Color3;
  103284. /**
  103285. * The color emitted from the material.
  103286. */
  103287. emissiveColor: Color3;
  103288. /**
  103289. * AKA Glossiness in other nomenclature.
  103290. */
  103291. microSurface: number;
  103292. /**
  103293. * Index of refraction of the material base layer.
  103294. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103295. *
  103296. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  103297. *
  103298. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  103299. */
  103300. get indexOfRefraction(): number;
  103301. set indexOfRefraction(value: number);
  103302. /**
  103303. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103304. */
  103305. get invertRefractionY(): boolean;
  103306. set invertRefractionY(value: boolean);
  103307. /**
  103308. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103309. * Materials half opaque for instance using refraction could benefit from this control.
  103310. */
  103311. get linkRefractionWithTransparency(): boolean;
  103312. set linkRefractionWithTransparency(value: boolean);
  103313. /**
  103314. * If true, the light map contains occlusion information instead of lighting info.
  103315. */
  103316. useLightmapAsShadowmap: boolean;
  103317. /**
  103318. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  103319. */
  103320. useAlphaFromAlbedoTexture: boolean;
  103321. /**
  103322. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  103323. */
  103324. forceAlphaTest: boolean;
  103325. /**
  103326. * Defines the alpha limits in alpha test mode.
  103327. */
  103328. alphaCutOff: number;
  103329. /**
  103330. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103331. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103332. */
  103333. useSpecularOverAlpha: boolean;
  103334. /**
  103335. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  103336. */
  103337. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  103338. /**
  103339. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  103340. */
  103341. useRoughnessFromMetallicTextureAlpha: boolean;
  103342. /**
  103343. * Specifies if the metallic texture contains the roughness information in its green channel.
  103344. */
  103345. useRoughnessFromMetallicTextureGreen: boolean;
  103346. /**
  103347. * Specifies if the metallic texture contains the metallness information in its blue channel.
  103348. */
  103349. useMetallnessFromMetallicTextureBlue: boolean;
  103350. /**
  103351. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  103352. */
  103353. useAmbientOcclusionFromMetallicTextureRed: boolean;
  103354. /**
  103355. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  103356. */
  103357. useAmbientInGrayScale: boolean;
  103358. /**
  103359. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  103360. * The material will try to infer what glossiness each pixel should be.
  103361. */
  103362. useAutoMicroSurfaceFromReflectivityMap: boolean;
  103363. /**
  103364. * BJS is using an harcoded light falloff based on a manually sets up range.
  103365. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103366. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103367. */
  103368. get usePhysicalLightFalloff(): boolean;
  103369. /**
  103370. * BJS is using an harcoded light falloff based on a manually sets up range.
  103371. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  103372. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  103373. */
  103374. set usePhysicalLightFalloff(value: boolean);
  103375. /**
  103376. * In order to support the falloff compatibility with gltf, a special mode has been added
  103377. * to reproduce the gltf light falloff.
  103378. */
  103379. get useGLTFLightFalloff(): boolean;
  103380. /**
  103381. * In order to support the falloff compatibility with gltf, a special mode has been added
  103382. * to reproduce the gltf light falloff.
  103383. */
  103384. set useGLTFLightFalloff(value: boolean);
  103385. /**
  103386. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103387. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103388. */
  103389. useRadianceOverAlpha: boolean;
  103390. /**
  103391. * Allows using an object space normal map (instead of tangent space).
  103392. */
  103393. useObjectSpaceNormalMap: boolean;
  103394. /**
  103395. * Allows using the bump map in parallax mode.
  103396. */
  103397. useParallax: boolean;
  103398. /**
  103399. * Allows using the bump map in parallax occlusion mode.
  103400. */
  103401. useParallaxOcclusion: boolean;
  103402. /**
  103403. * Controls the scale bias of the parallax mode.
  103404. */
  103405. parallaxScaleBias: number;
  103406. /**
  103407. * If sets to true, disables all the lights affecting the material.
  103408. */
  103409. disableLighting: boolean;
  103410. /**
  103411. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  103412. */
  103413. forceIrradianceInFragment: boolean;
  103414. /**
  103415. * Number of Simultaneous lights allowed on the material.
  103416. */
  103417. maxSimultaneousLights: number;
  103418. /**
  103419. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103420. */
  103421. invertNormalMapX: boolean;
  103422. /**
  103423. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103424. */
  103425. invertNormalMapY: boolean;
  103426. /**
  103427. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103428. */
  103429. twoSidedLighting: boolean;
  103430. /**
  103431. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103432. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  103433. */
  103434. useAlphaFresnel: boolean;
  103435. /**
  103436. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  103437. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  103438. */
  103439. useLinearAlphaFresnel: boolean;
  103440. /**
  103441. * Let user defines the brdf lookup texture used for IBL.
  103442. * A default 8bit version is embedded but you could point at :
  103443. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  103444. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  103445. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  103446. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  103447. */
  103448. environmentBRDFTexture: Nullable<BaseTexture>;
  103449. /**
  103450. * Force normal to face away from face.
  103451. */
  103452. forceNormalForward: boolean;
  103453. /**
  103454. * Enables specular anti aliasing in the PBR shader.
  103455. * It will both interacts on the Geometry for analytical and IBL lighting.
  103456. * It also prefilter the roughness map based on the bump values.
  103457. */
  103458. enableSpecularAntiAliasing: boolean;
  103459. /**
  103460. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  103461. * makes the reflect vector face the model (under horizon).
  103462. */
  103463. useHorizonOcclusion: boolean;
  103464. /**
  103465. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  103466. * too much the area relying on ambient texture to define their ambient occlusion.
  103467. */
  103468. useRadianceOcclusion: boolean;
  103469. /**
  103470. * If set to true, no lighting calculations will be applied.
  103471. */
  103472. unlit: boolean;
  103473. /**
  103474. * Gets the image processing configuration used either in this material.
  103475. */
  103476. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103477. /**
  103478. * Sets the Default image processing configuration used either in the this material.
  103479. *
  103480. * If sets to null, the scene one is in use.
  103481. */
  103482. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103483. /**
  103484. * Gets wether the color curves effect is enabled.
  103485. */
  103486. get cameraColorCurvesEnabled(): boolean;
  103487. /**
  103488. * Sets wether the color curves effect is enabled.
  103489. */
  103490. set cameraColorCurvesEnabled(value: boolean);
  103491. /**
  103492. * Gets wether the color grading effect is enabled.
  103493. */
  103494. get cameraColorGradingEnabled(): boolean;
  103495. /**
  103496. * Gets wether the color grading effect is enabled.
  103497. */
  103498. set cameraColorGradingEnabled(value: boolean);
  103499. /**
  103500. * Gets wether tonemapping is enabled or not.
  103501. */
  103502. get cameraToneMappingEnabled(): boolean;
  103503. /**
  103504. * Sets wether tonemapping is enabled or not
  103505. */
  103506. set cameraToneMappingEnabled(value: boolean);
  103507. /**
  103508. * The camera exposure used on this material.
  103509. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103510. * This corresponds to a photographic exposure.
  103511. */
  103512. get cameraExposure(): number;
  103513. /**
  103514. * The camera exposure used on this material.
  103515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103516. * This corresponds to a photographic exposure.
  103517. */
  103518. set cameraExposure(value: number);
  103519. /**
  103520. * Gets The camera contrast used on this material.
  103521. */
  103522. get cameraContrast(): number;
  103523. /**
  103524. * Sets The camera contrast used on this material.
  103525. */
  103526. set cameraContrast(value: number);
  103527. /**
  103528. * Gets the Color Grading 2D Lookup Texture.
  103529. */
  103530. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  103531. /**
  103532. * Sets the Color Grading 2D Lookup Texture.
  103533. */
  103534. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  103535. /**
  103536. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103537. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103538. * 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;
  103539. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103540. */
  103541. get cameraColorCurves(): Nullable<ColorCurves>;
  103542. /**
  103543. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103544. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103545. * 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;
  103546. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103547. */
  103548. set cameraColorCurves(value: Nullable<ColorCurves>);
  103549. /**
  103550. * Instantiates a new PBRMaterial instance.
  103551. *
  103552. * @param name The material name
  103553. * @param scene The scene the material will be use in.
  103554. */
  103555. constructor(name: string, scene: Scene);
  103556. /**
  103557. * Returns the name of this material class.
  103558. */
  103559. getClassName(): string;
  103560. /**
  103561. * Makes a duplicate of the current material.
  103562. * @param name - name to use for the new material.
  103563. */
  103564. clone(name: string): PBRMaterial;
  103565. /**
  103566. * Serializes this PBR Material.
  103567. * @returns - An object with the serialized material.
  103568. */
  103569. serialize(): any;
  103570. /**
  103571. * Parses a PBR Material from a serialized object.
  103572. * @param source - Serialized object.
  103573. * @param scene - BJS scene instance.
  103574. * @param rootUrl - url for the scene object
  103575. * @returns - PBRMaterial
  103576. */
  103577. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  103578. }
  103579. }
  103580. declare module BABYLON {
  103581. /** @hidden */
  103582. export var mrtFragmentDeclaration: {
  103583. name: string;
  103584. shader: string;
  103585. };
  103586. }
  103587. declare module BABYLON {
  103588. /** @hidden */
  103589. export var geometryPixelShader: {
  103590. name: string;
  103591. shader: string;
  103592. };
  103593. }
  103594. declare module BABYLON {
  103595. /** @hidden */
  103596. export var geometryVertexShader: {
  103597. name: string;
  103598. shader: string;
  103599. };
  103600. }
  103601. declare module BABYLON {
  103602. /** @hidden */
  103603. interface ISavedTransformationMatrix {
  103604. world: Matrix;
  103605. viewProjection: Matrix;
  103606. }
  103607. /**
  103608. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  103609. */
  103610. export class GeometryBufferRenderer {
  103611. /**
  103612. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  103613. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  103614. */
  103615. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  103616. /**
  103617. * Constant used to retrieve the position texture index in the G-Buffer textures array
  103618. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  103619. */
  103620. static readonly POSITION_TEXTURE_TYPE: number;
  103621. /**
  103622. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  103623. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  103624. */
  103625. static readonly VELOCITY_TEXTURE_TYPE: number;
  103626. /**
  103627. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  103628. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  103629. */
  103630. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  103631. /**
  103632. * Dictionary used to store the previous transformation matrices of each rendered mesh
  103633. * in order to compute objects velocities when enableVelocity is set to "true"
  103634. * @hidden
  103635. */
  103636. _previousTransformationMatrices: {
  103637. [index: number]: ISavedTransformationMatrix;
  103638. };
  103639. /**
  103640. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  103641. * in order to compute objects velocities when enableVelocity is set to "true"
  103642. * @hidden
  103643. */
  103644. _previousBonesTransformationMatrices: {
  103645. [index: number]: Float32Array;
  103646. };
  103647. /**
  103648. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  103649. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  103650. */
  103651. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  103652. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  103653. renderTransparentMeshes: boolean;
  103654. private _scene;
  103655. private _resizeObserver;
  103656. private _multiRenderTarget;
  103657. private _ratio;
  103658. private _enablePosition;
  103659. private _enableVelocity;
  103660. private _enableReflectivity;
  103661. private _positionIndex;
  103662. private _velocityIndex;
  103663. private _reflectivityIndex;
  103664. private _depthNormalIndex;
  103665. private _linkedWithPrePass;
  103666. private _prePassRenderer;
  103667. private _attachments;
  103668. protected _effect: Effect;
  103669. protected _cachedDefines: string;
  103670. /**
  103671. * @hidden
  103672. * Sets up internal structures to share outputs with PrePassRenderer
  103673. * This method should only be called by the PrePassRenderer itself
  103674. */
  103675. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  103676. /**
  103677. * @hidden
  103678. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  103679. * This method should only be called by the PrePassRenderer itself
  103680. */
  103681. _unlinkPrePassRenderer(): void;
  103682. /**
  103683. * @hidden
  103684. * Resets the geometry buffer layout
  103685. */
  103686. _resetLayout(): void;
  103687. /**
  103688. * @hidden
  103689. * Replaces a texture in the geometry buffer renderer
  103690. * Useful when linking textures of the prepass renderer
  103691. */
  103692. _forceTextureType(geometryBufferType: number, index: number): void;
  103693. /**
  103694. * @hidden
  103695. * Sets texture attachments
  103696. * Useful when linking textures of the prepass renderer
  103697. */
  103698. _setAttachments(attachments: number[]): void;
  103699. /**
  103700. * @hidden
  103701. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  103702. * Useful when linking textures of the prepass renderer
  103703. */
  103704. _linkInternalTexture(internalTexture: InternalTexture): void;
  103705. /**
  103706. * Gets the render list (meshes to be rendered) used in the G buffer.
  103707. */
  103708. get renderList(): Nullable<AbstractMesh[]>;
  103709. /**
  103710. * Set the render list (meshes to be rendered) used in the G buffer.
  103711. */
  103712. set renderList(meshes: Nullable<AbstractMesh[]>);
  103713. /**
  103714. * Gets wether or not G buffer are supported by the running hardware.
  103715. * This requires draw buffer supports
  103716. */
  103717. get isSupported(): boolean;
  103718. /**
  103719. * Returns the index of the given texture type in the G-Buffer textures array
  103720. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  103721. * @returns the index of the given texture type in the G-Buffer textures array
  103722. */
  103723. getTextureIndex(textureType: number): number;
  103724. /**
  103725. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  103726. */
  103727. get enablePosition(): boolean;
  103728. /**
  103729. * Sets whether or not objects positions are enabled for the G buffer.
  103730. */
  103731. set enablePosition(enable: boolean);
  103732. /**
  103733. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  103734. */
  103735. get enableVelocity(): boolean;
  103736. /**
  103737. * Sets wether or not objects velocities are enabled for the G buffer.
  103738. */
  103739. set enableVelocity(enable: boolean);
  103740. /**
  103741. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  103742. */
  103743. get enableReflectivity(): boolean;
  103744. /**
  103745. * Sets wether or not objects roughness are enabled for the G buffer.
  103746. */
  103747. set enableReflectivity(enable: boolean);
  103748. /**
  103749. * Gets the scene associated with the buffer.
  103750. */
  103751. get scene(): Scene;
  103752. /**
  103753. * Gets the ratio used by the buffer during its creation.
  103754. * How big is the buffer related to the main canvas.
  103755. */
  103756. get ratio(): number;
  103757. /** @hidden */
  103758. static _SceneComponentInitialization: (scene: Scene) => void;
  103759. /**
  103760. * Creates a new G Buffer for the scene
  103761. * @param scene The scene the buffer belongs to
  103762. * @param ratio How big is the buffer related to the main canvas.
  103763. */
  103764. constructor(scene: Scene, ratio?: number);
  103765. /**
  103766. * Checks wether everything is ready to render a submesh to the G buffer.
  103767. * @param subMesh the submesh to check readiness for
  103768. * @param useInstances is the mesh drawn using instance or not
  103769. * @returns true if ready otherwise false
  103770. */
  103771. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  103772. /**
  103773. * Gets the current underlying G Buffer.
  103774. * @returns the buffer
  103775. */
  103776. getGBuffer(): MultiRenderTarget;
  103777. /**
  103778. * Gets the number of samples used to render the buffer (anti aliasing).
  103779. */
  103780. get samples(): number;
  103781. /**
  103782. * Sets the number of samples used to render the buffer (anti aliasing).
  103783. */
  103784. set samples(value: number);
  103785. /**
  103786. * Disposes the renderer and frees up associated resources.
  103787. */
  103788. dispose(): void;
  103789. private _assignRenderTargetIndices;
  103790. protected _createRenderTargets(): void;
  103791. private _copyBonesTransformationMatrices;
  103792. }
  103793. }
  103794. declare module BABYLON {
  103795. /**
  103796. * Renders a pre pass of the scene
  103797. * This means every mesh in the scene will be rendered to a render target texture
  103798. * And then this texture will be composited to the rendering canvas with post processes
  103799. * It is necessary for effects like subsurface scattering or deferred shading
  103800. */
  103801. export class PrePassRenderer {
  103802. /** @hidden */
  103803. static _SceneComponentInitialization: (scene: Scene) => void;
  103804. private _textureFormats;
  103805. /**
  103806. * To save performance, we can excluded skinned meshes from the prepass
  103807. */
  103808. excludedSkinnedMesh: AbstractMesh[];
  103809. /**
  103810. * Force material to be excluded from the prepass
  103811. * Can be useful when `useGeometryBufferFallback` is set to `true`
  103812. * and you don't want a material to show in the effect.
  103813. */
  103814. excludedMaterials: Material[];
  103815. private _textureIndices;
  103816. private _scene;
  103817. private _engine;
  103818. private _isDirty;
  103819. /**
  103820. * Number of textures in the multi render target texture where the scene is directly rendered
  103821. */
  103822. mrtCount: number;
  103823. /**
  103824. * The render target where the scene is directly rendered
  103825. */
  103826. prePassRT: MultiRenderTarget;
  103827. private _multiRenderAttachments;
  103828. private _defaultAttachments;
  103829. private _clearAttachments;
  103830. private _postProcesses;
  103831. private readonly _clearColor;
  103832. /**
  103833. * Image processing post process for composition
  103834. */
  103835. imageProcessingPostProcess: ImageProcessingPostProcess;
  103836. /**
  103837. * Configuration for prepass effects
  103838. */
  103839. private _effectConfigurations;
  103840. private _mrtFormats;
  103841. private _mrtLayout;
  103842. private _enabled;
  103843. /**
  103844. * Indicates if the prepass is enabled
  103845. */
  103846. get enabled(): boolean;
  103847. /**
  103848. * How many samples are used for MSAA of the scene render target
  103849. */
  103850. get samples(): number;
  103851. set samples(n: number);
  103852. private _geometryBuffer;
  103853. private _useGeometryBufferFallback;
  103854. /**
  103855. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  103856. */
  103857. get useGeometryBufferFallback(): boolean;
  103858. set useGeometryBufferFallback(value: boolean);
  103859. /**
  103860. * Set to true to disable gamma transform in PrePass.
  103861. * Can be useful in case you already proceed to gamma transform on a material level
  103862. * and your post processes don't need to be in linear color space.
  103863. */
  103864. disableGammaTransform: boolean;
  103865. /**
  103866. * Instanciates a prepass renderer
  103867. * @param scene The scene
  103868. */
  103869. constructor(scene: Scene);
  103870. private _initializeAttachments;
  103871. private _createCompositionEffect;
  103872. /**
  103873. * Indicates if rendering a prepass is supported
  103874. */
  103875. get isSupported(): boolean;
  103876. /**
  103877. * Sets the proper output textures to draw in the engine.
  103878. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103879. * @param subMesh Submesh on which the effect is applied
  103880. */
  103881. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  103882. /**
  103883. * Restores attachments for single texture draw.
  103884. */
  103885. restoreAttachments(): void;
  103886. /**
  103887. * @hidden
  103888. */
  103889. _beforeCameraDraw(): void;
  103890. /**
  103891. * @hidden
  103892. */
  103893. _afterCameraDraw(): void;
  103894. private _checkRTSize;
  103895. private _bindFrameBuffer;
  103896. /**
  103897. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103898. */
  103899. clear(): void;
  103900. private _setState;
  103901. private _updateGeometryBufferLayout;
  103902. /**
  103903. * Adds an effect configuration to the prepass.
  103904. * If an effect has already been added, it won't add it twice and will return the configuration
  103905. * already present.
  103906. * @param cfg the effect configuration
  103907. * @return the effect configuration now used by the prepass
  103908. */
  103909. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103910. /**
  103911. * Returns the index of a texture in the multi render target texture array.
  103912. * @param type Texture type
  103913. * @return The index
  103914. */
  103915. getIndex(type: number): number;
  103916. private _enable;
  103917. private _disable;
  103918. private _resetLayout;
  103919. private _resetPostProcessChain;
  103920. private _bindPostProcessChain;
  103921. /**
  103922. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103923. */
  103924. markAsDirty(): void;
  103925. /**
  103926. * Enables a texture on the MultiRenderTarget for prepass
  103927. */
  103928. private _enableTextures;
  103929. private _update;
  103930. private _markAllMaterialsAsPrePassDirty;
  103931. /**
  103932. * Disposes the prepass renderer.
  103933. */
  103934. dispose(): void;
  103935. }
  103936. }
  103937. declare module BABYLON {
  103938. /**
  103939. * Size options for a post process
  103940. */
  103941. export type PostProcessOptions = {
  103942. width: number;
  103943. height: number;
  103944. };
  103945. /**
  103946. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103947. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103948. */
  103949. export class PostProcess {
  103950. /**
  103951. * Gets or sets the unique id of the post process
  103952. */
  103953. uniqueId: number;
  103954. /** Name of the PostProcess. */
  103955. name: string;
  103956. /**
  103957. * Width of the texture to apply the post process on
  103958. */
  103959. width: number;
  103960. /**
  103961. * Height of the texture to apply the post process on
  103962. */
  103963. height: number;
  103964. /**
  103965. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103966. */
  103967. nodeMaterialSource: Nullable<NodeMaterial>;
  103968. /**
  103969. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103970. * @hidden
  103971. */
  103972. _outputTexture: Nullable<InternalTexture>;
  103973. /**
  103974. * Sampling mode used by the shader
  103975. * See https://doc.babylonjs.com/classes/3.1/texture
  103976. */
  103977. renderTargetSamplingMode: number;
  103978. /**
  103979. * Clear color to use when screen clearing
  103980. */
  103981. clearColor: Color4;
  103982. /**
  103983. * If the buffer needs to be cleared before applying the post process. (default: true)
  103984. * Should be set to false if shader will overwrite all previous pixels.
  103985. */
  103986. autoClear: boolean;
  103987. /**
  103988. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103989. */
  103990. alphaMode: number;
  103991. /**
  103992. * Sets the setAlphaBlendConstants of the babylon engine
  103993. */
  103994. alphaConstants: Color4;
  103995. /**
  103996. * Animations to be used for the post processing
  103997. */
  103998. animations: Animation[];
  103999. /**
  104000. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  104001. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  104002. */
  104003. enablePixelPerfectMode: boolean;
  104004. /**
  104005. * Force the postprocess to be applied without taking in account viewport
  104006. */
  104007. forceFullscreenViewport: boolean;
  104008. /**
  104009. * List of inspectable custom properties (used by the Inspector)
  104010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104011. */
  104012. inspectableCustomProperties: IInspectable[];
  104013. /**
  104014. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  104015. *
  104016. * | Value | Type | Description |
  104017. * | ----- | ----------------------------------- | ----------- |
  104018. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  104019. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  104020. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  104021. *
  104022. */
  104023. scaleMode: number;
  104024. /**
  104025. * Force textures to be a power of two (default: false)
  104026. */
  104027. alwaysForcePOT: boolean;
  104028. private _samples;
  104029. /**
  104030. * Number of sample textures (default: 1)
  104031. */
  104032. get samples(): number;
  104033. set samples(n: number);
  104034. /**
  104035. * Modify the scale of the post process to be the same as the viewport (default: false)
  104036. */
  104037. adaptScaleToCurrentViewport: boolean;
  104038. private _camera;
  104039. protected _scene: Scene;
  104040. private _engine;
  104041. private _options;
  104042. private _reusable;
  104043. private _textureType;
  104044. private _textureFormat;
  104045. /**
  104046. * Smart array of input and output textures for the post process.
  104047. * @hidden
  104048. */
  104049. _textures: SmartArray<InternalTexture>;
  104050. /**
  104051. * The index in _textures that corresponds to the output texture.
  104052. * @hidden
  104053. */
  104054. _currentRenderTextureInd: number;
  104055. private _effect;
  104056. private _samplers;
  104057. private _fragmentUrl;
  104058. private _vertexUrl;
  104059. private _parameters;
  104060. private _scaleRatio;
  104061. protected _indexParameters: any;
  104062. private _shareOutputWithPostProcess;
  104063. private _texelSize;
  104064. private _forcedOutputTexture;
  104065. /**
  104066. * Prepass configuration in case this post process needs a texture from prepass
  104067. * @hidden
  104068. */
  104069. _prePassEffectConfiguration: PrePassEffectConfiguration;
  104070. /**
  104071. * Returns the fragment url or shader name used in the post process.
  104072. * @returns the fragment url or name in the shader store.
  104073. */
  104074. getEffectName(): string;
  104075. /**
  104076. * An event triggered when the postprocess is activated.
  104077. */
  104078. onActivateObservable: Observable<Camera>;
  104079. private _onActivateObserver;
  104080. /**
  104081. * A function that is added to the onActivateObservable
  104082. */
  104083. set onActivate(callback: Nullable<(camera: Camera) => void>);
  104084. /**
  104085. * An event triggered when the postprocess changes its size.
  104086. */
  104087. onSizeChangedObservable: Observable<PostProcess>;
  104088. private _onSizeChangedObserver;
  104089. /**
  104090. * A function that is added to the onSizeChangedObservable
  104091. */
  104092. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  104093. /**
  104094. * An event triggered when the postprocess applies its effect.
  104095. */
  104096. onApplyObservable: Observable<Effect>;
  104097. private _onApplyObserver;
  104098. /**
  104099. * A function that is added to the onApplyObservable
  104100. */
  104101. set onApply(callback: (effect: Effect) => void);
  104102. /**
  104103. * An event triggered before rendering the postprocess
  104104. */
  104105. onBeforeRenderObservable: Observable<Effect>;
  104106. private _onBeforeRenderObserver;
  104107. /**
  104108. * A function that is added to the onBeforeRenderObservable
  104109. */
  104110. set onBeforeRender(callback: (effect: Effect) => void);
  104111. /**
  104112. * An event triggered after rendering the postprocess
  104113. */
  104114. onAfterRenderObservable: Observable<Effect>;
  104115. private _onAfterRenderObserver;
  104116. /**
  104117. * A function that is added to the onAfterRenderObservable
  104118. */
  104119. set onAfterRender(callback: (efect: Effect) => void);
  104120. /**
  104121. * 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
  104122. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  104123. */
  104124. get inputTexture(): InternalTexture;
  104125. set inputTexture(value: InternalTexture);
  104126. /**
  104127. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  104128. * the only way to unset it is to use this function to restore its internal state
  104129. */
  104130. restoreDefaultInputTexture(): void;
  104131. /**
  104132. * Gets the camera which post process is applied to.
  104133. * @returns The camera the post process is applied to.
  104134. */
  104135. getCamera(): Camera;
  104136. /**
  104137. * Gets the texel size of the postprocess.
  104138. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  104139. */
  104140. get texelSize(): Vector2;
  104141. /**
  104142. * Creates a new instance PostProcess
  104143. * @param name The name of the PostProcess.
  104144. * @param fragmentUrl The url of the fragment shader to be used.
  104145. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  104146. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  104147. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104148. * @param camera The camera to apply the render pass to.
  104149. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104150. * @param engine The engine which the post process will be applied. (default: current engine)
  104151. * @param reusable If the post process can be reused on the same frame. (default: false)
  104152. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  104153. * @param textureType Type of textures used when performing the post process. (default: 0)
  104154. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  104155. * @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
  104156. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  104157. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104158. */
  104159. 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);
  104160. /**
  104161. * Gets a string identifying the name of the class
  104162. * @returns "PostProcess" string
  104163. */
  104164. getClassName(): string;
  104165. /**
  104166. * Gets the engine which this post process belongs to.
  104167. * @returns The engine the post process was enabled with.
  104168. */
  104169. getEngine(): Engine;
  104170. /**
  104171. * The effect that is created when initializing the post process.
  104172. * @returns The created effect corresponding the the postprocess.
  104173. */
  104174. getEffect(): Effect;
  104175. /**
  104176. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104177. * @param postProcess The post process to share the output with.
  104178. * @returns This post process.
  104179. */
  104180. shareOutputWith(postProcess: PostProcess): PostProcess;
  104181. /**
  104182. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104183. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104184. */
  104185. useOwnOutput(): void;
  104186. /**
  104187. * Updates the effect with the current post process compile time values and recompiles the shader.
  104188. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104189. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104190. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104191. * @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
  104192. * @param onCompiled Called when the shader has been compiled.
  104193. * @param onError Called if there is an error when compiling a shader.
  104194. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104195. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104196. */
  104197. 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;
  104198. /**
  104199. * The post process is reusable if it can be used multiple times within one frame.
  104200. * @returns If the post process is reusable
  104201. */
  104202. isReusable(): boolean;
  104203. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104204. markTextureDirty(): void;
  104205. /**
  104206. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104207. * 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.
  104208. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104209. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104210. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104211. * @returns The target texture that was bound to be written to.
  104212. */
  104213. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104214. /**
  104215. * If the post process is supported.
  104216. */
  104217. get isSupported(): boolean;
  104218. /**
  104219. * The aspect ratio of the output texture.
  104220. */
  104221. get aspectRatio(): number;
  104222. /**
  104223. * Get a value indicating if the post-process is ready to be used
  104224. * @returns true if the post-process is ready (shader is compiled)
  104225. */
  104226. isReady(): boolean;
  104227. /**
  104228. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104229. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104230. */
  104231. apply(): Nullable<Effect>;
  104232. private _disposeTextures;
  104233. /**
  104234. * Sets the required values to the prepass renderer.
  104235. * @param prePassRenderer defines the prepass renderer to setup.
  104236. * @returns true if the pre pass is needed.
  104237. */
  104238. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104239. /**
  104240. * Disposes the post process.
  104241. * @param camera The camera to dispose the post process on.
  104242. */
  104243. dispose(camera?: Camera): void;
  104244. /**
  104245. * Serializes the particle system to a JSON object
  104246. * @returns the JSON object
  104247. */
  104248. serialize(): any;
  104249. /**
  104250. * Creates a material from parsed material data
  104251. * @param parsedPostProcess defines parsed post process data
  104252. * @param scene defines the hosting scene
  104253. * @param rootUrl defines the root URL to use to load textures
  104254. * @returns a new post process
  104255. */
  104256. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104257. }
  104258. }
  104259. declare module BABYLON {
  104260. /** @hidden */
  104261. export var kernelBlurVaryingDeclaration: {
  104262. name: string;
  104263. shader: string;
  104264. };
  104265. }
  104266. declare module BABYLON {
  104267. /** @hidden */
  104268. export var packingFunctions: {
  104269. name: string;
  104270. shader: string;
  104271. };
  104272. }
  104273. declare module BABYLON {
  104274. /** @hidden */
  104275. export var kernelBlurFragment: {
  104276. name: string;
  104277. shader: string;
  104278. };
  104279. }
  104280. declare module BABYLON {
  104281. /** @hidden */
  104282. export var kernelBlurFragment2: {
  104283. name: string;
  104284. shader: string;
  104285. };
  104286. }
  104287. declare module BABYLON {
  104288. /** @hidden */
  104289. export var kernelBlurPixelShader: {
  104290. name: string;
  104291. shader: string;
  104292. };
  104293. }
  104294. declare module BABYLON {
  104295. /** @hidden */
  104296. export var kernelBlurVertex: {
  104297. name: string;
  104298. shader: string;
  104299. };
  104300. }
  104301. declare module BABYLON {
  104302. /** @hidden */
  104303. export var kernelBlurVertexShader: {
  104304. name: string;
  104305. shader: string;
  104306. };
  104307. }
  104308. declare module BABYLON {
  104309. /**
  104310. * The Blur Post Process which blurs an image based on a kernel and direction.
  104311. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104312. */
  104313. export class BlurPostProcess extends PostProcess {
  104314. private blockCompilation;
  104315. protected _kernel: number;
  104316. protected _idealKernel: number;
  104317. protected _packedFloat: boolean;
  104318. private _staticDefines;
  104319. /** The direction in which to blur the image. */
  104320. direction: Vector2;
  104321. /**
  104322. * Sets the length in pixels of the blur sample region
  104323. */
  104324. set kernel(v: number);
  104325. /**
  104326. * Gets the length in pixels of the blur sample region
  104327. */
  104328. get kernel(): number;
  104329. /**
  104330. * Sets wether or not the blur needs to unpack/repack floats
  104331. */
  104332. set packedFloat(v: boolean);
  104333. /**
  104334. * Gets wether or not the blur is unpacking/repacking floats
  104335. */
  104336. get packedFloat(): boolean;
  104337. /**
  104338. * Gets a string identifying the name of the class
  104339. * @returns "BlurPostProcess" string
  104340. */
  104341. getClassName(): string;
  104342. /**
  104343. * Creates a new instance BlurPostProcess
  104344. * @param name The name of the effect.
  104345. * @param direction The direction in which to blur the image.
  104346. * @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.
  104347. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104348. * @param camera The camera to apply the render pass to.
  104349. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104350. * @param engine The engine which the post process will be applied. (default: current engine)
  104351. * @param reusable If the post process can be reused on the same frame. (default: false)
  104352. * @param textureType Type of textures used when performing the post process. (default: 0)
  104353. * @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)
  104354. */
  104355. 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);
  104356. /**
  104357. * Updates the effect with the current post process compile time values and recompiles the shader.
  104358. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104359. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104360. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104361. * @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
  104362. * @param onCompiled Called when the shader has been compiled.
  104363. * @param onError Called if there is an error when compiling a shader.
  104364. */
  104365. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104366. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104367. /**
  104368. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104369. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104370. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104371. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104372. * The gaps between physical kernels are compensated for in the weighting of the samples
  104373. * @param idealKernel Ideal blur kernel.
  104374. * @return Nearest best kernel.
  104375. */
  104376. protected _nearestBestKernel(idealKernel: number): number;
  104377. /**
  104378. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104379. * @param x The point on the Gaussian distribution to sample.
  104380. * @return the value of the Gaussian function at x.
  104381. */
  104382. protected _gaussianWeight(x: number): number;
  104383. /**
  104384. * Generates a string that can be used as a floating point number in GLSL.
  104385. * @param x Value to print.
  104386. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104387. * @return GLSL float string.
  104388. */
  104389. protected _glslFloat(x: number, decimalFigures?: number): string;
  104390. /** @hidden */
  104391. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104392. }
  104393. }
  104394. declare module BABYLON {
  104395. /**
  104396. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104397. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104398. * You can then easily use it as a reflectionTexture on a flat surface.
  104399. * In case the surface is not a plane, please consider relying on reflection probes.
  104400. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104401. */
  104402. export class MirrorTexture extends RenderTargetTexture {
  104403. private scene;
  104404. /**
  104405. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104406. * 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.
  104407. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104408. */
  104409. mirrorPlane: Plane;
  104410. /**
  104411. * Define the blur ratio used to blur the reflection if needed.
  104412. */
  104413. set blurRatio(value: number);
  104414. get blurRatio(): number;
  104415. /**
  104416. * Define the adaptive blur kernel used to blur the reflection if needed.
  104417. * This will autocompute the closest best match for the `blurKernel`
  104418. */
  104419. set adaptiveBlurKernel(value: number);
  104420. /**
  104421. * Define the blur kernel used to blur the reflection if needed.
  104422. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104423. */
  104424. set blurKernel(value: number);
  104425. /**
  104426. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104427. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104428. */
  104429. set blurKernelX(value: number);
  104430. get blurKernelX(): number;
  104431. /**
  104432. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104433. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104434. */
  104435. set blurKernelY(value: number);
  104436. get blurKernelY(): number;
  104437. private _autoComputeBlurKernel;
  104438. protected _onRatioRescale(): void;
  104439. private _updateGammaSpace;
  104440. private _imageProcessingConfigChangeObserver;
  104441. private _transformMatrix;
  104442. private _mirrorMatrix;
  104443. private _savedViewMatrix;
  104444. private _blurX;
  104445. private _blurY;
  104446. private _adaptiveBlurKernel;
  104447. private _blurKernelX;
  104448. private _blurKernelY;
  104449. private _blurRatio;
  104450. /**
  104451. * Instantiates a Mirror Texture.
  104452. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104453. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104454. * You can then easily use it as a reflectionTexture on a flat surface.
  104455. * In case the surface is not a plane, please consider relying on reflection probes.
  104456. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104457. * @param name
  104458. * @param size
  104459. * @param scene
  104460. * @param generateMipMaps
  104461. * @param type
  104462. * @param samplingMode
  104463. * @param generateDepthBuffer
  104464. */
  104465. constructor(name: string, size: number | {
  104466. width: number;
  104467. height: number;
  104468. } | {
  104469. ratio: number;
  104470. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104471. private _preparePostProcesses;
  104472. /**
  104473. * Clone the mirror texture.
  104474. * @returns the cloned texture
  104475. */
  104476. clone(): MirrorTexture;
  104477. /**
  104478. * Serialize the texture to a JSON representation you could use in Parse later on
  104479. * @returns the serialized JSON representation
  104480. */
  104481. serialize(): any;
  104482. /**
  104483. * Dispose the texture and release its associated resources.
  104484. */
  104485. dispose(): void;
  104486. }
  104487. }
  104488. declare module BABYLON {
  104489. /**
  104490. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104491. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104492. */
  104493. export class Texture extends BaseTexture {
  104494. /**
  104495. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104496. */
  104497. static SerializeBuffers: boolean;
  104498. /**
  104499. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  104500. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  104501. */
  104502. static ForceSerializeBuffers: boolean;
  104503. /** @hidden */
  104504. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104505. /** @hidden */
  104506. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104507. /** @hidden */
  104508. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104509. /** nearest is mag = nearest and min = nearest and mip = linear */
  104510. static readonly NEAREST_SAMPLINGMODE: number;
  104511. /** nearest is mag = nearest and min = nearest and mip = linear */
  104512. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104513. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104514. static readonly BILINEAR_SAMPLINGMODE: number;
  104515. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104516. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104517. /** Trilinear is mag = linear and min = linear and mip = linear */
  104518. static readonly TRILINEAR_SAMPLINGMODE: number;
  104519. /** Trilinear is mag = linear and min = linear and mip = linear */
  104520. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104521. /** mag = nearest and min = nearest and mip = nearest */
  104522. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104523. /** mag = nearest and min = linear and mip = nearest */
  104524. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104525. /** mag = nearest and min = linear and mip = linear */
  104526. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104527. /** mag = nearest and min = linear and mip = none */
  104528. static readonly NEAREST_LINEAR: number;
  104529. /** mag = nearest and min = nearest and mip = none */
  104530. static readonly NEAREST_NEAREST: number;
  104531. /** mag = linear and min = nearest and mip = nearest */
  104532. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104533. /** mag = linear and min = nearest and mip = linear */
  104534. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104535. /** mag = linear and min = linear and mip = none */
  104536. static readonly LINEAR_LINEAR: number;
  104537. /** mag = linear and min = nearest and mip = none */
  104538. static readonly LINEAR_NEAREST: number;
  104539. /** Explicit coordinates mode */
  104540. static readonly EXPLICIT_MODE: number;
  104541. /** Spherical coordinates mode */
  104542. static readonly SPHERICAL_MODE: number;
  104543. /** Planar coordinates mode */
  104544. static readonly PLANAR_MODE: number;
  104545. /** Cubic coordinates mode */
  104546. static readonly CUBIC_MODE: number;
  104547. /** Projection coordinates mode */
  104548. static readonly PROJECTION_MODE: number;
  104549. /** Inverse Cubic coordinates mode */
  104550. static readonly SKYBOX_MODE: number;
  104551. /** Inverse Cubic coordinates mode */
  104552. static readonly INVCUBIC_MODE: number;
  104553. /** Equirectangular coordinates mode */
  104554. static readonly EQUIRECTANGULAR_MODE: number;
  104555. /** Equirectangular Fixed coordinates mode */
  104556. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104557. /** Equirectangular Fixed Mirrored coordinates mode */
  104558. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104559. /** Texture is not repeating outside of 0..1 UVs */
  104560. static readonly CLAMP_ADDRESSMODE: number;
  104561. /** Texture is repeating outside of 0..1 UVs */
  104562. static readonly WRAP_ADDRESSMODE: number;
  104563. /** Texture is repeating and mirrored */
  104564. static readonly MIRROR_ADDRESSMODE: number;
  104565. /**
  104566. * 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
  104567. */
  104568. static UseSerializedUrlIfAny: boolean;
  104569. /**
  104570. * Define the url of the texture.
  104571. */
  104572. url: Nullable<string>;
  104573. /**
  104574. * Define an offset on the texture to offset the u coordinates of the UVs
  104575. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104576. */
  104577. uOffset: number;
  104578. /**
  104579. * Define an offset on the texture to offset the v coordinates of the UVs
  104580. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104581. */
  104582. vOffset: number;
  104583. /**
  104584. * Define an offset on the texture to scale the u coordinates of the UVs
  104585. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104586. */
  104587. uScale: number;
  104588. /**
  104589. * Define an offset on the texture to scale the v coordinates of the UVs
  104590. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104591. */
  104592. vScale: number;
  104593. /**
  104594. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104595. * @see https://doc.babylonjs.com/how_to/more_materials
  104596. */
  104597. uAng: number;
  104598. /**
  104599. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104600. * @see https://doc.babylonjs.com/how_to/more_materials
  104601. */
  104602. vAng: number;
  104603. /**
  104604. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104605. * @see https://doc.babylonjs.com/how_to/more_materials
  104606. */
  104607. wAng: number;
  104608. /**
  104609. * Defines the center of rotation (U)
  104610. */
  104611. uRotationCenter: number;
  104612. /**
  104613. * Defines the center of rotation (V)
  104614. */
  104615. vRotationCenter: number;
  104616. /**
  104617. * Defines the center of rotation (W)
  104618. */
  104619. wRotationCenter: number;
  104620. /**
  104621. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  104622. */
  104623. homogeneousRotationInUVTransform: boolean;
  104624. /**
  104625. * Are mip maps generated for this texture or not.
  104626. */
  104627. get noMipmap(): boolean;
  104628. /**
  104629. * List of inspectable custom properties (used by the Inspector)
  104630. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104631. */
  104632. inspectableCustomProperties: Nullable<IInspectable[]>;
  104633. private _noMipmap;
  104634. /** @hidden */
  104635. _invertY: boolean;
  104636. private _rowGenerationMatrix;
  104637. private _cachedTextureMatrix;
  104638. private _projectionModeMatrix;
  104639. private _t0;
  104640. private _t1;
  104641. private _t2;
  104642. private _cachedUOffset;
  104643. private _cachedVOffset;
  104644. private _cachedUScale;
  104645. private _cachedVScale;
  104646. private _cachedUAng;
  104647. private _cachedVAng;
  104648. private _cachedWAng;
  104649. private _cachedProjectionMatrixId;
  104650. private _cachedURotationCenter;
  104651. private _cachedVRotationCenter;
  104652. private _cachedWRotationCenter;
  104653. private _cachedHomogeneousRotationInUVTransform;
  104654. private _cachedCoordinatesMode;
  104655. /** @hidden */
  104656. protected _initialSamplingMode: number;
  104657. /** @hidden */
  104658. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104659. private _deleteBuffer;
  104660. protected _format: Nullable<number>;
  104661. private _delayedOnLoad;
  104662. private _delayedOnError;
  104663. private _mimeType?;
  104664. private _loaderOptions?;
  104665. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104666. get mimeType(): string | undefined;
  104667. /**
  104668. * Observable triggered once the texture has been loaded.
  104669. */
  104670. onLoadObservable: Observable<Texture>;
  104671. protected _isBlocking: boolean;
  104672. /**
  104673. * Is the texture preventing material to render while loading.
  104674. * If false, a default texture will be used instead of the loading one during the preparation step.
  104675. */
  104676. set isBlocking(value: boolean);
  104677. get isBlocking(): boolean;
  104678. /**
  104679. * Get the current sampling mode associated with the texture.
  104680. */
  104681. get samplingMode(): number;
  104682. /**
  104683. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104684. */
  104685. get invertY(): boolean;
  104686. /**
  104687. * Instantiates a new texture.
  104688. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104689. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104690. * @param url defines the url of the picture to load as a texture
  104691. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104692. * @param noMipmap defines if the texture will require mip maps or not
  104693. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104694. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104695. * @param onLoad defines a callback triggered when the texture has been loaded
  104696. * @param onError defines a callback triggered when an error occurred during the loading session
  104697. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104698. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104699. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104700. * @param mimeType defines an optional mime type information
  104701. * @param loaderOptions options to be passed to the loader
  104702. */
  104703. 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, loaderOptions?: any);
  104704. /**
  104705. * Update the url (and optional buffer) of this texture if url was null during construction.
  104706. * @param url the url of the texture
  104707. * @param buffer the buffer of the texture (defaults to null)
  104708. * @param onLoad callback called when the texture is loaded (defaults to null)
  104709. */
  104710. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104711. /**
  104712. * Finish the loading sequence of a texture flagged as delayed load.
  104713. * @hidden
  104714. */
  104715. delayLoad(): void;
  104716. private _prepareRowForTextureGeneration;
  104717. /**
  104718. * Checks if the texture has the same transform matrix than another texture
  104719. * @param texture texture to check against
  104720. * @returns true if the transforms are the same, else false
  104721. */
  104722. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  104723. /**
  104724. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104725. * @returns the transform matrix of the texture.
  104726. */
  104727. getTextureMatrix(uBase?: number): Matrix;
  104728. /**
  104729. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104730. * @returns The reflection texture transform
  104731. */
  104732. getReflectionTextureMatrix(): Matrix;
  104733. /**
  104734. * Clones the texture.
  104735. * @returns the cloned texture
  104736. */
  104737. clone(): Texture;
  104738. /**
  104739. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104740. * @returns The JSON representation of the texture
  104741. */
  104742. serialize(): any;
  104743. /**
  104744. * Get the current class name of the texture useful for serialization or dynamic coding.
  104745. * @returns "Texture"
  104746. */
  104747. getClassName(): string;
  104748. /**
  104749. * Dispose the texture and release its associated resources.
  104750. */
  104751. dispose(): void;
  104752. /**
  104753. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104754. * @param parsedTexture Define the JSON representation of the texture
  104755. * @param scene Define the scene the parsed texture should be instantiated in
  104756. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104757. * @returns The parsed texture if successful
  104758. */
  104759. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104760. /**
  104761. * Creates a texture from its base 64 representation.
  104762. * @param data Define the base64 payload without the data: prefix
  104763. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104764. * @param scene Define the scene the texture should belong to
  104765. * @param noMipmap Forces the texture to not create mip map information if true
  104766. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104767. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104768. * @param onLoad define a callback triggered when the texture has been loaded
  104769. * @param onError define a callback triggered when an error occurred during the loading session
  104770. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104771. * @returns the created texture
  104772. */
  104773. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104774. /**
  104775. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104776. * @param data Define the base64 payload without the data: prefix
  104777. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104778. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104779. * @param scene Define the scene the texture should belong to
  104780. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104781. * @param noMipmap Forces the texture to not create mip map information if true
  104782. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104783. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104784. * @param onLoad define a callback triggered when the texture has been loaded
  104785. * @param onError define a callback triggered when an error occurred during the loading session
  104786. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104787. * @returns the created texture
  104788. */
  104789. 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;
  104790. }
  104791. }
  104792. declare module BABYLON {
  104793. /**
  104794. * ThinSprite Class used to represent a thin sprite
  104795. * This is the base class for sprites but can also directly be used with ThinEngine
  104796. * @see https://doc.babylonjs.com/babylon101/sprites
  104797. */
  104798. export class ThinSprite {
  104799. /** Gets or sets the cell index in the sprite sheet */
  104800. cellIndex: number;
  104801. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  104802. cellRef: string;
  104803. /** Gets or sets the current world position */
  104804. position: IVector3Like;
  104805. /** Gets or sets the main color */
  104806. color: IColor4Like;
  104807. /** Gets or sets the width */
  104808. width: number;
  104809. /** Gets or sets the height */
  104810. height: number;
  104811. /** Gets or sets rotation angle */
  104812. angle: number;
  104813. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  104814. invertU: boolean;
  104815. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  104816. invertV: boolean;
  104817. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  104818. isVisible: boolean;
  104819. /**
  104820. * Returns a boolean indicating if the animation is started
  104821. */
  104822. get animationStarted(): boolean;
  104823. /** Gets the initial key for the animation (setting it will restart the animation) */
  104824. get fromIndex(): number;
  104825. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  104826. get toIndex(): number;
  104827. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  104828. get loopAnimation(): boolean;
  104829. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  104830. get delay(): number;
  104831. /** @hidden */
  104832. _xOffset: number;
  104833. /** @hidden */
  104834. _yOffset: number;
  104835. /** @hidden */
  104836. _xSize: number;
  104837. /** @hidden */
  104838. _ySize: number;
  104839. private _animationStarted;
  104840. protected _loopAnimation: boolean;
  104841. protected _fromIndex: number;
  104842. protected _toIndex: number;
  104843. protected _delay: number;
  104844. private _direction;
  104845. private _time;
  104846. private _onBaseAnimationEnd;
  104847. /**
  104848. * Creates a new Thin Sprite
  104849. */
  104850. constructor();
  104851. /**
  104852. * Starts an animation
  104853. * @param from defines the initial key
  104854. * @param to defines the end key
  104855. * @param loop defines if the animation must loop
  104856. * @param delay defines the start delay (in ms)
  104857. * @param onAnimationEnd defines a callback for when the animation ends
  104858. */
  104859. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  104860. /** Stops current animation (if any) */
  104861. stopAnimation(): void;
  104862. /** @hidden */
  104863. _animate(deltaTime: number): void;
  104864. }
  104865. }
  104866. declare module BABYLON {
  104867. /** @hidden */
  104868. export var imageProcessingCompatibility: {
  104869. name: string;
  104870. shader: string;
  104871. };
  104872. }
  104873. declare module BABYLON {
  104874. /** @hidden */
  104875. export var spritesPixelShader: {
  104876. name: string;
  104877. shader: string;
  104878. };
  104879. }
  104880. declare module BABYLON {
  104881. /** @hidden */
  104882. export var spritesVertexShader: {
  104883. name: string;
  104884. shader: string;
  104885. };
  104886. }
  104887. declare module BABYLON {
  104888. /**
  104889. * Class used to render sprites.
  104890. *
  104891. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  104892. */
  104893. export class SpriteRenderer {
  104894. /**
  104895. * Defines the texture of the spritesheet
  104896. */
  104897. texture: Nullable<ThinTexture>;
  104898. /**
  104899. * Defines the default width of a cell in the spritesheet
  104900. */
  104901. cellWidth: number;
  104902. /**
  104903. * Defines the default height of a cell in the spritesheet
  104904. */
  104905. cellHeight: number;
  104906. /**
  104907. * Blend mode use to render the particle, it can be any of
  104908. * the static Constants.ALPHA_x properties provided in this class.
  104909. * Default value is Constants.ALPHA_COMBINE
  104910. */
  104911. blendMode: number;
  104912. /**
  104913. * Gets or sets a boolean indicating if alpha mode is automatically
  104914. * reset.
  104915. */
  104916. autoResetAlpha: boolean;
  104917. /**
  104918. * Disables writing to the depth buffer when rendering the sprites.
  104919. * It can be handy to disable depth writing when using textures without alpha channel
  104920. * and setting some specific blend modes.
  104921. */
  104922. disableDepthWrite: boolean;
  104923. /**
  104924. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  104925. */
  104926. fogEnabled: boolean;
  104927. /**
  104928. * Gets the capacity of the manager
  104929. */
  104930. get capacity(): number;
  104931. private readonly _engine;
  104932. private readonly _useVAO;
  104933. private readonly _useInstancing;
  104934. private readonly _scene;
  104935. private readonly _capacity;
  104936. private readonly _epsilon;
  104937. private _vertexBufferSize;
  104938. private _vertexData;
  104939. private _buffer;
  104940. private _vertexBuffers;
  104941. private _spriteBuffer;
  104942. private _indexBuffer;
  104943. private _effectBase;
  104944. private _effectFog;
  104945. private _vertexArrayObject;
  104946. /**
  104947. * Creates a new sprite Renderer
  104948. * @param engine defines the engine the renderer works with
  104949. * @param capacity defines the maximum allowed number of sprites
  104950. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  104951. * @param scene defines the hosting scene
  104952. */
  104953. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  104954. /**
  104955. * Render all child sprites
  104956. * @param sprites defines the list of sprites to render
  104957. * @param deltaTime defines the time since last frame
  104958. * @param viewMatrix defines the viewMatrix to use to render the sprites
  104959. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  104960. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  104961. */
  104962. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  104963. private _appendSpriteVertex;
  104964. /**
  104965. * Release associated resources
  104966. */
  104967. dispose(): void;
  104968. }
  104969. }
  104970. declare module BABYLON {
  104971. /**
  104972. * Defines the minimum interface to fullfil in order to be a sprite manager.
  104973. */
  104974. export interface ISpriteManager extends IDisposable {
  104975. /**
  104976. * Gets manager's name
  104977. */
  104978. name: string;
  104979. /**
  104980. * Restricts the camera to viewing objects with the same layerMask.
  104981. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  104982. */
  104983. layerMask: number;
  104984. /**
  104985. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  104986. */
  104987. isPickable: boolean;
  104988. /**
  104989. * Gets the hosting scene
  104990. */
  104991. scene: Scene;
  104992. /**
  104993. * Specifies the rendering group id for this mesh (0 by default)
  104994. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  104995. */
  104996. renderingGroupId: number;
  104997. /**
  104998. * Defines the list of sprites managed by the manager.
  104999. */
  105000. sprites: Array<Sprite>;
  105001. /**
  105002. * Gets or sets the spritesheet texture
  105003. */
  105004. texture: Texture;
  105005. /** Defines the default width of a cell in the spritesheet */
  105006. cellWidth: number;
  105007. /** Defines the default height of a cell in the spritesheet */
  105008. cellHeight: number;
  105009. /**
  105010. * Tests the intersection of a sprite with a specific ray.
  105011. * @param ray The ray we are sending to test the collision
  105012. * @param camera The camera space we are sending rays in
  105013. * @param predicate A predicate allowing excluding sprites from the list of object to test
  105014. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105015. * @returns picking info or null.
  105016. */
  105017. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  105018. /**
  105019. * Intersects the sprites with a ray
  105020. * @param ray defines the ray to intersect with
  105021. * @param camera defines the current active camera
  105022. * @param predicate defines a predicate used to select candidate sprites
  105023. * @returns null if no hit or a PickingInfo array
  105024. */
  105025. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  105026. /**
  105027. * Renders the list of sprites on screen.
  105028. */
  105029. render(): void;
  105030. }
  105031. /**
  105032. * Class used to manage multiple sprites on the same spritesheet
  105033. * @see https://doc.babylonjs.com/babylon101/sprites
  105034. */
  105035. export class SpriteManager implements ISpriteManager {
  105036. /** defines the manager's name */
  105037. name: string;
  105038. /** Define the Url to load snippets */
  105039. static SnippetUrl: string;
  105040. /** Snippet ID if the manager was created from the snippet server */
  105041. snippetId: string;
  105042. /** Gets the list of sprites */
  105043. sprites: Sprite[];
  105044. /** Gets or sets the rendering group id (0 by default) */
  105045. renderingGroupId: number;
  105046. /** Gets or sets camera layer mask */
  105047. layerMask: number;
  105048. /** Gets or sets a boolean indicating if the sprites are pickable */
  105049. isPickable: boolean;
  105050. /**
  105051. * An event triggered when the manager is disposed.
  105052. */
  105053. onDisposeObservable: Observable<SpriteManager>;
  105054. /**
  105055. * Callback called when the manager is disposed
  105056. */
  105057. set onDispose(callback: () => void);
  105058. /**
  105059. * Gets or sets the unique id of the sprite
  105060. */
  105061. uniqueId: number;
  105062. /**
  105063. * Gets the array of sprites
  105064. */
  105065. get children(): Sprite[];
  105066. /**
  105067. * Gets the hosting scene
  105068. */
  105069. get scene(): Scene;
  105070. /**
  105071. * Gets the capacity of the manager
  105072. */
  105073. get capacity(): number;
  105074. /**
  105075. * Gets or sets the spritesheet texture
  105076. */
  105077. get texture(): Texture;
  105078. set texture(value: Texture);
  105079. /** Defines the default width of a cell in the spritesheet */
  105080. get cellWidth(): number;
  105081. set cellWidth(value: number);
  105082. /** Defines the default height of a cell in the spritesheet */
  105083. get cellHeight(): number;
  105084. set cellHeight(value: number);
  105085. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  105086. get fogEnabled(): boolean;
  105087. set fogEnabled(value: boolean);
  105088. /**
  105089. * Blend mode use to render the particle, it can be any of
  105090. * the static Constants.ALPHA_x properties provided in this class.
  105091. * Default value is Constants.ALPHA_COMBINE
  105092. */
  105093. get blendMode(): number;
  105094. set blendMode(blendMode: number);
  105095. /** Disables writing to the depth buffer when rendering the sprites.
  105096. * It can be handy to disable depth writing when using textures without alpha channel
  105097. * and setting some specific blend modes.
  105098. */
  105099. disableDepthWrite: boolean;
  105100. private _spriteRenderer;
  105101. /** Associative array from JSON sprite data file */
  105102. private _cellData;
  105103. /** Array of sprite names from JSON sprite data file */
  105104. private _spriteMap;
  105105. /** True when packed cell data from JSON file is ready*/
  105106. private _packedAndReady;
  105107. private _textureContent;
  105108. private _onDisposeObserver;
  105109. private _fromPacked;
  105110. private _scene;
  105111. /**
  105112. * Creates a new sprite manager
  105113. * @param name defines the manager's name
  105114. * @param imgUrl defines the sprite sheet url
  105115. * @param capacity defines the maximum allowed number of sprites
  105116. * @param cellSize defines the size of a sprite cell
  105117. * @param scene defines the hosting scene
  105118. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  105119. * @param samplingMode defines the smapling mode to use with spritesheet
  105120. * @param fromPacked set to false; do not alter
  105121. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  105122. */
  105123. constructor(
  105124. /** defines the manager's name */
  105125. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  105126. /**
  105127. * Returns the string "SpriteManager"
  105128. * @returns "SpriteManager"
  105129. */
  105130. getClassName(): string;
  105131. private _makePacked;
  105132. private _checkTextureAlpha;
  105133. /**
  105134. * Intersects the sprites with a ray
  105135. * @param ray defines the ray to intersect with
  105136. * @param camera defines the current active camera
  105137. * @param predicate defines a predicate used to select candidate sprites
  105138. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  105139. * @returns null if no hit or a PickingInfo
  105140. */
  105141. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  105142. /**
  105143. * Intersects the sprites with a ray
  105144. * @param ray defines the ray to intersect with
  105145. * @param camera defines the current active camera
  105146. * @param predicate defines a predicate used to select candidate sprites
  105147. * @returns null if no hit or a PickingInfo array
  105148. */
  105149. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  105150. /**
  105151. * Render all child sprites
  105152. */
  105153. render(): void;
  105154. private _customUpdate;
  105155. /**
  105156. * Release associated resources
  105157. */
  105158. dispose(): void;
  105159. /**
  105160. * Serializes the sprite manager to a JSON object
  105161. * @param serializeTexture defines if the texture must be serialized as well
  105162. * @returns the JSON object
  105163. */
  105164. serialize(serializeTexture?: boolean): any;
  105165. /**
  105166. * Parses a JSON object to create a new sprite manager.
  105167. * @param parsedManager The JSON object to parse
  105168. * @param scene The scene to create the sprite managerin
  105169. * @param rootUrl The root url to use to load external dependencies like texture
  105170. * @returns the new sprite manager
  105171. */
  105172. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  105173. /**
  105174. * Creates a sprite manager from a snippet saved in a remote file
  105175. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  105176. * @param url defines the url to load from
  105177. * @param scene defines the hosting scene
  105178. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105179. * @returns a promise that will resolve to the new sprite manager
  105180. */
  105181. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105182. /**
  105183. * Creates a sprite manager from a snippet saved by the sprite editor
  105184. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  105185. * @param scene defines the hosting scene
  105186. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105187. * @returns a promise that will resolve to the new sprite manager
  105188. */
  105189. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  105190. }
  105191. }
  105192. declare module BABYLON {
  105193. /**
  105194. * Class used to represent a sprite
  105195. * @see https://doc.babylonjs.com/babylon101/sprites
  105196. */
  105197. export class Sprite extends ThinSprite implements IAnimatable {
  105198. /** defines the name */
  105199. name: string;
  105200. /** Gets or sets the current world position */
  105201. position: Vector3;
  105202. /** Gets or sets the main color */
  105203. color: Color4;
  105204. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  105205. disposeWhenFinishedAnimating: boolean;
  105206. /** Gets the list of attached animations */
  105207. animations: Nullable<Array<Animation>>;
  105208. /** Gets or sets a boolean indicating if the sprite can be picked */
  105209. isPickable: boolean;
  105210. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  105211. useAlphaForPicking: boolean;
  105212. /**
  105213. * Gets or sets the associated action manager
  105214. */
  105215. actionManager: Nullable<ActionManager>;
  105216. /**
  105217. * An event triggered when the control has been disposed
  105218. */
  105219. onDisposeObservable: Observable<Sprite>;
  105220. private _manager;
  105221. private _onAnimationEnd;
  105222. /**
  105223. * Gets or sets the sprite size
  105224. */
  105225. get size(): number;
  105226. set size(value: number);
  105227. /**
  105228. * Gets or sets the unique id of the sprite
  105229. */
  105230. uniqueId: number;
  105231. /**
  105232. * Gets the manager of this sprite
  105233. */
  105234. get manager(): ISpriteManager;
  105235. /**
  105236. * Creates a new Sprite
  105237. * @param name defines the name
  105238. * @param manager defines the manager
  105239. */
  105240. constructor(
  105241. /** defines the name */
  105242. name: string, manager: ISpriteManager);
  105243. /**
  105244. * Returns the string "Sprite"
  105245. * @returns "Sprite"
  105246. */
  105247. getClassName(): string;
  105248. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  105249. get fromIndex(): number;
  105250. set fromIndex(value: number);
  105251. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  105252. get toIndex(): number;
  105253. set toIndex(value: number);
  105254. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  105255. get loopAnimation(): boolean;
  105256. set loopAnimation(value: boolean);
  105257. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  105258. get delay(): number;
  105259. set delay(value: number);
  105260. /**
  105261. * Starts an animation
  105262. * @param from defines the initial key
  105263. * @param to defines the end key
  105264. * @param loop defines if the animation must loop
  105265. * @param delay defines the start delay (in ms)
  105266. * @param onAnimationEnd defines a callback to call when animation ends
  105267. */
  105268. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  105269. private _endAnimation;
  105270. /** Release associated resources */
  105271. dispose(): void;
  105272. /**
  105273. * Serializes the sprite to a JSON object
  105274. * @returns the JSON object
  105275. */
  105276. serialize(): any;
  105277. /**
  105278. * Parses a JSON object to create a new sprite
  105279. * @param parsedSprite The JSON object to parse
  105280. * @param manager defines the hosting manager
  105281. * @returns the new sprite
  105282. */
  105283. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  105284. }
  105285. }
  105286. declare module BABYLON {
  105287. /**
  105288. * Information about the result of picking within a scene
  105289. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  105290. */
  105291. export class PickingInfo {
  105292. /** @hidden */
  105293. _pickingUnavailable: boolean;
  105294. /**
  105295. * If the pick collided with an object
  105296. */
  105297. hit: boolean;
  105298. /**
  105299. * Distance away where the pick collided
  105300. */
  105301. distance: number;
  105302. /**
  105303. * The location of pick collision
  105304. */
  105305. pickedPoint: Nullable<Vector3>;
  105306. /**
  105307. * The mesh corresponding the the pick collision
  105308. */
  105309. pickedMesh: Nullable<AbstractMesh>;
  105310. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  105311. bu: number;
  105312. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  105313. bv: number;
  105314. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105315. faceId: number;
  105316. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  105317. subMeshFaceId: number;
  105318. /** Id of the the submesh that was picked */
  105319. subMeshId: number;
  105320. /** If a sprite was picked, this will be the sprite the pick collided with */
  105321. pickedSprite: Nullable<Sprite>;
  105322. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  105323. thinInstanceIndex: number;
  105324. /**
  105325. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  105326. */
  105327. originMesh: Nullable<AbstractMesh>;
  105328. /**
  105329. * The ray that was used to perform the picking.
  105330. */
  105331. ray: Nullable<Ray>;
  105332. /**
  105333. * Gets the normal correspodning to the face the pick collided with
  105334. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  105335. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  105336. * @returns The normal correspodning to the face the pick collided with
  105337. */
  105338. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  105339. /**
  105340. * Gets the texture coordinates of where the pick occured
  105341. * @returns the vector containing the coordnates of the texture
  105342. */
  105343. getTextureCoordinates(): Nullable<Vector2>;
  105344. }
  105345. }
  105346. declare module BABYLON {
  105347. /**
  105348. * Gather the list of pointer event types as constants.
  105349. */
  105350. export class PointerEventTypes {
  105351. /**
  105352. * 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.
  105353. */
  105354. static readonly POINTERDOWN: number;
  105355. /**
  105356. * The pointerup event is fired when a pointer is no longer active.
  105357. */
  105358. static readonly POINTERUP: number;
  105359. /**
  105360. * The pointermove event is fired when a pointer changes coordinates.
  105361. */
  105362. static readonly POINTERMOVE: number;
  105363. /**
  105364. * The pointerwheel event is fired when a mouse wheel has been rotated.
  105365. */
  105366. static readonly POINTERWHEEL: number;
  105367. /**
  105368. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  105369. */
  105370. static readonly POINTERPICK: number;
  105371. /**
  105372. * The pointertap event is fired when a the object has been touched and released without drag.
  105373. */
  105374. static readonly POINTERTAP: number;
  105375. /**
  105376. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  105377. */
  105378. static readonly POINTERDOUBLETAP: number;
  105379. }
  105380. /**
  105381. * Base class of pointer info types.
  105382. */
  105383. export class PointerInfoBase {
  105384. /**
  105385. * Defines the type of event (PointerEventTypes)
  105386. */
  105387. type: number;
  105388. /**
  105389. * Defines the related dom event
  105390. */
  105391. event: PointerEvent | MouseWheelEvent;
  105392. /**
  105393. * Instantiates the base class of pointers info.
  105394. * @param type Defines the type of event (PointerEventTypes)
  105395. * @param event Defines the related dom event
  105396. */
  105397. constructor(
  105398. /**
  105399. * Defines the type of event (PointerEventTypes)
  105400. */
  105401. type: number,
  105402. /**
  105403. * Defines the related dom event
  105404. */
  105405. event: PointerEvent | MouseWheelEvent);
  105406. }
  105407. /**
  105408. * This class is used to store pointer related info for the onPrePointerObservable event.
  105409. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  105410. */
  105411. export class PointerInfoPre extends PointerInfoBase {
  105412. /**
  105413. * Ray from a pointer if availible (eg. 6dof controller)
  105414. */
  105415. ray: Nullable<Ray>;
  105416. /**
  105417. * Defines the local position of the pointer on the canvas.
  105418. */
  105419. localPosition: Vector2;
  105420. /**
  105421. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  105422. */
  105423. skipOnPointerObservable: boolean;
  105424. /**
  105425. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  105426. * @param type Defines the type of event (PointerEventTypes)
  105427. * @param event Defines the related dom event
  105428. * @param localX Defines the local x coordinates of the pointer when the event occured
  105429. * @param localY Defines the local y coordinates of the pointer when the event occured
  105430. */
  105431. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  105432. }
  105433. /**
  105434. * This type contains all the data related to a pointer event in Babylon.js.
  105435. * 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.
  105436. */
  105437. export class PointerInfo extends PointerInfoBase {
  105438. /**
  105439. * Defines the picking info associated to the info (if any)\
  105440. */
  105441. pickInfo: Nullable<PickingInfo>;
  105442. /**
  105443. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  105444. * @param type Defines the type of event (PointerEventTypes)
  105445. * @param event Defines the related dom event
  105446. * @param pickInfo Defines the picking info associated to the info (if any)\
  105447. */
  105448. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  105449. /**
  105450. * Defines the picking info associated to the info (if any)\
  105451. */
  105452. pickInfo: Nullable<PickingInfo>);
  105453. }
  105454. /**
  105455. * Data relating to a touch event on the screen.
  105456. */
  105457. export interface PointerTouch {
  105458. /**
  105459. * X coordinate of touch.
  105460. */
  105461. x: number;
  105462. /**
  105463. * Y coordinate of touch.
  105464. */
  105465. y: number;
  105466. /**
  105467. * Id of touch. Unique for each finger.
  105468. */
  105469. pointerId: number;
  105470. /**
  105471. * Event type passed from DOM.
  105472. */
  105473. type: any;
  105474. }
  105475. }
  105476. declare module BABYLON {
  105477. /**
  105478. * Manage the mouse inputs to control the movement of a free camera.
  105479. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105480. */
  105481. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  105482. /**
  105483. * Define if touch is enabled in the mouse input
  105484. */
  105485. touchEnabled: boolean;
  105486. /**
  105487. * Defines the camera the input is attached to.
  105488. */
  105489. camera: FreeCamera;
  105490. /**
  105491. * Defines the buttons associated with the input to handle camera move.
  105492. */
  105493. buttons: number[];
  105494. /**
  105495. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  105496. */
  105497. angularSensibility: number;
  105498. private _pointerInput;
  105499. private _onMouseMove;
  105500. private _observer;
  105501. private previousPosition;
  105502. /**
  105503. * Observable for when a pointer move event occurs containing the move offset
  105504. */
  105505. onPointerMovedObservable: Observable<{
  105506. offsetX: number;
  105507. offsetY: number;
  105508. }>;
  105509. /**
  105510. * @hidden
  105511. * If the camera should be rotated automatically based on pointer movement
  105512. */
  105513. _allowCameraRotation: boolean;
  105514. /**
  105515. * Manage the mouse inputs to control the movement of a free camera.
  105516. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105517. * @param touchEnabled Defines if touch is enabled or not
  105518. */
  105519. constructor(
  105520. /**
  105521. * Define if touch is enabled in the mouse input
  105522. */
  105523. touchEnabled?: boolean);
  105524. /**
  105525. * Attach the input controls to a specific dom element to get the input from.
  105526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105527. */
  105528. attachControl(noPreventDefault?: boolean): void;
  105529. /**
  105530. * Called on JS contextmenu event.
  105531. * Override this method to provide functionality.
  105532. */
  105533. protected onContextMenu(evt: PointerEvent): void;
  105534. /**
  105535. * Detach the current controls from the specified dom element.
  105536. */
  105537. detachControl(): void;
  105538. /**
  105539. * Gets the class name of the current intput.
  105540. * @returns the class name
  105541. */
  105542. getClassName(): string;
  105543. /**
  105544. * Get the friendly name associated with the input class.
  105545. * @returns the input friendly name
  105546. */
  105547. getSimpleName(): string;
  105548. }
  105549. }
  105550. declare module BABYLON {
  105551. /**
  105552. * Base class for mouse wheel input..
  105553. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  105554. * for example usage.
  105555. */
  105556. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  105557. /**
  105558. * Defines the camera the input is attached to.
  105559. */
  105560. abstract camera: Camera;
  105561. /**
  105562. * How fast is the camera moves in relation to X axis mouseWheel events.
  105563. * Use negative value to reverse direction.
  105564. */
  105565. wheelPrecisionX: number;
  105566. /**
  105567. * How fast is the camera moves in relation to Y axis mouseWheel events.
  105568. * Use negative value to reverse direction.
  105569. */
  105570. wheelPrecisionY: number;
  105571. /**
  105572. * How fast is the camera moves in relation to Z axis mouseWheel events.
  105573. * Use negative value to reverse direction.
  105574. */
  105575. wheelPrecisionZ: number;
  105576. /**
  105577. * Observable for when a mouse wheel move event occurs.
  105578. */
  105579. onChangedObservable: Observable<{
  105580. wheelDeltaX: number;
  105581. wheelDeltaY: number;
  105582. wheelDeltaZ: number;
  105583. }>;
  105584. private _wheel;
  105585. private _observer;
  105586. /**
  105587. * Attach the input controls to a specific dom element to get the input from.
  105588. * @param noPreventDefault Defines whether event caught by the controls
  105589. * should call preventdefault().
  105590. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105591. */
  105592. attachControl(noPreventDefault?: boolean): void;
  105593. /**
  105594. * Detach the current controls from the specified dom element.
  105595. */
  105596. detachControl(): void;
  105597. /**
  105598. * Called for each rendered frame.
  105599. */
  105600. checkInputs(): void;
  105601. /**
  105602. * Gets the class name of the current intput.
  105603. * @returns the class name
  105604. */
  105605. getClassName(): string;
  105606. /**
  105607. * Get the friendly name associated with the input class.
  105608. * @returns the input friendly name
  105609. */
  105610. getSimpleName(): string;
  105611. /**
  105612. * Incremental value of multiple mouse wheel movements of the X axis.
  105613. * Should be zero-ed when read.
  105614. */
  105615. protected _wheelDeltaX: number;
  105616. /**
  105617. * Incremental value of multiple mouse wheel movements of the Y axis.
  105618. * Should be zero-ed when read.
  105619. */
  105620. protected _wheelDeltaY: number;
  105621. /**
  105622. * Incremental value of multiple mouse wheel movements of the Z axis.
  105623. * Should be zero-ed when read.
  105624. */
  105625. protected _wheelDeltaZ: number;
  105626. /**
  105627. * Firefox uses a different scheme to report scroll distances to other
  105628. * browsers. Rather than use complicated methods to calculate the exact
  105629. * multiple we need to apply, let's just cheat and use a constant.
  105630. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  105631. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  105632. */
  105633. private readonly _ffMultiplier;
  105634. /**
  105635. * Different event attributes for wheel data fall into a few set ranges.
  105636. * Some relevant but dated date here:
  105637. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  105638. */
  105639. private readonly _normalize;
  105640. }
  105641. }
  105642. declare module BABYLON {
  105643. /**
  105644. * Manage the mouse wheel inputs to control a free camera.
  105645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105646. */
  105647. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  105648. /**
  105649. * Defines the camera the input is attached to.
  105650. */
  105651. camera: FreeCamera;
  105652. /**
  105653. * Gets the class name of the current input.
  105654. * @returns the class name
  105655. */
  105656. getClassName(): string;
  105657. /**
  105658. * Set which movement axis (relative to camera's orientation) the mouse
  105659. * wheel's X axis controls.
  105660. * @param axis The axis to be moved. Set null to clear.
  105661. */
  105662. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  105663. /**
  105664. * Get the configured movement axis (relative to camera's orientation) the
  105665. * mouse wheel's X axis controls.
  105666. * @returns The configured axis or null if none.
  105667. */
  105668. get wheelXMoveRelative(): Nullable<Coordinate>;
  105669. /**
  105670. * Set which movement axis (relative to camera's orientation) the mouse
  105671. * wheel's Y axis controls.
  105672. * @param axis The axis to be moved. Set null to clear.
  105673. */
  105674. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  105675. /**
  105676. * Get the configured movement axis (relative to camera's orientation) the
  105677. * mouse wheel's Y axis controls.
  105678. * @returns The configured axis or null if none.
  105679. */
  105680. get wheelYMoveRelative(): Nullable<Coordinate>;
  105681. /**
  105682. * Set which movement axis (relative to camera's orientation) the mouse
  105683. * wheel's Z axis controls.
  105684. * @param axis The axis to be moved. Set null to clear.
  105685. */
  105686. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  105687. /**
  105688. * Get the configured movement axis (relative to camera's orientation) the
  105689. * mouse wheel's Z axis controls.
  105690. * @returns The configured axis or null if none.
  105691. */
  105692. get wheelZMoveRelative(): Nullable<Coordinate>;
  105693. /**
  105694. * Set which rotation axis (relative to camera's orientation) the mouse
  105695. * wheel's X axis controls.
  105696. * @param axis The axis to be moved. Set null to clear.
  105697. */
  105698. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  105699. /**
  105700. * Get the configured rotation axis (relative to camera's orientation) the
  105701. * mouse wheel's X axis controls.
  105702. * @returns The configured axis or null if none.
  105703. */
  105704. get wheelXRotateRelative(): Nullable<Coordinate>;
  105705. /**
  105706. * Set which rotation axis (relative to camera's orientation) the mouse
  105707. * wheel's Y axis controls.
  105708. * @param axis The axis to be moved. Set null to clear.
  105709. */
  105710. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  105711. /**
  105712. * Get the configured rotation axis (relative to camera's orientation) the
  105713. * mouse wheel's Y axis controls.
  105714. * @returns The configured axis or null if none.
  105715. */
  105716. get wheelYRotateRelative(): Nullable<Coordinate>;
  105717. /**
  105718. * Set which rotation axis (relative to camera's orientation) the mouse
  105719. * wheel's Z axis controls.
  105720. * @param axis The axis to be moved. Set null to clear.
  105721. */
  105722. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  105723. /**
  105724. * Get the configured rotation axis (relative to camera's orientation) the
  105725. * mouse wheel's Z axis controls.
  105726. * @returns The configured axis or null if none.
  105727. */
  105728. get wheelZRotateRelative(): Nullable<Coordinate>;
  105729. /**
  105730. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  105731. * controls.
  105732. * @param axis The axis to be moved. Set null to clear.
  105733. */
  105734. set wheelXMoveScene(axis: Nullable<Coordinate>);
  105735. /**
  105736. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105737. * X axis controls.
  105738. * @returns The configured axis or null if none.
  105739. */
  105740. get wheelXMoveScene(): Nullable<Coordinate>;
  105741. /**
  105742. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  105743. * controls.
  105744. * @param axis The axis to be moved. Set null to clear.
  105745. */
  105746. set wheelYMoveScene(axis: Nullable<Coordinate>);
  105747. /**
  105748. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105749. * Y axis controls.
  105750. * @returns The configured axis or null if none.
  105751. */
  105752. get wheelYMoveScene(): Nullable<Coordinate>;
  105753. /**
  105754. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  105755. * controls.
  105756. * @param axis The axis to be moved. Set null to clear.
  105757. */
  105758. set wheelZMoveScene(axis: Nullable<Coordinate>);
  105759. /**
  105760. * Get the configured movement axis (relative to the scene) the mouse wheel's
  105761. * Z axis controls.
  105762. * @returns The configured axis or null if none.
  105763. */
  105764. get wheelZMoveScene(): Nullable<Coordinate>;
  105765. /**
  105766. * Called for each rendered frame.
  105767. */
  105768. checkInputs(): void;
  105769. private _moveRelative;
  105770. private _rotateRelative;
  105771. private _moveScene;
  105772. /**
  105773. * These are set to the desired default behaviour.
  105774. */
  105775. private _wheelXAction;
  105776. private _wheelXActionCoordinate;
  105777. private _wheelYAction;
  105778. private _wheelYActionCoordinate;
  105779. private _wheelZAction;
  105780. private _wheelZActionCoordinate;
  105781. /**
  105782. * Update the camera according to any configured properties for the 3
  105783. * mouse-wheel axis.
  105784. */
  105785. private _updateCamera;
  105786. }
  105787. }
  105788. declare module BABYLON {
  105789. /**
  105790. * Manage the touch inputs to control the movement of a free camera.
  105791. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105792. */
  105793. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  105794. /**
  105795. * Define if mouse events can be treated as touch events
  105796. */
  105797. allowMouse: boolean;
  105798. /**
  105799. * Defines the camera the input is attached to.
  105800. */
  105801. camera: FreeCamera;
  105802. /**
  105803. * Defines the touch sensibility for rotation.
  105804. * The higher the faster.
  105805. */
  105806. touchAngularSensibility: number;
  105807. /**
  105808. * Defines the touch sensibility for move.
  105809. * The higher the faster.
  105810. */
  105811. touchMoveSensibility: number;
  105812. private _offsetX;
  105813. private _offsetY;
  105814. private _pointerPressed;
  105815. private _pointerInput?;
  105816. private _observer;
  105817. private _onLostFocus;
  105818. /**
  105819. * Manage the touch inputs to control the movement of a free camera.
  105820. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105821. * @param allowMouse Defines if mouse events can be treated as touch events
  105822. */
  105823. constructor(
  105824. /**
  105825. * Define if mouse events can be treated as touch events
  105826. */
  105827. allowMouse?: boolean);
  105828. /**
  105829. * Attach the input controls to a specific dom element to get the input from.
  105830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105831. */
  105832. attachControl(noPreventDefault?: boolean): void;
  105833. /**
  105834. * Detach the current controls from the specified dom element.
  105835. */
  105836. detachControl(): void;
  105837. /**
  105838. * Update the current camera state depending on the inputs that have been used this frame.
  105839. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105840. */
  105841. checkInputs(): void;
  105842. /**
  105843. * Gets the class name of the current intput.
  105844. * @returns the class name
  105845. */
  105846. getClassName(): string;
  105847. /**
  105848. * Get the friendly name associated with the input class.
  105849. * @returns the input friendly name
  105850. */
  105851. getSimpleName(): string;
  105852. }
  105853. }
  105854. declare module BABYLON {
  105855. /**
  105856. * Default Inputs manager for the FreeCamera.
  105857. * It groups all the default supported inputs for ease of use.
  105858. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  105859. */
  105860. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  105861. /**
  105862. * @hidden
  105863. */
  105864. _mouseInput: Nullable<FreeCameraMouseInput>;
  105865. /**
  105866. * @hidden
  105867. */
  105868. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  105869. /**
  105870. * Instantiates a new FreeCameraInputsManager.
  105871. * @param camera Defines the camera the inputs belong to
  105872. */
  105873. constructor(camera: FreeCamera);
  105874. /**
  105875. * Add keyboard input support to the input manager.
  105876. * @returns the current input manager
  105877. */
  105878. addKeyboard(): FreeCameraInputsManager;
  105879. /**
  105880. * Add mouse input support to the input manager.
  105881. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  105882. * @returns the current input manager
  105883. */
  105884. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  105885. /**
  105886. * Removes the mouse input support from the manager
  105887. * @returns the current input manager
  105888. */
  105889. removeMouse(): FreeCameraInputsManager;
  105890. /**
  105891. * Add mouse wheel input support to the input manager.
  105892. * @returns the current input manager
  105893. */
  105894. addMouseWheel(): FreeCameraInputsManager;
  105895. /**
  105896. * Removes the mouse wheel input support from the manager
  105897. * @returns the current input manager
  105898. */
  105899. removeMouseWheel(): FreeCameraInputsManager;
  105900. /**
  105901. * Add touch input support to the input manager.
  105902. * @returns the current input manager
  105903. */
  105904. addTouch(): FreeCameraInputsManager;
  105905. /**
  105906. * Remove all attached input methods from a camera
  105907. */
  105908. clear(): void;
  105909. }
  105910. }
  105911. declare module BABYLON {
  105912. /**
  105913. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105914. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  105915. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  105916. */
  105917. export class FreeCamera extends TargetCamera {
  105918. /**
  105919. * Define the collision ellipsoid of the camera.
  105920. * This is helpful to simulate a camera body like the player body around the camera
  105921. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  105922. */
  105923. ellipsoid: Vector3;
  105924. /**
  105925. * Define an offset for the position of the ellipsoid around the camera.
  105926. * This can be helpful to determine the center of the body near the gravity center of the body
  105927. * instead of its head.
  105928. */
  105929. ellipsoidOffset: Vector3;
  105930. /**
  105931. * Enable or disable collisions of the camera with the rest of the scene objects.
  105932. */
  105933. checkCollisions: boolean;
  105934. /**
  105935. * Enable or disable gravity on the camera.
  105936. */
  105937. applyGravity: boolean;
  105938. /**
  105939. * Define the input manager associated to the camera.
  105940. */
  105941. inputs: FreeCameraInputsManager;
  105942. /**
  105943. * Gets the input sensibility for a mouse input. (default is 2000.0)
  105944. * Higher values reduce sensitivity.
  105945. */
  105946. get angularSensibility(): number;
  105947. /**
  105948. * Sets the input sensibility for a mouse input. (default is 2000.0)
  105949. * Higher values reduce sensitivity.
  105950. */
  105951. set angularSensibility(value: number);
  105952. /**
  105953. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  105954. */
  105955. get keysUp(): number[];
  105956. set keysUp(value: number[]);
  105957. /**
  105958. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  105959. */
  105960. get keysUpward(): number[];
  105961. set keysUpward(value: number[]);
  105962. /**
  105963. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  105964. */
  105965. get keysDown(): number[];
  105966. set keysDown(value: number[]);
  105967. /**
  105968. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  105969. */
  105970. get keysDownward(): number[];
  105971. set keysDownward(value: number[]);
  105972. /**
  105973. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  105974. */
  105975. get keysLeft(): number[];
  105976. set keysLeft(value: number[]);
  105977. /**
  105978. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  105979. */
  105980. get keysRight(): number[];
  105981. set keysRight(value: number[]);
  105982. /**
  105983. * Event raised when the camera collide with a mesh in the scene.
  105984. */
  105985. onCollide: (collidedMesh: AbstractMesh) => void;
  105986. private _collider;
  105987. private _needMoveForGravity;
  105988. private _oldPosition;
  105989. private _diffPosition;
  105990. private _newPosition;
  105991. /** @hidden */
  105992. _localDirection: Vector3;
  105993. /** @hidden */
  105994. _transformedDirection: Vector3;
  105995. /**
  105996. * Instantiates a Free Camera.
  105997. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105998. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  105999. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  106000. * @param name Define the name of the camera in the scene
  106001. * @param position Define the start position of the camera in the scene
  106002. * @param scene Define the scene the camera belongs to
  106003. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  106004. */
  106005. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  106006. /**
  106007. * Attach the input controls to a specific dom element to get the input from.
  106008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106009. */
  106010. attachControl(noPreventDefault?: boolean): void;
  106011. /**
  106012. * Attach the input controls to a specific dom element to get the input from.
  106013. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  106014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  106015. * BACK COMPAT SIGNATURE ONLY.
  106016. */
  106017. attachControl(ignored: any, noPreventDefault?: boolean): void;
  106018. /**
  106019. * Detach the current controls from the specified dom element.
  106020. */
  106021. detachControl(): void;
  106022. /**
  106023. * Detach the current controls from the specified dom element.
  106024. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  106025. */
  106026. detachControl(ignored: any): void;
  106027. private _collisionMask;
  106028. /**
  106029. * Define a collision mask to limit the list of object the camera can collide with
  106030. */
  106031. get collisionMask(): number;
  106032. set collisionMask(mask: number);
  106033. /** @hidden */
  106034. _collideWithWorld(displacement: Vector3): void;
  106035. private _onCollisionPositionChange;
  106036. /** @hidden */
  106037. _checkInputs(): void;
  106038. /** @hidden */
  106039. _decideIfNeedsToMove(): boolean;
  106040. /** @hidden */
  106041. _updatePosition(): void;
  106042. /**
  106043. * Destroy the camera and release the current resources hold by it.
  106044. */
  106045. dispose(): void;
  106046. /**
  106047. * Gets the current object class name.
  106048. * @return the class name
  106049. */
  106050. getClassName(): string;
  106051. }
  106052. }
  106053. declare module BABYLON {
  106054. /**
  106055. * Represents a gamepad control stick position
  106056. */
  106057. export class StickValues {
  106058. /**
  106059. * The x component of the control stick
  106060. */
  106061. x: number;
  106062. /**
  106063. * The y component of the control stick
  106064. */
  106065. y: number;
  106066. /**
  106067. * Initializes the gamepad x and y control stick values
  106068. * @param x The x component of the gamepad control stick value
  106069. * @param y The y component of the gamepad control stick value
  106070. */
  106071. constructor(
  106072. /**
  106073. * The x component of the control stick
  106074. */
  106075. x: number,
  106076. /**
  106077. * The y component of the control stick
  106078. */
  106079. y: number);
  106080. }
  106081. /**
  106082. * An interface which manages callbacks for gamepad button changes
  106083. */
  106084. export interface GamepadButtonChanges {
  106085. /**
  106086. * Called when a gamepad has been changed
  106087. */
  106088. changed: boolean;
  106089. /**
  106090. * Called when a gamepad press event has been triggered
  106091. */
  106092. pressChanged: boolean;
  106093. /**
  106094. * Called when a touch event has been triggered
  106095. */
  106096. touchChanged: boolean;
  106097. /**
  106098. * Called when a value has changed
  106099. */
  106100. valueChanged: boolean;
  106101. }
  106102. /**
  106103. * Represents a gamepad
  106104. */
  106105. export class Gamepad {
  106106. /**
  106107. * The id of the gamepad
  106108. */
  106109. id: string;
  106110. /**
  106111. * The index of the gamepad
  106112. */
  106113. index: number;
  106114. /**
  106115. * The browser gamepad
  106116. */
  106117. browserGamepad: any;
  106118. /**
  106119. * Specifies what type of gamepad this represents
  106120. */
  106121. type: number;
  106122. private _leftStick;
  106123. private _rightStick;
  106124. /** @hidden */
  106125. _isConnected: boolean;
  106126. private _leftStickAxisX;
  106127. private _leftStickAxisY;
  106128. private _rightStickAxisX;
  106129. private _rightStickAxisY;
  106130. /**
  106131. * Triggered when the left control stick has been changed
  106132. */
  106133. private _onleftstickchanged;
  106134. /**
  106135. * Triggered when the right control stick has been changed
  106136. */
  106137. private _onrightstickchanged;
  106138. /**
  106139. * Represents a gamepad controller
  106140. */
  106141. static GAMEPAD: number;
  106142. /**
  106143. * Represents a generic controller
  106144. */
  106145. static GENERIC: number;
  106146. /**
  106147. * Represents an XBox controller
  106148. */
  106149. static XBOX: number;
  106150. /**
  106151. * Represents a pose-enabled controller
  106152. */
  106153. static POSE_ENABLED: number;
  106154. /**
  106155. * Represents an Dual Shock controller
  106156. */
  106157. static DUALSHOCK: number;
  106158. /**
  106159. * Specifies whether the left control stick should be Y-inverted
  106160. */
  106161. protected _invertLeftStickY: boolean;
  106162. /**
  106163. * Specifies if the gamepad has been connected
  106164. */
  106165. get isConnected(): boolean;
  106166. /**
  106167. * Initializes the gamepad
  106168. * @param id The id of the gamepad
  106169. * @param index The index of the gamepad
  106170. * @param browserGamepad The browser gamepad
  106171. * @param leftStickX The x component of the left joystick
  106172. * @param leftStickY The y component of the left joystick
  106173. * @param rightStickX The x component of the right joystick
  106174. * @param rightStickY The y component of the right joystick
  106175. */
  106176. constructor(
  106177. /**
  106178. * The id of the gamepad
  106179. */
  106180. id: string,
  106181. /**
  106182. * The index of the gamepad
  106183. */
  106184. index: number,
  106185. /**
  106186. * The browser gamepad
  106187. */
  106188. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  106189. /**
  106190. * Callback triggered when the left joystick has changed
  106191. * @param callback
  106192. */
  106193. onleftstickchanged(callback: (values: StickValues) => void): void;
  106194. /**
  106195. * Callback triggered when the right joystick has changed
  106196. * @param callback
  106197. */
  106198. onrightstickchanged(callback: (values: StickValues) => void): void;
  106199. /**
  106200. * Gets the left joystick
  106201. */
  106202. get leftStick(): StickValues;
  106203. /**
  106204. * Sets the left joystick values
  106205. */
  106206. set leftStick(newValues: StickValues);
  106207. /**
  106208. * Gets the right joystick
  106209. */
  106210. get rightStick(): StickValues;
  106211. /**
  106212. * Sets the right joystick value
  106213. */
  106214. set rightStick(newValues: StickValues);
  106215. /**
  106216. * Updates the gamepad joystick positions
  106217. */
  106218. update(): void;
  106219. /**
  106220. * Disposes the gamepad
  106221. */
  106222. dispose(): void;
  106223. }
  106224. /**
  106225. * Represents a generic gamepad
  106226. */
  106227. export class GenericPad extends Gamepad {
  106228. private _buttons;
  106229. private _onbuttondown;
  106230. private _onbuttonup;
  106231. /**
  106232. * Observable triggered when a button has been pressed
  106233. */
  106234. onButtonDownObservable: Observable<number>;
  106235. /**
  106236. * Observable triggered when a button has been released
  106237. */
  106238. onButtonUpObservable: Observable<number>;
  106239. /**
  106240. * Callback triggered when a button has been pressed
  106241. * @param callback Called when a button has been pressed
  106242. */
  106243. onbuttondown(callback: (buttonPressed: number) => void): void;
  106244. /**
  106245. * Callback triggered when a button has been released
  106246. * @param callback Called when a button has been released
  106247. */
  106248. onbuttonup(callback: (buttonReleased: number) => void): void;
  106249. /**
  106250. * Initializes the generic gamepad
  106251. * @param id The id of the generic gamepad
  106252. * @param index The index of the generic gamepad
  106253. * @param browserGamepad The browser gamepad
  106254. */
  106255. constructor(id: string, index: number, browserGamepad: any);
  106256. private _setButtonValue;
  106257. /**
  106258. * Updates the generic gamepad
  106259. */
  106260. update(): void;
  106261. /**
  106262. * Disposes the generic gamepad
  106263. */
  106264. dispose(): void;
  106265. }
  106266. }
  106267. declare module BABYLON {
  106268. /**
  106269. * Defines a runtime animation
  106270. */
  106271. export class RuntimeAnimation {
  106272. private _events;
  106273. /**
  106274. * The current frame of the runtime animation
  106275. */
  106276. private _currentFrame;
  106277. /**
  106278. * The animation used by the runtime animation
  106279. */
  106280. private _animation;
  106281. /**
  106282. * The target of the runtime animation
  106283. */
  106284. private _target;
  106285. /**
  106286. * The initiating animatable
  106287. */
  106288. private _host;
  106289. /**
  106290. * The original value of the runtime animation
  106291. */
  106292. private _originalValue;
  106293. /**
  106294. * The original blend value of the runtime animation
  106295. */
  106296. private _originalBlendValue;
  106297. /**
  106298. * The offsets cache of the runtime animation
  106299. */
  106300. private _offsetsCache;
  106301. /**
  106302. * The high limits cache of the runtime animation
  106303. */
  106304. private _highLimitsCache;
  106305. /**
  106306. * Specifies if the runtime animation has been stopped
  106307. */
  106308. private _stopped;
  106309. /**
  106310. * The blending factor of the runtime animation
  106311. */
  106312. private _blendingFactor;
  106313. /**
  106314. * The BabylonJS scene
  106315. */
  106316. private _scene;
  106317. /**
  106318. * The current value of the runtime animation
  106319. */
  106320. private _currentValue;
  106321. /** @hidden */
  106322. _animationState: _IAnimationState;
  106323. /**
  106324. * The active target of the runtime animation
  106325. */
  106326. private _activeTargets;
  106327. private _currentActiveTarget;
  106328. private _directTarget;
  106329. /**
  106330. * The target path of the runtime animation
  106331. */
  106332. private _targetPath;
  106333. /**
  106334. * The weight of the runtime animation
  106335. */
  106336. private _weight;
  106337. /**
  106338. * The ratio offset of the runtime animation
  106339. */
  106340. private _ratioOffset;
  106341. /**
  106342. * The previous delay of the runtime animation
  106343. */
  106344. private _previousDelay;
  106345. /**
  106346. * The previous ratio of the runtime animation
  106347. */
  106348. private _previousRatio;
  106349. private _enableBlending;
  106350. private _keys;
  106351. private _minFrame;
  106352. private _maxFrame;
  106353. private _minValue;
  106354. private _maxValue;
  106355. private _targetIsArray;
  106356. /**
  106357. * Gets the current frame of the runtime animation
  106358. */
  106359. get currentFrame(): number;
  106360. /**
  106361. * Gets the weight of the runtime animation
  106362. */
  106363. get weight(): number;
  106364. /**
  106365. * Gets the current value of the runtime animation
  106366. */
  106367. get currentValue(): any;
  106368. /**
  106369. * Gets the target path of the runtime animation
  106370. */
  106371. get targetPath(): string;
  106372. /**
  106373. * Gets the actual target of the runtime animation
  106374. */
  106375. get target(): any;
  106376. /**
  106377. * Gets the additive state of the runtime animation
  106378. */
  106379. get isAdditive(): boolean;
  106380. /** @hidden */
  106381. _onLoop: () => void;
  106382. /**
  106383. * Create a new RuntimeAnimation object
  106384. * @param target defines the target of the animation
  106385. * @param animation defines the source animation object
  106386. * @param scene defines the hosting scene
  106387. * @param host defines the initiating Animatable
  106388. */
  106389. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  106390. private _preparePath;
  106391. /**
  106392. * Gets the animation from the runtime animation
  106393. */
  106394. get animation(): Animation;
  106395. /**
  106396. * Resets the runtime animation to the beginning
  106397. * @param restoreOriginal defines whether to restore the target property to the original value
  106398. */
  106399. reset(restoreOriginal?: boolean): void;
  106400. /**
  106401. * Specifies if the runtime animation is stopped
  106402. * @returns Boolean specifying if the runtime animation is stopped
  106403. */
  106404. isStopped(): boolean;
  106405. /**
  106406. * Disposes of the runtime animation
  106407. */
  106408. dispose(): void;
  106409. /**
  106410. * Apply the interpolated value to the target
  106411. * @param currentValue defines the value computed by the animation
  106412. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  106413. */
  106414. setValue(currentValue: any, weight: number): void;
  106415. private _getOriginalValues;
  106416. private _setValue;
  106417. /**
  106418. * Gets the loop pmode of the runtime animation
  106419. * @returns Loop Mode
  106420. */
  106421. private _getCorrectLoopMode;
  106422. /**
  106423. * Move the current animation to a given frame
  106424. * @param frame defines the frame to move to
  106425. */
  106426. goToFrame(frame: number): void;
  106427. /**
  106428. * @hidden Internal use only
  106429. */
  106430. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  106431. /**
  106432. * Execute the current animation
  106433. * @param delay defines the delay to add to the current frame
  106434. * @param from defines the lower bound of the animation range
  106435. * @param to defines the upper bound of the animation range
  106436. * @param loop defines if the current animation must loop
  106437. * @param speedRatio defines the current speed ratio
  106438. * @param weight defines the weight of the animation (default is -1 so no weight)
  106439. * @param onLoop optional callback called when animation loops
  106440. * @returns a boolean indicating if the animation is running
  106441. */
  106442. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  106443. }
  106444. }
  106445. declare module BABYLON {
  106446. /**
  106447. * Class used to store an actual running animation
  106448. */
  106449. export class Animatable {
  106450. /** defines the target object */
  106451. target: any;
  106452. /** defines the starting frame number (default is 0) */
  106453. fromFrame: number;
  106454. /** defines the ending frame number (default is 100) */
  106455. toFrame: number;
  106456. /** defines if the animation must loop (default is false) */
  106457. loopAnimation: boolean;
  106458. /** defines a callback to call when animation ends if it is not looping */
  106459. onAnimationEnd?: (() => void) | null | undefined;
  106460. /** defines a callback to call when animation loops */
  106461. onAnimationLoop?: (() => void) | null | undefined;
  106462. /** defines whether the animation should be evaluated additively */
  106463. isAdditive: boolean;
  106464. private _localDelayOffset;
  106465. private _pausedDelay;
  106466. private _runtimeAnimations;
  106467. private _paused;
  106468. private _scene;
  106469. private _speedRatio;
  106470. private _weight;
  106471. private _syncRoot;
  106472. /**
  106473. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  106474. * This will only apply for non looping animation (default is true)
  106475. */
  106476. disposeOnEnd: boolean;
  106477. /**
  106478. * Gets a boolean indicating if the animation has started
  106479. */
  106480. animationStarted: boolean;
  106481. /**
  106482. * Observer raised when the animation ends
  106483. */
  106484. onAnimationEndObservable: Observable<Animatable>;
  106485. /**
  106486. * Observer raised when the animation loops
  106487. */
  106488. onAnimationLoopObservable: Observable<Animatable>;
  106489. /**
  106490. * Gets the root Animatable used to synchronize and normalize animations
  106491. */
  106492. get syncRoot(): Nullable<Animatable>;
  106493. /**
  106494. * Gets the current frame of the first RuntimeAnimation
  106495. * Used to synchronize Animatables
  106496. */
  106497. get masterFrame(): number;
  106498. /**
  106499. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  106500. */
  106501. get weight(): number;
  106502. set weight(value: number);
  106503. /**
  106504. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  106505. */
  106506. get speedRatio(): number;
  106507. set speedRatio(value: number);
  106508. /**
  106509. * Creates a new Animatable
  106510. * @param scene defines the hosting scene
  106511. * @param target defines the target object
  106512. * @param fromFrame defines the starting frame number (default is 0)
  106513. * @param toFrame defines the ending frame number (default is 100)
  106514. * @param loopAnimation defines if the animation must loop (default is false)
  106515. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  106516. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  106517. * @param animations defines a group of animation to add to the new Animatable
  106518. * @param onAnimationLoop defines a callback to call when animation loops
  106519. * @param isAdditive defines whether the animation should be evaluated additively
  106520. */
  106521. constructor(scene: Scene,
  106522. /** defines the target object */
  106523. target: any,
  106524. /** defines the starting frame number (default is 0) */
  106525. fromFrame?: number,
  106526. /** defines the ending frame number (default is 100) */
  106527. toFrame?: number,
  106528. /** defines if the animation must loop (default is false) */
  106529. loopAnimation?: boolean, speedRatio?: number,
  106530. /** defines a callback to call when animation ends if it is not looping */
  106531. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  106532. /** defines a callback to call when animation loops */
  106533. onAnimationLoop?: (() => void) | null | undefined,
  106534. /** defines whether the animation should be evaluated additively */
  106535. isAdditive?: boolean);
  106536. /**
  106537. * Synchronize and normalize current Animatable with a source Animatable
  106538. * This is useful when using animation weights and when animations are not of the same length
  106539. * @param root defines the root Animatable to synchronize with
  106540. * @returns the current Animatable
  106541. */
  106542. syncWith(root: Animatable): Animatable;
  106543. /**
  106544. * Gets the list of runtime animations
  106545. * @returns an array of RuntimeAnimation
  106546. */
  106547. getAnimations(): RuntimeAnimation[];
  106548. /**
  106549. * Adds more animations to the current animatable
  106550. * @param target defines the target of the animations
  106551. * @param animations defines the new animations to add
  106552. */
  106553. appendAnimations(target: any, animations: Animation[]): void;
  106554. /**
  106555. * Gets the source animation for a specific property
  106556. * @param property defines the propertyu to look for
  106557. * @returns null or the source animation for the given property
  106558. */
  106559. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  106560. /**
  106561. * Gets the runtime animation for a specific property
  106562. * @param property defines the propertyu to look for
  106563. * @returns null or the runtime animation for the given property
  106564. */
  106565. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  106566. /**
  106567. * Resets the animatable to its original state
  106568. */
  106569. reset(): void;
  106570. /**
  106571. * Allows the animatable to blend with current running animations
  106572. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106573. * @param blendingSpeed defines the blending speed to use
  106574. */
  106575. enableBlending(blendingSpeed: number): void;
  106576. /**
  106577. * Disable animation blending
  106578. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106579. */
  106580. disableBlending(): void;
  106581. /**
  106582. * Jump directly to a given frame
  106583. * @param frame defines the frame to jump to
  106584. */
  106585. goToFrame(frame: number): void;
  106586. /**
  106587. * Pause the animation
  106588. */
  106589. pause(): void;
  106590. /**
  106591. * Restart the animation
  106592. */
  106593. restart(): void;
  106594. private _raiseOnAnimationEnd;
  106595. /**
  106596. * Stop and delete the current animation
  106597. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  106598. * @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)
  106599. */
  106600. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  106601. /**
  106602. * Wait asynchronously for the animation to end
  106603. * @returns a promise which will be fullfilled when the animation ends
  106604. */
  106605. waitAsync(): Promise<Animatable>;
  106606. /** @hidden */
  106607. _animate(delay: number): boolean;
  106608. }
  106609. interface Scene {
  106610. /** @hidden */
  106611. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  106612. /** @hidden */
  106613. _processLateAnimationBindingsForMatrices(holder: {
  106614. totalWeight: number;
  106615. totalAdditiveWeight: number;
  106616. animations: RuntimeAnimation[];
  106617. additiveAnimations: RuntimeAnimation[];
  106618. originalValue: Matrix;
  106619. }): any;
  106620. /** @hidden */
  106621. _processLateAnimationBindingsForQuaternions(holder: {
  106622. totalWeight: number;
  106623. totalAdditiveWeight: number;
  106624. animations: RuntimeAnimation[];
  106625. additiveAnimations: RuntimeAnimation[];
  106626. originalValue: Quaternion;
  106627. }, refQuaternion: Quaternion): Quaternion;
  106628. /** @hidden */
  106629. _processLateAnimationBindings(): void;
  106630. /**
  106631. * Will start the animation sequence of a given target
  106632. * @param target defines the target
  106633. * @param from defines from which frame should animation start
  106634. * @param to defines until which frame should animation run.
  106635. * @param weight defines the weight to apply to the animation (1.0 by default)
  106636. * @param loop defines if the animation loops
  106637. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106638. * @param onAnimationEnd defines the function to be executed when the animation ends
  106639. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106640. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106641. * @param onAnimationLoop defines the callback to call when an animation loops
  106642. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106643. * @returns the animatable object created for this animation
  106644. */
  106645. 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;
  106646. /**
  106647. * Will start the animation sequence of a given target
  106648. * @param target defines the target
  106649. * @param from defines from which frame should animation start
  106650. * @param to defines until which frame should animation run.
  106651. * @param loop defines if the animation loops
  106652. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106653. * @param onAnimationEnd defines the function to be executed when the animation ends
  106654. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106655. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106656. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  106657. * @param onAnimationLoop defines the callback to call when an animation loops
  106658. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106659. * @returns the animatable object created for this animation
  106660. */
  106661. 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;
  106662. /**
  106663. * Will start the animation sequence of a given target and its hierarchy
  106664. * @param target defines the target
  106665. * @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.
  106666. * @param from defines from which frame should animation start
  106667. * @param to defines until which frame should animation run.
  106668. * @param loop defines if the animation loops
  106669. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  106670. * @param onAnimationEnd defines the function to be executed when the animation ends
  106671. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  106672. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  106673. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  106674. * @param onAnimationLoop defines the callback to call when an animation loops
  106675. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106676. * @returns the list of created animatables
  106677. */
  106678. 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[];
  106679. /**
  106680. * Begin a new animation on a given node
  106681. * @param target defines the target where the animation will take place
  106682. * @param animations defines the list of animations to start
  106683. * @param from defines the initial value
  106684. * @param to defines the final value
  106685. * @param loop defines if you want animation to loop (off by default)
  106686. * @param speedRatio defines the speed ratio to apply to all animations
  106687. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106688. * @param onAnimationLoop defines the callback to call when an animation loops
  106689. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106690. * @returns the list of created animatables
  106691. */
  106692. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  106693. /**
  106694. * Begin a new animation on a given node and its hierarchy
  106695. * @param target defines the root node where the animation will take place
  106696. * @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.
  106697. * @param animations defines the list of animations to start
  106698. * @param from defines the initial value
  106699. * @param to defines the final value
  106700. * @param loop defines if you want animation to loop (off by default)
  106701. * @param speedRatio defines the speed ratio to apply to all animations
  106702. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  106703. * @param onAnimationLoop defines the callback to call when an animation loops
  106704. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  106705. * @returns the list of animatables created for all nodes
  106706. */
  106707. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  106708. /**
  106709. * Gets the animatable associated with a specific target
  106710. * @param target defines the target of the animatable
  106711. * @returns the required animatable if found
  106712. */
  106713. getAnimatableByTarget(target: any): Nullable<Animatable>;
  106714. /**
  106715. * Gets all animatables associated with a given target
  106716. * @param target defines the target to look animatables for
  106717. * @returns an array of Animatables
  106718. */
  106719. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  106720. /**
  106721. * Stops and removes all animations that have been applied to the scene
  106722. */
  106723. stopAllAnimations(): void;
  106724. /**
  106725. * Gets the current delta time used by animation engine
  106726. */
  106727. deltaTime: number;
  106728. }
  106729. interface Bone {
  106730. /**
  106731. * Copy an animation range from another bone
  106732. * @param source defines the source bone
  106733. * @param rangeName defines the range name to copy
  106734. * @param frameOffset defines the frame offset
  106735. * @param rescaleAsRequired defines if rescaling must be applied if required
  106736. * @param skelDimensionsRatio defines the scaling ratio
  106737. * @returns true if operation was successful
  106738. */
  106739. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  106740. }
  106741. }
  106742. declare module BABYLON {
  106743. /**
  106744. * Class used to override all child animations of a given target
  106745. */
  106746. export class AnimationPropertiesOverride {
  106747. /**
  106748. * Gets or sets a value indicating if animation blending must be used
  106749. */
  106750. enableBlending: boolean;
  106751. /**
  106752. * Gets or sets the blending speed to use when enableBlending is true
  106753. */
  106754. blendingSpeed: number;
  106755. /**
  106756. * Gets or sets the default loop mode to use
  106757. */
  106758. loopMode: number;
  106759. }
  106760. }
  106761. declare module BABYLON {
  106762. /**
  106763. * Class used to handle skinning animations
  106764. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  106765. */
  106766. export class Skeleton implements IAnimatable {
  106767. /** defines the skeleton name */
  106768. name: string;
  106769. /** defines the skeleton Id */
  106770. id: string;
  106771. /**
  106772. * Defines the list of child bones
  106773. */
  106774. bones: Bone[];
  106775. /**
  106776. * Defines an estimate of the dimension of the skeleton at rest
  106777. */
  106778. dimensionsAtRest: Vector3;
  106779. /**
  106780. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  106781. */
  106782. needInitialSkinMatrix: boolean;
  106783. /**
  106784. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  106785. */
  106786. overrideMesh: Nullable<AbstractMesh>;
  106787. /**
  106788. * Gets the list of animations attached to this skeleton
  106789. */
  106790. animations: Array<Animation>;
  106791. private _scene;
  106792. private _isDirty;
  106793. private _transformMatrices;
  106794. private _transformMatrixTexture;
  106795. private _meshesWithPoseMatrix;
  106796. private _animatables;
  106797. private _identity;
  106798. private _synchronizedWithMesh;
  106799. private _ranges;
  106800. private _lastAbsoluteTransformsUpdateId;
  106801. private _canUseTextureForBones;
  106802. private _uniqueId;
  106803. /** @hidden */
  106804. _numBonesWithLinkedTransformNode: number;
  106805. /** @hidden */
  106806. _hasWaitingData: Nullable<boolean>;
  106807. /** @hidden */
  106808. _waitingOverrideMeshId: Nullable<string>;
  106809. /**
  106810. * Specifies if the skeleton should be serialized
  106811. */
  106812. doNotSerialize: boolean;
  106813. private _useTextureToStoreBoneMatrices;
  106814. /**
  106815. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  106816. * Please note that this option is not available if the hardware does not support it
  106817. */
  106818. get useTextureToStoreBoneMatrices(): boolean;
  106819. set useTextureToStoreBoneMatrices(value: boolean);
  106820. private _animationPropertiesOverride;
  106821. /**
  106822. * Gets or sets the animation properties override
  106823. */
  106824. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106825. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106826. /**
  106827. * List of inspectable custom properties (used by the Inspector)
  106828. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  106829. */
  106830. inspectableCustomProperties: IInspectable[];
  106831. /**
  106832. * An observable triggered before computing the skeleton's matrices
  106833. */
  106834. onBeforeComputeObservable: Observable<Skeleton>;
  106835. /**
  106836. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  106837. */
  106838. get isUsingTextureForMatrices(): boolean;
  106839. /**
  106840. * Gets the unique ID of this skeleton
  106841. */
  106842. get uniqueId(): number;
  106843. /**
  106844. * Creates a new skeleton
  106845. * @param name defines the skeleton name
  106846. * @param id defines the skeleton Id
  106847. * @param scene defines the hosting scene
  106848. */
  106849. constructor(
  106850. /** defines the skeleton name */
  106851. name: string,
  106852. /** defines the skeleton Id */
  106853. id: string, scene: Scene);
  106854. /**
  106855. * Gets the current object class name.
  106856. * @return the class name
  106857. */
  106858. getClassName(): string;
  106859. /**
  106860. * Returns an array containing the root bones
  106861. * @returns an array containing the root bones
  106862. */
  106863. getChildren(): Array<Bone>;
  106864. /**
  106865. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  106866. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106867. * @returns a Float32Array containing matrices data
  106868. */
  106869. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  106870. /**
  106871. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  106872. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  106873. * @returns a raw texture containing the data
  106874. */
  106875. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  106876. /**
  106877. * Gets the current hosting scene
  106878. * @returns a scene object
  106879. */
  106880. getScene(): Scene;
  106881. /**
  106882. * Gets a string representing the current skeleton data
  106883. * @param fullDetails defines a boolean indicating if we want a verbose version
  106884. * @returns a string representing the current skeleton data
  106885. */
  106886. toString(fullDetails?: boolean): string;
  106887. /**
  106888. * Get bone's index searching by name
  106889. * @param name defines bone's name to search for
  106890. * @return the indice of the bone. Returns -1 if not found
  106891. */
  106892. getBoneIndexByName(name: string): number;
  106893. /**
  106894. * Creater a new animation range
  106895. * @param name defines the name of the range
  106896. * @param from defines the start key
  106897. * @param to defines the end key
  106898. */
  106899. createAnimationRange(name: string, from: number, to: number): void;
  106900. /**
  106901. * Delete a specific animation range
  106902. * @param name defines the name of the range
  106903. * @param deleteFrames defines if frames must be removed as well
  106904. */
  106905. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  106906. /**
  106907. * Gets a specific animation range
  106908. * @param name defines the name of the range to look for
  106909. * @returns the requested animation range or null if not found
  106910. */
  106911. getAnimationRange(name: string): Nullable<AnimationRange>;
  106912. /**
  106913. * Gets the list of all animation ranges defined on this skeleton
  106914. * @returns an array
  106915. */
  106916. getAnimationRanges(): Nullable<AnimationRange>[];
  106917. /**
  106918. * Copy animation range from a source skeleton.
  106919. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  106920. * @param source defines the source skeleton
  106921. * @param name defines the name of the range to copy
  106922. * @param rescaleAsRequired defines if rescaling must be applied if required
  106923. * @returns true if operation was successful
  106924. */
  106925. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  106926. /**
  106927. * Forces the skeleton to go to rest pose
  106928. */
  106929. returnToRest(): void;
  106930. private _getHighestAnimationFrame;
  106931. /**
  106932. * Begin a specific animation range
  106933. * @param name defines the name of the range to start
  106934. * @param loop defines if looping must be turned on (false by default)
  106935. * @param speedRatio defines the speed ratio to apply (1 by default)
  106936. * @param onAnimationEnd defines a callback which will be called when animation will end
  106937. * @returns a new animatable
  106938. */
  106939. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  106940. /**
  106941. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  106942. * @param skeleton defines the Skeleton containing the animation range to convert
  106943. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  106944. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  106945. * @returns the original skeleton
  106946. */
  106947. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  106948. /** @hidden */
  106949. _markAsDirty(): void;
  106950. /** @hidden */
  106951. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106952. /** @hidden */
  106953. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  106954. private _computeTransformMatrices;
  106955. /**
  106956. * Build all resources required to render a skeleton
  106957. */
  106958. prepare(): void;
  106959. /**
  106960. * Gets the list of animatables currently running for this skeleton
  106961. * @returns an array of animatables
  106962. */
  106963. getAnimatables(): IAnimatable[];
  106964. /**
  106965. * Clone the current skeleton
  106966. * @param name defines the name of the new skeleton
  106967. * @param id defines the id of the new skeleton
  106968. * @returns the new skeleton
  106969. */
  106970. clone(name: string, id?: string): Skeleton;
  106971. /**
  106972. * Enable animation blending for this skeleton
  106973. * @param blendingSpeed defines the blending speed to apply
  106974. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  106975. */
  106976. enableBlending(blendingSpeed?: number): void;
  106977. /**
  106978. * Releases all resources associated with the current skeleton
  106979. */
  106980. dispose(): void;
  106981. /**
  106982. * Serialize the skeleton in a JSON object
  106983. * @returns a JSON object
  106984. */
  106985. serialize(): any;
  106986. /**
  106987. * Creates a new skeleton from serialized data
  106988. * @param parsedSkeleton defines the serialized data
  106989. * @param scene defines the hosting scene
  106990. * @returns a new skeleton
  106991. */
  106992. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  106993. /**
  106994. * Compute all node absolute transforms
  106995. * @param forceUpdate defines if computation must be done even if cache is up to date
  106996. */
  106997. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  106998. /**
  106999. * Gets the root pose matrix
  107000. * @returns a matrix
  107001. */
  107002. getPoseMatrix(): Nullable<Matrix>;
  107003. /**
  107004. * Sorts bones per internal index
  107005. */
  107006. sortBones(): void;
  107007. private _sortBones;
  107008. /**
  107009. * Set the current local matrix as the restPose for all bones in the skeleton.
  107010. */
  107011. setCurrentPoseAsRest(): void;
  107012. }
  107013. }
  107014. declare module BABYLON {
  107015. /**
  107016. * Class used to store bone information
  107017. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  107018. */
  107019. export class Bone extends Node {
  107020. /**
  107021. * defines the bone name
  107022. */
  107023. name: string;
  107024. private static _tmpVecs;
  107025. private static _tmpQuat;
  107026. private static _tmpMats;
  107027. /**
  107028. * Gets the list of child bones
  107029. */
  107030. children: Bone[];
  107031. /** Gets the animations associated with this bone */
  107032. animations: Animation[];
  107033. /**
  107034. * Gets or sets bone length
  107035. */
  107036. length: number;
  107037. /**
  107038. * @hidden Internal only
  107039. * Set this value to map this bone to a different index in the transform matrices
  107040. * Set this value to -1 to exclude the bone from the transform matrices
  107041. */
  107042. _index: Nullable<number>;
  107043. private _skeleton;
  107044. private _localMatrix;
  107045. private _restPose;
  107046. private _bindPose;
  107047. private _baseMatrix;
  107048. private _absoluteTransform;
  107049. private _invertedAbsoluteTransform;
  107050. private _parent;
  107051. private _scalingDeterminant;
  107052. private _worldTransform;
  107053. private _localScaling;
  107054. private _localRotation;
  107055. private _localPosition;
  107056. private _needToDecompose;
  107057. private _needToCompose;
  107058. /** @hidden */
  107059. _linkedTransformNode: Nullable<TransformNode>;
  107060. /** @hidden */
  107061. _waitingTransformNodeId: Nullable<string>;
  107062. /** @hidden */
  107063. get _matrix(): Matrix;
  107064. /** @hidden */
  107065. set _matrix(value: Matrix);
  107066. /**
  107067. * Create a new bone
  107068. * @param name defines the bone name
  107069. * @param skeleton defines the parent skeleton
  107070. * @param parentBone defines the parent (can be null if the bone is the root)
  107071. * @param localMatrix defines the local matrix
  107072. * @param restPose defines the rest pose matrix
  107073. * @param baseMatrix defines the base matrix
  107074. * @param index defines index of the bone in the hiearchy
  107075. */
  107076. constructor(
  107077. /**
  107078. * defines the bone name
  107079. */
  107080. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  107081. /**
  107082. * Gets the current object class name.
  107083. * @return the class name
  107084. */
  107085. getClassName(): string;
  107086. /**
  107087. * Gets the parent skeleton
  107088. * @returns a skeleton
  107089. */
  107090. getSkeleton(): Skeleton;
  107091. /**
  107092. * Gets parent bone
  107093. * @returns a bone or null if the bone is the root of the bone hierarchy
  107094. */
  107095. getParent(): Nullable<Bone>;
  107096. /**
  107097. * Returns an array containing the root bones
  107098. * @returns an array containing the root bones
  107099. */
  107100. getChildren(): Array<Bone>;
  107101. /**
  107102. * Gets the node index in matrix array generated for rendering
  107103. * @returns the node index
  107104. */
  107105. getIndex(): number;
  107106. /**
  107107. * Sets the parent bone
  107108. * @param parent defines the parent (can be null if the bone is the root)
  107109. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107110. */
  107111. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  107112. /**
  107113. * Gets the local matrix
  107114. * @returns a matrix
  107115. */
  107116. getLocalMatrix(): Matrix;
  107117. /**
  107118. * Gets the base matrix (initial matrix which remains unchanged)
  107119. * @returns a matrix
  107120. */
  107121. getBaseMatrix(): Matrix;
  107122. /**
  107123. * Gets the rest pose matrix
  107124. * @returns a matrix
  107125. */
  107126. getRestPose(): Matrix;
  107127. /**
  107128. * Sets the rest pose matrix
  107129. * @param matrix the local-space rest pose to set for this bone
  107130. */
  107131. setRestPose(matrix: Matrix): void;
  107132. /**
  107133. * Gets the bind pose matrix
  107134. * @returns the bind pose matrix
  107135. */
  107136. getBindPose(): Matrix;
  107137. /**
  107138. * Sets the bind pose matrix
  107139. * @param matrix the local-space bind pose to set for this bone
  107140. */
  107141. setBindPose(matrix: Matrix): void;
  107142. /**
  107143. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  107144. */
  107145. getWorldMatrix(): Matrix;
  107146. /**
  107147. * Sets the local matrix to rest pose matrix
  107148. */
  107149. returnToRest(): void;
  107150. /**
  107151. * Gets the inverse of the absolute transform matrix.
  107152. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  107153. * @returns a matrix
  107154. */
  107155. getInvertedAbsoluteTransform(): Matrix;
  107156. /**
  107157. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  107158. * @returns a matrix
  107159. */
  107160. getAbsoluteTransform(): Matrix;
  107161. /**
  107162. * Links with the given transform node.
  107163. * The local matrix of this bone is copied from the transform node every frame.
  107164. * @param transformNode defines the transform node to link to
  107165. */
  107166. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  107167. /**
  107168. * Gets the node used to drive the bone's transformation
  107169. * @returns a transform node or null
  107170. */
  107171. getTransformNode(): Nullable<TransformNode>;
  107172. /** Gets or sets current position (in local space) */
  107173. get position(): Vector3;
  107174. set position(newPosition: Vector3);
  107175. /** Gets or sets current rotation (in local space) */
  107176. get rotation(): Vector3;
  107177. set rotation(newRotation: Vector3);
  107178. /** Gets or sets current rotation quaternion (in local space) */
  107179. get rotationQuaternion(): Quaternion;
  107180. set rotationQuaternion(newRotation: Quaternion);
  107181. /** Gets or sets current scaling (in local space) */
  107182. get scaling(): Vector3;
  107183. set scaling(newScaling: Vector3);
  107184. /**
  107185. * Gets the animation properties override
  107186. */
  107187. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107188. private _decompose;
  107189. private _compose;
  107190. /**
  107191. * Update the base and local matrices
  107192. * @param matrix defines the new base or local matrix
  107193. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  107194. * @param updateLocalMatrix defines if the local matrix should be updated
  107195. */
  107196. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  107197. /** @hidden */
  107198. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  107199. /**
  107200. * Flag the bone as dirty (Forcing it to update everything)
  107201. */
  107202. markAsDirty(): void;
  107203. /** @hidden */
  107204. _markAsDirtyAndCompose(): void;
  107205. private _markAsDirtyAndDecompose;
  107206. /**
  107207. * Translate the bone in local or world space
  107208. * @param vec The amount to translate the bone
  107209. * @param space The space that the translation is in
  107210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107211. */
  107212. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107213. /**
  107214. * Set the postion of the bone in local or world space
  107215. * @param position The position to set the bone
  107216. * @param space The space that the position is in
  107217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107218. */
  107219. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107220. /**
  107221. * Set the absolute position of the bone (world space)
  107222. * @param position The position to set the bone
  107223. * @param mesh The mesh that this bone is attached to
  107224. */
  107225. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  107226. /**
  107227. * Scale the bone on the x, y and z axes (in local space)
  107228. * @param x The amount to scale the bone on the x axis
  107229. * @param y The amount to scale the bone on the y axis
  107230. * @param z The amount to scale the bone on the z axis
  107231. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  107232. */
  107233. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  107234. /**
  107235. * Set the bone scaling in local space
  107236. * @param scale defines the scaling vector
  107237. */
  107238. setScale(scale: Vector3): void;
  107239. /**
  107240. * Gets the current scaling in local space
  107241. * @returns the current scaling vector
  107242. */
  107243. getScale(): Vector3;
  107244. /**
  107245. * Gets the current scaling in local space and stores it in a target vector
  107246. * @param result defines the target vector
  107247. */
  107248. getScaleToRef(result: Vector3): void;
  107249. /**
  107250. * Set the yaw, pitch, and roll of the bone in local or world space
  107251. * @param yaw The rotation of the bone on the y axis
  107252. * @param pitch The rotation of the bone on the x axis
  107253. * @param roll The rotation of the bone on the z axis
  107254. * @param space The space that the axes of rotation are in
  107255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107256. */
  107257. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  107258. /**
  107259. * Add a rotation to the bone on an axis in local or world space
  107260. * @param axis The axis to rotate the bone on
  107261. * @param amount The amount to rotate the bone
  107262. * @param space The space that the axis is in
  107263. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107264. */
  107265. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  107266. /**
  107267. * Set the rotation of the bone to a particular axis angle in local or world space
  107268. * @param axis The axis to rotate the bone on
  107269. * @param angle The angle that the bone should be rotated to
  107270. * @param space The space that the axis is in
  107271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107272. */
  107273. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  107274. /**
  107275. * Set the euler rotation of the bone in local or world space
  107276. * @param rotation The euler rotation that the bone should be set to
  107277. * @param space The space that the rotation is in
  107278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107279. */
  107280. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  107281. /**
  107282. * Set the quaternion rotation of the bone in local or world space
  107283. * @param quat The quaternion rotation that the bone should be set to
  107284. * @param space The space that the rotation is in
  107285. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107286. */
  107287. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  107288. /**
  107289. * Set the rotation matrix of the bone in local or world space
  107290. * @param rotMat The rotation matrix that the bone should be set to
  107291. * @param space The space that the rotation is in
  107292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107293. */
  107294. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  107295. private _rotateWithMatrix;
  107296. private _getNegativeRotationToRef;
  107297. /**
  107298. * Get the position of the bone in local or world space
  107299. * @param space The space that the returned position is in
  107300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107301. * @returns The position of the bone
  107302. */
  107303. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107304. /**
  107305. * Copy the position of the bone to a vector3 in local or world space
  107306. * @param space The space that the returned position is in
  107307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107308. * @param result The vector3 to copy the position to
  107309. */
  107310. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  107311. /**
  107312. * Get the absolute position of the bone (world space)
  107313. * @param mesh The mesh that this bone is attached to
  107314. * @returns The absolute position of the bone
  107315. */
  107316. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  107317. /**
  107318. * Copy the absolute position of the bone (world space) to the result param
  107319. * @param mesh The mesh that this bone is attached to
  107320. * @param result The vector3 to copy the absolute position to
  107321. */
  107322. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  107323. /**
  107324. * Compute the absolute transforms of this bone and its children
  107325. */
  107326. computeAbsoluteTransforms(): void;
  107327. /**
  107328. * Get the world direction from an axis that is in the local space of the bone
  107329. * @param localAxis The local direction that is used to compute the world direction
  107330. * @param mesh The mesh that this bone is attached to
  107331. * @returns The world direction
  107332. */
  107333. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107334. /**
  107335. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  107336. * @param localAxis The local direction that is used to compute the world direction
  107337. * @param mesh The mesh that this bone is attached to
  107338. * @param result The vector3 that the world direction will be copied to
  107339. */
  107340. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107341. /**
  107342. * Get the euler rotation of the bone in local or world space
  107343. * @param space The space that the rotation should be in
  107344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107345. * @returns The euler rotation
  107346. */
  107347. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  107348. /**
  107349. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  107350. * @param space The space that the rotation should be in
  107351. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107352. * @param result The vector3 that the rotation should be copied to
  107353. */
  107354. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107355. /**
  107356. * Get the quaternion rotation of the bone in either local or world space
  107357. * @param space The space that the rotation should be in
  107358. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107359. * @returns The quaternion rotation
  107360. */
  107361. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  107362. /**
  107363. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  107364. * @param space The space that the rotation should be in
  107365. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107366. * @param result The quaternion that the rotation should be copied to
  107367. */
  107368. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  107369. /**
  107370. * Get the rotation matrix of the bone in local or world space
  107371. * @param space The space that the rotation should be in
  107372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107373. * @returns The rotation matrix
  107374. */
  107375. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  107376. /**
  107377. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  107378. * @param space The space that the rotation should be in
  107379. * @param mesh The mesh that this bone is attached to. This is only used in world space
  107380. * @param result The quaternion that the rotation should be copied to
  107381. */
  107382. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  107383. /**
  107384. * Get the world position of a point that is in the local space of the bone
  107385. * @param position The local position
  107386. * @param mesh The mesh that this bone is attached to
  107387. * @returns The world position
  107388. */
  107389. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107390. /**
  107391. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  107392. * @param position The local position
  107393. * @param mesh The mesh that this bone is attached to
  107394. * @param result The vector3 that the world position should be copied to
  107395. */
  107396. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107397. /**
  107398. * Get the local position of a point that is in world space
  107399. * @param position The world position
  107400. * @param mesh The mesh that this bone is attached to
  107401. * @returns The local position
  107402. */
  107403. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  107404. /**
  107405. * Get the local position of a point that is in world space and copy it to the result param
  107406. * @param position The world position
  107407. * @param mesh The mesh that this bone is attached to
  107408. * @param result The vector3 that the local position should be copied to
  107409. */
  107410. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  107411. /**
  107412. * Set the current local matrix as the restPose for this bone.
  107413. */
  107414. setCurrentPoseAsRest(): void;
  107415. }
  107416. }
  107417. declare module BABYLON {
  107418. /**
  107419. * 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.
  107420. * @see https://doc.babylonjs.com/how_to/transformnode
  107421. */
  107422. export class TransformNode extends Node {
  107423. /**
  107424. * Object will not rotate to face the camera
  107425. */
  107426. static BILLBOARDMODE_NONE: number;
  107427. /**
  107428. * Object will rotate to face the camera but only on the x axis
  107429. */
  107430. static BILLBOARDMODE_X: number;
  107431. /**
  107432. * Object will rotate to face the camera but only on the y axis
  107433. */
  107434. static BILLBOARDMODE_Y: number;
  107435. /**
  107436. * Object will rotate to face the camera but only on the z axis
  107437. */
  107438. static BILLBOARDMODE_Z: number;
  107439. /**
  107440. * Object will rotate to face the camera
  107441. */
  107442. static BILLBOARDMODE_ALL: number;
  107443. /**
  107444. * Object will rotate to face the camera's position instead of orientation
  107445. */
  107446. static BILLBOARDMODE_USE_POSITION: number;
  107447. private static _TmpRotation;
  107448. private static _TmpScaling;
  107449. private static _TmpTranslation;
  107450. private _forward;
  107451. private _forwardInverted;
  107452. private _up;
  107453. private _right;
  107454. private _rightInverted;
  107455. private _position;
  107456. private _rotation;
  107457. private _rotationQuaternion;
  107458. protected _scaling: Vector3;
  107459. protected _isDirty: boolean;
  107460. private _transformToBoneReferal;
  107461. private _isAbsoluteSynced;
  107462. private _billboardMode;
  107463. /**
  107464. * Gets or sets the billboard mode. Default is 0.
  107465. *
  107466. * | Value | Type | Description |
  107467. * | --- | --- | --- |
  107468. * | 0 | BILLBOARDMODE_NONE | |
  107469. * | 1 | BILLBOARDMODE_X | |
  107470. * | 2 | BILLBOARDMODE_Y | |
  107471. * | 4 | BILLBOARDMODE_Z | |
  107472. * | 7 | BILLBOARDMODE_ALL | |
  107473. *
  107474. */
  107475. get billboardMode(): number;
  107476. set billboardMode(value: number);
  107477. private _preserveParentRotationForBillboard;
  107478. /**
  107479. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  107480. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  107481. */
  107482. get preserveParentRotationForBillboard(): boolean;
  107483. set preserveParentRotationForBillboard(value: boolean);
  107484. /**
  107485. * 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
  107486. */
  107487. scalingDeterminant: number;
  107488. private _infiniteDistance;
  107489. /**
  107490. * Gets or sets the distance of the object to max, often used by skybox
  107491. */
  107492. get infiniteDistance(): boolean;
  107493. set infiniteDistance(value: boolean);
  107494. /**
  107495. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  107496. * By default the system will update normals to compensate
  107497. */
  107498. ignoreNonUniformScaling: boolean;
  107499. /**
  107500. * 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
  107501. */
  107502. reIntegrateRotationIntoRotationQuaternion: boolean;
  107503. /** @hidden */
  107504. _poseMatrix: Nullable<Matrix>;
  107505. /** @hidden */
  107506. _localMatrix: Matrix;
  107507. private _usePivotMatrix;
  107508. private _absolutePosition;
  107509. private _absoluteScaling;
  107510. private _absoluteRotationQuaternion;
  107511. private _pivotMatrix;
  107512. private _pivotMatrixInverse;
  107513. /** @hidden */
  107514. _postMultiplyPivotMatrix: boolean;
  107515. protected _isWorldMatrixFrozen: boolean;
  107516. /** @hidden */
  107517. _indexInSceneTransformNodesArray: number;
  107518. /**
  107519. * An event triggered after the world matrix is updated
  107520. */
  107521. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  107522. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  107523. /**
  107524. * Gets a string identifying the name of the class
  107525. * @returns "TransformNode" string
  107526. */
  107527. getClassName(): string;
  107528. /**
  107529. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  107530. */
  107531. get position(): Vector3;
  107532. set position(newPosition: Vector3);
  107533. /**
  107534. * 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)).
  107535. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  107536. */
  107537. get rotation(): Vector3;
  107538. set rotation(newRotation: Vector3);
  107539. /**
  107540. * 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)).
  107541. */
  107542. get scaling(): Vector3;
  107543. set scaling(newScaling: Vector3);
  107544. /**
  107545. * 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).
  107546. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  107547. */
  107548. get rotationQuaternion(): Nullable<Quaternion>;
  107549. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  107550. /**
  107551. * The forward direction of that transform in world space.
  107552. */
  107553. get forward(): Vector3;
  107554. /**
  107555. * The up direction of that transform in world space.
  107556. */
  107557. get up(): Vector3;
  107558. /**
  107559. * The right direction of that transform in world space.
  107560. */
  107561. get right(): Vector3;
  107562. /**
  107563. * Copies the parameter passed Matrix into the mesh Pose matrix.
  107564. * @param matrix the matrix to copy the pose from
  107565. * @returns this TransformNode.
  107566. */
  107567. updatePoseMatrix(matrix: Matrix): TransformNode;
  107568. /**
  107569. * Returns the mesh Pose matrix.
  107570. * @returns the pose matrix
  107571. */
  107572. getPoseMatrix(): Matrix;
  107573. /** @hidden */
  107574. _isSynchronized(): boolean;
  107575. /** @hidden */
  107576. _initCache(): void;
  107577. /**
  107578. * Flag the transform node as dirty (Forcing it to update everything)
  107579. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  107580. * @returns this transform node
  107581. */
  107582. markAsDirty(property: string): TransformNode;
  107583. /**
  107584. * Returns the current mesh absolute position.
  107585. * Returns a Vector3.
  107586. */
  107587. get absolutePosition(): Vector3;
  107588. /**
  107589. * Returns the current mesh absolute scaling.
  107590. * Returns a Vector3.
  107591. */
  107592. get absoluteScaling(): Vector3;
  107593. /**
  107594. * Returns the current mesh absolute rotation.
  107595. * Returns a Quaternion.
  107596. */
  107597. get absoluteRotationQuaternion(): Quaternion;
  107598. /**
  107599. * Sets a new matrix to apply before all other transformation
  107600. * @param matrix defines the transform matrix
  107601. * @returns the current TransformNode
  107602. */
  107603. setPreTransformMatrix(matrix: Matrix): TransformNode;
  107604. /**
  107605. * Sets a new pivot matrix to the current node
  107606. * @param matrix defines the new pivot matrix to use
  107607. * @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
  107608. * @returns the current TransformNode
  107609. */
  107610. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  107611. /**
  107612. * Returns the mesh pivot matrix.
  107613. * Default : Identity.
  107614. * @returns the matrix
  107615. */
  107616. getPivotMatrix(): Matrix;
  107617. /**
  107618. * Instantiate (when possible) or clone that node with its hierarchy
  107619. * @param newParent defines the new parent to use for the instance (or clone)
  107620. * @param options defines options to configure how copy is done
  107621. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  107622. * @returns an instance (or a clone) of the current node with its hiearchy
  107623. */
  107624. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  107625. doNotInstantiate: boolean;
  107626. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  107627. /**
  107628. * Prevents the World matrix to be computed any longer
  107629. * @param newWorldMatrix defines an optional matrix to use as world matrix
  107630. * @returns the TransformNode.
  107631. */
  107632. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  107633. /**
  107634. * Allows back the World matrix computation.
  107635. * @returns the TransformNode.
  107636. */
  107637. unfreezeWorldMatrix(): this;
  107638. /**
  107639. * True if the World matrix has been frozen.
  107640. */
  107641. get isWorldMatrixFrozen(): boolean;
  107642. /**
  107643. * Retuns the mesh absolute position in the World.
  107644. * @returns a Vector3.
  107645. */
  107646. getAbsolutePosition(): Vector3;
  107647. /**
  107648. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  107649. * @param absolutePosition the absolute position to set
  107650. * @returns the TransformNode.
  107651. */
  107652. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107653. /**
  107654. * Sets the mesh position in its local space.
  107655. * @param vector3 the position to set in localspace
  107656. * @returns the TransformNode.
  107657. */
  107658. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  107659. /**
  107660. * Returns the mesh position in the local space from the current World matrix values.
  107661. * @returns a new Vector3.
  107662. */
  107663. getPositionExpressedInLocalSpace(): Vector3;
  107664. /**
  107665. * Translates the mesh along the passed Vector3 in its local space.
  107666. * @param vector3 the distance to translate in localspace
  107667. * @returns the TransformNode.
  107668. */
  107669. locallyTranslate(vector3: Vector3): TransformNode;
  107670. private static _lookAtVectorCache;
  107671. /**
  107672. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  107673. * @param targetPoint the position (must be in same space as current mesh) to look at
  107674. * @param yawCor optional yaw (y-axis) correction in radians
  107675. * @param pitchCor optional pitch (x-axis) correction in radians
  107676. * @param rollCor optional roll (z-axis) correction in radians
  107677. * @param space the choosen space of the target
  107678. * @returns the TransformNode.
  107679. */
  107680. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  107681. /**
  107682. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107683. * This Vector3 is expressed in the World space.
  107684. * @param localAxis axis to rotate
  107685. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  107686. */
  107687. getDirection(localAxis: Vector3): Vector3;
  107688. /**
  107689. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  107690. * localAxis is expressed in the mesh local space.
  107691. * result is computed in the Wordl space from the mesh World matrix.
  107692. * @param localAxis axis to rotate
  107693. * @param result the resulting transformnode
  107694. * @returns this TransformNode.
  107695. */
  107696. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  107697. /**
  107698. * Sets this transform node rotation to the given local axis.
  107699. * @param localAxis the axis in local space
  107700. * @param yawCor optional yaw (y-axis) correction in radians
  107701. * @param pitchCor optional pitch (x-axis) correction in radians
  107702. * @param rollCor optional roll (z-axis) correction in radians
  107703. * @returns this TransformNode
  107704. */
  107705. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  107706. /**
  107707. * Sets a new pivot point to the current node
  107708. * @param point defines the new pivot point to use
  107709. * @param space defines if the point is in world or local space (local by default)
  107710. * @returns the current TransformNode
  107711. */
  107712. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  107713. /**
  107714. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  107715. * @returns the pivot point
  107716. */
  107717. getPivotPoint(): Vector3;
  107718. /**
  107719. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  107720. * @param result the vector3 to store the result
  107721. * @returns this TransformNode.
  107722. */
  107723. getPivotPointToRef(result: Vector3): TransformNode;
  107724. /**
  107725. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  107726. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  107727. */
  107728. getAbsolutePivotPoint(): Vector3;
  107729. /**
  107730. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  107731. * @param result vector3 to store the result
  107732. * @returns this TransformNode.
  107733. */
  107734. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  107735. /**
  107736. * Defines the passed node as the parent of the current node.
  107737. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  107738. * @see https://doc.babylonjs.com/how_to/parenting
  107739. * @param node the node ot set as the parent
  107740. * @returns this TransformNode.
  107741. */
  107742. setParent(node: Nullable<Node>): TransformNode;
  107743. private _nonUniformScaling;
  107744. /**
  107745. * True if the scaling property of this object is non uniform eg. (1,2,1)
  107746. */
  107747. get nonUniformScaling(): boolean;
  107748. /** @hidden */
  107749. _updateNonUniformScalingState(value: boolean): boolean;
  107750. /**
  107751. * Attach the current TransformNode to another TransformNode associated with a bone
  107752. * @param bone Bone affecting the TransformNode
  107753. * @param affectedTransformNode TransformNode associated with the bone
  107754. * @returns this object
  107755. */
  107756. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  107757. /**
  107758. * Detach the transform node if its associated with a bone
  107759. * @returns this object
  107760. */
  107761. detachFromBone(): TransformNode;
  107762. private static _rotationAxisCache;
  107763. /**
  107764. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  107765. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107766. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107767. * The passed axis is also normalized.
  107768. * @param axis the axis to rotate around
  107769. * @param amount the amount to rotate in radians
  107770. * @param space Space to rotate in (Default: local)
  107771. * @returns the TransformNode.
  107772. */
  107773. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107774. /**
  107775. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  107776. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  107777. * The passed axis is also normalized. .
  107778. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  107779. * @param point the point to rotate around
  107780. * @param axis the axis to rotate around
  107781. * @param amount the amount to rotate in radians
  107782. * @returns the TransformNode
  107783. */
  107784. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  107785. /**
  107786. * Translates the mesh along the axis vector for the passed distance in the given space.
  107787. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  107788. * @param axis the axis to translate in
  107789. * @param distance the distance to translate
  107790. * @param space Space to rotate in (Default: local)
  107791. * @returns the TransformNode.
  107792. */
  107793. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107794. /**
  107795. * Adds a rotation step to the mesh current rotation.
  107796. * x, y, z are Euler angles expressed in radians.
  107797. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  107798. * This means this rotation is made in the mesh local space only.
  107799. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  107800. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  107801. * ```javascript
  107802. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  107803. * ```
  107804. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  107805. * 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.
  107806. * @param x Rotation to add
  107807. * @param y Rotation to add
  107808. * @param z Rotation to add
  107809. * @returns the TransformNode.
  107810. */
  107811. addRotation(x: number, y: number, z: number): TransformNode;
  107812. /**
  107813. * @hidden
  107814. */
  107815. protected _getEffectiveParent(): Nullable<Node>;
  107816. /**
  107817. * Computes the world matrix of the node
  107818. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  107819. * @returns the world matrix
  107820. */
  107821. computeWorldMatrix(force?: boolean): Matrix;
  107822. /**
  107823. * Resets this nodeTransform's local matrix to Matrix.Identity().
  107824. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  107825. */
  107826. resetLocalMatrix(independentOfChildren?: boolean): void;
  107827. protected _afterComputeWorldMatrix(): void;
  107828. /**
  107829. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  107830. * @param func callback function to add
  107831. *
  107832. * @returns the TransformNode.
  107833. */
  107834. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107835. /**
  107836. * Removes a registered callback function.
  107837. * @param func callback function to remove
  107838. * @returns the TransformNode.
  107839. */
  107840. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  107841. /**
  107842. * Gets the position of the current mesh in camera space
  107843. * @param camera defines the camera to use
  107844. * @returns a position
  107845. */
  107846. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  107847. /**
  107848. * Returns the distance from the mesh to the active camera
  107849. * @param camera defines the camera to use
  107850. * @returns the distance
  107851. */
  107852. getDistanceToCamera(camera?: Nullable<Camera>): number;
  107853. /**
  107854. * Clone the current transform node
  107855. * @param name Name of the new clone
  107856. * @param newParent New parent for the clone
  107857. * @param doNotCloneChildren Do not clone children hierarchy
  107858. * @returns the new transform node
  107859. */
  107860. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  107861. /**
  107862. * Serializes the objects information.
  107863. * @param currentSerializationObject defines the object to serialize in
  107864. * @returns the serialized object
  107865. */
  107866. serialize(currentSerializationObject?: any): any;
  107867. /**
  107868. * Returns a new TransformNode object parsed from the source provided.
  107869. * @param parsedTransformNode is the source.
  107870. * @param scene the scne the object belongs to
  107871. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  107872. * @returns a new TransformNode object parsed from the source provided.
  107873. */
  107874. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  107875. /**
  107876. * Get all child-transformNodes of this node
  107877. * @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
  107878. * @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
  107879. * @returns an array of TransformNode
  107880. */
  107881. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  107882. /**
  107883. * Releases resources associated with this transform node.
  107884. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107885. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107886. */
  107887. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107888. /**
  107889. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  107890. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  107891. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  107892. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  107893. * @returns the current mesh
  107894. */
  107895. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  107896. private _syncAbsoluteScalingAndRotation;
  107897. }
  107898. }
  107899. declare module BABYLON {
  107900. /**
  107901. * Defines the types of pose enabled controllers that are supported
  107902. */
  107903. export enum PoseEnabledControllerType {
  107904. /**
  107905. * HTC Vive
  107906. */
  107907. VIVE = 0,
  107908. /**
  107909. * Oculus Rift
  107910. */
  107911. OCULUS = 1,
  107912. /**
  107913. * Windows mixed reality
  107914. */
  107915. WINDOWS = 2,
  107916. /**
  107917. * Samsung gear VR
  107918. */
  107919. GEAR_VR = 3,
  107920. /**
  107921. * Google Daydream
  107922. */
  107923. DAYDREAM = 4,
  107924. /**
  107925. * Generic
  107926. */
  107927. GENERIC = 5
  107928. }
  107929. /**
  107930. * Defines the MutableGamepadButton interface for the state of a gamepad button
  107931. */
  107932. export interface MutableGamepadButton {
  107933. /**
  107934. * Value of the button/trigger
  107935. */
  107936. value: number;
  107937. /**
  107938. * If the button/trigger is currently touched
  107939. */
  107940. touched: boolean;
  107941. /**
  107942. * If the button/trigger is currently pressed
  107943. */
  107944. pressed: boolean;
  107945. }
  107946. /**
  107947. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  107948. * @hidden
  107949. */
  107950. export interface ExtendedGamepadButton extends GamepadButton {
  107951. /**
  107952. * If the button/trigger is currently pressed
  107953. */
  107954. readonly pressed: boolean;
  107955. /**
  107956. * If the button/trigger is currently touched
  107957. */
  107958. readonly touched: boolean;
  107959. /**
  107960. * Value of the button/trigger
  107961. */
  107962. readonly value: number;
  107963. }
  107964. /** @hidden */
  107965. export interface _GamePadFactory {
  107966. /**
  107967. * Returns whether or not the current gamepad can be created for this type of controller.
  107968. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107969. * @returns true if it can be created, otherwise false
  107970. */
  107971. canCreate(gamepadInfo: any): boolean;
  107972. /**
  107973. * Creates a new instance of the Gamepad.
  107974. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  107975. * @returns the new gamepad instance
  107976. */
  107977. create(gamepadInfo: any): Gamepad;
  107978. }
  107979. /**
  107980. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107981. */
  107982. export class PoseEnabledControllerHelper {
  107983. /** @hidden */
  107984. static _ControllerFactories: _GamePadFactory[];
  107985. /** @hidden */
  107986. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  107987. /**
  107988. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  107989. * @param vrGamepad the gamepad to initialized
  107990. * @returns a vr controller of the type the gamepad identified as
  107991. */
  107992. static InitiateController(vrGamepad: any): Gamepad;
  107993. }
  107994. /**
  107995. * Defines the PoseEnabledController object that contains state of a vr capable controller
  107996. */
  107997. export class PoseEnabledController extends Gamepad implements PoseControlled {
  107998. /**
  107999. * If the controller is used in a webXR session
  108000. */
  108001. isXR: boolean;
  108002. private _deviceRoomPosition;
  108003. private _deviceRoomRotationQuaternion;
  108004. /**
  108005. * The device position in babylon space
  108006. */
  108007. devicePosition: Vector3;
  108008. /**
  108009. * The device rotation in babylon space
  108010. */
  108011. deviceRotationQuaternion: Quaternion;
  108012. /**
  108013. * The scale factor of the device in babylon space
  108014. */
  108015. deviceScaleFactor: number;
  108016. /**
  108017. * (Likely devicePosition should be used instead) The device position in its room space
  108018. */
  108019. position: Vector3;
  108020. /**
  108021. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  108022. */
  108023. rotationQuaternion: Quaternion;
  108024. /**
  108025. * The type of controller (Eg. Windows mixed reality)
  108026. */
  108027. controllerType: PoseEnabledControllerType;
  108028. protected _calculatedPosition: Vector3;
  108029. private _calculatedRotation;
  108030. /**
  108031. * The raw pose from the device
  108032. */
  108033. rawPose: DevicePose;
  108034. private _trackPosition;
  108035. private _maxRotationDistFromHeadset;
  108036. private _draggedRoomRotation;
  108037. /**
  108038. * @hidden
  108039. */
  108040. _disableTrackPosition(fixedPosition: Vector3): void;
  108041. /**
  108042. * Internal, the mesh attached to the controller
  108043. * @hidden
  108044. */
  108045. _mesh: Nullable<AbstractMesh>;
  108046. private _poseControlledCamera;
  108047. private _leftHandSystemQuaternion;
  108048. /**
  108049. * Internal, matrix used to convert room space to babylon space
  108050. * @hidden
  108051. */
  108052. _deviceToWorld: Matrix;
  108053. /**
  108054. * Node to be used when casting a ray from the controller
  108055. * @hidden
  108056. */
  108057. _pointingPoseNode: Nullable<TransformNode>;
  108058. /**
  108059. * Name of the child mesh that can be used to cast a ray from the controller
  108060. */
  108061. static readonly POINTING_POSE: string;
  108062. /**
  108063. * Creates a new PoseEnabledController from a gamepad
  108064. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  108065. */
  108066. constructor(browserGamepad: any);
  108067. private _workingMatrix;
  108068. /**
  108069. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  108070. */
  108071. update(): void;
  108072. /**
  108073. * Updates only the pose device and mesh without doing any button event checking
  108074. */
  108075. protected _updatePoseAndMesh(): void;
  108076. /**
  108077. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  108078. * @param poseData raw pose fromthe device
  108079. */
  108080. updateFromDevice(poseData: DevicePose): void;
  108081. /**
  108082. * @hidden
  108083. */
  108084. _meshAttachedObservable: Observable<AbstractMesh>;
  108085. /**
  108086. * Attaches a mesh to the controller
  108087. * @param mesh the mesh to be attached
  108088. */
  108089. attachToMesh(mesh: AbstractMesh): void;
  108090. /**
  108091. * Attaches the controllers mesh to a camera
  108092. * @param camera the camera the mesh should be attached to
  108093. */
  108094. attachToPoseControlledCamera(camera: TargetCamera): void;
  108095. /**
  108096. * Disposes of the controller
  108097. */
  108098. dispose(): void;
  108099. /**
  108100. * The mesh that is attached to the controller
  108101. */
  108102. get mesh(): Nullable<AbstractMesh>;
  108103. /**
  108104. * Gets the ray of the controller in the direction the controller is pointing
  108105. * @param length the length the resulting ray should be
  108106. * @returns a ray in the direction the controller is pointing
  108107. */
  108108. getForwardRay(length?: number): Ray;
  108109. }
  108110. }
  108111. declare module BABYLON {
  108112. /**
  108113. * Defines the WebVRController object that represents controllers tracked in 3D space
  108114. */
  108115. export abstract class WebVRController extends PoseEnabledController {
  108116. /**
  108117. * Internal, the default controller model for the controller
  108118. */
  108119. protected _defaultModel: Nullable<AbstractMesh>;
  108120. /**
  108121. * Fired when the trigger state has changed
  108122. */
  108123. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108124. /**
  108125. * Fired when the main button state has changed
  108126. */
  108127. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108128. /**
  108129. * Fired when the secondary button state has changed
  108130. */
  108131. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108132. /**
  108133. * Fired when the pad state has changed
  108134. */
  108135. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  108136. /**
  108137. * Fired when controllers stick values have changed
  108138. */
  108139. onPadValuesChangedObservable: Observable<StickValues>;
  108140. /**
  108141. * Array of button availible on the controller
  108142. */
  108143. protected _buttons: Array<MutableGamepadButton>;
  108144. private _onButtonStateChange;
  108145. /**
  108146. * Fired when a controller button's state has changed
  108147. * @param callback the callback containing the button that was modified
  108148. */
  108149. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  108150. /**
  108151. * X and Y axis corresponding to the controllers joystick
  108152. */
  108153. pad: StickValues;
  108154. /**
  108155. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  108156. */
  108157. hand: string;
  108158. /**
  108159. * The default controller model for the controller
  108160. */
  108161. get defaultModel(): Nullable<AbstractMesh>;
  108162. /**
  108163. * Creates a new WebVRController from a gamepad
  108164. * @param vrGamepad the gamepad that the WebVRController should be created from
  108165. */
  108166. constructor(vrGamepad: any);
  108167. /**
  108168. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  108169. */
  108170. update(): void;
  108171. /**
  108172. * Function to be called when a button is modified
  108173. */
  108174. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108175. /**
  108176. * Loads a mesh and attaches it to the controller
  108177. * @param scene the scene the mesh should be added to
  108178. * @param meshLoaded callback for when the mesh has been loaded
  108179. */
  108180. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108181. private _setButtonValue;
  108182. private _changes;
  108183. private _checkChanges;
  108184. /**
  108185. * Disposes of th webVRCOntroller
  108186. */
  108187. dispose(): void;
  108188. }
  108189. }
  108190. declare module BABYLON {
  108191. /**
  108192. * The HemisphericLight simulates the ambient environment light,
  108193. * so the passed direction is the light reflection direction, not the incoming direction.
  108194. */
  108195. export class HemisphericLight extends Light {
  108196. /**
  108197. * The groundColor is the light in the opposite direction to the one specified during creation.
  108198. * 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.
  108199. */
  108200. groundColor: Color3;
  108201. /**
  108202. * The light reflection direction, not the incoming direction.
  108203. */
  108204. direction: Vector3;
  108205. /**
  108206. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  108207. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  108208. * The HemisphericLight can't cast shadows.
  108209. * Documentation : https://doc.babylonjs.com/babylon101/lights
  108210. * @param name The friendly name of the light
  108211. * @param direction The direction of the light reflection
  108212. * @param scene The scene the light belongs to
  108213. */
  108214. constructor(name: string, direction: Vector3, scene: Scene);
  108215. protected _buildUniformLayout(): void;
  108216. /**
  108217. * Returns the string "HemisphericLight".
  108218. * @return The class name
  108219. */
  108220. getClassName(): string;
  108221. /**
  108222. * Sets the HemisphericLight direction towards the passed target (Vector3).
  108223. * Returns the updated direction.
  108224. * @param target The target the direction should point to
  108225. * @return The computed direction
  108226. */
  108227. setDirectionToTarget(target: Vector3): Vector3;
  108228. /**
  108229. * Returns the shadow generator associated to the light.
  108230. * @returns Always null for hemispheric lights because it does not support shadows.
  108231. */
  108232. getShadowGenerator(): Nullable<IShadowGenerator>;
  108233. /**
  108234. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  108235. * @param effect The effect to update
  108236. * @param lightIndex The index of the light in the effect to update
  108237. * @returns The hemispheric light
  108238. */
  108239. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  108240. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  108241. /**
  108242. * Computes the world matrix of the node
  108243. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  108244. * @param useWasUpdatedFlag defines a reserved property
  108245. * @returns the world matrix
  108246. */
  108247. computeWorldMatrix(): Matrix;
  108248. /**
  108249. * Returns the integer 3.
  108250. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  108251. */
  108252. getTypeID(): number;
  108253. /**
  108254. * Prepares the list of defines specific to the light type.
  108255. * @param defines the list of defines
  108256. * @param lightIndex defines the index of the light for the effect
  108257. */
  108258. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  108259. }
  108260. }
  108261. declare module BABYLON {
  108262. /** @hidden */
  108263. export var vrMultiviewToSingleviewPixelShader: {
  108264. name: string;
  108265. shader: string;
  108266. };
  108267. }
  108268. declare module BABYLON {
  108269. /**
  108270. * Renders to multiple views with a single draw call
  108271. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  108272. */
  108273. export class MultiviewRenderTarget extends RenderTargetTexture {
  108274. /**
  108275. * Creates a multiview render target
  108276. * @param scene scene used with the render target
  108277. * @param size the size of the render target (used for each view)
  108278. */
  108279. constructor(scene: Scene, size?: number | {
  108280. width: number;
  108281. height: number;
  108282. } | {
  108283. ratio: number;
  108284. });
  108285. /**
  108286. * @hidden
  108287. * @param faceIndex the face index, if its a cube texture
  108288. */
  108289. _bindFrameBuffer(faceIndex?: number): void;
  108290. /**
  108291. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  108292. * @returns the view count
  108293. */
  108294. getViewCount(): number;
  108295. }
  108296. }
  108297. declare module BABYLON {
  108298. interface Engine {
  108299. /**
  108300. * Creates a new multiview render target
  108301. * @param width defines the width of the texture
  108302. * @param height defines the height of the texture
  108303. * @returns the created multiview texture
  108304. */
  108305. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  108306. /**
  108307. * Binds a multiview framebuffer to be drawn to
  108308. * @param multiviewTexture texture to bind
  108309. */
  108310. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  108311. }
  108312. interface Camera {
  108313. /**
  108314. * @hidden
  108315. * 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)
  108316. */
  108317. _useMultiviewToSingleView: boolean;
  108318. /**
  108319. * @hidden
  108320. * 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)
  108321. */
  108322. _multiviewTexture: Nullable<RenderTargetTexture>;
  108323. /**
  108324. * @hidden
  108325. * ensures the multiview texture of the camera exists and has the specified width/height
  108326. * @param width height to set on the multiview texture
  108327. * @param height width to set on the multiview texture
  108328. */
  108329. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  108330. }
  108331. interface Scene {
  108332. /** @hidden */
  108333. _transformMatrixR: Matrix;
  108334. /** @hidden */
  108335. _multiviewSceneUbo: Nullable<UniformBuffer>;
  108336. /** @hidden */
  108337. _createMultiviewUbo(): void;
  108338. /** @hidden */
  108339. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  108340. /** @hidden */
  108341. _renderMultiviewToSingleView(camera: Camera): void;
  108342. }
  108343. }
  108344. declare module BABYLON {
  108345. /**
  108346. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  108347. * This will not be used for webXR as it supports displaying texture arrays directly
  108348. */
  108349. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  108350. /**
  108351. * Gets a string identifying the name of the class
  108352. * @returns "VRMultiviewToSingleviewPostProcess" string
  108353. */
  108354. getClassName(): string;
  108355. /**
  108356. * Initializes a VRMultiviewToSingleview
  108357. * @param name name of the post process
  108358. * @param camera camera to be applied to
  108359. * @param scaleFactor scaling factor to the size of the output texture
  108360. */
  108361. constructor(name: string, camera: Camera, scaleFactor: number);
  108362. }
  108363. }
  108364. declare module BABYLON {
  108365. /**
  108366. * Interface used to define additional presentation attributes
  108367. */
  108368. export interface IVRPresentationAttributes {
  108369. /**
  108370. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  108371. */
  108372. highRefreshRate: boolean;
  108373. /**
  108374. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  108375. */
  108376. foveationLevel: number;
  108377. }
  108378. interface Engine {
  108379. /** @hidden */
  108380. _vrDisplay: any;
  108381. /** @hidden */
  108382. _vrSupported: boolean;
  108383. /** @hidden */
  108384. _oldSize: Size;
  108385. /** @hidden */
  108386. _oldHardwareScaleFactor: number;
  108387. /** @hidden */
  108388. _vrExclusivePointerMode: boolean;
  108389. /** @hidden */
  108390. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  108391. /** @hidden */
  108392. _onVRDisplayPointerRestricted: () => void;
  108393. /** @hidden */
  108394. _onVRDisplayPointerUnrestricted: () => void;
  108395. /** @hidden */
  108396. _onVrDisplayConnect: Nullable<(display: any) => void>;
  108397. /** @hidden */
  108398. _onVrDisplayDisconnect: Nullable<() => void>;
  108399. /** @hidden */
  108400. _onVrDisplayPresentChange: Nullable<() => void>;
  108401. /**
  108402. * Observable signaled when VR display mode changes
  108403. */
  108404. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  108405. /**
  108406. * Observable signaled when VR request present is complete
  108407. */
  108408. onVRRequestPresentComplete: Observable<boolean>;
  108409. /**
  108410. * Observable signaled when VR request present starts
  108411. */
  108412. onVRRequestPresentStart: Observable<Engine>;
  108413. /**
  108414. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  108415. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  108416. */
  108417. isInVRExclusivePointerMode: boolean;
  108418. /**
  108419. * Gets a boolean indicating if a webVR device was detected
  108420. * @returns true if a webVR device was detected
  108421. */
  108422. isVRDevicePresent(): boolean;
  108423. /**
  108424. * Gets the current webVR device
  108425. * @returns the current webVR device (or null)
  108426. */
  108427. getVRDevice(): any;
  108428. /**
  108429. * Initializes a webVR display and starts listening to display change events
  108430. * The onVRDisplayChangedObservable will be notified upon these changes
  108431. * @returns A promise containing a VRDisplay and if vr is supported
  108432. */
  108433. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  108434. /** @hidden */
  108435. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  108436. /**
  108437. * Gets or sets the presentation attributes used to configure VR rendering
  108438. */
  108439. vrPresentationAttributes?: IVRPresentationAttributes;
  108440. /**
  108441. * Call this function to switch to webVR mode
  108442. * Will do nothing if webVR is not supported or if there is no webVR device
  108443. * @param options the webvr options provided to the camera. mainly used for multiview
  108444. * @see https://doc.babylonjs.com/how_to/webvr_camera
  108445. */
  108446. enableVR(options: WebVROptions): void;
  108447. /** @hidden */
  108448. _onVRFullScreenTriggered(): void;
  108449. }
  108450. }
  108451. declare module BABYLON {
  108452. /**
  108453. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  108454. * IMPORTANT!! The data is right-hand data.
  108455. * @export
  108456. * @interface DevicePose
  108457. */
  108458. export interface DevicePose {
  108459. /**
  108460. * The position of the device, values in array are [x,y,z].
  108461. */
  108462. readonly position: Nullable<Float32Array>;
  108463. /**
  108464. * The linearVelocity of the device, values in array are [x,y,z].
  108465. */
  108466. readonly linearVelocity: Nullable<Float32Array>;
  108467. /**
  108468. * The linearAcceleration of the device, values in array are [x,y,z].
  108469. */
  108470. readonly linearAcceleration: Nullable<Float32Array>;
  108471. /**
  108472. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  108473. */
  108474. readonly orientation: Nullable<Float32Array>;
  108475. /**
  108476. * The angularVelocity of the device, values in array are [x,y,z].
  108477. */
  108478. readonly angularVelocity: Nullable<Float32Array>;
  108479. /**
  108480. * The angularAcceleration of the device, values in array are [x,y,z].
  108481. */
  108482. readonly angularAcceleration: Nullable<Float32Array>;
  108483. }
  108484. /**
  108485. * Interface representing a pose controlled object in Babylon.
  108486. * A pose controlled object has both regular pose values as well as pose values
  108487. * from an external device such as a VR head mounted display
  108488. */
  108489. export interface PoseControlled {
  108490. /**
  108491. * The position of the object in babylon space.
  108492. */
  108493. position: Vector3;
  108494. /**
  108495. * The rotation quaternion of the object in babylon space.
  108496. */
  108497. rotationQuaternion: Quaternion;
  108498. /**
  108499. * The position of the device in babylon space.
  108500. */
  108501. devicePosition?: Vector3;
  108502. /**
  108503. * The rotation quaternion of the device in babylon space.
  108504. */
  108505. deviceRotationQuaternion: Quaternion;
  108506. /**
  108507. * The raw pose coming from the device.
  108508. */
  108509. rawPose: Nullable<DevicePose>;
  108510. /**
  108511. * The scale of the device to be used when translating from device space to babylon space.
  108512. */
  108513. deviceScaleFactor: number;
  108514. /**
  108515. * Updates the poseControlled values based on the input device pose.
  108516. * @param poseData the pose data to update the object with
  108517. */
  108518. updateFromDevice(poseData: DevicePose): void;
  108519. }
  108520. /**
  108521. * Set of options to customize the webVRCamera
  108522. */
  108523. export interface WebVROptions {
  108524. /**
  108525. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  108526. */
  108527. trackPosition?: boolean;
  108528. /**
  108529. * Sets the scale of the vrDevice in babylon space. (default: 1)
  108530. */
  108531. positionScale?: number;
  108532. /**
  108533. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  108534. */
  108535. displayName?: string;
  108536. /**
  108537. * Should the native controller meshes be initialized. (default: true)
  108538. */
  108539. controllerMeshes?: boolean;
  108540. /**
  108541. * Creating a default HemiLight only on controllers. (default: true)
  108542. */
  108543. defaultLightingOnControllers?: boolean;
  108544. /**
  108545. * If you don't want to use the default VR button of the helper. (default: false)
  108546. */
  108547. useCustomVRButton?: boolean;
  108548. /**
  108549. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  108550. */
  108551. customVRButton?: HTMLButtonElement;
  108552. /**
  108553. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  108554. */
  108555. rayLength?: number;
  108556. /**
  108557. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  108558. */
  108559. defaultHeight?: number;
  108560. /**
  108561. * If multiview should be used if availible (default: false)
  108562. */
  108563. useMultiview?: boolean;
  108564. }
  108565. /**
  108566. * This represents a WebVR camera.
  108567. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  108568. * @example https://doc.babylonjs.com/how_to/webvr_camera
  108569. */
  108570. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  108571. private webVROptions;
  108572. /**
  108573. * @hidden
  108574. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  108575. */
  108576. _vrDevice: any;
  108577. /**
  108578. * The rawPose of the vrDevice.
  108579. */
  108580. rawPose: Nullable<DevicePose>;
  108581. private _onVREnabled;
  108582. private _specsVersion;
  108583. private _attached;
  108584. private _frameData;
  108585. protected _descendants: Array<Node>;
  108586. private _deviceRoomPosition;
  108587. /** @hidden */
  108588. _deviceRoomRotationQuaternion: Quaternion;
  108589. private _standingMatrix;
  108590. /**
  108591. * Represents device position in babylon space.
  108592. */
  108593. devicePosition: Vector3;
  108594. /**
  108595. * Represents device rotation in babylon space.
  108596. */
  108597. deviceRotationQuaternion: Quaternion;
  108598. /**
  108599. * The scale of the device to be used when translating from device space to babylon space.
  108600. */
  108601. deviceScaleFactor: number;
  108602. private _deviceToWorld;
  108603. private _worldToDevice;
  108604. /**
  108605. * References to the webVR controllers for the vrDevice.
  108606. */
  108607. controllers: Array<WebVRController>;
  108608. /**
  108609. * Emits an event when a controller is attached.
  108610. */
  108611. onControllersAttachedObservable: Observable<WebVRController[]>;
  108612. /**
  108613. * Emits an event when a controller's mesh has been loaded;
  108614. */
  108615. onControllerMeshLoadedObservable: Observable<WebVRController>;
  108616. /**
  108617. * Emits an event when the HMD's pose has been updated.
  108618. */
  108619. onPoseUpdatedFromDeviceObservable: Observable<any>;
  108620. private _poseSet;
  108621. /**
  108622. * If the rig cameras be used as parent instead of this camera.
  108623. */
  108624. rigParenting: boolean;
  108625. private _lightOnControllers;
  108626. private _defaultHeight?;
  108627. /**
  108628. * Instantiates a WebVRFreeCamera.
  108629. * @param name The name of the WebVRFreeCamera
  108630. * @param position The starting anchor position for the camera
  108631. * @param scene The scene the camera belongs to
  108632. * @param webVROptions a set of customizable options for the webVRCamera
  108633. */
  108634. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  108635. /**
  108636. * Gets the device distance from the ground in meters.
  108637. * @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.
  108638. */
  108639. deviceDistanceToRoomGround(): number;
  108640. /**
  108641. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108642. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  108643. */
  108644. useStandingMatrix(callback?: (bool: boolean) => void): void;
  108645. /**
  108646. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  108647. * @returns A promise with a boolean set to if the standing matrix is supported.
  108648. */
  108649. useStandingMatrixAsync(): Promise<boolean>;
  108650. /**
  108651. * Disposes the camera
  108652. */
  108653. dispose(): void;
  108654. /**
  108655. * Gets a vrController by name.
  108656. * @param name The name of the controller to retreive
  108657. * @returns the controller matching the name specified or null if not found
  108658. */
  108659. getControllerByName(name: string): Nullable<WebVRController>;
  108660. private _leftController;
  108661. /**
  108662. * The controller corresponding to the users left hand.
  108663. */
  108664. get leftController(): Nullable<WebVRController>;
  108665. private _rightController;
  108666. /**
  108667. * The controller corresponding to the users right hand.
  108668. */
  108669. get rightController(): Nullable<WebVRController>;
  108670. /**
  108671. * Casts a ray forward from the vrCamera's gaze.
  108672. * @param length Length of the ray (default: 100)
  108673. * @returns the ray corresponding to the gaze
  108674. */
  108675. getForwardRay(length?: number): Ray;
  108676. /**
  108677. * @hidden
  108678. * Updates the camera based on device's frame data
  108679. */
  108680. _checkInputs(): void;
  108681. /**
  108682. * Updates the poseControlled values based on the input device pose.
  108683. * @param poseData Pose coming from the device
  108684. */
  108685. updateFromDevice(poseData: DevicePose): void;
  108686. private _detachIfAttached;
  108687. /**
  108688. * WebVR's attach control will start broadcasting frames to the device.
  108689. * Note that in certain browsers (chrome for example) this function must be called
  108690. * within a user-interaction callback. Example:
  108691. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  108692. *
  108693. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  108694. */
  108695. attachControl(noPreventDefault?: boolean): void;
  108696. /**
  108697. * Detach the current controls from the specified dom element.
  108698. */
  108699. detachControl(): void;
  108700. /**
  108701. * @returns the name of this class
  108702. */
  108703. getClassName(): string;
  108704. /**
  108705. * Calls resetPose on the vrDisplay
  108706. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  108707. */
  108708. resetToCurrentRotation(): void;
  108709. /**
  108710. * @hidden
  108711. * Updates the rig cameras (left and right eye)
  108712. */
  108713. _updateRigCameras(): void;
  108714. private _workingVector;
  108715. private _oneVector;
  108716. private _workingMatrix;
  108717. private updateCacheCalled;
  108718. private _correctPositionIfNotTrackPosition;
  108719. /**
  108720. * @hidden
  108721. * Updates the cached values of the camera
  108722. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  108723. */
  108724. _updateCache(ignoreParentClass?: boolean): void;
  108725. /**
  108726. * @hidden
  108727. * Get current device position in babylon world
  108728. */
  108729. _computeDevicePosition(): void;
  108730. /**
  108731. * Updates the current device position and rotation in the babylon world
  108732. */
  108733. update(): void;
  108734. /**
  108735. * @hidden
  108736. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  108737. * @returns an identity matrix
  108738. */
  108739. _getViewMatrix(): Matrix;
  108740. private _tmpMatrix;
  108741. /**
  108742. * This function is called by the two RIG cameras.
  108743. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  108744. * @hidden
  108745. */
  108746. _getWebVRViewMatrix(): Matrix;
  108747. /** @hidden */
  108748. _getWebVRProjectionMatrix(): Matrix;
  108749. private _onGamepadConnectedObserver;
  108750. private _onGamepadDisconnectedObserver;
  108751. private _updateCacheWhenTrackingDisabledObserver;
  108752. /**
  108753. * Initializes the controllers and their meshes
  108754. */
  108755. initControllers(): void;
  108756. }
  108757. }
  108758. declare module BABYLON {
  108759. /**
  108760. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  108761. *
  108762. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  108763. *
  108764. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  108765. */
  108766. export class MaterialHelper {
  108767. /**
  108768. * Bind the current view position to an effect.
  108769. * @param effect The effect to be bound
  108770. * @param scene The scene the eyes position is used from
  108771. * @param variableName name of the shader variable that will hold the eye position
  108772. */
  108773. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  108774. /**
  108775. * Helps preparing the defines values about the UVs in used in the effect.
  108776. * UVs are shared as much as we can accross channels in the shaders.
  108777. * @param texture The texture we are preparing the UVs for
  108778. * @param defines The defines to update
  108779. * @param key The channel key "diffuse", "specular"... used in the shader
  108780. */
  108781. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  108782. /**
  108783. * Binds a texture matrix value to its corrsponding uniform
  108784. * @param texture The texture to bind the matrix for
  108785. * @param uniformBuffer The uniform buffer receivin the data
  108786. * @param key The channel key "diffuse", "specular"... used in the shader
  108787. */
  108788. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  108789. /**
  108790. * Gets the current status of the fog (should it be enabled?)
  108791. * @param mesh defines the mesh to evaluate for fog support
  108792. * @param scene defines the hosting scene
  108793. * @returns true if fog must be enabled
  108794. */
  108795. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  108796. /**
  108797. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  108798. * @param mesh defines the current mesh
  108799. * @param scene defines the current scene
  108800. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  108801. * @param pointsCloud defines if point cloud rendering has to be turned on
  108802. * @param fogEnabled defines if fog has to be turned on
  108803. * @param alphaTest defines if alpha testing has to be turned on
  108804. * @param defines defines the current list of defines
  108805. */
  108806. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  108807. /**
  108808. * Helper used to prepare the list of defines associated with frame values for shader compilation
  108809. * @param scene defines the current scene
  108810. * @param engine defines the current engine
  108811. * @param defines specifies the list of active defines
  108812. * @param useInstances defines if instances have to be turned on
  108813. * @param useClipPlane defines if clip plane have to be turned on
  108814. * @param useInstances defines if instances have to be turned on
  108815. * @param useThinInstances defines if thin instances have to be turned on
  108816. */
  108817. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  108818. /**
  108819. * Prepares the defines for bones
  108820. * @param mesh The mesh containing the geometry data we will draw
  108821. * @param defines The defines to update
  108822. */
  108823. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  108824. /**
  108825. * Prepares the defines for morph targets
  108826. * @param mesh The mesh containing the geometry data we will draw
  108827. * @param defines The defines to update
  108828. */
  108829. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  108830. /**
  108831. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  108832. * @param mesh The mesh containing the geometry data we will draw
  108833. * @param defines The defines to update
  108834. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  108835. * @param useBones Precise whether bones should be used or not (override mesh info)
  108836. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  108837. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  108838. * @returns false if defines are considered not dirty and have not been checked
  108839. */
  108840. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  108841. /**
  108842. * Prepares the defines related to multiview
  108843. * @param scene The scene we are intending to draw
  108844. * @param defines The defines to update
  108845. */
  108846. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  108847. /**
  108848. * Prepares the defines related to the prepass
  108849. * @param scene The scene we are intending to draw
  108850. * @param defines The defines to update
  108851. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  108852. */
  108853. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  108854. /**
  108855. * Prepares the defines related to the light information passed in parameter
  108856. * @param scene The scene we are intending to draw
  108857. * @param mesh The mesh the effect is compiling for
  108858. * @param light The light the effect is compiling for
  108859. * @param lightIndex The index of the light
  108860. * @param defines The defines to update
  108861. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108862. * @param state Defines the current state regarding what is needed (normals, etc...)
  108863. */
  108864. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  108865. needNormals: boolean;
  108866. needRebuild: boolean;
  108867. shadowEnabled: boolean;
  108868. specularEnabled: boolean;
  108869. lightmapMode: boolean;
  108870. }): void;
  108871. /**
  108872. * Prepares the defines related to the light information passed in parameter
  108873. * @param scene The scene we are intending to draw
  108874. * @param mesh The mesh the effect is compiling for
  108875. * @param defines The defines to update
  108876. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  108877. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  108878. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  108879. * @returns true if normals will be required for the rest of the effect
  108880. */
  108881. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  108882. /**
  108883. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  108884. * @param lightIndex defines the light index
  108885. * @param uniformsList The uniform list
  108886. * @param samplersList The sampler list
  108887. * @param projectedLightTexture defines if projected texture must be used
  108888. * @param uniformBuffersList defines an optional list of uniform buffers
  108889. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  108890. */
  108891. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  108892. /**
  108893. * Prepares the uniforms and samplers list to be used in the effect
  108894. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  108895. * @param samplersList The sampler list
  108896. * @param defines The defines helping in the list generation
  108897. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  108898. */
  108899. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  108900. /**
  108901. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  108902. * @param defines The defines to update while falling back
  108903. * @param fallbacks The authorized effect fallbacks
  108904. * @param maxSimultaneousLights The maximum number of lights allowed
  108905. * @param rank the current rank of the Effect
  108906. * @returns The newly affected rank
  108907. */
  108908. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  108909. private static _TmpMorphInfluencers;
  108910. /**
  108911. * Prepares the list of attributes required for morph targets according to the effect defines.
  108912. * @param attribs The current list of supported attribs
  108913. * @param mesh The mesh to prepare the morph targets attributes for
  108914. * @param influencers The number of influencers
  108915. */
  108916. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  108917. /**
  108918. * Prepares the list of attributes required for morph targets according to the effect defines.
  108919. * @param attribs The current list of supported attribs
  108920. * @param mesh The mesh to prepare the morph targets attributes for
  108921. * @param defines The current Defines of the effect
  108922. */
  108923. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  108924. /**
  108925. * Prepares the list of attributes required for bones according to the effect defines.
  108926. * @param attribs The current list of supported attribs
  108927. * @param mesh The mesh to prepare the bones attributes for
  108928. * @param defines The current Defines of the effect
  108929. * @param fallbacks The current efffect fallback strategy
  108930. */
  108931. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  108932. /**
  108933. * Check and prepare the list of attributes required for instances according to the effect defines.
  108934. * @param attribs The current list of supported attribs
  108935. * @param defines The current MaterialDefines of the effect
  108936. */
  108937. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  108938. /**
  108939. * Add the list of attributes required for instances to the attribs array.
  108940. * @param attribs The current list of supported attribs
  108941. */
  108942. static PushAttributesForInstances(attribs: string[]): void;
  108943. /**
  108944. * Binds the light information to the effect.
  108945. * @param light The light containing the generator
  108946. * @param effect The effect we are binding the data to
  108947. * @param lightIndex The light index in the effect used to render
  108948. */
  108949. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  108950. /**
  108951. * Binds the lights information from the scene to the effect for the given mesh.
  108952. * @param light Light to bind
  108953. * @param lightIndex Light index
  108954. * @param scene The scene where the light belongs to
  108955. * @param effect The effect we are binding the data to
  108956. * @param useSpecular Defines if specular is supported
  108957. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108958. */
  108959. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  108960. /**
  108961. * Binds the lights information from the scene to the effect for the given mesh.
  108962. * @param scene The scene the lights belongs to
  108963. * @param mesh The mesh we are binding the information to render
  108964. * @param effect The effect we are binding the data to
  108965. * @param defines The generated defines for the effect
  108966. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  108967. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  108968. */
  108969. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  108970. private static _tempFogColor;
  108971. /**
  108972. * Binds the fog information from the scene to the effect for the given mesh.
  108973. * @param scene The scene the lights belongs to
  108974. * @param mesh The mesh we are binding the information to render
  108975. * @param effect The effect we are binding the data to
  108976. * @param linearSpace Defines if the fog effect is applied in linear space
  108977. */
  108978. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  108979. /**
  108980. * Binds the bones information from the mesh to the effect.
  108981. * @param mesh The mesh we are binding the information to render
  108982. * @param effect The effect we are binding the data to
  108983. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  108984. */
  108985. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  108986. private static _CopyBonesTransformationMatrices;
  108987. /**
  108988. * Binds the morph targets information from the mesh to the effect.
  108989. * @param abstractMesh The mesh we are binding the information to render
  108990. * @param effect The effect we are binding the data to
  108991. */
  108992. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  108993. /**
  108994. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  108995. * @param defines The generated defines used in the effect
  108996. * @param effect The effect we are binding the data to
  108997. * @param scene The scene we are willing to render with logarithmic scale for
  108998. */
  108999. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  109000. /**
  109001. * Binds the clip plane information from the scene to the effect.
  109002. * @param scene The scene the clip plane information are extracted from
  109003. * @param effect The effect we are binding the data to
  109004. */
  109005. static BindClipPlane(effect: Effect, scene: Scene): void;
  109006. }
  109007. }
  109008. declare module BABYLON {
  109009. /** @hidden */
  109010. export var bayerDitherFunctions: {
  109011. name: string;
  109012. shader: string;
  109013. };
  109014. }
  109015. declare module BABYLON {
  109016. /** @hidden */
  109017. export var shadowMapFragmentDeclaration: {
  109018. name: string;
  109019. shader: string;
  109020. };
  109021. }
  109022. declare module BABYLON {
  109023. /** @hidden */
  109024. export var shadowMapFragment: {
  109025. name: string;
  109026. shader: string;
  109027. };
  109028. }
  109029. declare module BABYLON {
  109030. /** @hidden */
  109031. export var shadowMapPixelShader: {
  109032. name: string;
  109033. shader: string;
  109034. };
  109035. }
  109036. declare module BABYLON {
  109037. /** @hidden */
  109038. export var shadowMapVertexDeclaration: {
  109039. name: string;
  109040. shader: string;
  109041. };
  109042. }
  109043. declare module BABYLON {
  109044. /** @hidden */
  109045. export var shadowMapVertexNormalBias: {
  109046. name: string;
  109047. shader: string;
  109048. };
  109049. }
  109050. declare module BABYLON {
  109051. /** @hidden */
  109052. export var shadowMapVertexMetric: {
  109053. name: string;
  109054. shader: string;
  109055. };
  109056. }
  109057. declare module BABYLON {
  109058. /** @hidden */
  109059. export var shadowMapVertexShader: {
  109060. name: string;
  109061. shader: string;
  109062. };
  109063. }
  109064. declare module BABYLON {
  109065. /** @hidden */
  109066. export var depthBoxBlurPixelShader: {
  109067. name: string;
  109068. shader: string;
  109069. };
  109070. }
  109071. declare module BABYLON {
  109072. /** @hidden */
  109073. export var shadowMapFragmentSoftTransparentShadow: {
  109074. name: string;
  109075. shader: string;
  109076. };
  109077. }
  109078. declare module BABYLON {
  109079. /**
  109080. * Creates an instance based on a source mesh.
  109081. */
  109082. export class InstancedMesh extends AbstractMesh {
  109083. private _sourceMesh;
  109084. private _currentLOD;
  109085. /** @hidden */
  109086. _indexInSourceMeshInstanceArray: number;
  109087. constructor(name: string, source: Mesh);
  109088. /**
  109089. * Returns the string "InstancedMesh".
  109090. */
  109091. getClassName(): string;
  109092. /** Gets the list of lights affecting that mesh */
  109093. get lightSources(): Light[];
  109094. _resyncLightSources(): void;
  109095. _resyncLightSource(light: Light): void;
  109096. _removeLightSource(light: Light, dispose: boolean): void;
  109097. /**
  109098. * If the source mesh receives shadows
  109099. */
  109100. get receiveShadows(): boolean;
  109101. /**
  109102. * The material of the source mesh
  109103. */
  109104. get material(): Nullable<Material>;
  109105. /**
  109106. * Visibility of the source mesh
  109107. */
  109108. get visibility(): number;
  109109. /**
  109110. * Skeleton of the source mesh
  109111. */
  109112. get skeleton(): Nullable<Skeleton>;
  109113. /**
  109114. * Rendering ground id of the source mesh
  109115. */
  109116. get renderingGroupId(): number;
  109117. set renderingGroupId(value: number);
  109118. /**
  109119. * Returns the total number of vertices (integer).
  109120. */
  109121. getTotalVertices(): number;
  109122. /**
  109123. * Returns a positive integer : the total number of indices in this mesh geometry.
  109124. * @returns the numner of indices or zero if the mesh has no geometry.
  109125. */
  109126. getTotalIndices(): number;
  109127. /**
  109128. * The source mesh of the instance
  109129. */
  109130. get sourceMesh(): Mesh;
  109131. /**
  109132. * Creates a new InstancedMesh object from the mesh model.
  109133. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109134. * @param name defines the name of the new instance
  109135. * @returns a new InstancedMesh
  109136. */
  109137. createInstance(name: string): InstancedMesh;
  109138. /**
  109139. * Is this node ready to be used/rendered
  109140. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109141. * @return {boolean} is it ready
  109142. */
  109143. isReady(completeCheck?: boolean): boolean;
  109144. /**
  109145. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  109146. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  109147. * @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.
  109148. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  109149. */
  109150. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  109151. /**
  109152. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109153. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109154. * The `data` are either a numeric array either a Float32Array.
  109155. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  109156. * 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).
  109157. * Note that a new underlying VertexBuffer object is created each call.
  109158. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109159. *
  109160. * Possible `kind` values :
  109161. * - VertexBuffer.PositionKind
  109162. * - VertexBuffer.UVKind
  109163. * - VertexBuffer.UV2Kind
  109164. * - VertexBuffer.UV3Kind
  109165. * - VertexBuffer.UV4Kind
  109166. * - VertexBuffer.UV5Kind
  109167. * - VertexBuffer.UV6Kind
  109168. * - VertexBuffer.ColorKind
  109169. * - VertexBuffer.MatricesIndicesKind
  109170. * - VertexBuffer.MatricesIndicesExtraKind
  109171. * - VertexBuffer.MatricesWeightsKind
  109172. * - VertexBuffer.MatricesWeightsExtraKind
  109173. *
  109174. * Returns the Mesh.
  109175. */
  109176. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109177. /**
  109178. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109179. * If the mesh has no geometry, it is simply returned as it is.
  109180. * The `data` are either a numeric array either a Float32Array.
  109181. * No new underlying VertexBuffer object is created.
  109182. * 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.
  109183. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  109184. *
  109185. * Possible `kind` values :
  109186. * - VertexBuffer.PositionKind
  109187. * - VertexBuffer.UVKind
  109188. * - VertexBuffer.UV2Kind
  109189. * - VertexBuffer.UV3Kind
  109190. * - VertexBuffer.UV4Kind
  109191. * - VertexBuffer.UV5Kind
  109192. * - VertexBuffer.UV6Kind
  109193. * - VertexBuffer.ColorKind
  109194. * - VertexBuffer.MatricesIndicesKind
  109195. * - VertexBuffer.MatricesIndicesExtraKind
  109196. * - VertexBuffer.MatricesWeightsKind
  109197. * - VertexBuffer.MatricesWeightsExtraKind
  109198. *
  109199. * Returns the Mesh.
  109200. */
  109201. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  109202. /**
  109203. * Sets the mesh indices.
  109204. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  109205. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109206. * This method creates a new index buffer each call.
  109207. * Returns the Mesh.
  109208. */
  109209. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  109210. /**
  109211. * Boolean : True if the mesh owns the requested kind of data.
  109212. */
  109213. isVerticesDataPresent(kind: string): boolean;
  109214. /**
  109215. * Returns an array of indices (IndicesArray).
  109216. */
  109217. getIndices(): Nullable<IndicesArray>;
  109218. get _positions(): Nullable<Vector3[]>;
  109219. /**
  109220. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109221. * This means the mesh underlying bounding box and sphere are recomputed.
  109222. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109223. * @returns the current mesh
  109224. */
  109225. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  109226. /** @hidden */
  109227. _preActivate(): InstancedMesh;
  109228. /** @hidden */
  109229. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109230. /** @hidden */
  109231. _postActivate(): void;
  109232. getWorldMatrix(): Matrix;
  109233. get isAnInstance(): boolean;
  109234. /**
  109235. * Returns the current associated LOD AbstractMesh.
  109236. */
  109237. getLOD(camera: Camera): AbstractMesh;
  109238. /** @hidden */
  109239. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109240. /** @hidden */
  109241. _syncSubMeshes(): InstancedMesh;
  109242. /** @hidden */
  109243. _generatePointsArray(): boolean;
  109244. /** @hidden */
  109245. _updateBoundingInfo(): AbstractMesh;
  109246. /**
  109247. * Creates a new InstancedMesh from the current mesh.
  109248. * - name (string) : the cloned mesh name
  109249. * - newParent (optional Node) : the optional Node to parent the clone to.
  109250. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  109251. *
  109252. * Returns the clone.
  109253. */
  109254. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  109255. /**
  109256. * Disposes the InstancedMesh.
  109257. * Returns nothing.
  109258. */
  109259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109260. }
  109261. interface Mesh {
  109262. /**
  109263. * Register a custom buffer that will be instanced
  109264. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109265. * @param kind defines the buffer kind
  109266. * @param stride defines the stride in floats
  109267. */
  109268. registerInstancedBuffer(kind: string, stride: number): void;
  109269. /**
  109270. * true to use the edge renderer for all instances of this mesh
  109271. */
  109272. edgesShareWithInstances: boolean;
  109273. /** @hidden */
  109274. _userInstancedBuffersStorage: {
  109275. data: {
  109276. [key: string]: Float32Array;
  109277. };
  109278. sizes: {
  109279. [key: string]: number;
  109280. };
  109281. vertexBuffers: {
  109282. [key: string]: Nullable<VertexBuffer>;
  109283. };
  109284. strides: {
  109285. [key: string]: number;
  109286. };
  109287. };
  109288. }
  109289. interface AbstractMesh {
  109290. /**
  109291. * Object used to store instanced buffers defined by user
  109292. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  109293. */
  109294. instancedBuffers: {
  109295. [key: string]: any;
  109296. };
  109297. }
  109298. }
  109299. declare module BABYLON {
  109300. /**
  109301. * Defines the options associated with the creation of a shader material.
  109302. */
  109303. export interface IShaderMaterialOptions {
  109304. /**
  109305. * Does the material work in alpha blend mode
  109306. */
  109307. needAlphaBlending: boolean;
  109308. /**
  109309. * Does the material work in alpha test mode
  109310. */
  109311. needAlphaTesting: boolean;
  109312. /**
  109313. * The list of attribute names used in the shader
  109314. */
  109315. attributes: string[];
  109316. /**
  109317. * The list of unifrom names used in the shader
  109318. */
  109319. uniforms: string[];
  109320. /**
  109321. * The list of UBO names used in the shader
  109322. */
  109323. uniformBuffers: string[];
  109324. /**
  109325. * The list of sampler names used in the shader
  109326. */
  109327. samplers: string[];
  109328. /**
  109329. * The list of defines used in the shader
  109330. */
  109331. defines: string[];
  109332. }
  109333. /**
  109334. * 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.
  109335. *
  109336. * This returned material effects how the mesh will look based on the code in the shaders.
  109337. *
  109338. * @see https://doc.babylonjs.com/how_to/shader_material
  109339. */
  109340. export class ShaderMaterial extends Material {
  109341. private _shaderPath;
  109342. private _options;
  109343. private _textures;
  109344. private _textureArrays;
  109345. private _floats;
  109346. private _ints;
  109347. private _floatsArrays;
  109348. private _colors3;
  109349. private _colors3Arrays;
  109350. private _colors4;
  109351. private _colors4Arrays;
  109352. private _vectors2;
  109353. private _vectors3;
  109354. private _vectors4;
  109355. private _matrices;
  109356. private _matrixArrays;
  109357. private _matrices3x3;
  109358. private _matrices2x2;
  109359. private _vectors2Arrays;
  109360. private _vectors3Arrays;
  109361. private _vectors4Arrays;
  109362. private _cachedWorldViewMatrix;
  109363. private _cachedWorldViewProjectionMatrix;
  109364. private _renderId;
  109365. private _multiview;
  109366. private _cachedDefines;
  109367. /** Define the Url to load snippets */
  109368. static SnippetUrl: string;
  109369. /** Snippet ID if the material was created from the snippet server */
  109370. snippetId: string;
  109371. /**
  109372. * Instantiate a new shader material.
  109373. * 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.
  109374. * This returned material effects how the mesh will look based on the code in the shaders.
  109375. * @see https://doc.babylonjs.com/how_to/shader_material
  109376. * @param name Define the name of the material in the scene
  109377. * @param scene Define the scene the material belongs to
  109378. * @param shaderPath Defines the route to the shader code in one of three ways:
  109379. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  109380. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  109381. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  109382. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  109383. * @param options Define the options used to create the shader
  109384. */
  109385. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  109386. /**
  109387. * Gets the shader path used to define the shader code
  109388. * It can be modified to trigger a new compilation
  109389. */
  109390. get shaderPath(): any;
  109391. /**
  109392. * Sets the shader path used to define the shader code
  109393. * It can be modified to trigger a new compilation
  109394. */
  109395. set shaderPath(shaderPath: any);
  109396. /**
  109397. * Gets the options used to compile the shader.
  109398. * They can be modified to trigger a new compilation
  109399. */
  109400. get options(): IShaderMaterialOptions;
  109401. /**
  109402. * Gets the current class name of the material e.g. "ShaderMaterial"
  109403. * Mainly use in serialization.
  109404. * @returns the class name
  109405. */
  109406. getClassName(): string;
  109407. /**
  109408. * Specifies if the material will require alpha blending
  109409. * @returns a boolean specifying if alpha blending is needed
  109410. */
  109411. needAlphaBlending(): boolean;
  109412. /**
  109413. * Specifies if this material should be rendered in alpha test mode
  109414. * @returns a boolean specifying if an alpha test is needed.
  109415. */
  109416. needAlphaTesting(): boolean;
  109417. private _checkUniform;
  109418. /**
  109419. * Set a texture in the shader.
  109420. * @param name Define the name of the uniform samplers as defined in the shader
  109421. * @param texture Define the texture to bind to this sampler
  109422. * @return the material itself allowing "fluent" like uniform updates
  109423. */
  109424. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  109425. /**
  109426. * Set a texture array in the shader.
  109427. * @param name Define the name of the uniform sampler array as defined in the shader
  109428. * @param textures Define the list of textures to bind to this sampler
  109429. * @return the material itself allowing "fluent" like uniform updates
  109430. */
  109431. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  109432. /**
  109433. * Set a float in the shader.
  109434. * @param name Define the name of the uniform as defined in the shader
  109435. * @param value Define the value to give to the uniform
  109436. * @return the material itself allowing "fluent" like uniform updates
  109437. */
  109438. setFloat(name: string, value: number): ShaderMaterial;
  109439. /**
  109440. * Set a int in the shader.
  109441. * @param name Define the name of the uniform as defined in the shader
  109442. * @param value Define the value to give to the uniform
  109443. * @return the material itself allowing "fluent" like uniform updates
  109444. */
  109445. setInt(name: string, value: number): ShaderMaterial;
  109446. /**
  109447. * Set an array of floats in the shader.
  109448. * @param name Define the name of the uniform as defined in the shader
  109449. * @param value Define the value to give to the uniform
  109450. * @return the material itself allowing "fluent" like uniform updates
  109451. */
  109452. setFloats(name: string, value: number[]): ShaderMaterial;
  109453. /**
  109454. * Set a vec3 in the shader from a Color3.
  109455. * @param name Define the name of the uniform as defined in the shader
  109456. * @param value Define the value to give to the uniform
  109457. * @return the material itself allowing "fluent" like uniform updates
  109458. */
  109459. setColor3(name: string, value: Color3): ShaderMaterial;
  109460. /**
  109461. * Set a vec3 array in the shader from a Color3 array.
  109462. * @param name Define the name of the uniform as defined in the shader
  109463. * @param value Define the value to give to the uniform
  109464. * @return the material itself allowing "fluent" like uniform updates
  109465. */
  109466. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  109467. /**
  109468. * Set a vec4 in the shader from a Color4.
  109469. * @param name Define the name of the uniform as defined in the shader
  109470. * @param value Define the value to give to the uniform
  109471. * @return the material itself allowing "fluent" like uniform updates
  109472. */
  109473. setColor4(name: string, value: Color4): ShaderMaterial;
  109474. /**
  109475. * Set a vec4 array in the shader from a Color4 array.
  109476. * @param name Define the name of the uniform as defined in the shader
  109477. * @param value Define the value to give to the uniform
  109478. * @return the material itself allowing "fluent" like uniform updates
  109479. */
  109480. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  109481. /**
  109482. * Set a vec2 in the shader from a Vector2.
  109483. * @param name Define the name of the uniform as defined in the shader
  109484. * @param value Define the value to give to the uniform
  109485. * @return the material itself allowing "fluent" like uniform updates
  109486. */
  109487. setVector2(name: string, value: Vector2): ShaderMaterial;
  109488. /**
  109489. * Set a vec3 in the shader from a Vector3.
  109490. * @param name Define the name of the uniform as defined in the shader
  109491. * @param value Define the value to give to the uniform
  109492. * @return the material itself allowing "fluent" like uniform updates
  109493. */
  109494. setVector3(name: string, value: Vector3): ShaderMaterial;
  109495. /**
  109496. * Set a vec4 in the shader from a Vector4.
  109497. * @param name Define the name of the uniform as defined in the shader
  109498. * @param value Define the value to give to the uniform
  109499. * @return the material itself allowing "fluent" like uniform updates
  109500. */
  109501. setVector4(name: string, value: Vector4): ShaderMaterial;
  109502. /**
  109503. * Set a mat4 in the shader from a Matrix.
  109504. * @param name Define the name of the uniform as defined in the shader
  109505. * @param value Define the value to give to the uniform
  109506. * @return the material itself allowing "fluent" like uniform updates
  109507. */
  109508. setMatrix(name: string, value: Matrix): ShaderMaterial;
  109509. /**
  109510. * Set a float32Array in the shader from a matrix array.
  109511. * @param name Define the name of the uniform as defined in the shader
  109512. * @param value Define the value to give to the uniform
  109513. * @return the material itself allowing "fluent" like uniform updates
  109514. */
  109515. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  109516. /**
  109517. * Set a mat3 in the shader from a Float32Array.
  109518. * @param name Define the name of the uniform as defined in the shader
  109519. * @param value Define the value to give to the uniform
  109520. * @return the material itself allowing "fluent" like uniform updates
  109521. */
  109522. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109523. /**
  109524. * Set a mat2 in the shader from a Float32Array.
  109525. * @param name Define the name of the uniform as defined in the shader
  109526. * @param value Define the value to give to the uniform
  109527. * @return the material itself allowing "fluent" like uniform updates
  109528. */
  109529. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  109530. /**
  109531. * Set a vec2 array in the shader from a number array.
  109532. * @param name Define the name of the uniform as defined in the shader
  109533. * @param value Define the value to give to the uniform
  109534. * @return the material itself allowing "fluent" like uniform updates
  109535. */
  109536. setArray2(name: string, value: number[]): ShaderMaterial;
  109537. /**
  109538. * Set a vec3 array in the shader from a number array.
  109539. * @param name Define the name of the uniform as defined in the shader
  109540. * @param value Define the value to give to the uniform
  109541. * @return the material itself allowing "fluent" like uniform updates
  109542. */
  109543. setArray3(name: string, value: number[]): ShaderMaterial;
  109544. /**
  109545. * Set a vec4 array in the shader from a number array.
  109546. * @param name Define the name of the uniform as defined in the shader
  109547. * @param value Define the value to give to the uniform
  109548. * @return the material itself allowing "fluent" like uniform updates
  109549. */
  109550. setArray4(name: string, value: number[]): ShaderMaterial;
  109551. private _checkCache;
  109552. /**
  109553. * Specifies that the submesh is ready to be used
  109554. * @param mesh defines the mesh to check
  109555. * @param subMesh defines which submesh to check
  109556. * @param useInstances specifies that instances should be used
  109557. * @returns a boolean indicating that the submesh is ready or not
  109558. */
  109559. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  109560. /**
  109561. * Checks if the material is ready to render the requested mesh
  109562. * @param mesh Define the mesh to render
  109563. * @param useInstances Define whether or not the material is used with instances
  109564. * @returns true if ready, otherwise false
  109565. */
  109566. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  109567. /**
  109568. * Binds the world matrix to the material
  109569. * @param world defines the world transformation matrix
  109570. * @param effectOverride - If provided, use this effect instead of internal effect
  109571. */
  109572. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  109573. /**
  109574. * Binds the submesh to this material by preparing the effect and shader to draw
  109575. * @param world defines the world transformation matrix
  109576. * @param mesh defines the mesh containing the submesh
  109577. * @param subMesh defines the submesh to bind the material to
  109578. */
  109579. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  109580. /**
  109581. * Binds the material to the mesh
  109582. * @param world defines the world transformation matrix
  109583. * @param mesh defines the mesh to bind the material to
  109584. * @param effectOverride - If provided, use this effect instead of internal effect
  109585. */
  109586. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  109587. protected _afterBind(mesh?: Mesh): void;
  109588. /**
  109589. * Gets the active textures from the material
  109590. * @returns an array of textures
  109591. */
  109592. getActiveTextures(): BaseTexture[];
  109593. /**
  109594. * Specifies if the material uses a texture
  109595. * @param texture defines the texture to check against the material
  109596. * @returns a boolean specifying if the material uses the texture
  109597. */
  109598. hasTexture(texture: BaseTexture): boolean;
  109599. /**
  109600. * Makes a duplicate of the material, and gives it a new name
  109601. * @param name defines the new name for the duplicated material
  109602. * @returns the cloned material
  109603. */
  109604. clone(name: string): ShaderMaterial;
  109605. /**
  109606. * Disposes the material
  109607. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  109608. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  109609. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  109610. */
  109611. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  109612. /**
  109613. * Serializes this material in a JSON representation
  109614. * @returns the serialized material object
  109615. */
  109616. serialize(): any;
  109617. /**
  109618. * Creates a shader material from parsed shader material data
  109619. * @param source defines the JSON represnetation of the material
  109620. * @param scene defines the hosting scene
  109621. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109622. * @returns a new material
  109623. */
  109624. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  109625. /**
  109626. * Creates a new ShaderMaterial from a snippet saved in a remote file
  109627. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  109628. * @param url defines the url to load from
  109629. * @param scene defines the hosting scene
  109630. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109631. * @returns a promise that will resolve to the new ShaderMaterial
  109632. */
  109633. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109634. /**
  109635. * Creates a ShaderMaterial from a snippet saved by the Inspector
  109636. * @param snippetId defines the snippet to load
  109637. * @param scene defines the hosting scene
  109638. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  109639. * @returns a promise that will resolve to the new ShaderMaterial
  109640. */
  109641. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  109642. }
  109643. }
  109644. declare module BABYLON {
  109645. /** @hidden */
  109646. export var colorPixelShader: {
  109647. name: string;
  109648. shader: string;
  109649. };
  109650. }
  109651. declare module BABYLON {
  109652. /** @hidden */
  109653. export var colorVertexShader: {
  109654. name: string;
  109655. shader: string;
  109656. };
  109657. }
  109658. declare module BABYLON {
  109659. /**
  109660. * Line mesh
  109661. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  109662. */
  109663. export class LinesMesh extends Mesh {
  109664. /**
  109665. * If vertex color should be applied to the mesh
  109666. */
  109667. readonly useVertexColor?: boolean | undefined;
  109668. /**
  109669. * If vertex alpha should be applied to the mesh
  109670. */
  109671. readonly useVertexAlpha?: boolean | undefined;
  109672. /**
  109673. * Color of the line (Default: White)
  109674. */
  109675. color: Color3;
  109676. /**
  109677. * Alpha of the line (Default: 1)
  109678. */
  109679. alpha: number;
  109680. /**
  109681. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109682. * This margin is expressed in world space coordinates, so its value may vary.
  109683. * Default value is 0.1
  109684. */
  109685. intersectionThreshold: number;
  109686. private _colorShader;
  109687. private color4;
  109688. /**
  109689. * Creates a new LinesMesh
  109690. * @param name defines the name
  109691. * @param scene defines the hosting scene
  109692. * @param parent defines the parent mesh if any
  109693. * @param source defines the optional source LinesMesh used to clone data from
  109694. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  109695. * When false, achieved by calling a clone(), also passing False.
  109696. * This will make creation of children, recursive.
  109697. * @param useVertexColor defines if this LinesMesh supports vertex color
  109698. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  109699. */
  109700. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  109701. /**
  109702. * If vertex color should be applied to the mesh
  109703. */
  109704. useVertexColor?: boolean | undefined,
  109705. /**
  109706. * If vertex alpha should be applied to the mesh
  109707. */
  109708. useVertexAlpha?: boolean | undefined);
  109709. private _addClipPlaneDefine;
  109710. private _removeClipPlaneDefine;
  109711. isReady(): boolean;
  109712. /**
  109713. * Returns the string "LineMesh"
  109714. */
  109715. getClassName(): string;
  109716. /**
  109717. * @hidden
  109718. */
  109719. get material(): Material;
  109720. /**
  109721. * @hidden
  109722. */
  109723. set material(value: Material);
  109724. /**
  109725. * @hidden
  109726. */
  109727. get checkCollisions(): boolean;
  109728. /** @hidden */
  109729. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109730. /** @hidden */
  109731. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109732. /**
  109733. * Disposes of the line mesh
  109734. * @param doNotRecurse If children should be disposed
  109735. */
  109736. dispose(doNotRecurse?: boolean): void;
  109737. /**
  109738. * Returns a new LineMesh object cloned from the current one.
  109739. */
  109740. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  109741. /**
  109742. * Creates a new InstancedLinesMesh object from the mesh model.
  109743. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109744. * @param name defines the name of the new instance
  109745. * @returns a new InstancedLinesMesh
  109746. */
  109747. createInstance(name: string): InstancedLinesMesh;
  109748. }
  109749. /**
  109750. * Creates an instance based on a source LinesMesh
  109751. */
  109752. export class InstancedLinesMesh extends InstancedMesh {
  109753. /**
  109754. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  109755. * This margin is expressed in world space coordinates, so its value may vary.
  109756. * Initilized with the intersectionThreshold value of the source LinesMesh
  109757. */
  109758. intersectionThreshold: number;
  109759. constructor(name: string, source: LinesMesh);
  109760. /**
  109761. * Returns the string "InstancedLinesMesh".
  109762. */
  109763. getClassName(): string;
  109764. }
  109765. }
  109766. declare module BABYLON {
  109767. /** @hidden */
  109768. export var linePixelShader: {
  109769. name: string;
  109770. shader: string;
  109771. };
  109772. }
  109773. declare module BABYLON {
  109774. /** @hidden */
  109775. export var lineVertexShader: {
  109776. name: string;
  109777. shader: string;
  109778. };
  109779. }
  109780. declare module BABYLON {
  109781. interface Scene {
  109782. /** @hidden */
  109783. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  109784. }
  109785. interface AbstractMesh {
  109786. /**
  109787. * Gets the edgesRenderer associated with the mesh
  109788. */
  109789. edgesRenderer: Nullable<EdgesRenderer>;
  109790. }
  109791. interface LinesMesh {
  109792. /**
  109793. * Enables the edge rendering mode on the mesh.
  109794. * This mode makes the mesh edges visible
  109795. * @param epsilon defines the maximal distance between two angles to detect a face
  109796. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109797. * @returns the currentAbstractMesh
  109798. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109799. */
  109800. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  109801. }
  109802. interface InstancedLinesMesh {
  109803. /**
  109804. * Enables the edge rendering mode on the mesh.
  109805. * This mode makes the mesh edges visible
  109806. * @param epsilon defines the maximal distance between two angles to detect a face
  109807. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  109808. * @returns the current InstancedLinesMesh
  109809. * @see https://www.babylonjs-playground.com/#19O9TU#0
  109810. */
  109811. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  109812. }
  109813. /**
  109814. * Defines the minimum contract an Edges renderer should follow.
  109815. */
  109816. export interface IEdgesRenderer extends IDisposable {
  109817. /**
  109818. * Gets or sets a boolean indicating if the edgesRenderer is active
  109819. */
  109820. isEnabled: boolean;
  109821. /**
  109822. * Renders the edges of the attached mesh,
  109823. */
  109824. render(): void;
  109825. /**
  109826. * Checks wether or not the edges renderer is ready to render.
  109827. * @return true if ready, otherwise false.
  109828. */
  109829. isReady(): boolean;
  109830. /**
  109831. * List of instances to render in case the source mesh has instances
  109832. */
  109833. customInstances: SmartArray<Matrix>;
  109834. }
  109835. /**
  109836. * Defines the additional options of the edges renderer
  109837. */
  109838. export interface IEdgesRendererOptions {
  109839. /**
  109840. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  109841. * If not defined, the default value is true
  109842. */
  109843. useAlternateEdgeFinder?: boolean;
  109844. /**
  109845. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  109846. * If not defined, the default value is true.
  109847. * 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)
  109848. * This option is used only if useAlternateEdgeFinder = true
  109849. */
  109850. useFastVertexMerger?: boolean;
  109851. /**
  109852. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  109853. * The default value is 1e-6
  109854. * This option is used only if useAlternateEdgeFinder = true
  109855. */
  109856. epsilonVertexMerge?: number;
  109857. /**
  109858. * 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
  109859. * 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.
  109860. * This option is used only if useAlternateEdgeFinder = true
  109861. */
  109862. applyTessellation?: boolean;
  109863. /**
  109864. * 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
  109865. * The default value is 1e-6
  109866. * This option is used only if useAlternateEdgeFinder = true
  109867. */
  109868. epsilonVertexAligned?: number;
  109869. }
  109870. /**
  109871. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  109872. */
  109873. export class EdgesRenderer implements IEdgesRenderer {
  109874. /**
  109875. * Define the size of the edges with an orthographic camera
  109876. */
  109877. edgesWidthScalerForOrthographic: number;
  109878. /**
  109879. * Define the size of the edges with a perspective camera
  109880. */
  109881. edgesWidthScalerForPerspective: number;
  109882. protected _source: AbstractMesh;
  109883. protected _linesPositions: number[];
  109884. protected _linesNormals: number[];
  109885. protected _linesIndices: number[];
  109886. protected _epsilon: number;
  109887. protected _indicesCount: number;
  109888. protected _lineShader: ShaderMaterial;
  109889. protected _ib: DataBuffer;
  109890. protected _buffers: {
  109891. [key: string]: Nullable<VertexBuffer>;
  109892. };
  109893. protected _buffersForInstances: {
  109894. [key: string]: Nullable<VertexBuffer>;
  109895. };
  109896. protected _checkVerticesInsteadOfIndices: boolean;
  109897. protected _options: Nullable<IEdgesRendererOptions>;
  109898. private _meshRebuildObserver;
  109899. private _meshDisposeObserver;
  109900. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  109901. isEnabled: boolean;
  109902. /** Gets the vertices generated by the edge renderer */
  109903. get linesPositions(): Immutable<Array<number>>;
  109904. /** Gets the normals generated by the edge renderer */
  109905. get linesNormals(): Immutable<Array<number>>;
  109906. /** Gets the indices generated by the edge renderer */
  109907. get linesIndices(): Immutable<Array<number>>;
  109908. /**
  109909. * List of instances to render in case the source mesh has instances
  109910. */
  109911. customInstances: SmartArray<Matrix>;
  109912. private static GetShader;
  109913. /**
  109914. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  109915. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  109916. * @param source Mesh used to create edges
  109917. * @param epsilon sum of angles in adjacency to check for edge
  109918. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  109919. * @param generateEdgesLines - should generate Lines or only prepare resources.
  109920. * @param options The options to apply when generating the edges
  109921. */
  109922. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  109923. protected _prepareRessources(): void;
  109924. /** @hidden */
  109925. _rebuild(): void;
  109926. /**
  109927. * Releases the required resources for the edges renderer
  109928. */
  109929. dispose(): void;
  109930. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  109931. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  109932. /**
  109933. * Checks if the pair of p0 and p1 is en edge
  109934. * @param faceIndex
  109935. * @param edge
  109936. * @param faceNormals
  109937. * @param p0
  109938. * @param p1
  109939. * @private
  109940. */
  109941. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  109942. /**
  109943. * push line into the position, normal and index buffer
  109944. * @protected
  109945. */
  109946. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  109947. /**
  109948. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  109949. */
  109950. private _tessellateTriangle;
  109951. private _generateEdgesLinesAlternate;
  109952. /**
  109953. * Generates lines edges from adjacencjes
  109954. * @private
  109955. */
  109956. _generateEdgesLines(): void;
  109957. /**
  109958. * Checks wether or not the edges renderer is ready to render.
  109959. * @return true if ready, otherwise false.
  109960. */
  109961. isReady(): boolean;
  109962. /**
  109963. * Renders the edges of the attached mesh,
  109964. */
  109965. render(): void;
  109966. }
  109967. /**
  109968. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  109969. */
  109970. export class LineEdgesRenderer extends EdgesRenderer {
  109971. /**
  109972. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  109973. * @param source LineMesh used to generate edges
  109974. * @param epsilon not important (specified angle for edge detection)
  109975. * @param checkVerticesInsteadOfIndices not important for LineMesh
  109976. */
  109977. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  109978. /**
  109979. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  109980. */
  109981. _generateEdgesLines(): void;
  109982. }
  109983. }
  109984. declare module BABYLON {
  109985. /**
  109986. * This represents the object necessary to create a rendering group.
  109987. * This is exclusively used and created by the rendering manager.
  109988. * To modify the behavior, you use the available helpers in your scene or meshes.
  109989. * @hidden
  109990. */
  109991. export class RenderingGroup {
  109992. index: number;
  109993. private static _zeroVector;
  109994. private _scene;
  109995. private _opaqueSubMeshes;
  109996. private _transparentSubMeshes;
  109997. private _alphaTestSubMeshes;
  109998. private _depthOnlySubMeshes;
  109999. private _particleSystems;
  110000. private _spriteManagers;
  110001. private _opaqueSortCompareFn;
  110002. private _alphaTestSortCompareFn;
  110003. private _transparentSortCompareFn;
  110004. private _renderOpaque;
  110005. private _renderAlphaTest;
  110006. private _renderTransparent;
  110007. /** @hidden */
  110008. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  110009. onBeforeTransparentRendering: () => void;
  110010. /**
  110011. * Set the opaque sort comparison function.
  110012. * If null the sub meshes will be render in the order they were created
  110013. */
  110014. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110015. /**
  110016. * Set the alpha test sort comparison function.
  110017. * If null the sub meshes will be render in the order they were created
  110018. */
  110019. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110020. /**
  110021. * Set the transparent sort comparison function.
  110022. * If null the sub meshes will be render in the order they were created
  110023. */
  110024. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  110025. /**
  110026. * Creates a new rendering group.
  110027. * @param index The rendering group index
  110028. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  110029. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  110030. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  110031. */
  110032. 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>);
  110033. /**
  110034. * Render all the sub meshes contained in the group.
  110035. * @param customRenderFunction Used to override the default render behaviour of the group.
  110036. * @returns true if rendered some submeshes.
  110037. */
  110038. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  110039. /**
  110040. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  110041. * @param subMeshes The submeshes to render
  110042. */
  110043. private renderOpaqueSorted;
  110044. /**
  110045. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  110046. * @param subMeshes The submeshes to render
  110047. */
  110048. private renderAlphaTestSorted;
  110049. /**
  110050. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  110051. * @param subMeshes The submeshes to render
  110052. */
  110053. private renderTransparentSorted;
  110054. /**
  110055. * Renders the submeshes in a specified order.
  110056. * @param subMeshes The submeshes to sort before render
  110057. * @param sortCompareFn The comparison function use to sort
  110058. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  110059. * @param transparent Specifies to activate blending if true
  110060. */
  110061. private static renderSorted;
  110062. /**
  110063. * Renders the submeshes in the order they were dispatched (no sort applied).
  110064. * @param subMeshes The submeshes to render
  110065. */
  110066. private static renderUnsorted;
  110067. /**
  110068. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110069. * are rendered back to front if in the same alpha index.
  110070. *
  110071. * @param a The first submesh
  110072. * @param b The second submesh
  110073. * @returns The result of the comparison
  110074. */
  110075. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  110076. /**
  110077. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110078. * are rendered back to front.
  110079. *
  110080. * @param a The first submesh
  110081. * @param b The second submesh
  110082. * @returns The result of the comparison
  110083. */
  110084. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  110085. /**
  110086. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  110087. * are rendered front to back (prevent overdraw).
  110088. *
  110089. * @param a The first submesh
  110090. * @param b The second submesh
  110091. * @returns The result of the comparison
  110092. */
  110093. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  110094. /**
  110095. * Resets the different lists of submeshes to prepare a new frame.
  110096. */
  110097. prepare(): void;
  110098. dispose(): void;
  110099. /**
  110100. * Inserts the submesh in its correct queue depending on its material.
  110101. * @param subMesh The submesh to dispatch
  110102. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110103. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110104. */
  110105. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110106. dispatchSprites(spriteManager: ISpriteManager): void;
  110107. dispatchParticles(particleSystem: IParticleSystem): void;
  110108. private _renderParticles;
  110109. private _renderSprites;
  110110. }
  110111. }
  110112. declare module BABYLON {
  110113. /**
  110114. * Interface describing the different options available in the rendering manager
  110115. * regarding Auto Clear between groups.
  110116. */
  110117. export interface IRenderingManagerAutoClearSetup {
  110118. /**
  110119. * Defines whether or not autoclear is enable.
  110120. */
  110121. autoClear: boolean;
  110122. /**
  110123. * Defines whether or not to autoclear the depth buffer.
  110124. */
  110125. depth: boolean;
  110126. /**
  110127. * Defines whether or not to autoclear the stencil buffer.
  110128. */
  110129. stencil: boolean;
  110130. }
  110131. /**
  110132. * This class is used by the onRenderingGroupObservable
  110133. */
  110134. export class RenderingGroupInfo {
  110135. /**
  110136. * The Scene that being rendered
  110137. */
  110138. scene: Scene;
  110139. /**
  110140. * The camera currently used for the rendering pass
  110141. */
  110142. camera: Nullable<Camera>;
  110143. /**
  110144. * The ID of the renderingGroup being processed
  110145. */
  110146. renderingGroupId: number;
  110147. }
  110148. /**
  110149. * This is the manager responsible of all the rendering for meshes sprites and particles.
  110150. * It is enable to manage the different groups as well as the different necessary sort functions.
  110151. * This should not be used directly aside of the few static configurations
  110152. */
  110153. export class RenderingManager {
  110154. /**
  110155. * The max id used for rendering groups (not included)
  110156. */
  110157. static MAX_RENDERINGGROUPS: number;
  110158. /**
  110159. * The min id used for rendering groups (included)
  110160. */
  110161. static MIN_RENDERINGGROUPS: number;
  110162. /**
  110163. * Used to globally prevent autoclearing scenes.
  110164. */
  110165. static AUTOCLEAR: boolean;
  110166. /**
  110167. * @hidden
  110168. */
  110169. _useSceneAutoClearSetup: boolean;
  110170. private _scene;
  110171. private _renderingGroups;
  110172. private _depthStencilBufferAlreadyCleaned;
  110173. private _autoClearDepthStencil;
  110174. private _customOpaqueSortCompareFn;
  110175. private _customAlphaTestSortCompareFn;
  110176. private _customTransparentSortCompareFn;
  110177. private _renderingGroupInfo;
  110178. /**
  110179. * Instantiates a new rendering group for a particular scene
  110180. * @param scene Defines the scene the groups belongs to
  110181. */
  110182. constructor(scene: Scene);
  110183. private _clearDepthStencilBuffer;
  110184. /**
  110185. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  110186. * @hidden
  110187. */
  110188. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  110189. /**
  110190. * Resets the different information of the group to prepare a new frame
  110191. * @hidden
  110192. */
  110193. reset(): void;
  110194. /**
  110195. * Dispose and release the group and its associated resources.
  110196. * @hidden
  110197. */
  110198. dispose(): void;
  110199. /**
  110200. * Clear the info related to rendering groups preventing retention points during dispose.
  110201. */
  110202. freeRenderingGroups(): void;
  110203. private _prepareRenderingGroup;
  110204. /**
  110205. * Add a sprite manager to the rendering manager in order to render it this frame.
  110206. * @param spriteManager Define the sprite manager to render
  110207. */
  110208. dispatchSprites(spriteManager: ISpriteManager): void;
  110209. /**
  110210. * Add a particle system to the rendering manager in order to render it this frame.
  110211. * @param particleSystem Define the particle system to render
  110212. */
  110213. dispatchParticles(particleSystem: IParticleSystem): void;
  110214. /**
  110215. * Add a submesh to the manager in order to render it this frame
  110216. * @param subMesh The submesh to dispatch
  110217. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  110218. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  110219. */
  110220. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  110221. /**
  110222. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110223. * This allowed control for front to back rendering or reversly depending of the special needs.
  110224. *
  110225. * @param renderingGroupId The rendering group id corresponding to its index
  110226. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110227. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110228. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110229. */
  110230. 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;
  110231. /**
  110232. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110233. *
  110234. * @param renderingGroupId The rendering group id corresponding to its index
  110235. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110236. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110237. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110238. */
  110239. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110240. /**
  110241. * Gets the current auto clear configuration for one rendering group of the rendering
  110242. * manager.
  110243. * @param index the rendering group index to get the information for
  110244. * @returns The auto clear setup for the requested rendering group
  110245. */
  110246. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110247. }
  110248. }
  110249. declare module BABYLON {
  110250. /**
  110251. * Defines the options associated with the creation of a custom shader for a shadow generator.
  110252. */
  110253. export interface ICustomShaderOptions {
  110254. /**
  110255. * Gets or sets the custom shader name to use
  110256. */
  110257. shaderName: string;
  110258. /**
  110259. * The list of attribute names used in the shader
  110260. */
  110261. attributes?: string[];
  110262. /**
  110263. * The list of unifrom names used in the shader
  110264. */
  110265. uniforms?: string[];
  110266. /**
  110267. * The list of sampler names used in the shader
  110268. */
  110269. samplers?: string[];
  110270. /**
  110271. * The list of defines used in the shader
  110272. */
  110273. defines?: string[];
  110274. }
  110275. /**
  110276. * Interface to implement to create a shadow generator compatible with BJS.
  110277. */
  110278. export interface IShadowGenerator {
  110279. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110280. id: string;
  110281. /**
  110282. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110283. * @returns The render target texture if present otherwise, null
  110284. */
  110285. getShadowMap(): Nullable<RenderTargetTexture>;
  110286. /**
  110287. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110288. * @param subMesh The submesh we want to render in the shadow map
  110289. * @param useInstances Defines wether will draw in the map using instances
  110290. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110291. * @returns true if ready otherwise, false
  110292. */
  110293. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110294. /**
  110295. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110296. * @param defines Defines of the material we want to update
  110297. * @param lightIndex Index of the light in the enabled light list of the material
  110298. */
  110299. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  110300. /**
  110301. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110302. * defined in the generator but impacting the effect).
  110303. * It implies the unifroms available on the materials are the standard BJS ones.
  110304. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110305. * @param effect The effect we are binfing the information for
  110306. */
  110307. bindShadowLight(lightIndex: string, effect: Effect): void;
  110308. /**
  110309. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110310. * (eq to shadow prjection matrix * light transform matrix)
  110311. * @returns The transform matrix used to create the shadow map
  110312. */
  110313. getTransformMatrix(): Matrix;
  110314. /**
  110315. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110316. * Cube and 2D textures for instance.
  110317. */
  110318. recreateShadowMap(): void;
  110319. /**
  110320. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110321. * @param onCompiled Callback triggered at the and of the effects compilation
  110322. * @param options Sets of optional options forcing the compilation with different modes
  110323. */
  110324. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110325. useInstances: boolean;
  110326. }>): void;
  110327. /**
  110328. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110329. * @param options Sets of optional options forcing the compilation with different modes
  110330. * @returns A promise that resolves when the compilation completes
  110331. */
  110332. forceCompilationAsync(options?: Partial<{
  110333. useInstances: boolean;
  110334. }>): Promise<void>;
  110335. /**
  110336. * Serializes the shadow generator setup to a json object.
  110337. * @returns The serialized JSON object
  110338. */
  110339. serialize(): any;
  110340. /**
  110341. * Disposes the Shadow map and related Textures and effects.
  110342. */
  110343. dispose(): void;
  110344. }
  110345. /**
  110346. * Default implementation IShadowGenerator.
  110347. * This is the main object responsible of generating shadows in the framework.
  110348. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  110349. */
  110350. export class ShadowGenerator implements IShadowGenerator {
  110351. /**
  110352. * Name of the shadow generator class
  110353. */
  110354. static CLASSNAME: string;
  110355. /**
  110356. * Shadow generator mode None: no filtering applied.
  110357. */
  110358. static readonly FILTER_NONE: number;
  110359. /**
  110360. * Shadow generator mode ESM: Exponential Shadow Mapping.
  110361. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110362. */
  110363. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  110364. /**
  110365. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  110366. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  110367. */
  110368. static readonly FILTER_POISSONSAMPLING: number;
  110369. /**
  110370. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  110371. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110372. */
  110373. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  110374. /**
  110375. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  110376. * edge artifacts on steep falloff.
  110377. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110378. */
  110379. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  110380. /**
  110381. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  110382. * edge artifacts on steep falloff.
  110383. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  110384. */
  110385. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  110386. /**
  110387. * Shadow generator mode PCF: Percentage Closer Filtering
  110388. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110389. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  110390. */
  110391. static readonly FILTER_PCF: number;
  110392. /**
  110393. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  110394. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  110395. * Contact Hardening
  110396. */
  110397. static readonly FILTER_PCSS: number;
  110398. /**
  110399. * Reserved for PCF and PCSS
  110400. * Highest Quality.
  110401. *
  110402. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  110403. *
  110404. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  110405. */
  110406. static readonly QUALITY_HIGH: number;
  110407. /**
  110408. * Reserved for PCF and PCSS
  110409. * Good tradeoff for quality/perf cross devices
  110410. *
  110411. * Execute PCF on a 3*3 kernel.
  110412. *
  110413. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  110414. */
  110415. static readonly QUALITY_MEDIUM: number;
  110416. /**
  110417. * Reserved for PCF and PCSS
  110418. * The lowest quality but the fastest.
  110419. *
  110420. * Execute PCF on a 1*1 kernel.
  110421. *
  110422. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  110423. */
  110424. static readonly QUALITY_LOW: number;
  110425. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  110426. id: string;
  110427. /** Gets or sets the custom shader name to use */
  110428. customShaderOptions: ICustomShaderOptions;
  110429. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  110430. customAllowRendering: (subMesh: SubMesh) => boolean;
  110431. /**
  110432. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  110433. */
  110434. onBeforeShadowMapRenderObservable: Observable<Effect>;
  110435. /**
  110436. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  110437. */
  110438. onAfterShadowMapRenderObservable: Observable<Effect>;
  110439. /**
  110440. * Observable triggered before a mesh is rendered in the shadow map.
  110441. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  110442. */
  110443. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  110444. /**
  110445. * Observable triggered after a mesh is rendered in the shadow map.
  110446. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  110447. */
  110448. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  110449. protected _bias: number;
  110450. /**
  110451. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  110452. */
  110453. get bias(): number;
  110454. /**
  110455. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  110456. */
  110457. set bias(bias: number);
  110458. protected _normalBias: number;
  110459. /**
  110460. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110461. */
  110462. get normalBias(): number;
  110463. /**
  110464. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  110465. */
  110466. set normalBias(normalBias: number);
  110467. protected _blurBoxOffset: number;
  110468. /**
  110469. * Gets the blur box offset: offset applied during the blur pass.
  110470. * Only useful if useKernelBlur = false
  110471. */
  110472. get blurBoxOffset(): number;
  110473. /**
  110474. * Sets the blur box offset: offset applied during the blur pass.
  110475. * Only useful if useKernelBlur = false
  110476. */
  110477. set blurBoxOffset(value: number);
  110478. protected _blurScale: number;
  110479. /**
  110480. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  110481. * 2 means half of the size.
  110482. */
  110483. get blurScale(): number;
  110484. /**
  110485. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  110486. * 2 means half of the size.
  110487. */
  110488. set blurScale(value: number);
  110489. protected _blurKernel: number;
  110490. /**
  110491. * Gets the blur kernel: kernel size of the blur pass.
  110492. * Only useful if useKernelBlur = true
  110493. */
  110494. get blurKernel(): number;
  110495. /**
  110496. * Sets the blur kernel: kernel size of the blur pass.
  110497. * Only useful if useKernelBlur = true
  110498. */
  110499. set blurKernel(value: number);
  110500. protected _useKernelBlur: boolean;
  110501. /**
  110502. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  110503. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110504. */
  110505. get useKernelBlur(): boolean;
  110506. /**
  110507. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  110508. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  110509. */
  110510. set useKernelBlur(value: boolean);
  110511. protected _depthScale: number;
  110512. /**
  110513. * Gets the depth scale used in ESM mode.
  110514. */
  110515. get depthScale(): number;
  110516. /**
  110517. * Sets the depth scale used in ESM mode.
  110518. * This can override the scale stored on the light.
  110519. */
  110520. set depthScale(value: number);
  110521. protected _validateFilter(filter: number): number;
  110522. protected _filter: number;
  110523. /**
  110524. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  110525. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110526. */
  110527. get filter(): number;
  110528. /**
  110529. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  110530. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  110531. */
  110532. set filter(value: number);
  110533. /**
  110534. * Gets if the current filter is set to Poisson Sampling.
  110535. */
  110536. get usePoissonSampling(): boolean;
  110537. /**
  110538. * Sets the current filter to Poisson Sampling.
  110539. */
  110540. set usePoissonSampling(value: boolean);
  110541. /**
  110542. * Gets if the current filter is set to ESM.
  110543. */
  110544. get useExponentialShadowMap(): boolean;
  110545. /**
  110546. * Sets the current filter is to ESM.
  110547. */
  110548. set useExponentialShadowMap(value: boolean);
  110549. /**
  110550. * Gets if the current filter is set to filtered ESM.
  110551. */
  110552. get useBlurExponentialShadowMap(): boolean;
  110553. /**
  110554. * Gets if the current filter is set to filtered ESM.
  110555. */
  110556. set useBlurExponentialShadowMap(value: boolean);
  110557. /**
  110558. * Gets if the current filter is set to "close ESM" (using the inverse of the
  110559. * exponential to prevent steep falloff artifacts).
  110560. */
  110561. get useCloseExponentialShadowMap(): boolean;
  110562. /**
  110563. * Sets the current filter to "close ESM" (using the inverse of the
  110564. * exponential to prevent steep falloff artifacts).
  110565. */
  110566. set useCloseExponentialShadowMap(value: boolean);
  110567. /**
  110568. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  110569. * exponential to prevent steep falloff artifacts).
  110570. */
  110571. get useBlurCloseExponentialShadowMap(): boolean;
  110572. /**
  110573. * Sets the current filter to filtered "close ESM" (using the inverse of the
  110574. * exponential to prevent steep falloff artifacts).
  110575. */
  110576. set useBlurCloseExponentialShadowMap(value: boolean);
  110577. /**
  110578. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  110579. */
  110580. get usePercentageCloserFiltering(): boolean;
  110581. /**
  110582. * Sets the current filter to "PCF" (percentage closer filtering).
  110583. */
  110584. set usePercentageCloserFiltering(value: boolean);
  110585. protected _filteringQuality: number;
  110586. /**
  110587. * Gets the PCF or PCSS Quality.
  110588. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110589. */
  110590. get filteringQuality(): number;
  110591. /**
  110592. * Sets the PCF or PCSS Quality.
  110593. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  110594. */
  110595. set filteringQuality(filteringQuality: number);
  110596. /**
  110597. * Gets if the current filter is set to "PCSS" (contact hardening).
  110598. */
  110599. get useContactHardeningShadow(): boolean;
  110600. /**
  110601. * Sets the current filter to "PCSS" (contact hardening).
  110602. */
  110603. set useContactHardeningShadow(value: boolean);
  110604. protected _contactHardeningLightSizeUVRatio: number;
  110605. /**
  110606. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110607. * Using a ratio helps keeping shape stability independently of the map size.
  110608. *
  110609. * It does not account for the light projection as it was having too much
  110610. * instability during the light setup or during light position changes.
  110611. *
  110612. * Only valid if useContactHardeningShadow is true.
  110613. */
  110614. get contactHardeningLightSizeUVRatio(): number;
  110615. /**
  110616. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  110617. * Using a ratio helps keeping shape stability independently of the map size.
  110618. *
  110619. * It does not account for the light projection as it was having too much
  110620. * instability during the light setup or during light position changes.
  110621. *
  110622. * Only valid if useContactHardeningShadow is true.
  110623. */
  110624. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  110625. protected _darkness: number;
  110626. /** Gets or sets the actual darkness of a shadow */
  110627. get darkness(): number;
  110628. set darkness(value: number);
  110629. /**
  110630. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  110631. * 0 means strongest and 1 would means no shadow.
  110632. * @returns the darkness.
  110633. */
  110634. getDarkness(): number;
  110635. /**
  110636. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  110637. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  110638. * @returns the shadow generator allowing fluent coding.
  110639. */
  110640. setDarkness(darkness: number): ShadowGenerator;
  110641. protected _transparencyShadow: boolean;
  110642. /** Gets or sets the ability to have transparent shadow */
  110643. get transparencyShadow(): boolean;
  110644. set transparencyShadow(value: boolean);
  110645. /**
  110646. * Sets the ability to have transparent shadow (boolean).
  110647. * @param transparent True if transparent else False
  110648. * @returns the shadow generator allowing fluent coding
  110649. */
  110650. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  110651. /**
  110652. * Enables or disables shadows with varying strength based on the transparency
  110653. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  110654. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  110655. * mesh.visibility * alphaTexture.a
  110656. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  110657. */
  110658. enableSoftTransparentShadow: boolean;
  110659. protected _shadowMap: Nullable<RenderTargetTexture>;
  110660. protected _shadowMap2: Nullable<RenderTargetTexture>;
  110661. /**
  110662. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  110663. * @returns The render target texture if present otherwise, null
  110664. */
  110665. getShadowMap(): Nullable<RenderTargetTexture>;
  110666. /**
  110667. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  110668. * @returns The render target texture if the shadow map is present otherwise, null
  110669. */
  110670. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  110671. /**
  110672. * Gets the class name of that object
  110673. * @returns "ShadowGenerator"
  110674. */
  110675. getClassName(): string;
  110676. /**
  110677. * Helper function to add a mesh and its descendants to the list of shadow casters.
  110678. * @param mesh Mesh to add
  110679. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  110680. * @returns the Shadow Generator itself
  110681. */
  110682. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110683. /**
  110684. * Helper function to remove a mesh and its descendants from the list of shadow casters
  110685. * @param mesh Mesh to remove
  110686. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  110687. * @returns the Shadow Generator itself
  110688. */
  110689. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  110690. /**
  110691. * Controls the extent to which the shadows fade out at the edge of the frustum
  110692. */
  110693. frustumEdgeFalloff: number;
  110694. protected _light: IShadowLight;
  110695. /**
  110696. * Returns the associated light object.
  110697. * @returns the light generating the shadow
  110698. */
  110699. getLight(): IShadowLight;
  110700. /**
  110701. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  110702. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  110703. * It might on the other hand introduce peter panning.
  110704. */
  110705. forceBackFacesOnly: boolean;
  110706. protected _scene: Scene;
  110707. protected _lightDirection: Vector3;
  110708. protected _effect: Effect;
  110709. protected _viewMatrix: Matrix;
  110710. protected _projectionMatrix: Matrix;
  110711. protected _transformMatrix: Matrix;
  110712. protected _cachedPosition: Vector3;
  110713. protected _cachedDirection: Vector3;
  110714. protected _cachedDefines: string;
  110715. protected _currentRenderID: number;
  110716. protected _boxBlurPostprocess: Nullable<PostProcess>;
  110717. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  110718. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  110719. protected _blurPostProcesses: PostProcess[];
  110720. protected _mapSize: number;
  110721. protected _currentFaceIndex: number;
  110722. protected _currentFaceIndexCache: number;
  110723. protected _textureType: number;
  110724. protected _defaultTextureMatrix: Matrix;
  110725. protected _storedUniqueId: Nullable<number>;
  110726. /** @hidden */
  110727. static _SceneComponentInitialization: (scene: Scene) => void;
  110728. /**
  110729. * Gets or sets the size of the texture what stores the shadows
  110730. */
  110731. get mapSize(): number;
  110732. set mapSize(size: number);
  110733. /**
  110734. * Creates a ShadowGenerator object.
  110735. * A ShadowGenerator is the required tool to use the shadows.
  110736. * Each light casting shadows needs to use its own ShadowGenerator.
  110737. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  110738. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  110739. * @param light The light object generating the shadows.
  110740. * @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.
  110741. */
  110742. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  110743. protected _initializeGenerator(): void;
  110744. protected _createTargetRenderTexture(): void;
  110745. protected _initializeShadowMap(): void;
  110746. protected _initializeBlurRTTAndPostProcesses(): void;
  110747. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  110748. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  110749. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  110750. protected _applyFilterValues(): void;
  110751. /**
  110752. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110753. * @param onCompiled Callback triggered at the and of the effects compilation
  110754. * @param options Sets of optional options forcing the compilation with different modes
  110755. */
  110756. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  110757. useInstances: boolean;
  110758. }>): void;
  110759. /**
  110760. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  110761. * @param options Sets of optional options forcing the compilation with different modes
  110762. * @returns A promise that resolves when the compilation completes
  110763. */
  110764. forceCompilationAsync(options?: Partial<{
  110765. useInstances: boolean;
  110766. }>): Promise<void>;
  110767. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  110768. private _prepareShadowDefines;
  110769. /**
  110770. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  110771. * @param subMesh The submesh we want to render in the shadow map
  110772. * @param useInstances Defines wether will draw in the map using instances
  110773. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  110774. * @returns true if ready otherwise, false
  110775. */
  110776. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  110777. /**
  110778. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  110779. * @param defines Defines of the material we want to update
  110780. * @param lightIndex Index of the light in the enabled light list of the material
  110781. */
  110782. prepareDefines(defines: any, lightIndex: number): void;
  110783. /**
  110784. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  110785. * defined in the generator but impacting the effect).
  110786. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  110787. * @param effect The effect we are binfing the information for
  110788. */
  110789. bindShadowLight(lightIndex: string, effect: Effect): void;
  110790. /**
  110791. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  110792. * (eq to shadow prjection matrix * light transform matrix)
  110793. * @returns The transform matrix used to create the shadow map
  110794. */
  110795. getTransformMatrix(): Matrix;
  110796. /**
  110797. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  110798. * Cube and 2D textures for instance.
  110799. */
  110800. recreateShadowMap(): void;
  110801. protected _disposeBlurPostProcesses(): void;
  110802. protected _disposeRTTandPostProcesses(): void;
  110803. /**
  110804. * Disposes the ShadowGenerator.
  110805. * Returns nothing.
  110806. */
  110807. dispose(): void;
  110808. /**
  110809. * Serializes the shadow generator setup to a json object.
  110810. * @returns The serialized JSON object
  110811. */
  110812. serialize(): any;
  110813. /**
  110814. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  110815. * @param parsedShadowGenerator The JSON object to parse
  110816. * @param scene The scene to create the shadow map for
  110817. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  110818. * @returns The parsed shadow generator
  110819. */
  110820. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  110821. }
  110822. }
  110823. declare module BABYLON {
  110824. /**
  110825. * Options to be used when creating a shadow depth material
  110826. */
  110827. export interface IIOptionShadowDepthMaterial {
  110828. /** Variables in the vertex shader code that need to have their names remapped.
  110829. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110830. * "var_name" should be either: worldPos or vNormalW
  110831. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110832. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110833. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110834. */
  110835. remappedVariables?: string[];
  110836. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110837. standalone?: boolean;
  110838. }
  110839. /**
  110840. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110841. */
  110842. export class ShadowDepthWrapper {
  110843. private _scene;
  110844. private _options?;
  110845. private _baseMaterial;
  110846. private _onEffectCreatedObserver;
  110847. private _subMeshToEffect;
  110848. private _subMeshToDepthEffect;
  110849. private _meshes;
  110850. /** @hidden */
  110851. _matriceNames: any;
  110852. /** Gets the standalone status of the wrapper */
  110853. get standalone(): boolean;
  110854. /** Gets the base material the wrapper is built upon */
  110855. get baseMaterial(): Material;
  110856. /**
  110857. * Instantiate a new shadow depth wrapper.
  110858. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110859. * generate the shadow depth map. For more information, please refer to the documentation:
  110860. * https://doc.babylonjs.com/babylon101/shadows
  110861. * @param baseMaterial Material to wrap
  110862. * @param scene Define the scene the material belongs to
  110863. * @param options Options used to create the wrapper
  110864. */
  110865. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110866. /**
  110867. * Gets the effect to use to generate the depth map
  110868. * @param subMesh subMesh to get the effect for
  110869. * @param shadowGenerator shadow generator to get the effect for
  110870. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110871. */
  110872. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110873. /**
  110874. * Specifies that the submesh is ready to be used for depth rendering
  110875. * @param subMesh submesh to check
  110876. * @param defines the list of defines to take into account when checking the effect
  110877. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110878. * @param useInstances specifies that instances should be used
  110879. * @returns a boolean indicating that the submesh is ready or not
  110880. */
  110881. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110882. /**
  110883. * Disposes the resources
  110884. */
  110885. dispose(): void;
  110886. private _makeEffect;
  110887. }
  110888. }
  110889. declare module BABYLON {
  110890. /**
  110891. * Options for compiling materials.
  110892. */
  110893. export interface IMaterialCompilationOptions {
  110894. /**
  110895. * Defines whether clip planes are enabled.
  110896. */
  110897. clipPlane: boolean;
  110898. /**
  110899. * Defines whether instances are enabled.
  110900. */
  110901. useInstances: boolean;
  110902. }
  110903. /**
  110904. * Options passed when calling customShaderNameResolve
  110905. */
  110906. export interface ICustomShaderNameResolveOptions {
  110907. /**
  110908. * 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
  110909. */
  110910. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110911. }
  110912. /**
  110913. * Base class for the main features of a material in Babylon.js
  110914. */
  110915. export class Material implements IAnimatable {
  110916. /**
  110917. * Returns the triangle fill mode
  110918. */
  110919. static readonly TriangleFillMode: number;
  110920. /**
  110921. * Returns the wireframe mode
  110922. */
  110923. static readonly WireFrameFillMode: number;
  110924. /**
  110925. * Returns the point fill mode
  110926. */
  110927. static readonly PointFillMode: number;
  110928. /**
  110929. * Returns the point list draw mode
  110930. */
  110931. static readonly PointListDrawMode: number;
  110932. /**
  110933. * Returns the line list draw mode
  110934. */
  110935. static readonly LineListDrawMode: number;
  110936. /**
  110937. * Returns the line loop draw mode
  110938. */
  110939. static readonly LineLoopDrawMode: number;
  110940. /**
  110941. * Returns the line strip draw mode
  110942. */
  110943. static readonly LineStripDrawMode: number;
  110944. /**
  110945. * Returns the triangle strip draw mode
  110946. */
  110947. static readonly TriangleStripDrawMode: number;
  110948. /**
  110949. * Returns the triangle fan draw mode
  110950. */
  110951. static readonly TriangleFanDrawMode: number;
  110952. /**
  110953. * Stores the clock-wise side orientation
  110954. */
  110955. static readonly ClockWiseSideOrientation: number;
  110956. /**
  110957. * Stores the counter clock-wise side orientation
  110958. */
  110959. static readonly CounterClockWiseSideOrientation: number;
  110960. /**
  110961. * The dirty texture flag value
  110962. */
  110963. static readonly TextureDirtyFlag: number;
  110964. /**
  110965. * The dirty light flag value
  110966. */
  110967. static readonly LightDirtyFlag: number;
  110968. /**
  110969. * The dirty fresnel flag value
  110970. */
  110971. static readonly FresnelDirtyFlag: number;
  110972. /**
  110973. * The dirty attribute flag value
  110974. */
  110975. static readonly AttributesDirtyFlag: number;
  110976. /**
  110977. * The dirty misc flag value
  110978. */
  110979. static readonly MiscDirtyFlag: number;
  110980. /**
  110981. * The dirty prepass flag value
  110982. */
  110983. static readonly PrePassDirtyFlag: number;
  110984. /**
  110985. * The all dirty flag value
  110986. */
  110987. static readonly AllDirtyFlag: number;
  110988. /**
  110989. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110990. */
  110991. static readonly MATERIAL_OPAQUE: number;
  110992. /**
  110993. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110994. */
  110995. static readonly MATERIAL_ALPHATEST: number;
  110996. /**
  110997. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110998. */
  110999. static readonly MATERIAL_ALPHABLEND: number;
  111000. /**
  111001. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  111002. * They are also discarded below the alpha cutoff threshold to improve performances.
  111003. */
  111004. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  111005. /**
  111006. * The Whiteout method is used to blend normals.
  111007. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  111008. */
  111009. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  111010. /**
  111011. * The Reoriented Normal Mapping method is used to blend normals.
  111012. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  111013. */
  111014. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  111015. /**
  111016. * Custom callback helping to override the default shader used in the material.
  111017. */
  111018. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  111019. /**
  111020. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  111021. */
  111022. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  111023. /**
  111024. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  111025. * This means that the material can keep using a previous shader while a new one is being compiled.
  111026. * This is mostly used when shader parallel compilation is supported (true by default)
  111027. */
  111028. allowShaderHotSwapping: boolean;
  111029. /**
  111030. * The ID of the material
  111031. */
  111032. id: string;
  111033. /**
  111034. * Gets or sets the unique id of the material
  111035. */
  111036. uniqueId: number;
  111037. /**
  111038. * The name of the material
  111039. */
  111040. name: string;
  111041. /**
  111042. * Gets or sets user defined metadata
  111043. */
  111044. metadata: any;
  111045. /**
  111046. * For internal use only. Please do not use.
  111047. */
  111048. reservedDataStore: any;
  111049. /**
  111050. * Specifies if the ready state should be checked on each call
  111051. */
  111052. checkReadyOnEveryCall: boolean;
  111053. /**
  111054. * Specifies if the ready state should be checked once
  111055. */
  111056. checkReadyOnlyOnce: boolean;
  111057. /**
  111058. * The state of the material
  111059. */
  111060. state: string;
  111061. /**
  111062. * If the material can be rendered to several textures with MRT extension
  111063. */
  111064. get canRenderToMRT(): boolean;
  111065. /**
  111066. * The alpha value of the material
  111067. */
  111068. protected _alpha: number;
  111069. /**
  111070. * List of inspectable custom properties (used by the Inspector)
  111071. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  111072. */
  111073. inspectableCustomProperties: IInspectable[];
  111074. /**
  111075. * Sets the alpha value of the material
  111076. */
  111077. set alpha(value: number);
  111078. /**
  111079. * Gets the alpha value of the material
  111080. */
  111081. get alpha(): number;
  111082. /**
  111083. * Specifies if back face culling is enabled
  111084. */
  111085. protected _backFaceCulling: boolean;
  111086. /**
  111087. * Sets the back-face culling state
  111088. */
  111089. set backFaceCulling(value: boolean);
  111090. /**
  111091. * Gets the back-face culling state
  111092. */
  111093. get backFaceCulling(): boolean;
  111094. /**
  111095. * Stores the value for side orientation
  111096. */
  111097. sideOrientation: number;
  111098. /**
  111099. * Callback triggered when the material is compiled
  111100. */
  111101. onCompiled: Nullable<(effect: Effect) => void>;
  111102. /**
  111103. * Callback triggered when an error occurs
  111104. */
  111105. onError: Nullable<(effect: Effect, errors: string) => void>;
  111106. /**
  111107. * Callback triggered to get the render target textures
  111108. */
  111109. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  111110. /**
  111111. * Gets a boolean indicating that current material needs to register RTT
  111112. */
  111113. get hasRenderTargetTextures(): boolean;
  111114. /**
  111115. * Specifies if the material should be serialized
  111116. */
  111117. doNotSerialize: boolean;
  111118. /**
  111119. * @hidden
  111120. */
  111121. _storeEffectOnSubMeshes: boolean;
  111122. /**
  111123. * Stores the animations for the material
  111124. */
  111125. animations: Nullable<Array<Animation>>;
  111126. /**
  111127. * An event triggered when the material is disposed
  111128. */
  111129. onDisposeObservable: Observable<Material>;
  111130. /**
  111131. * An observer which watches for dispose events
  111132. */
  111133. private _onDisposeObserver;
  111134. private _onUnBindObservable;
  111135. /**
  111136. * Called during a dispose event
  111137. */
  111138. set onDispose(callback: () => void);
  111139. private _onBindObservable;
  111140. /**
  111141. * An event triggered when the material is bound
  111142. */
  111143. get onBindObservable(): Observable<AbstractMesh>;
  111144. /**
  111145. * An observer which watches for bind events
  111146. */
  111147. private _onBindObserver;
  111148. /**
  111149. * Called during a bind event
  111150. */
  111151. set onBind(callback: (Mesh: AbstractMesh) => void);
  111152. /**
  111153. * An event triggered when the material is unbound
  111154. */
  111155. get onUnBindObservable(): Observable<Material>;
  111156. protected _onEffectCreatedObservable: Nullable<Observable<{
  111157. effect: Effect;
  111158. subMesh: Nullable<SubMesh>;
  111159. }>>;
  111160. /**
  111161. * An event triggered when the effect is (re)created
  111162. */
  111163. get onEffectCreatedObservable(): Observable<{
  111164. effect: Effect;
  111165. subMesh: Nullable<SubMesh>;
  111166. }>;
  111167. /**
  111168. * Stores the value of the alpha mode
  111169. */
  111170. private _alphaMode;
  111171. /**
  111172. * Sets the value of the alpha mode.
  111173. *
  111174. * | Value | Type | Description |
  111175. * | --- | --- | --- |
  111176. * | 0 | ALPHA_DISABLE | |
  111177. * | 1 | ALPHA_ADD | |
  111178. * | 2 | ALPHA_COMBINE | |
  111179. * | 3 | ALPHA_SUBTRACT | |
  111180. * | 4 | ALPHA_MULTIPLY | |
  111181. * | 5 | ALPHA_MAXIMIZED | |
  111182. * | 6 | ALPHA_ONEONE | |
  111183. * | 7 | ALPHA_PREMULTIPLIED | |
  111184. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  111185. * | 9 | ALPHA_INTERPOLATE | |
  111186. * | 10 | ALPHA_SCREENMODE | |
  111187. *
  111188. */
  111189. set alphaMode(value: number);
  111190. /**
  111191. * Gets the value of the alpha mode
  111192. */
  111193. get alphaMode(): number;
  111194. /**
  111195. * Stores the state of the need depth pre-pass value
  111196. */
  111197. private _needDepthPrePass;
  111198. /**
  111199. * Sets the need depth pre-pass value
  111200. */
  111201. set needDepthPrePass(value: boolean);
  111202. /**
  111203. * Gets the depth pre-pass value
  111204. */
  111205. get needDepthPrePass(): boolean;
  111206. /**
  111207. * Specifies if depth writing should be disabled
  111208. */
  111209. disableDepthWrite: boolean;
  111210. /**
  111211. * Specifies if color writing should be disabled
  111212. */
  111213. disableColorWrite: boolean;
  111214. /**
  111215. * Specifies if depth writing should be forced
  111216. */
  111217. forceDepthWrite: boolean;
  111218. /**
  111219. * Specifies the depth function that should be used. 0 means the default engine function
  111220. */
  111221. depthFunction: number;
  111222. /**
  111223. * Specifies if there should be a separate pass for culling
  111224. */
  111225. separateCullingPass: boolean;
  111226. /**
  111227. * Stores the state specifing if fog should be enabled
  111228. */
  111229. private _fogEnabled;
  111230. /**
  111231. * Sets the state for enabling fog
  111232. */
  111233. set fogEnabled(value: boolean);
  111234. /**
  111235. * Gets the value of the fog enabled state
  111236. */
  111237. get fogEnabled(): boolean;
  111238. /**
  111239. * Stores the size of points
  111240. */
  111241. pointSize: number;
  111242. /**
  111243. * Stores the z offset value
  111244. */
  111245. zOffset: number;
  111246. get wireframe(): boolean;
  111247. /**
  111248. * Sets the state of wireframe mode
  111249. */
  111250. set wireframe(value: boolean);
  111251. /**
  111252. * Gets the value specifying if point clouds are enabled
  111253. */
  111254. get pointsCloud(): boolean;
  111255. /**
  111256. * Sets the state of point cloud mode
  111257. */
  111258. set pointsCloud(value: boolean);
  111259. /**
  111260. * Gets the material fill mode
  111261. */
  111262. get fillMode(): number;
  111263. /**
  111264. * Sets the material fill mode
  111265. */
  111266. set fillMode(value: number);
  111267. /**
  111268. * @hidden
  111269. * Stores the effects for the material
  111270. */
  111271. _effect: Nullable<Effect>;
  111272. /**
  111273. * Specifies if uniform buffers should be used
  111274. */
  111275. private _useUBO;
  111276. /**
  111277. * Stores a reference to the scene
  111278. */
  111279. private _scene;
  111280. /**
  111281. * Stores the fill mode state
  111282. */
  111283. private _fillMode;
  111284. /**
  111285. * Specifies if the depth write state should be cached
  111286. */
  111287. private _cachedDepthWriteState;
  111288. /**
  111289. * Specifies if the color write state should be cached
  111290. */
  111291. private _cachedColorWriteState;
  111292. /**
  111293. * Specifies if the depth function state should be cached
  111294. */
  111295. private _cachedDepthFunctionState;
  111296. /**
  111297. * Stores the uniform buffer
  111298. */
  111299. protected _uniformBuffer: UniformBuffer;
  111300. /** @hidden */
  111301. _indexInSceneMaterialArray: number;
  111302. /** @hidden */
  111303. meshMap: Nullable<{
  111304. [id: string]: AbstractMesh | undefined;
  111305. }>;
  111306. /**
  111307. * Creates a material instance
  111308. * @param name defines the name of the material
  111309. * @param scene defines the scene to reference
  111310. * @param doNotAdd specifies if the material should be added to the scene
  111311. */
  111312. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  111313. /**
  111314. * Returns a string representation of the current material
  111315. * @param fullDetails defines a boolean indicating which levels of logging is desired
  111316. * @returns a string with material information
  111317. */
  111318. toString(fullDetails?: boolean): string;
  111319. /**
  111320. * Gets the class name of the material
  111321. * @returns a string with the class name of the material
  111322. */
  111323. getClassName(): string;
  111324. /**
  111325. * Specifies if updates for the material been locked
  111326. */
  111327. get isFrozen(): boolean;
  111328. /**
  111329. * Locks updates for the material
  111330. */
  111331. freeze(): void;
  111332. /**
  111333. * Unlocks updates for the material
  111334. */
  111335. unfreeze(): void;
  111336. /**
  111337. * Specifies if the material is ready to be used
  111338. * @param mesh defines the mesh to check
  111339. * @param useInstances specifies if instances should be used
  111340. * @returns a boolean indicating if the material is ready to be used
  111341. */
  111342. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  111343. /**
  111344. * Specifies that the submesh is ready to be used
  111345. * @param mesh defines the mesh to check
  111346. * @param subMesh defines which submesh to check
  111347. * @param useInstances specifies that instances should be used
  111348. * @returns a boolean indicating that the submesh is ready or not
  111349. */
  111350. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111351. /**
  111352. * Returns the material effect
  111353. * @returns the effect associated with the material
  111354. */
  111355. getEffect(): Nullable<Effect>;
  111356. /**
  111357. * Returns the current scene
  111358. * @returns a Scene
  111359. */
  111360. getScene(): Scene;
  111361. /**
  111362. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  111363. */
  111364. protected _forceAlphaTest: boolean;
  111365. /**
  111366. * The transparency mode of the material.
  111367. */
  111368. protected _transparencyMode: Nullable<number>;
  111369. /**
  111370. * Gets the current transparency mode.
  111371. */
  111372. get transparencyMode(): Nullable<number>;
  111373. /**
  111374. * Sets the transparency mode of the material.
  111375. *
  111376. * | Value | Type | Description |
  111377. * | ----- | ----------------------------------- | ----------- |
  111378. * | 0 | OPAQUE | |
  111379. * | 1 | ALPHATEST | |
  111380. * | 2 | ALPHABLEND | |
  111381. * | 3 | ALPHATESTANDBLEND | |
  111382. *
  111383. */
  111384. set transparencyMode(value: Nullable<number>);
  111385. /**
  111386. * Returns true if alpha blending should be disabled.
  111387. */
  111388. protected get _disableAlphaBlending(): boolean;
  111389. /**
  111390. * Specifies whether or not this material should be rendered in alpha blend mode.
  111391. * @returns a boolean specifying if alpha blending is needed
  111392. */
  111393. needAlphaBlending(): boolean;
  111394. /**
  111395. * Specifies if the mesh will require alpha blending
  111396. * @param mesh defines the mesh to check
  111397. * @returns a boolean specifying if alpha blending is needed for the mesh
  111398. */
  111399. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  111400. /**
  111401. * Specifies whether or not this material should be rendered in alpha test mode.
  111402. * @returns a boolean specifying if an alpha test is needed.
  111403. */
  111404. needAlphaTesting(): boolean;
  111405. /**
  111406. * Specifies if material alpha testing should be turned on for the mesh
  111407. * @param mesh defines the mesh to check
  111408. */
  111409. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  111410. /**
  111411. * Gets the texture used for the alpha test
  111412. * @returns the texture to use for alpha testing
  111413. */
  111414. getAlphaTestTexture(): Nullable<BaseTexture>;
  111415. /**
  111416. * Marks the material to indicate that it needs to be re-calculated
  111417. */
  111418. markDirty(): void;
  111419. /** @hidden */
  111420. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  111421. /**
  111422. * Binds the material to the mesh
  111423. * @param world defines the world transformation matrix
  111424. * @param mesh defines the mesh to bind the material to
  111425. */
  111426. bind(world: Matrix, mesh?: Mesh): void;
  111427. /**
  111428. * Binds the submesh to the material
  111429. * @param world defines the world transformation matrix
  111430. * @param mesh defines the mesh containing the submesh
  111431. * @param subMesh defines the submesh to bind the material to
  111432. */
  111433. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111434. /**
  111435. * Binds the world matrix to the material
  111436. * @param world defines the world transformation matrix
  111437. */
  111438. bindOnlyWorldMatrix(world: Matrix): void;
  111439. /**
  111440. * Binds the scene's uniform buffer to the effect.
  111441. * @param effect defines the effect to bind to the scene uniform buffer
  111442. * @param sceneUbo defines the uniform buffer storing scene data
  111443. */
  111444. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  111445. /**
  111446. * Binds the view matrix to the effect
  111447. * @param effect defines the effect to bind the view matrix to
  111448. */
  111449. bindView(effect: Effect): void;
  111450. /**
  111451. * Binds the view projection matrix to the effect
  111452. * @param effect defines the effect to bind the view projection matrix to
  111453. */
  111454. bindViewProjection(effect: Effect): void;
  111455. /**
  111456. * Processes to execute after binding the material to a mesh
  111457. * @param mesh defines the rendered mesh
  111458. */
  111459. protected _afterBind(mesh?: Mesh): void;
  111460. /**
  111461. * Unbinds the material from the mesh
  111462. */
  111463. unbind(): void;
  111464. /**
  111465. * Gets the active textures from the material
  111466. * @returns an array of textures
  111467. */
  111468. getActiveTextures(): BaseTexture[];
  111469. /**
  111470. * Specifies if the material uses a texture
  111471. * @param texture defines the texture to check against the material
  111472. * @returns a boolean specifying if the material uses the texture
  111473. */
  111474. hasTexture(texture: BaseTexture): boolean;
  111475. /**
  111476. * Makes a duplicate of the material, and gives it a new name
  111477. * @param name defines the new name for the duplicated material
  111478. * @returns the cloned material
  111479. */
  111480. clone(name: string): Nullable<Material>;
  111481. /**
  111482. * Gets the meshes bound to the material
  111483. * @returns an array of meshes bound to the material
  111484. */
  111485. getBindedMeshes(): AbstractMesh[];
  111486. /**
  111487. * Force shader compilation
  111488. * @param mesh defines the mesh associated with this material
  111489. * @param onCompiled defines a function to execute once the material is compiled
  111490. * @param options defines the options to configure the compilation
  111491. * @param onError defines a function to execute if the material fails compiling
  111492. */
  111493. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  111494. /**
  111495. * Force shader compilation
  111496. * @param mesh defines the mesh that will use this material
  111497. * @param options defines additional options for compiling the shaders
  111498. * @returns a promise that resolves when the compilation completes
  111499. */
  111500. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  111501. private static readonly _AllDirtyCallBack;
  111502. private static readonly _ImageProcessingDirtyCallBack;
  111503. private static readonly _TextureDirtyCallBack;
  111504. private static readonly _FresnelDirtyCallBack;
  111505. private static readonly _MiscDirtyCallBack;
  111506. private static readonly _PrePassDirtyCallBack;
  111507. private static readonly _LightsDirtyCallBack;
  111508. private static readonly _AttributeDirtyCallBack;
  111509. private static _FresnelAndMiscDirtyCallBack;
  111510. private static _TextureAndMiscDirtyCallBack;
  111511. private static readonly _DirtyCallbackArray;
  111512. private static readonly _RunDirtyCallBacks;
  111513. /**
  111514. * Marks a define in the material to indicate that it needs to be re-computed
  111515. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  111516. */
  111517. markAsDirty(flag: number): void;
  111518. /**
  111519. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  111520. * @param func defines a function which checks material defines against the submeshes
  111521. */
  111522. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  111523. /**
  111524. * Indicates that the scene should check if the rendering now needs a prepass
  111525. */
  111526. protected _markScenePrePassDirty(): void;
  111527. /**
  111528. * Indicates that we need to re-calculated for all submeshes
  111529. */
  111530. protected _markAllSubMeshesAsAllDirty(): void;
  111531. /**
  111532. * Indicates that image processing needs to be re-calculated for all submeshes
  111533. */
  111534. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  111535. /**
  111536. * Indicates that textures need to be re-calculated for all submeshes
  111537. */
  111538. protected _markAllSubMeshesAsTexturesDirty(): void;
  111539. /**
  111540. * Indicates that fresnel needs to be re-calculated for all submeshes
  111541. */
  111542. protected _markAllSubMeshesAsFresnelDirty(): void;
  111543. /**
  111544. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  111545. */
  111546. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  111547. /**
  111548. * Indicates that lights need to be re-calculated for all submeshes
  111549. */
  111550. protected _markAllSubMeshesAsLightsDirty(): void;
  111551. /**
  111552. * Indicates that attributes need to be re-calculated for all submeshes
  111553. */
  111554. protected _markAllSubMeshesAsAttributesDirty(): void;
  111555. /**
  111556. * Indicates that misc needs to be re-calculated for all submeshes
  111557. */
  111558. protected _markAllSubMeshesAsMiscDirty(): void;
  111559. /**
  111560. * Indicates that prepass needs to be re-calculated for all submeshes
  111561. */
  111562. protected _markAllSubMeshesAsPrePassDirty(): void;
  111563. /**
  111564. * Indicates that textures and misc need to be re-calculated for all submeshes
  111565. */
  111566. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  111567. /**
  111568. * Sets the required values to the prepass renderer.
  111569. * @param prePassRenderer defines the prepass renderer to setup.
  111570. * @returns true if the pre pass is needed.
  111571. */
  111572. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  111573. /**
  111574. * Disposes the material
  111575. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111576. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111577. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  111578. */
  111579. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  111580. /** @hidden */
  111581. private releaseVertexArrayObject;
  111582. /**
  111583. * Serializes this material
  111584. * @returns the serialized material object
  111585. */
  111586. serialize(): any;
  111587. /**
  111588. * Creates a material from parsed material data
  111589. * @param parsedMaterial defines parsed material data
  111590. * @param scene defines the hosting scene
  111591. * @param rootUrl defines the root URL to use to load textures
  111592. * @returns a new material
  111593. */
  111594. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  111595. }
  111596. }
  111597. declare module BABYLON {
  111598. /**
  111599. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111600. * separate meshes. This can be use to improve performances.
  111601. * @see https://doc.babylonjs.com/how_to/multi_materials
  111602. */
  111603. export class MultiMaterial extends Material {
  111604. private _subMaterials;
  111605. /**
  111606. * Gets or Sets the list of Materials used within the multi material.
  111607. * They need to be ordered according to the submeshes order in the associated mesh
  111608. */
  111609. get subMaterials(): Nullable<Material>[];
  111610. set subMaterials(value: Nullable<Material>[]);
  111611. /**
  111612. * Function used to align with Node.getChildren()
  111613. * @returns the list of Materials used within the multi material
  111614. */
  111615. getChildren(): Nullable<Material>[];
  111616. /**
  111617. * Instantiates a new Multi Material
  111618. * A multi-material is used to apply different materials to different parts of the same object without the need of
  111619. * separate meshes. This can be use to improve performances.
  111620. * @see https://doc.babylonjs.com/how_to/multi_materials
  111621. * @param name Define the name in the scene
  111622. * @param scene Define the scene the material belongs to
  111623. */
  111624. constructor(name: string, scene: Scene);
  111625. private _hookArray;
  111626. /**
  111627. * Get one of the submaterial by its index in the submaterials array
  111628. * @param index The index to look the sub material at
  111629. * @returns The Material if the index has been defined
  111630. */
  111631. getSubMaterial(index: number): Nullable<Material>;
  111632. /**
  111633. * Get the list of active textures for the whole sub materials list.
  111634. * @returns All the textures that will be used during the rendering
  111635. */
  111636. getActiveTextures(): BaseTexture[];
  111637. /**
  111638. * Specifies if any sub-materials of this multi-material use a given texture.
  111639. * @param texture Defines the texture to check against this multi-material's sub-materials.
  111640. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  111641. */
  111642. hasTexture(texture: BaseTexture): boolean;
  111643. /**
  111644. * Gets the current class name of the material e.g. "MultiMaterial"
  111645. * Mainly use in serialization.
  111646. * @returns the class name
  111647. */
  111648. getClassName(): string;
  111649. /**
  111650. * Checks if the material is ready to render the requested sub mesh
  111651. * @param mesh Define the mesh the submesh belongs to
  111652. * @param subMesh Define the sub mesh to look readyness for
  111653. * @param useInstances Define whether or not the material is used with instances
  111654. * @returns true if ready, otherwise false
  111655. */
  111656. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111657. /**
  111658. * Clones the current material and its related sub materials
  111659. * @param name Define the name of the newly cloned material
  111660. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  111661. * @returns the cloned material
  111662. */
  111663. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  111664. /**
  111665. * Serializes the materials into a JSON representation.
  111666. * @returns the JSON representation
  111667. */
  111668. serialize(): any;
  111669. /**
  111670. * Dispose the material and release its associated resources
  111671. * @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)
  111672. * @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)
  111673. * @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)
  111674. */
  111675. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111676. /**
  111677. * Creates a MultiMaterial from parsed MultiMaterial data.
  111678. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111679. * @param scene defines the hosting scene
  111680. * @returns a new MultiMaterial
  111681. */
  111682. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111683. }
  111684. }
  111685. declare module BABYLON {
  111686. /**
  111687. * Defines a subdivision inside a mesh
  111688. */
  111689. export class SubMesh implements ICullable {
  111690. /** the material index to use */
  111691. materialIndex: number;
  111692. /** vertex index start */
  111693. verticesStart: number;
  111694. /** vertices count */
  111695. verticesCount: number;
  111696. /** index start */
  111697. indexStart: number;
  111698. /** indices count */
  111699. indexCount: number;
  111700. /** @hidden */
  111701. _materialDefines: Nullable<MaterialDefines>;
  111702. /** @hidden */
  111703. _materialEffect: Nullable<Effect>;
  111704. /** @hidden */
  111705. _effectOverride: Nullable<Effect>;
  111706. /**
  111707. * Gets material defines used by the effect associated to the sub mesh
  111708. */
  111709. get materialDefines(): Nullable<MaterialDefines>;
  111710. /**
  111711. * Sets material defines used by the effect associated to the sub mesh
  111712. */
  111713. set materialDefines(defines: Nullable<MaterialDefines>);
  111714. /**
  111715. * Gets associated effect
  111716. */
  111717. get effect(): Nullable<Effect>;
  111718. /**
  111719. * Sets associated effect (effect used to render this submesh)
  111720. * @param effect defines the effect to associate with
  111721. * @param defines defines the set of defines used to compile this effect
  111722. */
  111723. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111724. /** @hidden */
  111725. _linesIndexCount: number;
  111726. private _mesh;
  111727. private _renderingMesh;
  111728. private _boundingInfo;
  111729. private _linesIndexBuffer;
  111730. /** @hidden */
  111731. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111732. /** @hidden */
  111733. _trianglePlanes: Plane[];
  111734. /** @hidden */
  111735. _lastColliderTransformMatrix: Nullable<Matrix>;
  111736. /** @hidden */
  111737. _renderId: number;
  111738. /** @hidden */
  111739. _alphaIndex: number;
  111740. /** @hidden */
  111741. _distanceToCamera: number;
  111742. /** @hidden */
  111743. _id: number;
  111744. private _currentMaterial;
  111745. /**
  111746. * Add a new submesh to a mesh
  111747. * @param materialIndex defines the material index to use
  111748. * @param verticesStart defines vertex index start
  111749. * @param verticesCount defines vertices count
  111750. * @param indexStart defines index start
  111751. * @param indexCount defines indices count
  111752. * @param mesh defines the parent mesh
  111753. * @param renderingMesh defines an optional rendering mesh
  111754. * @param createBoundingBox defines if bounding box should be created for this submesh
  111755. * @returns the new submesh
  111756. */
  111757. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111758. /**
  111759. * Creates a new submesh
  111760. * @param materialIndex defines the material index to use
  111761. * @param verticesStart defines vertex index start
  111762. * @param verticesCount defines vertices count
  111763. * @param indexStart defines index start
  111764. * @param indexCount defines indices count
  111765. * @param mesh defines the parent mesh
  111766. * @param renderingMesh defines an optional rendering mesh
  111767. * @param createBoundingBox defines if bounding box should be created for this submesh
  111768. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111769. */
  111770. constructor(
  111771. /** the material index to use */
  111772. materialIndex: number,
  111773. /** vertex index start */
  111774. verticesStart: number,
  111775. /** vertices count */
  111776. verticesCount: number,
  111777. /** index start */
  111778. indexStart: number,
  111779. /** indices count */
  111780. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111781. /**
  111782. * Returns true if this submesh covers the entire parent mesh
  111783. * @ignorenaming
  111784. */
  111785. get IsGlobal(): boolean;
  111786. /**
  111787. * Returns the submesh BoudingInfo object
  111788. * @returns current bounding info (or mesh's one if the submesh is global)
  111789. */
  111790. getBoundingInfo(): BoundingInfo;
  111791. /**
  111792. * Sets the submesh BoundingInfo
  111793. * @param boundingInfo defines the new bounding info to use
  111794. * @returns the SubMesh
  111795. */
  111796. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111797. /**
  111798. * Returns the mesh of the current submesh
  111799. * @return the parent mesh
  111800. */
  111801. getMesh(): AbstractMesh;
  111802. /**
  111803. * Returns the rendering mesh of the submesh
  111804. * @returns the rendering mesh (could be different from parent mesh)
  111805. */
  111806. getRenderingMesh(): Mesh;
  111807. /**
  111808. * Returns the replacement mesh of the submesh
  111809. * @returns the replacement mesh (could be different from parent mesh)
  111810. */
  111811. getReplacementMesh(): Nullable<AbstractMesh>;
  111812. /**
  111813. * Returns the effective mesh of the submesh
  111814. * @returns the effective mesh (could be different from parent mesh)
  111815. */
  111816. getEffectiveMesh(): AbstractMesh;
  111817. /**
  111818. * Returns the submesh material
  111819. * @returns null or the current material
  111820. */
  111821. getMaterial(): Nullable<Material>;
  111822. private _IsMultiMaterial;
  111823. /**
  111824. * Sets a new updated BoundingInfo object to the submesh
  111825. * @param data defines an optional position array to use to determine the bounding info
  111826. * @returns the SubMesh
  111827. */
  111828. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111829. /** @hidden */
  111830. _checkCollision(collider: Collider): boolean;
  111831. /**
  111832. * Updates the submesh BoundingInfo
  111833. * @param world defines the world matrix to use to update the bounding info
  111834. * @returns the submesh
  111835. */
  111836. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111837. /**
  111838. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111839. * @param frustumPlanes defines the frustum planes
  111840. * @returns true if the submesh is intersecting with the frustum
  111841. */
  111842. isInFrustum(frustumPlanes: Plane[]): boolean;
  111843. /**
  111844. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111845. * @param frustumPlanes defines the frustum planes
  111846. * @returns true if the submesh is inside the frustum
  111847. */
  111848. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111849. /**
  111850. * Renders the submesh
  111851. * @param enableAlphaMode defines if alpha needs to be used
  111852. * @returns the submesh
  111853. */
  111854. render(enableAlphaMode: boolean): SubMesh;
  111855. /**
  111856. * @hidden
  111857. */
  111858. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111859. /**
  111860. * Checks if the submesh intersects with a ray
  111861. * @param ray defines the ray to test
  111862. * @returns true is the passed ray intersects the submesh bounding box
  111863. */
  111864. canIntersects(ray: Ray): boolean;
  111865. /**
  111866. * Intersects current submesh with a ray
  111867. * @param ray defines the ray to test
  111868. * @param positions defines mesh's positions array
  111869. * @param indices defines mesh's indices array
  111870. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111871. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111872. * @returns intersection info or null if no intersection
  111873. */
  111874. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111875. /** @hidden */
  111876. private _intersectLines;
  111877. /** @hidden */
  111878. private _intersectUnIndexedLines;
  111879. /** @hidden */
  111880. private _intersectTriangles;
  111881. /** @hidden */
  111882. private _intersectUnIndexedTriangles;
  111883. /** @hidden */
  111884. _rebuild(): void;
  111885. /**
  111886. * Creates a new submesh from the passed mesh
  111887. * @param newMesh defines the new hosting mesh
  111888. * @param newRenderingMesh defines an optional rendering mesh
  111889. * @returns the new submesh
  111890. */
  111891. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111892. /**
  111893. * Release associated resources
  111894. */
  111895. dispose(): void;
  111896. /**
  111897. * Gets the class name
  111898. * @returns the string "SubMesh".
  111899. */
  111900. getClassName(): string;
  111901. /**
  111902. * Creates a new submesh from indices data
  111903. * @param materialIndex the index of the main mesh material
  111904. * @param startIndex the index where to start the copy in the mesh indices array
  111905. * @param indexCount the number of indices to copy then from the startIndex
  111906. * @param mesh the main mesh to create the submesh from
  111907. * @param renderingMesh the optional rendering mesh
  111908. * @returns a new submesh
  111909. */
  111910. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111911. }
  111912. }
  111913. declare module BABYLON {
  111914. /**
  111915. * Class used to represent data loading progression
  111916. */
  111917. export class SceneLoaderFlags {
  111918. private static _ForceFullSceneLoadingForIncremental;
  111919. private static _ShowLoadingScreen;
  111920. private static _CleanBoneMatrixWeights;
  111921. private static _loggingLevel;
  111922. /**
  111923. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111924. */
  111925. static get ForceFullSceneLoadingForIncremental(): boolean;
  111926. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111927. /**
  111928. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111929. */
  111930. static get ShowLoadingScreen(): boolean;
  111931. static set ShowLoadingScreen(value: boolean);
  111932. /**
  111933. * Defines the current logging level (while loading the scene)
  111934. * @ignorenaming
  111935. */
  111936. static get loggingLevel(): number;
  111937. static set loggingLevel(value: number);
  111938. /**
  111939. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111940. */
  111941. static get CleanBoneMatrixWeights(): boolean;
  111942. static set CleanBoneMatrixWeights(value: boolean);
  111943. }
  111944. }
  111945. declare module BABYLON {
  111946. /**
  111947. * Class used to store geometry data (vertex buffers + index buffer)
  111948. */
  111949. export class Geometry implements IGetSetVerticesData {
  111950. /**
  111951. * Gets or sets the ID of the geometry
  111952. */
  111953. id: string;
  111954. /**
  111955. * Gets or sets the unique ID of the geometry
  111956. */
  111957. uniqueId: number;
  111958. /**
  111959. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111960. */
  111961. delayLoadState: number;
  111962. /**
  111963. * Gets the file containing the data to load when running in delay load state
  111964. */
  111965. delayLoadingFile: Nullable<string>;
  111966. /**
  111967. * Callback called when the geometry is updated
  111968. */
  111969. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111970. private _scene;
  111971. private _engine;
  111972. private _meshes;
  111973. private _totalVertices;
  111974. /** @hidden */
  111975. _indices: IndicesArray;
  111976. /** @hidden */
  111977. _vertexBuffers: {
  111978. [key: string]: VertexBuffer;
  111979. };
  111980. private _isDisposed;
  111981. private _extend;
  111982. private _boundingBias;
  111983. /** @hidden */
  111984. _delayInfo: Array<string>;
  111985. private _indexBuffer;
  111986. private _indexBufferIsUpdatable;
  111987. /** @hidden */
  111988. _boundingInfo: Nullable<BoundingInfo>;
  111989. /** @hidden */
  111990. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111991. /** @hidden */
  111992. _softwareSkinningFrameId: number;
  111993. private _vertexArrayObjects;
  111994. private _updatable;
  111995. /** @hidden */
  111996. _positions: Nullable<Vector3[]>;
  111997. private _positionsCache;
  111998. /**
  111999. * 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
  112000. */
  112001. get boundingBias(): Vector2;
  112002. /**
  112003. * 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
  112004. */
  112005. set boundingBias(value: Vector2);
  112006. /**
  112007. * Static function used to attach a new empty geometry to a mesh
  112008. * @param mesh defines the mesh to attach the geometry to
  112009. * @returns the new Geometry
  112010. */
  112011. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  112012. /** Get the list of meshes using this geometry */
  112013. get meshes(): Mesh[];
  112014. /**
  112015. * 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
  112016. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  112017. */
  112018. useBoundingInfoFromGeometry: boolean;
  112019. /**
  112020. * Creates a new geometry
  112021. * @param id defines the unique ID
  112022. * @param scene defines the hosting scene
  112023. * @param vertexData defines the VertexData used to get geometry data
  112024. * @param updatable defines if geometry must be updatable (false by default)
  112025. * @param mesh defines the mesh that will be associated with the geometry
  112026. */
  112027. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  112028. /**
  112029. * Gets the current extend of the geometry
  112030. */
  112031. get extend(): {
  112032. minimum: Vector3;
  112033. maximum: Vector3;
  112034. };
  112035. /**
  112036. * Gets the hosting scene
  112037. * @returns the hosting Scene
  112038. */
  112039. getScene(): Scene;
  112040. /**
  112041. * Gets the hosting engine
  112042. * @returns the hosting Engine
  112043. */
  112044. getEngine(): Engine;
  112045. /**
  112046. * Defines if the geometry is ready to use
  112047. * @returns true if the geometry is ready to be used
  112048. */
  112049. isReady(): boolean;
  112050. /**
  112051. * Gets a value indicating that the geometry should not be serialized
  112052. */
  112053. get doNotSerialize(): boolean;
  112054. /** @hidden */
  112055. _rebuild(): void;
  112056. /**
  112057. * Affects all geometry data in one call
  112058. * @param vertexData defines the geometry data
  112059. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  112060. */
  112061. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  112062. /**
  112063. * Set specific vertex data
  112064. * @param kind defines the data kind (Position, normal, etc...)
  112065. * @param data defines the vertex data to use
  112066. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  112067. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  112068. */
  112069. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  112070. /**
  112071. * Removes a specific vertex data
  112072. * @param kind defines the data kind (Position, normal, etc...)
  112073. */
  112074. removeVerticesData(kind: string): void;
  112075. /**
  112076. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  112077. * @param buffer defines the vertex buffer to use
  112078. * @param totalVertices defines the total number of vertices for position kind (could be null)
  112079. */
  112080. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  112081. /**
  112082. * Update a specific vertex buffer
  112083. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  112084. * It will do nothing if the buffer is not updatable
  112085. * @param kind defines the data kind (Position, normal, etc...)
  112086. * @param data defines the data to use
  112087. * @param offset defines the offset in the target buffer where to store the data
  112088. * @param useBytes set to true if the offset is in bytes
  112089. */
  112090. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  112091. /**
  112092. * Update a specific vertex buffer
  112093. * This function will create a new buffer if the current one is not updatable
  112094. * @param kind defines the data kind (Position, normal, etc...)
  112095. * @param data defines the data to use
  112096. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  112097. */
  112098. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  112099. private _updateBoundingInfo;
  112100. /** @hidden */
  112101. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  112102. /**
  112103. * Gets total number of vertices
  112104. * @returns the total number of vertices
  112105. */
  112106. getTotalVertices(): number;
  112107. /**
  112108. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  112109. * @param kind defines the data kind (Position, normal, etc...)
  112110. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  112111. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  112112. * @returns a float array containing vertex data
  112113. */
  112114. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  112115. /**
  112116. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  112117. * @param kind defines the data kind (Position, normal, etc...)
  112118. * @returns true if the vertex buffer with the specified kind is updatable
  112119. */
  112120. isVertexBufferUpdatable(kind: string): boolean;
  112121. /**
  112122. * Gets a specific vertex buffer
  112123. * @param kind defines the data kind (Position, normal, etc...)
  112124. * @returns a VertexBuffer
  112125. */
  112126. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  112127. /**
  112128. * Returns all vertex buffers
  112129. * @return an object holding all vertex buffers indexed by kind
  112130. */
  112131. getVertexBuffers(): Nullable<{
  112132. [key: string]: VertexBuffer;
  112133. }>;
  112134. /**
  112135. * Gets a boolean indicating if specific vertex buffer is present
  112136. * @param kind defines the data kind (Position, normal, etc...)
  112137. * @returns true if data is present
  112138. */
  112139. isVerticesDataPresent(kind: string): boolean;
  112140. /**
  112141. * Gets a list of all attached data kinds (Position, normal, etc...)
  112142. * @returns a list of string containing all kinds
  112143. */
  112144. getVerticesDataKinds(): string[];
  112145. /**
  112146. * Update index buffer
  112147. * @param indices defines the indices to store in the index buffer
  112148. * @param offset defines the offset in the target buffer where to store the data
  112149. * @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)
  112150. */
  112151. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  112152. /**
  112153. * Creates a new index buffer
  112154. * @param indices defines the indices to store in the index buffer
  112155. * @param totalVertices defines the total number of vertices (could be null)
  112156. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  112157. */
  112158. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  112159. /**
  112160. * Return the total number of indices
  112161. * @returns the total number of indices
  112162. */
  112163. getTotalIndices(): number;
  112164. /**
  112165. * Gets the index buffer array
  112166. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  112167. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  112168. * @returns the index buffer array
  112169. */
  112170. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  112171. /**
  112172. * Gets the index buffer
  112173. * @return the index buffer
  112174. */
  112175. getIndexBuffer(): Nullable<DataBuffer>;
  112176. /** @hidden */
  112177. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  112178. /**
  112179. * Release the associated resources for a specific mesh
  112180. * @param mesh defines the source mesh
  112181. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  112182. */
  112183. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  112184. /**
  112185. * Apply current geometry to a given mesh
  112186. * @param mesh defines the mesh to apply geometry to
  112187. */
  112188. applyToMesh(mesh: Mesh): void;
  112189. private _updateExtend;
  112190. private _applyToMesh;
  112191. private notifyUpdate;
  112192. /**
  112193. * Load the geometry if it was flagged as delay loaded
  112194. * @param scene defines the hosting scene
  112195. * @param onLoaded defines a callback called when the geometry is loaded
  112196. */
  112197. load(scene: Scene, onLoaded?: () => void): void;
  112198. private _queueLoad;
  112199. /**
  112200. * Invert the geometry to move from a right handed system to a left handed one.
  112201. */
  112202. toLeftHanded(): void;
  112203. /** @hidden */
  112204. _resetPointsArrayCache(): void;
  112205. /** @hidden */
  112206. _generatePointsArray(): boolean;
  112207. /**
  112208. * Gets a value indicating if the geometry is disposed
  112209. * @returns true if the geometry was disposed
  112210. */
  112211. isDisposed(): boolean;
  112212. private _disposeVertexArrayObjects;
  112213. /**
  112214. * Free all associated resources
  112215. */
  112216. dispose(): void;
  112217. /**
  112218. * Clone the current geometry into a new geometry
  112219. * @param id defines the unique ID of the new geometry
  112220. * @returns a new geometry object
  112221. */
  112222. copy(id: string): Geometry;
  112223. /**
  112224. * Serialize the current geometry info (and not the vertices data) into a JSON object
  112225. * @return a JSON representation of the current geometry data (without the vertices data)
  112226. */
  112227. serialize(): any;
  112228. private toNumberArray;
  112229. /**
  112230. * Serialize all vertices data into a JSON oject
  112231. * @returns a JSON representation of the current geometry data
  112232. */
  112233. serializeVerticeData(): any;
  112234. /**
  112235. * Extracts a clone of a mesh geometry
  112236. * @param mesh defines the source mesh
  112237. * @param id defines the unique ID of the new geometry object
  112238. * @returns the new geometry object
  112239. */
  112240. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  112241. /**
  112242. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  112243. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  112244. * Be aware Math.random() could cause collisions, but:
  112245. * "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"
  112246. * @returns a string containing a new GUID
  112247. */
  112248. static RandomId(): string;
  112249. /** @hidden */
  112250. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  112251. private static _CleanMatricesWeights;
  112252. /**
  112253. * Create a new geometry from persisted data (Using .babylon file format)
  112254. * @param parsedVertexData defines the persisted data
  112255. * @param scene defines the hosting scene
  112256. * @param rootUrl defines the root url to use to load assets (like delayed data)
  112257. * @returns the new geometry object
  112258. */
  112259. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  112260. }
  112261. }
  112262. declare module BABYLON {
  112263. /**
  112264. * Defines a target to use with MorphTargetManager
  112265. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112266. */
  112267. export class MorphTarget implements IAnimatable {
  112268. /** defines the name of the target */
  112269. name: string;
  112270. /**
  112271. * Gets or sets the list of animations
  112272. */
  112273. animations: Animation[];
  112274. private _scene;
  112275. private _positions;
  112276. private _normals;
  112277. private _tangents;
  112278. private _uvs;
  112279. private _influence;
  112280. private _uniqueId;
  112281. /**
  112282. * Observable raised when the influence changes
  112283. */
  112284. onInfluenceChanged: Observable<boolean>;
  112285. /** @hidden */
  112286. _onDataLayoutChanged: Observable<void>;
  112287. /**
  112288. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112289. */
  112290. get influence(): number;
  112291. set influence(influence: number);
  112292. /**
  112293. * Gets or sets the id of the morph Target
  112294. */
  112295. id: string;
  112296. private _animationPropertiesOverride;
  112297. /**
  112298. * Gets or sets the animation properties override
  112299. */
  112300. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112301. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112302. /**
  112303. * Creates a new MorphTarget
  112304. * @param name defines the name of the target
  112305. * @param influence defines the influence to use
  112306. * @param scene defines the scene the morphtarget belongs to
  112307. */
  112308. constructor(
  112309. /** defines the name of the target */
  112310. name: string, influence?: number, scene?: Nullable<Scene>);
  112311. /**
  112312. * Gets the unique ID of this manager
  112313. */
  112314. get uniqueId(): number;
  112315. /**
  112316. * Gets a boolean defining if the target contains position data
  112317. */
  112318. get hasPositions(): boolean;
  112319. /**
  112320. * Gets a boolean defining if the target contains normal data
  112321. */
  112322. get hasNormals(): boolean;
  112323. /**
  112324. * Gets a boolean defining if the target contains tangent data
  112325. */
  112326. get hasTangents(): boolean;
  112327. /**
  112328. * Gets a boolean defining if the target contains texture coordinates data
  112329. */
  112330. get hasUVs(): boolean;
  112331. /**
  112332. * Affects position data to this target
  112333. * @param data defines the position data to use
  112334. */
  112335. setPositions(data: Nullable<FloatArray>): void;
  112336. /**
  112337. * Gets the position data stored in this target
  112338. * @returns a FloatArray containing the position data (or null if not present)
  112339. */
  112340. getPositions(): Nullable<FloatArray>;
  112341. /**
  112342. * Affects normal data to this target
  112343. * @param data defines the normal data to use
  112344. */
  112345. setNormals(data: Nullable<FloatArray>): void;
  112346. /**
  112347. * Gets the normal data stored in this target
  112348. * @returns a FloatArray containing the normal data (or null if not present)
  112349. */
  112350. getNormals(): Nullable<FloatArray>;
  112351. /**
  112352. * Affects tangent data to this target
  112353. * @param data defines the tangent data to use
  112354. */
  112355. setTangents(data: Nullable<FloatArray>): void;
  112356. /**
  112357. * Gets the tangent data stored in this target
  112358. * @returns a FloatArray containing the tangent data (or null if not present)
  112359. */
  112360. getTangents(): Nullable<FloatArray>;
  112361. /**
  112362. * Affects texture coordinates data to this target
  112363. * @param data defines the texture coordinates data to use
  112364. */
  112365. setUVs(data: Nullable<FloatArray>): void;
  112366. /**
  112367. * Gets the texture coordinates data stored in this target
  112368. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112369. */
  112370. getUVs(): Nullable<FloatArray>;
  112371. /**
  112372. * Clone the current target
  112373. * @returns a new MorphTarget
  112374. */
  112375. clone(): MorphTarget;
  112376. /**
  112377. * Serializes the current target into a Serialization object
  112378. * @returns the serialized object
  112379. */
  112380. serialize(): any;
  112381. /**
  112382. * Returns the string "MorphTarget"
  112383. * @returns "MorphTarget"
  112384. */
  112385. getClassName(): string;
  112386. /**
  112387. * Creates a new target from serialized data
  112388. * @param serializationObject defines the serialized data to use
  112389. * @returns a new MorphTarget
  112390. */
  112391. static Parse(serializationObject: any): MorphTarget;
  112392. /**
  112393. * Creates a MorphTarget from mesh data
  112394. * @param mesh defines the source mesh
  112395. * @param name defines the name to use for the new target
  112396. * @param influence defines the influence to attach to the target
  112397. * @returns a new MorphTarget
  112398. */
  112399. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112400. }
  112401. }
  112402. declare module BABYLON {
  112403. /**
  112404. * This class is used to deform meshes using morphing between different targets
  112405. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112406. */
  112407. export class MorphTargetManager {
  112408. private _targets;
  112409. private _targetInfluenceChangedObservers;
  112410. private _targetDataLayoutChangedObservers;
  112411. private _activeTargets;
  112412. private _scene;
  112413. private _influences;
  112414. private _supportsNormals;
  112415. private _supportsTangents;
  112416. private _supportsUVs;
  112417. private _vertexCount;
  112418. private _uniqueId;
  112419. private _tempInfluences;
  112420. /**
  112421. * Gets or sets a boolean indicating if normals must be morphed
  112422. */
  112423. enableNormalMorphing: boolean;
  112424. /**
  112425. * Gets or sets a boolean indicating if tangents must be morphed
  112426. */
  112427. enableTangentMorphing: boolean;
  112428. /**
  112429. * Gets or sets a boolean indicating if UV must be morphed
  112430. */
  112431. enableUVMorphing: boolean;
  112432. /**
  112433. * Creates a new MorphTargetManager
  112434. * @param scene defines the current scene
  112435. */
  112436. constructor(scene?: Nullable<Scene>);
  112437. /**
  112438. * Gets the unique ID of this manager
  112439. */
  112440. get uniqueId(): number;
  112441. /**
  112442. * Gets the number of vertices handled by this manager
  112443. */
  112444. get vertexCount(): number;
  112445. /**
  112446. * Gets a boolean indicating if this manager supports morphing of normals
  112447. */
  112448. get supportsNormals(): boolean;
  112449. /**
  112450. * Gets a boolean indicating if this manager supports morphing of tangents
  112451. */
  112452. get supportsTangents(): boolean;
  112453. /**
  112454. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112455. */
  112456. get supportsUVs(): boolean;
  112457. /**
  112458. * Gets the number of targets stored in this manager
  112459. */
  112460. get numTargets(): number;
  112461. /**
  112462. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112463. */
  112464. get numInfluencers(): number;
  112465. /**
  112466. * Gets the list of influences (one per target)
  112467. */
  112468. get influences(): Float32Array;
  112469. /**
  112470. * Gets the active target at specified index. An active target is a target with an influence > 0
  112471. * @param index defines the index to check
  112472. * @returns the requested target
  112473. */
  112474. getActiveTarget(index: number): MorphTarget;
  112475. /**
  112476. * Gets the target at specified index
  112477. * @param index defines the index to check
  112478. * @returns the requested target
  112479. */
  112480. getTarget(index: number): MorphTarget;
  112481. /**
  112482. * Add a new target to this manager
  112483. * @param target defines the target to add
  112484. */
  112485. addTarget(target: MorphTarget): void;
  112486. /**
  112487. * Removes a target from the manager
  112488. * @param target defines the target to remove
  112489. */
  112490. removeTarget(target: MorphTarget): void;
  112491. /**
  112492. * Clone the current manager
  112493. * @returns a new MorphTargetManager
  112494. */
  112495. clone(): MorphTargetManager;
  112496. /**
  112497. * Serializes the current manager into a Serialization object
  112498. * @returns the serialized object
  112499. */
  112500. serialize(): any;
  112501. private _syncActiveTargets;
  112502. /**
  112503. * Syncrhonize the targets with all the meshes using this morph target manager
  112504. */
  112505. synchronize(): void;
  112506. /**
  112507. * Creates a new MorphTargetManager from serialized data
  112508. * @param serializationObject defines the serialized data
  112509. * @param scene defines the hosting scene
  112510. * @returns the new MorphTargetManager
  112511. */
  112512. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112513. }
  112514. }
  112515. declare module BABYLON {
  112516. /**
  112517. * Class used to represent a specific level of detail of a mesh
  112518. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112519. */
  112520. export class MeshLODLevel {
  112521. /** Defines the distance where this level should start being displayed */
  112522. distance: number;
  112523. /** Defines the mesh to use to render this level */
  112524. mesh: Nullable<Mesh>;
  112525. /**
  112526. * Creates a new LOD level
  112527. * @param distance defines the distance where this level should star being displayed
  112528. * @param mesh defines the mesh to use to render this level
  112529. */
  112530. constructor(
  112531. /** Defines the distance where this level should start being displayed */
  112532. distance: number,
  112533. /** Defines the mesh to use to render this level */
  112534. mesh: Nullable<Mesh>);
  112535. }
  112536. }
  112537. declare module BABYLON {
  112538. /**
  112539. * Helper class used to generate a canvas to manipulate images
  112540. */
  112541. export class CanvasGenerator {
  112542. /**
  112543. * Create a new canvas (or offscreen canvas depending on the context)
  112544. * @param width defines the expected width
  112545. * @param height defines the expected height
  112546. * @return a new canvas or offscreen canvas
  112547. */
  112548. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112549. }
  112550. }
  112551. declare module BABYLON {
  112552. /**
  112553. * Mesh representing the gorund
  112554. */
  112555. export class GroundMesh extends Mesh {
  112556. /** If octree should be generated */
  112557. generateOctree: boolean;
  112558. private _heightQuads;
  112559. /** @hidden */
  112560. _subdivisionsX: number;
  112561. /** @hidden */
  112562. _subdivisionsY: number;
  112563. /** @hidden */
  112564. _width: number;
  112565. /** @hidden */
  112566. _height: number;
  112567. /** @hidden */
  112568. _minX: number;
  112569. /** @hidden */
  112570. _maxX: number;
  112571. /** @hidden */
  112572. _minZ: number;
  112573. /** @hidden */
  112574. _maxZ: number;
  112575. constructor(name: string, scene: Scene);
  112576. /**
  112577. * "GroundMesh"
  112578. * @returns "GroundMesh"
  112579. */
  112580. getClassName(): string;
  112581. /**
  112582. * The minimum of x and y subdivisions
  112583. */
  112584. get subdivisions(): number;
  112585. /**
  112586. * X subdivisions
  112587. */
  112588. get subdivisionsX(): number;
  112589. /**
  112590. * Y subdivisions
  112591. */
  112592. get subdivisionsY(): number;
  112593. /**
  112594. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112595. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112596. * @param chunksCount the number of subdivisions for x and y
  112597. * @param octreeBlocksSize (Default: 32)
  112598. */
  112599. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112600. /**
  112601. * Returns a height (y) value in the Worl system :
  112602. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112603. * @param x x coordinate
  112604. * @param z z coordinate
  112605. * @returns the ground y position if (x, z) are outside the ground surface.
  112606. */
  112607. getHeightAtCoordinates(x: number, z: number): number;
  112608. /**
  112609. * Returns a normalized vector (Vector3) orthogonal to the ground
  112610. * at the ground coordinates (x, z) expressed in the World system.
  112611. * @param x x coordinate
  112612. * @param z z coordinate
  112613. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112614. */
  112615. getNormalAtCoordinates(x: number, z: number): Vector3;
  112616. /**
  112617. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112618. * at the ground coordinates (x, z) expressed in the World system.
  112619. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112620. * @param x x coordinate
  112621. * @param z z coordinate
  112622. * @param ref vector to store the result
  112623. * @returns the GroundMesh.
  112624. */
  112625. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112626. /**
  112627. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112628. * if the ground has been updated.
  112629. * This can be used in the render loop.
  112630. * @returns the GroundMesh.
  112631. */
  112632. updateCoordinateHeights(): GroundMesh;
  112633. private _getFacetAt;
  112634. private _initHeightQuads;
  112635. private _computeHeightQuads;
  112636. /**
  112637. * Serializes this ground mesh
  112638. * @param serializationObject object to write serialization to
  112639. */
  112640. serialize(serializationObject: any): void;
  112641. /**
  112642. * Parses a serialized ground mesh
  112643. * @param parsedMesh the serialized mesh
  112644. * @param scene the scene to create the ground mesh in
  112645. * @returns the created ground mesh
  112646. */
  112647. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112648. }
  112649. }
  112650. declare module BABYLON {
  112651. /**
  112652. * Interface for Physics-Joint data
  112653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112654. */
  112655. export interface PhysicsJointData {
  112656. /**
  112657. * The main pivot of the joint
  112658. */
  112659. mainPivot?: Vector3;
  112660. /**
  112661. * The connected pivot of the joint
  112662. */
  112663. connectedPivot?: Vector3;
  112664. /**
  112665. * The main axis of the joint
  112666. */
  112667. mainAxis?: Vector3;
  112668. /**
  112669. * The connected axis of the joint
  112670. */
  112671. connectedAxis?: Vector3;
  112672. /**
  112673. * The collision of the joint
  112674. */
  112675. collision?: boolean;
  112676. /**
  112677. * Native Oimo/Cannon/Energy data
  112678. */
  112679. nativeParams?: any;
  112680. }
  112681. /**
  112682. * This is a holder class for the physics joint created by the physics plugin
  112683. * It holds a set of functions to control the underlying joint
  112684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112685. */
  112686. export class PhysicsJoint {
  112687. /**
  112688. * The type of the physics joint
  112689. */
  112690. type: number;
  112691. /**
  112692. * The data for the physics joint
  112693. */
  112694. jointData: PhysicsJointData;
  112695. private _physicsJoint;
  112696. protected _physicsPlugin: IPhysicsEnginePlugin;
  112697. /**
  112698. * Initializes the physics joint
  112699. * @param type The type of the physics joint
  112700. * @param jointData The data for the physics joint
  112701. */
  112702. constructor(
  112703. /**
  112704. * The type of the physics joint
  112705. */
  112706. type: number,
  112707. /**
  112708. * The data for the physics joint
  112709. */
  112710. jointData: PhysicsJointData);
  112711. /**
  112712. * Gets the physics joint
  112713. */
  112714. get physicsJoint(): any;
  112715. /**
  112716. * Sets the physics joint
  112717. */
  112718. set physicsJoint(newJoint: any);
  112719. /**
  112720. * Sets the physics plugin
  112721. */
  112722. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112723. /**
  112724. * Execute a function that is physics-plugin specific.
  112725. * @param {Function} func the function that will be executed.
  112726. * It accepts two parameters: the physics world and the physics joint
  112727. */
  112728. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112729. /**
  112730. * Distance-Joint type
  112731. */
  112732. static DistanceJoint: number;
  112733. /**
  112734. * Hinge-Joint type
  112735. */
  112736. static HingeJoint: number;
  112737. /**
  112738. * Ball-and-Socket joint type
  112739. */
  112740. static BallAndSocketJoint: number;
  112741. /**
  112742. * Wheel-Joint type
  112743. */
  112744. static WheelJoint: number;
  112745. /**
  112746. * Slider-Joint type
  112747. */
  112748. static SliderJoint: number;
  112749. /**
  112750. * Prismatic-Joint type
  112751. */
  112752. static PrismaticJoint: number;
  112753. /**
  112754. * Universal-Joint type
  112755. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112756. */
  112757. static UniversalJoint: number;
  112758. /**
  112759. * Hinge-Joint 2 type
  112760. */
  112761. static Hinge2Joint: number;
  112762. /**
  112763. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112764. */
  112765. static PointToPointJoint: number;
  112766. /**
  112767. * Spring-Joint type
  112768. */
  112769. static SpringJoint: number;
  112770. /**
  112771. * Lock-Joint type
  112772. */
  112773. static LockJoint: number;
  112774. }
  112775. /**
  112776. * A class representing a physics distance joint
  112777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112778. */
  112779. export class DistanceJoint extends PhysicsJoint {
  112780. /**
  112781. *
  112782. * @param jointData The data for the Distance-Joint
  112783. */
  112784. constructor(jointData: DistanceJointData);
  112785. /**
  112786. * Update the predefined distance.
  112787. * @param maxDistance The maximum preferred distance
  112788. * @param minDistance The minimum preferred distance
  112789. */
  112790. updateDistance(maxDistance: number, minDistance?: number): void;
  112791. }
  112792. /**
  112793. * Represents a Motor-Enabled Joint
  112794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112795. */
  112796. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112797. /**
  112798. * Initializes the Motor-Enabled Joint
  112799. * @param type The type of the joint
  112800. * @param jointData The physica joint data for the joint
  112801. */
  112802. constructor(type: number, jointData: PhysicsJointData);
  112803. /**
  112804. * Set the motor values.
  112805. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112806. * @param force the force to apply
  112807. * @param maxForce max force for this motor.
  112808. */
  112809. setMotor(force?: number, maxForce?: number): void;
  112810. /**
  112811. * Set the motor's limits.
  112812. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112813. * @param upperLimit The upper limit of the motor
  112814. * @param lowerLimit The lower limit of the motor
  112815. */
  112816. setLimit(upperLimit: number, lowerLimit?: number): void;
  112817. }
  112818. /**
  112819. * This class represents a single physics Hinge-Joint
  112820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112821. */
  112822. export class HingeJoint extends MotorEnabledJoint {
  112823. /**
  112824. * Initializes the Hinge-Joint
  112825. * @param jointData The joint data for the Hinge-Joint
  112826. */
  112827. constructor(jointData: PhysicsJointData);
  112828. /**
  112829. * Set the motor values.
  112830. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112831. * @param {number} force the force to apply
  112832. * @param {number} maxForce max force for this motor.
  112833. */
  112834. setMotor(force?: number, maxForce?: number): void;
  112835. /**
  112836. * Set the motor's limits.
  112837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112838. * @param upperLimit The upper limit of the motor
  112839. * @param lowerLimit The lower limit of the motor
  112840. */
  112841. setLimit(upperLimit: number, lowerLimit?: number): void;
  112842. }
  112843. /**
  112844. * This class represents a dual hinge physics joint (same as wheel joint)
  112845. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112846. */
  112847. export class Hinge2Joint extends MotorEnabledJoint {
  112848. /**
  112849. * Initializes the Hinge2-Joint
  112850. * @param jointData The joint data for the Hinge2-Joint
  112851. */
  112852. constructor(jointData: PhysicsJointData);
  112853. /**
  112854. * Set the motor values.
  112855. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112856. * @param {number} targetSpeed the speed the motor is to reach
  112857. * @param {number} maxForce max force for this motor.
  112858. * @param {motorIndex} the motor's index, 0 or 1.
  112859. */
  112860. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112861. /**
  112862. * Set the motor limits.
  112863. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112864. * @param {number} upperLimit the upper limit
  112865. * @param {number} lowerLimit lower limit
  112866. * @param {motorIndex} the motor's index, 0 or 1.
  112867. */
  112868. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112869. }
  112870. /**
  112871. * Interface for a motor enabled joint
  112872. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112873. */
  112874. export interface IMotorEnabledJoint {
  112875. /**
  112876. * Physics joint
  112877. */
  112878. physicsJoint: any;
  112879. /**
  112880. * Sets the motor of the motor-enabled joint
  112881. * @param force The force of the motor
  112882. * @param maxForce The maximum force of the motor
  112883. * @param motorIndex The index of the motor
  112884. */
  112885. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112886. /**
  112887. * Sets the limit of the motor
  112888. * @param upperLimit The upper limit of the motor
  112889. * @param lowerLimit The lower limit of the motor
  112890. * @param motorIndex The index of the motor
  112891. */
  112892. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112893. }
  112894. /**
  112895. * Joint data for a Distance-Joint
  112896. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112897. */
  112898. export interface DistanceJointData extends PhysicsJointData {
  112899. /**
  112900. * Max distance the 2 joint objects can be apart
  112901. */
  112902. maxDistance: number;
  112903. }
  112904. /**
  112905. * Joint data from a spring joint
  112906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112907. */
  112908. export interface SpringJointData extends PhysicsJointData {
  112909. /**
  112910. * Length of the spring
  112911. */
  112912. length: number;
  112913. /**
  112914. * Stiffness of the spring
  112915. */
  112916. stiffness: number;
  112917. /**
  112918. * Damping of the spring
  112919. */
  112920. damping: number;
  112921. /** this callback will be called when applying the force to the impostors. */
  112922. forceApplicationCallback: () => void;
  112923. }
  112924. }
  112925. declare module BABYLON {
  112926. /**
  112927. * Holds the data for the raycast result
  112928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112929. */
  112930. export class PhysicsRaycastResult {
  112931. private _hasHit;
  112932. private _hitDistance;
  112933. private _hitNormalWorld;
  112934. private _hitPointWorld;
  112935. private _rayFromWorld;
  112936. private _rayToWorld;
  112937. /**
  112938. * Gets if there was a hit
  112939. */
  112940. get hasHit(): boolean;
  112941. /**
  112942. * Gets the distance from the hit
  112943. */
  112944. get hitDistance(): number;
  112945. /**
  112946. * Gets the hit normal/direction in the world
  112947. */
  112948. get hitNormalWorld(): Vector3;
  112949. /**
  112950. * Gets the hit point in the world
  112951. */
  112952. get hitPointWorld(): Vector3;
  112953. /**
  112954. * Gets the ray "start point" of the ray in the world
  112955. */
  112956. get rayFromWorld(): Vector3;
  112957. /**
  112958. * Gets the ray "end point" of the ray in the world
  112959. */
  112960. get rayToWorld(): Vector3;
  112961. /**
  112962. * Sets the hit data (normal & point in world space)
  112963. * @param hitNormalWorld defines the normal in world space
  112964. * @param hitPointWorld defines the point in world space
  112965. */
  112966. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112967. /**
  112968. * Sets the distance from the start point to the hit point
  112969. * @param distance
  112970. */
  112971. setHitDistance(distance: number): void;
  112972. /**
  112973. * Calculates the distance manually
  112974. */
  112975. calculateHitDistance(): void;
  112976. /**
  112977. * Resets all the values to default
  112978. * @param from The from point on world space
  112979. * @param to The to point on world space
  112980. */
  112981. reset(from?: Vector3, to?: Vector3): void;
  112982. }
  112983. /**
  112984. * Interface for the size containing width and height
  112985. */
  112986. interface IXYZ {
  112987. /**
  112988. * X
  112989. */
  112990. x: number;
  112991. /**
  112992. * Y
  112993. */
  112994. y: number;
  112995. /**
  112996. * Z
  112997. */
  112998. z: number;
  112999. }
  113000. }
  113001. declare module BABYLON {
  113002. /**
  113003. * Interface used to describe a physics joint
  113004. */
  113005. export interface PhysicsImpostorJoint {
  113006. /** Defines the main impostor to which the joint is linked */
  113007. mainImpostor: PhysicsImpostor;
  113008. /** Defines the impostor that is connected to the main impostor using this joint */
  113009. connectedImpostor: PhysicsImpostor;
  113010. /** Defines the joint itself */
  113011. joint: PhysicsJoint;
  113012. }
  113013. /** @hidden */
  113014. export interface IPhysicsEnginePlugin {
  113015. world: any;
  113016. name: string;
  113017. setGravity(gravity: Vector3): void;
  113018. setTimeStep(timeStep: number): void;
  113019. getTimeStep(): number;
  113020. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113021. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113022. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113023. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113024. removePhysicsBody(impostor: PhysicsImpostor): void;
  113025. generateJoint(joint: PhysicsImpostorJoint): void;
  113026. removeJoint(joint: PhysicsImpostorJoint): void;
  113027. isSupported(): boolean;
  113028. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113029. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113030. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113031. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113032. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113033. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113034. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113035. getBodyMass(impostor: PhysicsImpostor): number;
  113036. getBodyFriction(impostor: PhysicsImpostor): number;
  113037. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113038. getBodyRestitution(impostor: PhysicsImpostor): number;
  113039. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113040. getBodyPressure?(impostor: PhysicsImpostor): number;
  113041. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  113042. getBodyStiffness?(impostor: PhysicsImpostor): number;
  113043. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  113044. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  113045. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  113046. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  113047. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  113048. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113049. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113050. sleepBody(impostor: PhysicsImpostor): void;
  113051. wakeUpBody(impostor: PhysicsImpostor): void;
  113052. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113053. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113054. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  113055. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113056. getRadius(impostor: PhysicsImpostor): number;
  113057. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113058. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113059. dispose(): void;
  113060. }
  113061. /**
  113062. * Interface used to define a physics engine
  113063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113064. */
  113065. export interface IPhysicsEngine {
  113066. /**
  113067. * Gets the gravity vector used by the simulation
  113068. */
  113069. gravity: Vector3;
  113070. /**
  113071. * Sets the gravity vector used by the simulation
  113072. * @param gravity defines the gravity vector to use
  113073. */
  113074. setGravity(gravity: Vector3): void;
  113075. /**
  113076. * Set the time step of the physics engine.
  113077. * Default is 1/60.
  113078. * To slow it down, enter 1/600 for example.
  113079. * To speed it up, 1/30
  113080. * @param newTimeStep the new timestep to apply to this world.
  113081. */
  113082. setTimeStep(newTimeStep: number): void;
  113083. /**
  113084. * Get the time step of the physics engine.
  113085. * @returns the current time step
  113086. */
  113087. getTimeStep(): number;
  113088. /**
  113089. * Set the sub time step of the physics engine.
  113090. * Default is 0 meaning there is no sub steps
  113091. * To increase physics resolution precision, set a small value (like 1 ms)
  113092. * @param subTimeStep defines the new sub timestep used for physics resolution.
  113093. */
  113094. setSubTimeStep(subTimeStep: number): void;
  113095. /**
  113096. * Get the sub time step of the physics engine.
  113097. * @returns the current sub time step
  113098. */
  113099. getSubTimeStep(): number;
  113100. /**
  113101. * Release all resources
  113102. */
  113103. dispose(): void;
  113104. /**
  113105. * Gets the name of the current physics plugin
  113106. * @returns the name of the plugin
  113107. */
  113108. getPhysicsPluginName(): string;
  113109. /**
  113110. * Adding a new impostor for the impostor tracking.
  113111. * This will be done by the impostor itself.
  113112. * @param impostor the impostor to add
  113113. */
  113114. addImpostor(impostor: PhysicsImpostor): void;
  113115. /**
  113116. * Remove an impostor from the engine.
  113117. * This impostor and its mesh will not longer be updated by the physics engine.
  113118. * @param impostor the impostor to remove
  113119. */
  113120. removeImpostor(impostor: PhysicsImpostor): void;
  113121. /**
  113122. * Add a joint to the physics engine
  113123. * @param mainImpostor defines the main impostor to which the joint is added.
  113124. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113125. * @param joint defines the joint that will connect both impostors.
  113126. */
  113127. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113128. /**
  113129. * Removes a joint from the simulation
  113130. * @param mainImpostor defines the impostor used with the joint
  113131. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113132. * @param joint defines the joint to remove
  113133. */
  113134. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113135. /**
  113136. * Gets the current plugin used to run the simulation
  113137. * @returns current plugin
  113138. */
  113139. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113140. /**
  113141. * Gets the list of physic impostors
  113142. * @returns an array of PhysicsImpostor
  113143. */
  113144. getImpostors(): Array<PhysicsImpostor>;
  113145. /**
  113146. * Gets the impostor for a physics enabled object
  113147. * @param object defines the object impersonated by the impostor
  113148. * @returns the PhysicsImpostor or null if not found
  113149. */
  113150. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113151. /**
  113152. * Gets the impostor for a physics body object
  113153. * @param body defines physics body used by the impostor
  113154. * @returns the PhysicsImpostor or null if not found
  113155. */
  113156. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113157. /**
  113158. * Does a raycast in the physics world
  113159. * @param from when should the ray start?
  113160. * @param to when should the ray end?
  113161. * @returns PhysicsRaycastResult
  113162. */
  113163. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113164. /**
  113165. * Called by the scene. No need to call it.
  113166. * @param delta defines the timespam between frames
  113167. */
  113168. _step(delta: number): void;
  113169. }
  113170. }
  113171. declare module BABYLON {
  113172. /**
  113173. * The interface for the physics imposter parameters
  113174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113175. */
  113176. export interface PhysicsImpostorParameters {
  113177. /**
  113178. * The mass of the physics imposter
  113179. */
  113180. mass: number;
  113181. /**
  113182. * The friction of the physics imposter
  113183. */
  113184. friction?: number;
  113185. /**
  113186. * The coefficient of restitution of the physics imposter
  113187. */
  113188. restitution?: number;
  113189. /**
  113190. * The native options of the physics imposter
  113191. */
  113192. nativeOptions?: any;
  113193. /**
  113194. * Specifies if the parent should be ignored
  113195. */
  113196. ignoreParent?: boolean;
  113197. /**
  113198. * Specifies if bi-directional transformations should be disabled
  113199. */
  113200. disableBidirectionalTransformation?: boolean;
  113201. /**
  113202. * The pressure inside the physics imposter, soft object only
  113203. */
  113204. pressure?: number;
  113205. /**
  113206. * The stiffness the physics imposter, soft object only
  113207. */
  113208. stiffness?: number;
  113209. /**
  113210. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113211. */
  113212. velocityIterations?: number;
  113213. /**
  113214. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113215. */
  113216. positionIterations?: number;
  113217. /**
  113218. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113219. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113220. * Add to fix multiple points
  113221. */
  113222. fixedPoints?: number;
  113223. /**
  113224. * The collision margin around a soft object
  113225. */
  113226. margin?: number;
  113227. /**
  113228. * The collision margin around a soft object
  113229. */
  113230. damping?: number;
  113231. /**
  113232. * The path for a rope based on an extrusion
  113233. */
  113234. path?: any;
  113235. /**
  113236. * The shape of an extrusion used for a rope based on an extrusion
  113237. */
  113238. shape?: any;
  113239. }
  113240. /**
  113241. * Interface for a physics-enabled object
  113242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113243. */
  113244. export interface IPhysicsEnabledObject {
  113245. /**
  113246. * The position of the physics-enabled object
  113247. */
  113248. position: Vector3;
  113249. /**
  113250. * The rotation of the physics-enabled object
  113251. */
  113252. rotationQuaternion: Nullable<Quaternion>;
  113253. /**
  113254. * The scale of the physics-enabled object
  113255. */
  113256. scaling: Vector3;
  113257. /**
  113258. * The rotation of the physics-enabled object
  113259. */
  113260. rotation?: Vector3;
  113261. /**
  113262. * The parent of the physics-enabled object
  113263. */
  113264. parent?: any;
  113265. /**
  113266. * The bounding info of the physics-enabled object
  113267. * @returns The bounding info of the physics-enabled object
  113268. */
  113269. getBoundingInfo(): BoundingInfo;
  113270. /**
  113271. * Computes the world matrix
  113272. * @param force Specifies if the world matrix should be computed by force
  113273. * @returns A world matrix
  113274. */
  113275. computeWorldMatrix(force: boolean): Matrix;
  113276. /**
  113277. * Gets the world matrix
  113278. * @returns A world matrix
  113279. */
  113280. getWorldMatrix?(): Matrix;
  113281. /**
  113282. * Gets the child meshes
  113283. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113284. * @returns An array of abstract meshes
  113285. */
  113286. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113287. /**
  113288. * Gets the vertex data
  113289. * @param kind The type of vertex data
  113290. * @returns A nullable array of numbers, or a float32 array
  113291. */
  113292. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113293. /**
  113294. * Gets the indices from the mesh
  113295. * @returns A nullable array of index arrays
  113296. */
  113297. getIndices?(): Nullable<IndicesArray>;
  113298. /**
  113299. * Gets the scene from the mesh
  113300. * @returns the indices array or null
  113301. */
  113302. getScene?(): Scene;
  113303. /**
  113304. * Gets the absolute position from the mesh
  113305. * @returns the absolute position
  113306. */
  113307. getAbsolutePosition(): Vector3;
  113308. /**
  113309. * Gets the absolute pivot point from the mesh
  113310. * @returns the absolute pivot point
  113311. */
  113312. getAbsolutePivotPoint(): Vector3;
  113313. /**
  113314. * Rotates the mesh
  113315. * @param axis The axis of rotation
  113316. * @param amount The amount of rotation
  113317. * @param space The space of the rotation
  113318. * @returns The rotation transform node
  113319. */
  113320. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113321. /**
  113322. * Translates the mesh
  113323. * @param axis The axis of translation
  113324. * @param distance The distance of translation
  113325. * @param space The space of the translation
  113326. * @returns The transform node
  113327. */
  113328. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113329. /**
  113330. * Sets the absolute position of the mesh
  113331. * @param absolutePosition The absolute position of the mesh
  113332. * @returns The transform node
  113333. */
  113334. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113335. /**
  113336. * Gets the class name of the mesh
  113337. * @returns The class name
  113338. */
  113339. getClassName(): string;
  113340. }
  113341. /**
  113342. * Represents a physics imposter
  113343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113344. */
  113345. export class PhysicsImpostor {
  113346. /**
  113347. * The physics-enabled object used as the physics imposter
  113348. */
  113349. object: IPhysicsEnabledObject;
  113350. /**
  113351. * The type of the physics imposter
  113352. */
  113353. type: number;
  113354. private _options;
  113355. private _scene?;
  113356. /**
  113357. * The default object size of the imposter
  113358. */
  113359. static DEFAULT_OBJECT_SIZE: Vector3;
  113360. /**
  113361. * The identity quaternion of the imposter
  113362. */
  113363. static IDENTITY_QUATERNION: Quaternion;
  113364. /** @hidden */
  113365. _pluginData: any;
  113366. private _physicsEngine;
  113367. private _physicsBody;
  113368. private _bodyUpdateRequired;
  113369. private _onBeforePhysicsStepCallbacks;
  113370. private _onAfterPhysicsStepCallbacks;
  113371. /** @hidden */
  113372. _onPhysicsCollideCallbacks: Array<{
  113373. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113374. otherImpostors: Array<PhysicsImpostor>;
  113375. }>;
  113376. private _deltaPosition;
  113377. private _deltaRotation;
  113378. private _deltaRotationConjugated;
  113379. /** @hidden */
  113380. _isFromLine: boolean;
  113381. private _parent;
  113382. private _isDisposed;
  113383. private static _tmpVecs;
  113384. private static _tmpQuat;
  113385. /**
  113386. * Specifies if the physics imposter is disposed
  113387. */
  113388. get isDisposed(): boolean;
  113389. /**
  113390. * Gets the mass of the physics imposter
  113391. */
  113392. get mass(): number;
  113393. set mass(value: number);
  113394. /**
  113395. * Gets the coefficient of friction
  113396. */
  113397. get friction(): number;
  113398. /**
  113399. * Sets the coefficient of friction
  113400. */
  113401. set friction(value: number);
  113402. /**
  113403. * Gets the coefficient of restitution
  113404. */
  113405. get restitution(): number;
  113406. /**
  113407. * Sets the coefficient of restitution
  113408. */
  113409. set restitution(value: number);
  113410. /**
  113411. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113412. */
  113413. get pressure(): number;
  113414. /**
  113415. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113416. */
  113417. set pressure(value: number);
  113418. /**
  113419. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113420. */
  113421. get stiffness(): number;
  113422. /**
  113423. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113424. */
  113425. set stiffness(value: number);
  113426. /**
  113427. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113428. */
  113429. get velocityIterations(): number;
  113430. /**
  113431. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113432. */
  113433. set velocityIterations(value: number);
  113434. /**
  113435. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113436. */
  113437. get positionIterations(): number;
  113438. /**
  113439. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113440. */
  113441. set positionIterations(value: number);
  113442. /**
  113443. * The unique id of the physics imposter
  113444. * set by the physics engine when adding this impostor to the array
  113445. */
  113446. uniqueId: number;
  113447. /**
  113448. * @hidden
  113449. */
  113450. soft: boolean;
  113451. /**
  113452. * @hidden
  113453. */
  113454. segments: number;
  113455. private _joints;
  113456. /**
  113457. * Initializes the physics imposter
  113458. * @param object The physics-enabled object used as the physics imposter
  113459. * @param type The type of the physics imposter
  113460. * @param _options The options for the physics imposter
  113461. * @param _scene The Babylon scene
  113462. */
  113463. constructor(
  113464. /**
  113465. * The physics-enabled object used as the physics imposter
  113466. */
  113467. object: IPhysicsEnabledObject,
  113468. /**
  113469. * The type of the physics imposter
  113470. */
  113471. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113472. /**
  113473. * This function will completly initialize this impostor.
  113474. * It will create a new body - but only if this mesh has no parent.
  113475. * If it has, this impostor will not be used other than to define the impostor
  113476. * of the child mesh.
  113477. * @hidden
  113478. */
  113479. _init(): void;
  113480. private _getPhysicsParent;
  113481. /**
  113482. * Should a new body be generated.
  113483. * @returns boolean specifying if body initialization is required
  113484. */
  113485. isBodyInitRequired(): boolean;
  113486. /**
  113487. * Sets the updated scaling
  113488. * @param updated Specifies if the scaling is updated
  113489. */
  113490. setScalingUpdated(): void;
  113491. /**
  113492. * Force a regeneration of this or the parent's impostor's body.
  113493. * Use under cautious - This will remove all joints already implemented.
  113494. */
  113495. forceUpdate(): void;
  113496. /**
  113497. * Gets the body that holds this impostor. Either its own, or its parent.
  113498. */
  113499. get physicsBody(): any;
  113500. /**
  113501. * Get the parent of the physics imposter
  113502. * @returns Physics imposter or null
  113503. */
  113504. get parent(): Nullable<PhysicsImpostor>;
  113505. /**
  113506. * Sets the parent of the physics imposter
  113507. */
  113508. set parent(value: Nullable<PhysicsImpostor>);
  113509. /**
  113510. * Set the physics body. Used mainly by the physics engine/plugin
  113511. */
  113512. set physicsBody(physicsBody: any);
  113513. /**
  113514. * Resets the update flags
  113515. */
  113516. resetUpdateFlags(): void;
  113517. /**
  113518. * Gets the object extend size
  113519. * @returns the object extend size
  113520. */
  113521. getObjectExtendSize(): Vector3;
  113522. /**
  113523. * Gets the object center
  113524. * @returns The object center
  113525. */
  113526. getObjectCenter(): Vector3;
  113527. /**
  113528. * Get a specific parameter from the options parameters
  113529. * @param paramName The object parameter name
  113530. * @returns The object parameter
  113531. */
  113532. getParam(paramName: string): any;
  113533. /**
  113534. * Sets a specific parameter in the options given to the physics plugin
  113535. * @param paramName The parameter name
  113536. * @param value The value of the parameter
  113537. */
  113538. setParam(paramName: string, value: number): void;
  113539. /**
  113540. * Specifically change the body's mass option. Won't recreate the physics body object
  113541. * @param mass The mass of the physics imposter
  113542. */
  113543. setMass(mass: number): void;
  113544. /**
  113545. * Gets the linear velocity
  113546. * @returns linear velocity or null
  113547. */
  113548. getLinearVelocity(): Nullable<Vector3>;
  113549. /**
  113550. * Sets the linear velocity
  113551. * @param velocity linear velocity or null
  113552. */
  113553. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113554. /**
  113555. * Gets the angular velocity
  113556. * @returns angular velocity or null
  113557. */
  113558. getAngularVelocity(): Nullable<Vector3>;
  113559. /**
  113560. * Sets the angular velocity
  113561. * @param velocity The velocity or null
  113562. */
  113563. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113564. /**
  113565. * Execute a function with the physics plugin native code
  113566. * Provide a function the will have two variables - the world object and the physics body object
  113567. * @param func The function to execute with the physics plugin native code
  113568. */
  113569. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113570. /**
  113571. * Register a function that will be executed before the physics world is stepping forward
  113572. * @param func The function to execute before the physics world is stepped forward
  113573. */
  113574. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113575. /**
  113576. * Unregister a function that will be executed before the physics world is stepping forward
  113577. * @param func The function to execute before the physics world is stepped forward
  113578. */
  113579. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113580. /**
  113581. * Register a function that will be executed after the physics step
  113582. * @param func The function to execute after physics step
  113583. */
  113584. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113585. /**
  113586. * Unregisters a function that will be executed after the physics step
  113587. * @param func The function to execute after physics step
  113588. */
  113589. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113590. /**
  113591. * register a function that will be executed when this impostor collides against a different body
  113592. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113593. * @param func Callback that is executed on collision
  113594. */
  113595. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113596. /**
  113597. * Unregisters the physics imposter on contact
  113598. * @param collideAgainst The physics object to collide against
  113599. * @param func Callback to execute on collision
  113600. */
  113601. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113602. private _tmpQuat;
  113603. private _tmpQuat2;
  113604. /**
  113605. * Get the parent rotation
  113606. * @returns The parent rotation
  113607. */
  113608. getParentsRotation(): Quaternion;
  113609. /**
  113610. * this function is executed by the physics engine.
  113611. */
  113612. beforeStep: () => void;
  113613. /**
  113614. * this function is executed by the physics engine
  113615. */
  113616. afterStep: () => void;
  113617. /**
  113618. * Legacy collision detection event support
  113619. */
  113620. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113621. /**
  113622. * event and body object due to cannon's event-based architecture.
  113623. */
  113624. onCollide: (e: {
  113625. body: any;
  113626. point: Nullable<Vector3>;
  113627. }) => void;
  113628. /**
  113629. * Apply a force
  113630. * @param force The force to apply
  113631. * @param contactPoint The contact point for the force
  113632. * @returns The physics imposter
  113633. */
  113634. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113635. /**
  113636. * Apply an impulse
  113637. * @param force The impulse force
  113638. * @param contactPoint The contact point for the impulse force
  113639. * @returns The physics imposter
  113640. */
  113641. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113642. /**
  113643. * A help function to create a joint
  113644. * @param otherImpostor A physics imposter used to create a joint
  113645. * @param jointType The type of joint
  113646. * @param jointData The data for the joint
  113647. * @returns The physics imposter
  113648. */
  113649. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113650. /**
  113651. * Add a joint to this impostor with a different impostor
  113652. * @param otherImpostor A physics imposter used to add a joint
  113653. * @param joint The joint to add
  113654. * @returns The physics imposter
  113655. */
  113656. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113657. /**
  113658. * Add an anchor to a cloth impostor
  113659. * @param otherImpostor rigid impostor to anchor to
  113660. * @param width ratio across width from 0 to 1
  113661. * @param height ratio up height from 0 to 1
  113662. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113663. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113664. * @returns impostor the soft imposter
  113665. */
  113666. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113667. /**
  113668. * Add a hook to a rope impostor
  113669. * @param otherImpostor rigid impostor to anchor to
  113670. * @param length ratio across rope from 0 to 1
  113671. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113672. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113673. * @returns impostor the rope imposter
  113674. */
  113675. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113676. /**
  113677. * Will keep this body still, in a sleep mode.
  113678. * @returns the physics imposter
  113679. */
  113680. sleep(): PhysicsImpostor;
  113681. /**
  113682. * Wake the body up.
  113683. * @returns The physics imposter
  113684. */
  113685. wakeUp(): PhysicsImpostor;
  113686. /**
  113687. * Clones the physics imposter
  113688. * @param newObject The physics imposter clones to this physics-enabled object
  113689. * @returns A nullable physics imposter
  113690. */
  113691. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113692. /**
  113693. * Disposes the physics imposter
  113694. */
  113695. dispose(): void;
  113696. /**
  113697. * Sets the delta position
  113698. * @param position The delta position amount
  113699. */
  113700. setDeltaPosition(position: Vector3): void;
  113701. /**
  113702. * Sets the delta rotation
  113703. * @param rotation The delta rotation amount
  113704. */
  113705. setDeltaRotation(rotation: Quaternion): void;
  113706. /**
  113707. * Gets the box size of the physics imposter and stores the result in the input parameter
  113708. * @param result Stores the box size
  113709. * @returns The physics imposter
  113710. */
  113711. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113712. /**
  113713. * Gets the radius of the physics imposter
  113714. * @returns Radius of the physics imposter
  113715. */
  113716. getRadius(): number;
  113717. /**
  113718. * Sync a bone with this impostor
  113719. * @param bone The bone to sync to the impostor.
  113720. * @param boneMesh The mesh that the bone is influencing.
  113721. * @param jointPivot The pivot of the joint / bone in local space.
  113722. * @param distToJoint Optional distance from the impostor to the joint.
  113723. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113724. */
  113725. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113726. /**
  113727. * Sync impostor to a bone
  113728. * @param bone The bone that the impostor will be synced to.
  113729. * @param boneMesh The mesh that the bone is influencing.
  113730. * @param jointPivot The pivot of the joint / bone in local space.
  113731. * @param distToJoint Optional distance from the impostor to the joint.
  113732. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113733. * @param boneAxis Optional vector3 axis the bone is aligned with
  113734. */
  113735. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113736. /**
  113737. * No-Imposter type
  113738. */
  113739. static NoImpostor: number;
  113740. /**
  113741. * Sphere-Imposter type
  113742. */
  113743. static SphereImpostor: number;
  113744. /**
  113745. * Box-Imposter type
  113746. */
  113747. static BoxImpostor: number;
  113748. /**
  113749. * Plane-Imposter type
  113750. */
  113751. static PlaneImpostor: number;
  113752. /**
  113753. * Mesh-imposter type
  113754. */
  113755. static MeshImpostor: number;
  113756. /**
  113757. * Capsule-Impostor type (Ammo.js plugin only)
  113758. */
  113759. static CapsuleImpostor: number;
  113760. /**
  113761. * Cylinder-Imposter type
  113762. */
  113763. static CylinderImpostor: number;
  113764. /**
  113765. * Particle-Imposter type
  113766. */
  113767. static ParticleImpostor: number;
  113768. /**
  113769. * Heightmap-Imposter type
  113770. */
  113771. static HeightmapImpostor: number;
  113772. /**
  113773. * ConvexHull-Impostor type (Ammo.js plugin only)
  113774. */
  113775. static ConvexHullImpostor: number;
  113776. /**
  113777. * Custom-Imposter type (Ammo.js plugin only)
  113778. */
  113779. static CustomImpostor: number;
  113780. /**
  113781. * Rope-Imposter type
  113782. */
  113783. static RopeImpostor: number;
  113784. /**
  113785. * Cloth-Imposter type
  113786. */
  113787. static ClothImpostor: number;
  113788. /**
  113789. * Softbody-Imposter type
  113790. */
  113791. static SoftbodyImpostor: number;
  113792. }
  113793. }
  113794. declare module BABYLON {
  113795. /**
  113796. * @hidden
  113797. **/
  113798. export class _CreationDataStorage {
  113799. closePath?: boolean;
  113800. closeArray?: boolean;
  113801. idx: number[];
  113802. dashSize: number;
  113803. gapSize: number;
  113804. path3D: Path3D;
  113805. pathArray: Vector3[][];
  113806. arc: number;
  113807. radius: number;
  113808. cap: number;
  113809. tessellation: number;
  113810. }
  113811. /**
  113812. * @hidden
  113813. **/
  113814. class _InstanceDataStorage {
  113815. visibleInstances: any;
  113816. batchCache: _InstancesBatch;
  113817. instancesBufferSize: number;
  113818. instancesBuffer: Nullable<Buffer>;
  113819. instancesData: Float32Array;
  113820. overridenInstanceCount: number;
  113821. isFrozen: boolean;
  113822. previousBatch: Nullable<_InstancesBatch>;
  113823. hardwareInstancedRendering: boolean;
  113824. sideOrientation: number;
  113825. manualUpdate: boolean;
  113826. previousRenderId: number;
  113827. }
  113828. /**
  113829. * @hidden
  113830. **/
  113831. export class _InstancesBatch {
  113832. mustReturn: boolean;
  113833. visibleInstances: Nullable<InstancedMesh[]>[];
  113834. renderSelf: boolean[];
  113835. hardwareInstancedRendering: boolean[];
  113836. }
  113837. /**
  113838. * @hidden
  113839. **/
  113840. class _ThinInstanceDataStorage {
  113841. instancesCount: number;
  113842. matrixBuffer: Nullable<Buffer>;
  113843. matrixBufferSize: number;
  113844. matrixData: Nullable<Float32Array>;
  113845. boundingVectors: Array<Vector3>;
  113846. worldMatrices: Nullable<Matrix[]>;
  113847. }
  113848. /**
  113849. * Class used to represent renderable models
  113850. */
  113851. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113852. /**
  113853. * Mesh side orientation : usually the external or front surface
  113854. */
  113855. static readonly FRONTSIDE: number;
  113856. /**
  113857. * Mesh side orientation : usually the internal or back surface
  113858. */
  113859. static readonly BACKSIDE: number;
  113860. /**
  113861. * Mesh side orientation : both internal and external or front and back surfaces
  113862. */
  113863. static readonly DOUBLESIDE: number;
  113864. /**
  113865. * Mesh side orientation : by default, `FRONTSIDE`
  113866. */
  113867. static readonly DEFAULTSIDE: number;
  113868. /**
  113869. * Mesh cap setting : no cap
  113870. */
  113871. static readonly NO_CAP: number;
  113872. /**
  113873. * Mesh cap setting : one cap at the beginning of the mesh
  113874. */
  113875. static readonly CAP_START: number;
  113876. /**
  113877. * Mesh cap setting : one cap at the end of the mesh
  113878. */
  113879. static readonly CAP_END: number;
  113880. /**
  113881. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113882. */
  113883. static readonly CAP_ALL: number;
  113884. /**
  113885. * Mesh pattern setting : no flip or rotate
  113886. */
  113887. static readonly NO_FLIP: number;
  113888. /**
  113889. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113890. */
  113891. static readonly FLIP_TILE: number;
  113892. /**
  113893. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113894. */
  113895. static readonly ROTATE_TILE: number;
  113896. /**
  113897. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113898. */
  113899. static readonly FLIP_ROW: number;
  113900. /**
  113901. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113902. */
  113903. static readonly ROTATE_ROW: number;
  113904. /**
  113905. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113906. */
  113907. static readonly FLIP_N_ROTATE_TILE: number;
  113908. /**
  113909. * Mesh pattern setting : rotate pattern and rotate
  113910. */
  113911. static readonly FLIP_N_ROTATE_ROW: number;
  113912. /**
  113913. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113914. */
  113915. static readonly CENTER: number;
  113916. /**
  113917. * Mesh tile positioning : part tiles on left
  113918. */
  113919. static readonly LEFT: number;
  113920. /**
  113921. * Mesh tile positioning : part tiles on right
  113922. */
  113923. static readonly RIGHT: number;
  113924. /**
  113925. * Mesh tile positioning : part tiles on top
  113926. */
  113927. static readonly TOP: number;
  113928. /**
  113929. * Mesh tile positioning : part tiles on bottom
  113930. */
  113931. static readonly BOTTOM: number;
  113932. /**
  113933. * Gets the default side orientation.
  113934. * @param orientation the orientation to value to attempt to get
  113935. * @returns the default orientation
  113936. * @hidden
  113937. */
  113938. static _GetDefaultSideOrientation(orientation?: number): number;
  113939. private _internalMeshDataInfo;
  113940. get computeBonesUsingShaders(): boolean;
  113941. set computeBonesUsingShaders(value: boolean);
  113942. /**
  113943. * An event triggered before rendering the mesh
  113944. */
  113945. get onBeforeRenderObservable(): Observable<Mesh>;
  113946. /**
  113947. * An event triggered before binding the mesh
  113948. */
  113949. get onBeforeBindObservable(): Observable<Mesh>;
  113950. /**
  113951. * An event triggered after rendering the mesh
  113952. */
  113953. get onAfterRenderObservable(): Observable<Mesh>;
  113954. /**
  113955. * An event triggered before drawing the mesh
  113956. */
  113957. get onBeforeDrawObservable(): Observable<Mesh>;
  113958. private _onBeforeDrawObserver;
  113959. /**
  113960. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113961. */
  113962. set onBeforeDraw(callback: () => void);
  113963. get hasInstances(): boolean;
  113964. get hasThinInstances(): boolean;
  113965. /**
  113966. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113967. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113968. */
  113969. delayLoadState: number;
  113970. /**
  113971. * Gets the list of instances created from this mesh
  113972. * it is not supposed to be modified manually.
  113973. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113974. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113975. */
  113976. instances: InstancedMesh[];
  113977. /**
  113978. * Gets the file containing delay loading data for this mesh
  113979. */
  113980. delayLoadingFile: string;
  113981. /** @hidden */
  113982. _binaryInfo: any;
  113983. /**
  113984. * User defined function used to change how LOD level selection is done
  113985. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113986. */
  113987. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113988. /**
  113989. * Gets or sets the morph target manager
  113990. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  113991. */
  113992. get morphTargetManager(): Nullable<MorphTargetManager>;
  113993. set morphTargetManager(value: Nullable<MorphTargetManager>);
  113994. /** @hidden */
  113995. _creationDataStorage: Nullable<_CreationDataStorage>;
  113996. /** @hidden */
  113997. _geometry: Nullable<Geometry>;
  113998. /** @hidden */
  113999. _delayInfo: Array<string>;
  114000. /** @hidden */
  114001. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  114002. /** @hidden */
  114003. _instanceDataStorage: _InstanceDataStorage;
  114004. /** @hidden */
  114005. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  114006. private _effectiveMaterial;
  114007. /** @hidden */
  114008. _shouldGenerateFlatShading: boolean;
  114009. /** @hidden */
  114010. _originalBuilderSideOrientation: number;
  114011. /**
  114012. * Use this property to change the original side orientation defined at construction time
  114013. */
  114014. overrideMaterialSideOrientation: Nullable<number>;
  114015. /**
  114016. * Gets the source mesh (the one used to clone this one from)
  114017. */
  114018. get source(): Nullable<Mesh>;
  114019. /**
  114020. * Gets the list of clones of this mesh
  114021. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  114022. * Note that useClonedMeshMap=true is the default setting
  114023. */
  114024. get cloneMeshMap(): Nullable<{
  114025. [id: string]: Mesh | undefined;
  114026. }>;
  114027. /**
  114028. * Gets or sets a boolean indicating that this mesh does not use index buffer
  114029. */
  114030. get isUnIndexed(): boolean;
  114031. set isUnIndexed(value: boolean);
  114032. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  114033. get worldMatrixInstancedBuffer(): Float32Array;
  114034. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  114035. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  114036. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  114037. /**
  114038. * @constructor
  114039. * @param name The value used by scene.getMeshByName() to do a lookup.
  114040. * @param scene The scene to add this mesh to.
  114041. * @param parent The parent of this mesh, if it has one
  114042. * @param source An optional Mesh from which geometry is shared, cloned.
  114043. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114044. * When false, achieved by calling a clone(), also passing False.
  114045. * This will make creation of children, recursive.
  114046. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  114047. */
  114048. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  114049. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  114050. doNotInstantiate: boolean;
  114051. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  114052. /**
  114053. * Gets the class name
  114054. * @returns the string "Mesh".
  114055. */
  114056. getClassName(): string;
  114057. /** @hidden */
  114058. get _isMesh(): boolean;
  114059. /**
  114060. * Returns a description of this mesh
  114061. * @param fullDetails define if full details about this mesh must be used
  114062. * @returns a descriptive string representing this mesh
  114063. */
  114064. toString(fullDetails?: boolean): string;
  114065. /** @hidden */
  114066. _unBindEffect(): void;
  114067. /**
  114068. * Gets a boolean indicating if this mesh has LOD
  114069. */
  114070. get hasLODLevels(): boolean;
  114071. /**
  114072. * Gets the list of MeshLODLevel associated with the current mesh
  114073. * @returns an array of MeshLODLevel
  114074. */
  114075. getLODLevels(): MeshLODLevel[];
  114076. private _sortLODLevels;
  114077. /**
  114078. * Add a mesh as LOD level triggered at the given distance.
  114079. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114080. * @param distance The distance from the center of the object to show this level
  114081. * @param mesh The mesh to be added as LOD level (can be null)
  114082. * @return This mesh (for chaining)
  114083. */
  114084. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  114085. /**
  114086. * Returns the LOD level mesh at the passed distance or null if not found.
  114087. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114088. * @param distance The distance from the center of the object to show this level
  114089. * @returns a Mesh or `null`
  114090. */
  114091. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  114092. /**
  114093. * Remove a mesh from the LOD array
  114094. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114095. * @param mesh defines the mesh to be removed
  114096. * @return This mesh (for chaining)
  114097. */
  114098. removeLODLevel(mesh: Mesh): Mesh;
  114099. /**
  114100. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  114101. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114102. * @param camera defines the camera to use to compute distance
  114103. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  114104. * @return This mesh (for chaining)
  114105. */
  114106. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  114107. /**
  114108. * Gets the mesh internal Geometry object
  114109. */
  114110. get geometry(): Nullable<Geometry>;
  114111. /**
  114112. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  114113. * @returns the total number of vertices
  114114. */
  114115. getTotalVertices(): number;
  114116. /**
  114117. * Returns the content of an associated vertex buffer
  114118. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114119. * - VertexBuffer.PositionKind
  114120. * - VertexBuffer.UVKind
  114121. * - VertexBuffer.UV2Kind
  114122. * - VertexBuffer.UV3Kind
  114123. * - VertexBuffer.UV4Kind
  114124. * - VertexBuffer.UV5Kind
  114125. * - VertexBuffer.UV6Kind
  114126. * - VertexBuffer.ColorKind
  114127. * - VertexBuffer.MatricesIndicesKind
  114128. * - VertexBuffer.MatricesIndicesExtraKind
  114129. * - VertexBuffer.MatricesWeightsKind
  114130. * - VertexBuffer.MatricesWeightsExtraKind
  114131. * @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
  114132. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114133. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114134. */
  114135. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114136. /**
  114137. * Returns the mesh VertexBuffer object from the requested `kind`
  114138. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114139. * - VertexBuffer.PositionKind
  114140. * - VertexBuffer.NormalKind
  114141. * - VertexBuffer.UVKind
  114142. * - VertexBuffer.UV2Kind
  114143. * - VertexBuffer.UV3Kind
  114144. * - VertexBuffer.UV4Kind
  114145. * - VertexBuffer.UV5Kind
  114146. * - VertexBuffer.UV6Kind
  114147. * - VertexBuffer.ColorKind
  114148. * - VertexBuffer.MatricesIndicesKind
  114149. * - VertexBuffer.MatricesIndicesExtraKind
  114150. * - VertexBuffer.MatricesWeightsKind
  114151. * - VertexBuffer.MatricesWeightsExtraKind
  114152. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114153. */
  114154. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114155. /**
  114156. * Tests if a specific vertex buffer is associated with this mesh
  114157. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114158. * - VertexBuffer.PositionKind
  114159. * - VertexBuffer.NormalKind
  114160. * - VertexBuffer.UVKind
  114161. * - VertexBuffer.UV2Kind
  114162. * - VertexBuffer.UV3Kind
  114163. * - VertexBuffer.UV4Kind
  114164. * - VertexBuffer.UV5Kind
  114165. * - VertexBuffer.UV6Kind
  114166. * - VertexBuffer.ColorKind
  114167. * - VertexBuffer.MatricesIndicesKind
  114168. * - VertexBuffer.MatricesIndicesExtraKind
  114169. * - VertexBuffer.MatricesWeightsKind
  114170. * - VertexBuffer.MatricesWeightsExtraKind
  114171. * @returns a boolean
  114172. */
  114173. isVerticesDataPresent(kind: string): boolean;
  114174. /**
  114175. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114176. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114177. * - VertexBuffer.PositionKind
  114178. * - VertexBuffer.UVKind
  114179. * - VertexBuffer.UV2Kind
  114180. * - VertexBuffer.UV3Kind
  114181. * - VertexBuffer.UV4Kind
  114182. * - VertexBuffer.UV5Kind
  114183. * - VertexBuffer.UV6Kind
  114184. * - VertexBuffer.ColorKind
  114185. * - VertexBuffer.MatricesIndicesKind
  114186. * - VertexBuffer.MatricesIndicesExtraKind
  114187. * - VertexBuffer.MatricesWeightsKind
  114188. * - VertexBuffer.MatricesWeightsExtraKind
  114189. * @returns a boolean
  114190. */
  114191. isVertexBufferUpdatable(kind: string): boolean;
  114192. /**
  114193. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114194. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114195. * - VertexBuffer.PositionKind
  114196. * - VertexBuffer.NormalKind
  114197. * - VertexBuffer.UVKind
  114198. * - VertexBuffer.UV2Kind
  114199. * - VertexBuffer.UV3Kind
  114200. * - VertexBuffer.UV4Kind
  114201. * - VertexBuffer.UV5Kind
  114202. * - VertexBuffer.UV6Kind
  114203. * - VertexBuffer.ColorKind
  114204. * - VertexBuffer.MatricesIndicesKind
  114205. * - VertexBuffer.MatricesIndicesExtraKind
  114206. * - VertexBuffer.MatricesWeightsKind
  114207. * - VertexBuffer.MatricesWeightsExtraKind
  114208. * @returns an array of strings
  114209. */
  114210. getVerticesDataKinds(): string[];
  114211. /**
  114212. * Returns a positive integer : the total number of indices in this mesh geometry.
  114213. * @returns the numner of indices or zero if the mesh has no geometry.
  114214. */
  114215. getTotalIndices(): number;
  114216. /**
  114217. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114218. * @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.
  114219. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114220. * @returns the indices array or an empty array if the mesh has no geometry
  114221. */
  114222. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114223. get isBlocked(): boolean;
  114224. /**
  114225. * Determine if the current mesh is ready to be rendered
  114226. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114227. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114228. * @returns true if all associated assets are ready (material, textures, shaders)
  114229. */
  114230. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114231. /**
  114232. * 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.
  114233. */
  114234. get areNormalsFrozen(): boolean;
  114235. /**
  114236. * 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.
  114237. * @returns the current mesh
  114238. */
  114239. freezeNormals(): Mesh;
  114240. /**
  114241. * 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
  114242. * @returns the current mesh
  114243. */
  114244. unfreezeNormals(): Mesh;
  114245. /**
  114246. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114247. */
  114248. set overridenInstanceCount(count: number);
  114249. /** @hidden */
  114250. _preActivate(): Mesh;
  114251. /** @hidden */
  114252. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114253. /** @hidden */
  114254. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114255. protected _afterComputeWorldMatrix(): void;
  114256. /** @hidden */
  114257. _postActivate(): void;
  114258. /**
  114259. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114260. * This means the mesh underlying bounding box and sphere are recomputed.
  114261. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114262. * @returns the current mesh
  114263. */
  114264. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114265. /** @hidden */
  114266. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114267. /**
  114268. * This function will subdivide the mesh into multiple submeshes
  114269. * @param count defines the expected number of submeshes
  114270. */
  114271. subdivide(count: number): void;
  114272. /**
  114273. * Copy a FloatArray into a specific associated vertex buffer
  114274. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114275. * - VertexBuffer.PositionKind
  114276. * - VertexBuffer.UVKind
  114277. * - VertexBuffer.UV2Kind
  114278. * - VertexBuffer.UV3Kind
  114279. * - VertexBuffer.UV4Kind
  114280. * - VertexBuffer.UV5Kind
  114281. * - VertexBuffer.UV6Kind
  114282. * - VertexBuffer.ColorKind
  114283. * - VertexBuffer.MatricesIndicesKind
  114284. * - VertexBuffer.MatricesIndicesExtraKind
  114285. * - VertexBuffer.MatricesWeightsKind
  114286. * - VertexBuffer.MatricesWeightsExtraKind
  114287. * @param data defines the data source
  114288. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114289. * @param stride defines the data stride size (can be null)
  114290. * @returns the current mesh
  114291. */
  114292. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114293. /**
  114294. * Delete a vertex buffer associated with this mesh
  114295. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114296. * - VertexBuffer.PositionKind
  114297. * - VertexBuffer.UVKind
  114298. * - VertexBuffer.UV2Kind
  114299. * - VertexBuffer.UV3Kind
  114300. * - VertexBuffer.UV4Kind
  114301. * - VertexBuffer.UV5Kind
  114302. * - VertexBuffer.UV6Kind
  114303. * - VertexBuffer.ColorKind
  114304. * - VertexBuffer.MatricesIndicesKind
  114305. * - VertexBuffer.MatricesIndicesExtraKind
  114306. * - VertexBuffer.MatricesWeightsKind
  114307. * - VertexBuffer.MatricesWeightsExtraKind
  114308. */
  114309. removeVerticesData(kind: string): void;
  114310. /**
  114311. * Flags an associated vertex buffer as updatable
  114312. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114313. * - VertexBuffer.PositionKind
  114314. * - VertexBuffer.UVKind
  114315. * - VertexBuffer.UV2Kind
  114316. * - VertexBuffer.UV3Kind
  114317. * - VertexBuffer.UV4Kind
  114318. * - VertexBuffer.UV5Kind
  114319. * - VertexBuffer.UV6Kind
  114320. * - VertexBuffer.ColorKind
  114321. * - VertexBuffer.MatricesIndicesKind
  114322. * - VertexBuffer.MatricesIndicesExtraKind
  114323. * - VertexBuffer.MatricesWeightsKind
  114324. * - VertexBuffer.MatricesWeightsExtraKind
  114325. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114326. */
  114327. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114328. /**
  114329. * Sets the mesh global Vertex Buffer
  114330. * @param buffer defines the buffer to use
  114331. * @returns the current mesh
  114332. */
  114333. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114334. /**
  114335. * Update a specific associated vertex buffer
  114336. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114337. * - VertexBuffer.PositionKind
  114338. * - VertexBuffer.UVKind
  114339. * - VertexBuffer.UV2Kind
  114340. * - VertexBuffer.UV3Kind
  114341. * - VertexBuffer.UV4Kind
  114342. * - VertexBuffer.UV5Kind
  114343. * - VertexBuffer.UV6Kind
  114344. * - VertexBuffer.ColorKind
  114345. * - VertexBuffer.MatricesIndicesKind
  114346. * - VertexBuffer.MatricesIndicesExtraKind
  114347. * - VertexBuffer.MatricesWeightsKind
  114348. * - VertexBuffer.MatricesWeightsExtraKind
  114349. * @param data defines the data source
  114350. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114351. * @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)
  114352. * @returns the current mesh
  114353. */
  114354. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114355. /**
  114356. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114357. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114358. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114359. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114360. * @returns the current mesh
  114361. */
  114362. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114363. /**
  114364. * Creates a un-shared specific occurence of the geometry for the mesh.
  114365. * @returns the current mesh
  114366. */
  114367. makeGeometryUnique(): Mesh;
  114368. /**
  114369. * Set the index buffer of this mesh
  114370. * @param indices defines the source data
  114371. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114372. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114373. * @returns the current mesh
  114374. */
  114375. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114376. /**
  114377. * Update the current index buffer
  114378. * @param indices defines the source data
  114379. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114380. * @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)
  114381. * @returns the current mesh
  114382. */
  114383. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114384. /**
  114385. * Invert the geometry to move from a right handed system to a left handed one.
  114386. * @returns the current mesh
  114387. */
  114388. toLeftHanded(): Mesh;
  114389. /** @hidden */
  114390. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114391. /** @hidden */
  114392. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114393. /**
  114394. * Registers for this mesh a javascript function called just before the rendering process
  114395. * @param func defines the function to call before rendering this mesh
  114396. * @returns the current mesh
  114397. */
  114398. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114399. /**
  114400. * Disposes a previously registered javascript function called before the rendering
  114401. * @param func defines the function to remove
  114402. * @returns the current mesh
  114403. */
  114404. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114405. /**
  114406. * Registers for this mesh a javascript function called just after the rendering is complete
  114407. * @param func defines the function to call after rendering this mesh
  114408. * @returns the current mesh
  114409. */
  114410. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114411. /**
  114412. * Disposes a previously registered javascript function called after the rendering.
  114413. * @param func defines the function to remove
  114414. * @returns the current mesh
  114415. */
  114416. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114417. /** @hidden */
  114418. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114419. /** @hidden */
  114420. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114421. /** @hidden */
  114422. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114423. /** @hidden */
  114424. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114425. /** @hidden */
  114426. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114427. /** @hidden */
  114428. _rebuild(): void;
  114429. /** @hidden */
  114430. _freeze(): void;
  114431. /** @hidden */
  114432. _unFreeze(): void;
  114433. /**
  114434. * 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
  114435. * @param subMesh defines the subMesh to render
  114436. * @param enableAlphaMode defines if alpha mode can be changed
  114437. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114438. * @returns the current mesh
  114439. */
  114440. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114441. private _onBeforeDraw;
  114442. /**
  114443. * Renormalize the mesh and patch it up if there are no weights
  114444. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114445. * However in the case of zero weights then we set just a single influence to 1.
  114446. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114447. */
  114448. cleanMatrixWeights(): void;
  114449. private normalizeSkinFourWeights;
  114450. private normalizeSkinWeightsAndExtra;
  114451. /**
  114452. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114453. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114454. * the user know there was an issue with importing the mesh
  114455. * @returns a validation object with skinned, valid and report string
  114456. */
  114457. validateSkinning(): {
  114458. skinned: boolean;
  114459. valid: boolean;
  114460. report: string;
  114461. };
  114462. /** @hidden */
  114463. _checkDelayState(): Mesh;
  114464. private _queueLoad;
  114465. /**
  114466. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114467. * A mesh is in the frustum if its bounding box intersects the frustum
  114468. * @param frustumPlanes defines the frustum to test
  114469. * @returns true if the mesh is in the frustum planes
  114470. */
  114471. isInFrustum(frustumPlanes: Plane[]): boolean;
  114472. /**
  114473. * Sets the mesh material by the material or multiMaterial `id` property
  114474. * @param id is a string identifying the material or the multiMaterial
  114475. * @returns the current mesh
  114476. */
  114477. setMaterialByID(id: string): Mesh;
  114478. /**
  114479. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114480. * @returns an array of IAnimatable
  114481. */
  114482. getAnimatables(): IAnimatable[];
  114483. /**
  114484. * Modifies the mesh geometry according to the passed transformation matrix.
  114485. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114486. * The mesh normals are modified using the same transformation.
  114487. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114488. * @param transform defines the transform matrix to use
  114489. * @see https://doc.babylonjs.com/resources/baking_transformations
  114490. * @returns the current mesh
  114491. */
  114492. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114493. /**
  114494. * Modifies the mesh geometry according to its own current World Matrix.
  114495. * The mesh World Matrix is then reset.
  114496. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114497. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114498. * @see https://doc.babylonjs.com/resources/baking_transformations
  114499. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114500. * @returns the current mesh
  114501. */
  114502. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114503. /** @hidden */
  114504. get _positions(): Nullable<Vector3[]>;
  114505. /** @hidden */
  114506. _resetPointsArrayCache(): Mesh;
  114507. /** @hidden */
  114508. _generatePointsArray(): boolean;
  114509. /**
  114510. * Returns a new Mesh object generated from the current mesh properties.
  114511. * This method must not get confused with createInstance()
  114512. * @param name is a string, the name given to the new mesh
  114513. * @param newParent can be any Node object (default `null`)
  114514. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114515. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114516. * @returns a new mesh
  114517. */
  114518. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114519. /**
  114520. * Releases resources associated with this mesh.
  114521. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114522. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114523. */
  114524. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114525. /** @hidden */
  114526. _disposeInstanceSpecificData(): void;
  114527. /** @hidden */
  114528. _disposeThinInstanceSpecificData(): void;
  114529. /**
  114530. * Modifies the mesh geometry according to a displacement map.
  114531. * 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.
  114532. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114533. * @param url is a string, the URL from the image file is to be downloaded.
  114534. * @param minHeight is the lower limit of the displacement.
  114535. * @param maxHeight is the upper limit of the displacement.
  114536. * @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.
  114537. * @param uvOffset is an optional vector2 used to offset UV.
  114538. * @param uvScale is an optional vector2 used to scale UV.
  114539. * @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.
  114540. * @returns the Mesh.
  114541. */
  114542. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114543. /**
  114544. * Modifies the mesh geometry according to a displacementMap buffer.
  114545. * 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.
  114546. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114547. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114548. * @param heightMapWidth is the width of the buffer image.
  114549. * @param heightMapHeight is the height of the buffer image.
  114550. * @param minHeight is the lower limit of the displacement.
  114551. * @param maxHeight is the upper limit of the displacement.
  114552. * @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.
  114553. * @param uvOffset is an optional vector2 used to offset UV.
  114554. * @param uvScale is an optional vector2 used to scale UV.
  114555. * @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.
  114556. * @returns the Mesh.
  114557. */
  114558. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114559. /**
  114560. * Modify the mesh to get a flat shading rendering.
  114561. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114562. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114563. * @returns current mesh
  114564. */
  114565. convertToFlatShadedMesh(): Mesh;
  114566. /**
  114567. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114568. * In other words, more vertices, no more indices and a single bigger VBO.
  114569. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114570. * @returns current mesh
  114571. */
  114572. convertToUnIndexedMesh(): Mesh;
  114573. /**
  114574. * Inverses facet orientations.
  114575. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114576. * @param flipNormals will also inverts the normals
  114577. * @returns current mesh
  114578. */
  114579. flipFaces(flipNormals?: boolean): Mesh;
  114580. /**
  114581. * Increase the number of facets and hence vertices in a mesh
  114582. * Vertex normals are interpolated from existing vertex normals
  114583. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114584. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114585. */
  114586. increaseVertices(numberPerEdge: number): void;
  114587. /**
  114588. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114589. * This will undo any application of covertToFlatShadedMesh
  114590. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114591. */
  114592. forceSharedVertices(): void;
  114593. /** @hidden */
  114594. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114595. /** @hidden */
  114596. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114597. /**
  114598. * Creates a new InstancedMesh object from the mesh model.
  114599. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114600. * @param name defines the name of the new instance
  114601. * @returns a new InstancedMesh
  114602. */
  114603. createInstance(name: string): InstancedMesh;
  114604. /**
  114605. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114606. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114607. * @returns the current mesh
  114608. */
  114609. synchronizeInstances(): Mesh;
  114610. /**
  114611. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114612. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114613. * This should be used together with the simplification to avoid disappearing triangles.
  114614. * @param successCallback an optional success callback to be called after the optimization finished.
  114615. * @returns the current mesh
  114616. */
  114617. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114618. /**
  114619. * Serialize current mesh
  114620. * @param serializationObject defines the object which will receive the serialization data
  114621. */
  114622. serialize(serializationObject: any): void;
  114623. /** @hidden */
  114624. _syncGeometryWithMorphTargetManager(): void;
  114625. /** @hidden */
  114626. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114627. /**
  114628. * Returns a new Mesh object parsed from the source provided.
  114629. * @param parsedMesh is the source
  114630. * @param scene defines the hosting scene
  114631. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114632. * @returns a new Mesh
  114633. */
  114634. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114635. /**
  114636. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114637. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114638. * @param name defines the name of the mesh to create
  114639. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114640. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114641. * @param closePath creates a seam between the first and the last points of each path of the path array
  114642. * @param offset is taken in account only if the `pathArray` is containing a single path
  114643. * @param scene defines the hosting scene
  114644. * @param updatable defines if the mesh must be flagged as updatable
  114645. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114646. * @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)
  114647. * @returns a new Mesh
  114648. */
  114649. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114650. /**
  114651. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114652. * @param name defines the name of the mesh to create
  114653. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114654. * @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
  114655. * @param scene defines the hosting scene
  114656. * @param updatable defines if the mesh must be flagged as updatable
  114657. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114658. * @returns a new Mesh
  114659. */
  114660. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114661. /**
  114662. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114663. * @param name defines the name of the mesh to create
  114664. * @param size sets the size (float) of each box side (default 1)
  114665. * @param scene defines the hosting scene
  114666. * @param updatable defines if the mesh must be flagged as updatable
  114667. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114668. * @returns a new Mesh
  114669. */
  114670. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114671. /**
  114672. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114673. * @param name defines the name of the mesh to create
  114674. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114675. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114676. * @param scene defines the hosting scene
  114677. * @param updatable defines if the mesh must be flagged as updatable
  114678. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114679. * @returns a new Mesh
  114680. */
  114681. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114682. /**
  114683. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114684. * @param name defines the name of the mesh to create
  114685. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114686. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114687. * @param scene defines the hosting scene
  114688. * @returns a new Mesh
  114689. */
  114690. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114691. /**
  114692. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114693. * @param name defines the name of the mesh to create
  114694. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114695. * @param diameterTop set the top cap diameter (floats, default 1)
  114696. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114697. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114698. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114699. * @param scene defines the hosting scene
  114700. * @param updatable defines if the mesh must be flagged as updatable
  114701. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114702. * @returns a new Mesh
  114703. */
  114704. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114705. /**
  114706. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114707. * @param name defines the name of the mesh to create
  114708. * @param diameter sets the diameter size (float) of the torus (default 1)
  114709. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114710. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114711. * @param scene defines the hosting scene
  114712. * @param updatable defines if the mesh must be flagged as updatable
  114713. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114714. * @returns a new Mesh
  114715. */
  114716. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114717. /**
  114718. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114719. * @param name defines the name of the mesh to create
  114720. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114721. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114722. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114723. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114724. * @param p the number of windings on X axis (positive integers, default 2)
  114725. * @param q the number of windings on Y axis (positive integers, default 3)
  114726. * @param scene defines the hosting scene
  114727. * @param updatable defines if the mesh must be flagged as updatable
  114728. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114729. * @returns a new Mesh
  114730. */
  114731. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114732. /**
  114733. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114734. * @param name defines the name of the mesh to create
  114735. * @param points is an array successive Vector3
  114736. * @param scene defines the hosting scene
  114737. * @param updatable defines if the mesh must be flagged as updatable
  114738. * @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).
  114739. * @returns a new Mesh
  114740. */
  114741. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114742. /**
  114743. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114744. * @param name defines the name of the mesh to create
  114745. * @param points is an array successive Vector3
  114746. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114747. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114748. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114749. * @param scene defines the hosting scene
  114750. * @param updatable defines if the mesh must be flagged as updatable
  114751. * @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)
  114752. * @returns a new Mesh
  114753. */
  114754. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114755. /**
  114756. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114757. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114758. * 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.
  114759. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114760. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114761. * Remember you can only change the shape positions, not their number when updating a polygon.
  114762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114763. * @param name defines the name of the mesh to create
  114764. * @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
  114765. * @param scene defines the hosting scene
  114766. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114767. * @param updatable defines if the mesh must be flagged as updatable
  114768. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114769. * @param earcutInjection can be used to inject your own earcut reference
  114770. * @returns a new Mesh
  114771. */
  114772. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114773. /**
  114774. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114776. * @param name defines the name of the mesh to create
  114777. * @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
  114778. * @param depth defines the height of extrusion
  114779. * @param scene defines the hosting scene
  114780. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114781. * @param updatable defines if the mesh must be flagged as updatable
  114782. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114783. * @param earcutInjection can be used to inject your own earcut reference
  114784. * @returns a new Mesh
  114785. */
  114786. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114787. /**
  114788. * Creates an extruded shape mesh.
  114789. * 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
  114790. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114792. * @param name defines the name of the mesh to create
  114793. * @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
  114794. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114795. * @param scale is the value to scale the shape
  114796. * @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
  114797. * @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
  114798. * @param scene defines the hosting scene
  114799. * @param updatable defines if the mesh must be flagged as updatable
  114800. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114801. * @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)
  114802. * @returns a new Mesh
  114803. */
  114804. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114805. /**
  114806. * Creates an custom extruded shape mesh.
  114807. * The custom extrusion is a parametric shape.
  114808. * It has no predefined shape. Its final shape will depend on the input parameters.
  114809. * Please consider using the same method from the MeshBuilder class instead
  114810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114811. * @param name defines the name of the mesh to create
  114812. * @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
  114813. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114814. * @param scaleFunction is a custom Javascript function called on each path point
  114815. * @param rotationFunction is a custom Javascript function called on each path point
  114816. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114817. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114818. * @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
  114819. * @param scene defines the hosting scene
  114820. * @param updatable defines if the mesh must be flagged as updatable
  114821. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114822. * @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)
  114823. * @returns a new Mesh
  114824. */
  114825. 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;
  114826. /**
  114827. * Creates lathe mesh.
  114828. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114829. * Please consider using the same method from the MeshBuilder class instead
  114830. * @param name defines the name of the mesh to create
  114831. * @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
  114832. * @param radius is the radius value of the lathe
  114833. * @param tessellation is the side number of the lathe.
  114834. * @param scene defines the hosting scene
  114835. * @param updatable defines if the mesh must be flagged as updatable
  114836. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114837. * @returns a new Mesh
  114838. */
  114839. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114840. /**
  114841. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114842. * @param name defines the name of the mesh to create
  114843. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114844. * @param scene defines the hosting scene
  114845. * @param updatable defines if the mesh must be flagged as updatable
  114846. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114847. * @returns a new Mesh
  114848. */
  114849. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114850. /**
  114851. * Creates a ground mesh.
  114852. * Please consider using the same method from the MeshBuilder class instead
  114853. * @param name defines the name of the mesh to create
  114854. * @param width set the width of the ground
  114855. * @param height set the height of the ground
  114856. * @param subdivisions sets the number of subdivisions per side
  114857. * @param scene defines the hosting scene
  114858. * @param updatable defines if the mesh must be flagged as updatable
  114859. * @returns a new Mesh
  114860. */
  114861. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114862. /**
  114863. * Creates a tiled ground mesh.
  114864. * Please consider using the same method from the MeshBuilder class instead
  114865. * @param name defines the name of the mesh to create
  114866. * @param xmin set the ground minimum X coordinate
  114867. * @param zmin set the ground minimum Y coordinate
  114868. * @param xmax set the ground maximum X coordinate
  114869. * @param zmax set the ground maximum Z coordinate
  114870. * @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
  114871. * @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
  114872. * @param scene defines the hosting scene
  114873. * @param updatable defines if the mesh must be flagged as updatable
  114874. * @returns a new Mesh
  114875. */
  114876. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114877. w: number;
  114878. h: number;
  114879. }, precision: {
  114880. w: number;
  114881. h: number;
  114882. }, scene: Scene, updatable?: boolean): Mesh;
  114883. /**
  114884. * Creates a ground mesh from a height map.
  114885. * Please consider using the same method from the MeshBuilder class instead
  114886. * @see https://doc.babylonjs.com/babylon101/height_map
  114887. * @param name defines the name of the mesh to create
  114888. * @param url sets the URL of the height map image resource
  114889. * @param width set the ground width size
  114890. * @param height set the ground height size
  114891. * @param subdivisions sets the number of subdivision per side
  114892. * @param minHeight is the minimum altitude on the ground
  114893. * @param maxHeight is the maximum altitude on the ground
  114894. * @param scene defines the hosting scene
  114895. * @param updatable defines if the mesh must be flagged as updatable
  114896. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114897. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114898. * @returns a new Mesh
  114899. */
  114900. 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;
  114901. /**
  114902. * Creates a tube mesh.
  114903. * The tube is a parametric shape.
  114904. * It has no predefined shape. Its final shape will depend on the input parameters.
  114905. * Please consider using the same method from the MeshBuilder class instead
  114906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114907. * @param name defines the name of the mesh to create
  114908. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114909. * @param radius sets the tube radius size
  114910. * @param tessellation is the number of sides on the tubular surface
  114911. * @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
  114912. * @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
  114913. * @param scene defines the hosting scene
  114914. * @param updatable defines if the mesh must be flagged as updatable
  114915. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114916. * @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)
  114917. * @returns a new Mesh
  114918. */
  114919. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114920. (i: number, distance: number): number;
  114921. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114922. /**
  114923. * Creates a polyhedron mesh.
  114924. * Please consider using the same method from the MeshBuilder class instead.
  114925. * * 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
  114926. * * The parameter `size` (positive float, default 1) sets the polygon size
  114927. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114928. * * 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`
  114929. * * 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
  114930. * * 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)`)
  114931. * * 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
  114932. * * 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
  114933. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114934. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114936. * @param name defines the name of the mesh to create
  114937. * @param options defines the options used to create the mesh
  114938. * @param scene defines the hosting scene
  114939. * @returns a new Mesh
  114940. */
  114941. static CreatePolyhedron(name: string, options: {
  114942. type?: number;
  114943. size?: number;
  114944. sizeX?: number;
  114945. sizeY?: number;
  114946. sizeZ?: number;
  114947. custom?: any;
  114948. faceUV?: Vector4[];
  114949. faceColors?: Color4[];
  114950. updatable?: boolean;
  114951. sideOrientation?: number;
  114952. }, scene: Scene): Mesh;
  114953. /**
  114954. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114955. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114956. * * 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`)
  114957. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114958. * * 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
  114959. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114962. * @param name defines the name of the mesh
  114963. * @param options defines the options used to create the mesh
  114964. * @param scene defines the hosting scene
  114965. * @returns a new Mesh
  114966. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114967. */
  114968. static CreateIcoSphere(name: string, options: {
  114969. radius?: number;
  114970. flat?: boolean;
  114971. subdivisions?: number;
  114972. sideOrientation?: number;
  114973. updatable?: boolean;
  114974. }, scene: Scene): Mesh;
  114975. /**
  114976. * Creates a decal mesh.
  114977. * Please consider using the same method from the MeshBuilder class instead.
  114978. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114979. * @param name defines the name of the mesh
  114980. * @param sourceMesh defines the mesh receiving the decal
  114981. * @param position sets the position of the decal in world coordinates
  114982. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114983. * @param size sets the decal scaling
  114984. * @param angle sets the angle to rotate the decal
  114985. * @returns a new Mesh
  114986. */
  114987. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114988. /** Creates a Capsule Mesh
  114989. * @param name defines the name of the mesh.
  114990. * @param options the constructors options used to shape the mesh.
  114991. * @param scene defines the scene the mesh is scoped to.
  114992. * @returns the capsule mesh
  114993. * @see https://doc.babylonjs.com/how_to/capsule_shape
  114994. */
  114995. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  114996. /**
  114997. * Prepare internal position array for software CPU skinning
  114998. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  114999. */
  115000. setPositionsForCPUSkinning(): Float32Array;
  115001. /**
  115002. * Prepare internal normal array for software CPU skinning
  115003. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  115004. */
  115005. setNormalsForCPUSkinning(): Float32Array;
  115006. /**
  115007. * Updates the vertex buffer by applying transformation from the bones
  115008. * @param skeleton defines the skeleton to apply to current mesh
  115009. * @returns the current mesh
  115010. */
  115011. applySkeleton(skeleton: Skeleton): Mesh;
  115012. /**
  115013. * 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
  115014. * @param meshes defines the list of meshes to scan
  115015. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  115016. */
  115017. static MinMax(meshes: AbstractMesh[]): {
  115018. min: Vector3;
  115019. max: Vector3;
  115020. };
  115021. /**
  115022. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  115023. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  115024. * @returns a vector3
  115025. */
  115026. static Center(meshesOrMinMaxVector: {
  115027. min: Vector3;
  115028. max: Vector3;
  115029. } | AbstractMesh[]): Vector3;
  115030. /**
  115031. * Merge the array of meshes into a single mesh for performance reasons.
  115032. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  115033. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  115034. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  115035. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  115036. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  115037. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  115038. * @returns a new mesh
  115039. */
  115040. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  115041. /** @hidden */
  115042. addInstance(instance: InstancedMesh): void;
  115043. /** @hidden */
  115044. removeInstance(instance: InstancedMesh): void;
  115045. }
  115046. }
  115047. declare module BABYLON {
  115048. /**
  115049. * The options Interface for creating a Capsule Mesh
  115050. */
  115051. export interface ICreateCapsuleOptions {
  115052. /** The Orientation of the capsule. Default : Vector3.Up() */
  115053. orientation?: Vector3;
  115054. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  115055. subdivisions: number;
  115056. /** Number of cylindrical segments on the capsule. */
  115057. tessellation: number;
  115058. /** Height or Length of the capsule. */
  115059. height: number;
  115060. /** Radius of the capsule. */
  115061. radius: number;
  115062. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  115063. capSubdivisions: number;
  115064. /** Overwrite for the top radius. */
  115065. radiusTop?: number;
  115066. /** Overwrite for the bottom radius. */
  115067. radiusBottom?: number;
  115068. /** Overwrite for the top capSubdivisions. */
  115069. topCapSubdivisions?: number;
  115070. /** Overwrite for the bottom capSubdivisions. */
  115071. bottomCapSubdivisions?: number;
  115072. }
  115073. /**
  115074. * Class containing static functions to help procedurally build meshes
  115075. */
  115076. export class CapsuleBuilder {
  115077. /**
  115078. * Creates a capsule or a pill mesh
  115079. * @param name defines the name of the mesh
  115080. * @param options The constructors options.
  115081. * @param scene The scene the mesh is scoped to.
  115082. * @returns Capsule Mesh
  115083. */
  115084. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  115085. }
  115086. }
  115087. declare module BABYLON {
  115088. /**
  115089. * Define an interface for all classes that will get and set the data on vertices
  115090. */
  115091. export interface IGetSetVerticesData {
  115092. /**
  115093. * Gets a boolean indicating if specific vertex data is present
  115094. * @param kind defines the vertex data kind to use
  115095. * @returns true is data kind is present
  115096. */
  115097. isVerticesDataPresent(kind: string): boolean;
  115098. /**
  115099. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  115100. * @param kind defines the data kind (Position, normal, etc...)
  115101. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  115102. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115103. * @returns a float array containing vertex data
  115104. */
  115105. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  115106. /**
  115107. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  115108. * @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.
  115109. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  115110. * @returns the indices array or an empty array if the mesh has no geometry
  115111. */
  115112. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  115113. /**
  115114. * Set specific vertex data
  115115. * @param kind defines the data kind (Position, normal, etc...)
  115116. * @param data defines the vertex data to use
  115117. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  115118. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  115119. */
  115120. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  115121. /**
  115122. * Update a specific associated vertex buffer
  115123. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  115124. * - VertexBuffer.PositionKind
  115125. * - VertexBuffer.UVKind
  115126. * - VertexBuffer.UV2Kind
  115127. * - VertexBuffer.UV3Kind
  115128. * - VertexBuffer.UV4Kind
  115129. * - VertexBuffer.UV5Kind
  115130. * - VertexBuffer.UV6Kind
  115131. * - VertexBuffer.ColorKind
  115132. * - VertexBuffer.MatricesIndicesKind
  115133. * - VertexBuffer.MatricesIndicesExtraKind
  115134. * - VertexBuffer.MatricesWeightsKind
  115135. * - VertexBuffer.MatricesWeightsExtraKind
  115136. * @param data defines the data source
  115137. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  115138. * @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)
  115139. */
  115140. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  115141. /**
  115142. * Creates a new index buffer
  115143. * @param indices defines the indices to store in the index buffer
  115144. * @param totalVertices defines the total number of vertices (could be null)
  115145. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  115146. */
  115147. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  115148. }
  115149. /**
  115150. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  115151. */
  115152. export class VertexData {
  115153. /**
  115154. * Mesh side orientation : usually the external or front surface
  115155. */
  115156. static readonly FRONTSIDE: number;
  115157. /**
  115158. * Mesh side orientation : usually the internal or back surface
  115159. */
  115160. static readonly BACKSIDE: number;
  115161. /**
  115162. * Mesh side orientation : both internal and external or front and back surfaces
  115163. */
  115164. static readonly DOUBLESIDE: number;
  115165. /**
  115166. * Mesh side orientation : by default, `FRONTSIDE`
  115167. */
  115168. static readonly DEFAULTSIDE: number;
  115169. /**
  115170. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  115171. */
  115172. positions: Nullable<FloatArray>;
  115173. /**
  115174. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  115175. */
  115176. normals: Nullable<FloatArray>;
  115177. /**
  115178. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  115179. */
  115180. tangents: Nullable<FloatArray>;
  115181. /**
  115182. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115183. */
  115184. uvs: Nullable<FloatArray>;
  115185. /**
  115186. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115187. */
  115188. uvs2: Nullable<FloatArray>;
  115189. /**
  115190. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115191. */
  115192. uvs3: Nullable<FloatArray>;
  115193. /**
  115194. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115195. */
  115196. uvs4: Nullable<FloatArray>;
  115197. /**
  115198. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115199. */
  115200. uvs5: Nullable<FloatArray>;
  115201. /**
  115202. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  115203. */
  115204. uvs6: Nullable<FloatArray>;
  115205. /**
  115206. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  115207. */
  115208. colors: Nullable<FloatArray>;
  115209. /**
  115210. * 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).
  115211. */
  115212. matricesIndices: Nullable<FloatArray>;
  115213. /**
  115214. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  115215. */
  115216. matricesWeights: Nullable<FloatArray>;
  115217. /**
  115218. * An array extending the number of possible indices
  115219. */
  115220. matricesIndicesExtra: Nullable<FloatArray>;
  115221. /**
  115222. * An array extending the number of possible weights when the number of indices is extended
  115223. */
  115224. matricesWeightsExtra: Nullable<FloatArray>;
  115225. /**
  115226. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  115227. */
  115228. indices: Nullable<IndicesArray>;
  115229. /**
  115230. * Uses the passed data array to set the set the values for the specified kind of data
  115231. * @param data a linear array of floating numbers
  115232. * @param kind the type of data that is being set, eg positions, colors etc
  115233. */
  115234. set(data: FloatArray, kind: string): void;
  115235. /**
  115236. * Associates the vertexData to the passed Mesh.
  115237. * Sets it as updatable or not (default `false`)
  115238. * @param mesh the mesh the vertexData is applied to
  115239. * @param updatable when used and having the value true allows new data to update the vertexData
  115240. * @returns the VertexData
  115241. */
  115242. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  115243. /**
  115244. * Associates the vertexData to the passed Geometry.
  115245. * Sets it as updatable or not (default `false`)
  115246. * @param geometry the geometry the vertexData is applied to
  115247. * @param updatable when used and having the value true allows new data to update the vertexData
  115248. * @returns VertexData
  115249. */
  115250. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  115251. /**
  115252. * Updates the associated mesh
  115253. * @param mesh the mesh to be updated
  115254. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115255. * @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
  115256. * @returns VertexData
  115257. */
  115258. updateMesh(mesh: Mesh): VertexData;
  115259. /**
  115260. * Updates the associated geometry
  115261. * @param geometry the geometry to be updated
  115262. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  115263. * @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
  115264. * @returns VertexData.
  115265. */
  115266. updateGeometry(geometry: Geometry): VertexData;
  115267. private _applyTo;
  115268. private _update;
  115269. /**
  115270. * Transforms each position and each normal of the vertexData according to the passed Matrix
  115271. * @param matrix the transforming matrix
  115272. * @returns the VertexData
  115273. */
  115274. transform(matrix: Matrix): VertexData;
  115275. /**
  115276. * Merges the passed VertexData into the current one
  115277. * @param other the VertexData to be merged into the current one
  115278. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  115279. * @returns the modified VertexData
  115280. */
  115281. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  115282. private _mergeElement;
  115283. private _validate;
  115284. /**
  115285. * Serializes the VertexData
  115286. * @returns a serialized object
  115287. */
  115288. serialize(): any;
  115289. /**
  115290. * Extracts the vertexData from a mesh
  115291. * @param mesh the mesh from which to extract the VertexData
  115292. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  115293. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115294. * @returns the object VertexData associated to the passed mesh
  115295. */
  115296. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115297. /**
  115298. * Extracts the vertexData from the geometry
  115299. * @param geometry the geometry from which to extract the VertexData
  115300. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  115301. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  115302. * @returns the object VertexData associated to the passed mesh
  115303. */
  115304. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  115305. private static _ExtractFrom;
  115306. /**
  115307. * Creates the VertexData for a Ribbon
  115308. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  115309. * * pathArray array of paths, each of which an array of successive Vector3
  115310. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  115311. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  115312. * * 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
  115313. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115314. * * 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)
  115315. * * 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)
  115316. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  115317. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  115318. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  115319. * @returns the VertexData of the ribbon
  115320. */
  115321. static CreateRibbon(options: {
  115322. pathArray: Vector3[][];
  115323. closeArray?: boolean;
  115324. closePath?: boolean;
  115325. offset?: number;
  115326. sideOrientation?: number;
  115327. frontUVs?: Vector4;
  115328. backUVs?: Vector4;
  115329. invertUV?: boolean;
  115330. uvs?: Vector2[];
  115331. colors?: Color4[];
  115332. }): VertexData;
  115333. /**
  115334. * Creates the VertexData for a box
  115335. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115336. * * size sets the width, height and depth of the box to the value of size, optional default 1
  115337. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  115338. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  115339. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  115340. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115341. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115342. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115343. * * 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)
  115344. * * 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)
  115345. * @returns the VertexData of the box
  115346. */
  115347. static CreateBox(options: {
  115348. size?: number;
  115349. width?: number;
  115350. height?: number;
  115351. depth?: number;
  115352. faceUV?: Vector4[];
  115353. faceColors?: Color4[];
  115354. sideOrientation?: number;
  115355. frontUVs?: Vector4;
  115356. backUVs?: Vector4;
  115357. }): VertexData;
  115358. /**
  115359. * Creates the VertexData for a tiled box
  115360. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115361. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115362. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  115363. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  115364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115365. * @returns the VertexData of the box
  115366. */
  115367. static CreateTiledBox(options: {
  115368. pattern?: number;
  115369. width?: number;
  115370. height?: number;
  115371. depth?: number;
  115372. tileSize?: number;
  115373. tileWidth?: number;
  115374. tileHeight?: number;
  115375. alignHorizontal?: number;
  115376. alignVertical?: number;
  115377. faceUV?: Vector4[];
  115378. faceColors?: Color4[];
  115379. sideOrientation?: number;
  115380. }): VertexData;
  115381. /**
  115382. * Creates the VertexData for a tiled plane
  115383. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115384. * * pattern a limited pattern arrangement depending on the number
  115385. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  115386. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  115387. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  115388. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115389. * * 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)
  115390. * * 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)
  115391. * @returns the VertexData of the tiled plane
  115392. */
  115393. static CreateTiledPlane(options: {
  115394. pattern?: number;
  115395. tileSize?: number;
  115396. tileWidth?: number;
  115397. tileHeight?: number;
  115398. size?: number;
  115399. width?: number;
  115400. height?: number;
  115401. alignHorizontal?: number;
  115402. alignVertical?: number;
  115403. sideOrientation?: number;
  115404. frontUVs?: Vector4;
  115405. backUVs?: Vector4;
  115406. }): VertexData;
  115407. /**
  115408. * Creates the VertexData for an ellipsoid, defaults to a sphere
  115409. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115410. * * segments sets the number of horizontal strips optional, default 32
  115411. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  115412. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  115413. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  115414. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  115415. * * 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
  115416. * * 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
  115417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115418. * * 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)
  115419. * * 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)
  115420. * @returns the VertexData of the ellipsoid
  115421. */
  115422. static CreateSphere(options: {
  115423. segments?: number;
  115424. diameter?: number;
  115425. diameterX?: number;
  115426. diameterY?: number;
  115427. diameterZ?: number;
  115428. arc?: number;
  115429. slice?: number;
  115430. sideOrientation?: number;
  115431. frontUVs?: Vector4;
  115432. backUVs?: Vector4;
  115433. }): VertexData;
  115434. /**
  115435. * Creates the VertexData for a cylinder, cone or prism
  115436. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115437. * * height sets the height (y direction) of the cylinder, optional, default 2
  115438. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  115439. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  115440. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  115441. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115442. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  115443. * * 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
  115444. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115445. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115446. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  115447. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  115448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115449. * * 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)
  115450. * * 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)
  115451. * @returns the VertexData of the cylinder, cone or prism
  115452. */
  115453. static CreateCylinder(options: {
  115454. height?: number;
  115455. diameterTop?: number;
  115456. diameterBottom?: number;
  115457. diameter?: number;
  115458. tessellation?: number;
  115459. subdivisions?: number;
  115460. arc?: number;
  115461. faceColors?: Color4[];
  115462. faceUV?: Vector4[];
  115463. hasRings?: boolean;
  115464. enclose?: boolean;
  115465. sideOrientation?: number;
  115466. frontUVs?: Vector4;
  115467. backUVs?: Vector4;
  115468. }): VertexData;
  115469. /**
  115470. * Creates the VertexData for a torus
  115471. * @param options an object used to set the following optional parameters for the box, required but can be empty
  115472. * * diameter the diameter of the torus, optional default 1
  115473. * * thickness the diameter of the tube forming the torus, optional default 0.5
  115474. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  115475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115476. * * 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)
  115477. * * 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)
  115478. * @returns the VertexData of the torus
  115479. */
  115480. static CreateTorus(options: {
  115481. diameter?: number;
  115482. thickness?: number;
  115483. tessellation?: number;
  115484. sideOrientation?: number;
  115485. frontUVs?: Vector4;
  115486. backUVs?: Vector4;
  115487. }): VertexData;
  115488. /**
  115489. * Creates the VertexData of the LineSystem
  115490. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  115491. * - lines an array of lines, each line being an array of successive Vector3
  115492. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  115493. * @returns the VertexData of the LineSystem
  115494. */
  115495. static CreateLineSystem(options: {
  115496. lines: Vector3[][];
  115497. colors?: Nullable<Color4[][]>;
  115498. }): VertexData;
  115499. /**
  115500. * Create the VertexData for a DashedLines
  115501. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  115502. * - points an array successive Vector3
  115503. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  115504. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  115505. * - dashNb the intended total number of dashes, optional, default 200
  115506. * @returns the VertexData for the DashedLines
  115507. */
  115508. static CreateDashedLines(options: {
  115509. points: Vector3[];
  115510. dashSize?: number;
  115511. gapSize?: number;
  115512. dashNb?: number;
  115513. }): VertexData;
  115514. /**
  115515. * Creates the VertexData for a Ground
  115516. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115517. * - width the width (x direction) of the ground, optional, default 1
  115518. * - height the height (z direction) of the ground, optional, default 1
  115519. * - subdivisions the number of subdivisions per side, optional, default 1
  115520. * @returns the VertexData of the Ground
  115521. */
  115522. static CreateGround(options: {
  115523. width?: number;
  115524. height?: number;
  115525. subdivisions?: number;
  115526. subdivisionsX?: number;
  115527. subdivisionsY?: number;
  115528. }): VertexData;
  115529. /**
  115530. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  115531. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  115532. * * xmin the ground minimum X coordinate, optional, default -1
  115533. * * zmin the ground minimum Z coordinate, optional, default -1
  115534. * * xmax the ground maximum X coordinate, optional, default 1
  115535. * * zmax the ground maximum Z coordinate, optional, default 1
  115536. * * 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}
  115537. * * 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}
  115538. * @returns the VertexData of the TiledGround
  115539. */
  115540. static CreateTiledGround(options: {
  115541. xmin: number;
  115542. zmin: number;
  115543. xmax: number;
  115544. zmax: number;
  115545. subdivisions?: {
  115546. w: number;
  115547. h: number;
  115548. };
  115549. precision?: {
  115550. w: number;
  115551. h: number;
  115552. };
  115553. }): VertexData;
  115554. /**
  115555. * Creates the VertexData of the Ground designed from a heightmap
  115556. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  115557. * * width the width (x direction) of the ground
  115558. * * height the height (z direction) of the ground
  115559. * * subdivisions the number of subdivisions per side
  115560. * * minHeight the minimum altitude on the ground, optional, default 0
  115561. * * maxHeight the maximum altitude on the ground, optional default 1
  115562. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  115563. * * buffer the array holding the image color data
  115564. * * bufferWidth the width of image
  115565. * * bufferHeight the height of image
  115566. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  115567. * @returns the VertexData of the Ground designed from a heightmap
  115568. */
  115569. static CreateGroundFromHeightMap(options: {
  115570. width: number;
  115571. height: number;
  115572. subdivisions: number;
  115573. minHeight: number;
  115574. maxHeight: number;
  115575. colorFilter: Color3;
  115576. buffer: Uint8Array;
  115577. bufferWidth: number;
  115578. bufferHeight: number;
  115579. alphaFilter: number;
  115580. }): VertexData;
  115581. /**
  115582. * Creates the VertexData for a Plane
  115583. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  115584. * * size sets the width and height of the plane to the value of size, optional default 1
  115585. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  115586. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  115587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115588. * * 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)
  115589. * * 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)
  115590. * @returns the VertexData of the box
  115591. */
  115592. static CreatePlane(options: {
  115593. size?: number;
  115594. width?: number;
  115595. height?: number;
  115596. sideOrientation?: number;
  115597. frontUVs?: Vector4;
  115598. backUVs?: Vector4;
  115599. }): VertexData;
  115600. /**
  115601. * Creates the VertexData of the Disc or regular Polygon
  115602. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  115603. * * radius the radius of the disc, optional default 0.5
  115604. * * tessellation the number of polygon sides, optional, default 64
  115605. * * 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
  115606. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115607. * * 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)
  115608. * * 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)
  115609. * @returns the VertexData of the box
  115610. */
  115611. static CreateDisc(options: {
  115612. radius?: number;
  115613. tessellation?: number;
  115614. arc?: number;
  115615. sideOrientation?: number;
  115616. frontUVs?: Vector4;
  115617. backUVs?: Vector4;
  115618. }): VertexData;
  115619. /**
  115620. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  115621. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  115622. * @param polygon a mesh built from polygonTriangulation.build()
  115623. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115624. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115625. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115626. * @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)
  115627. * @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)
  115628. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  115629. * @returns the VertexData of the Polygon
  115630. */
  115631. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  115632. /**
  115633. * Creates the VertexData of the IcoSphere
  115634. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  115635. * * radius the radius of the IcoSphere, optional default 1
  115636. * * radiusX allows stretching in the x direction, optional, default radius
  115637. * * radiusY allows stretching in the y direction, optional, default radius
  115638. * * radiusZ allows stretching in the z direction, optional, default radius
  115639. * * flat when true creates a flat shaded mesh, optional, default true
  115640. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115641. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115642. * * 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)
  115643. * * 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)
  115644. * @returns the VertexData of the IcoSphere
  115645. */
  115646. static CreateIcoSphere(options: {
  115647. radius?: number;
  115648. radiusX?: number;
  115649. radiusY?: number;
  115650. radiusZ?: number;
  115651. flat?: boolean;
  115652. subdivisions?: number;
  115653. sideOrientation?: number;
  115654. frontUVs?: Vector4;
  115655. backUVs?: Vector4;
  115656. }): VertexData;
  115657. /**
  115658. * Creates the VertexData for a Polyhedron
  115659. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  115660. * * type provided types are:
  115661. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  115662. * * 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)
  115663. * * size the size of the IcoSphere, optional default 1
  115664. * * sizeX allows stretching in the x direction, optional, default size
  115665. * * sizeY allows stretching in the y direction, optional, default size
  115666. * * sizeZ allows stretching in the z direction, optional, default size
  115667. * * 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
  115668. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  115669. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  115670. * * flat when true creates a flat shaded mesh, optional, default true
  115671. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  115672. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115673. * * 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)
  115674. * * 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)
  115675. * @returns the VertexData of the Polyhedron
  115676. */
  115677. static CreatePolyhedron(options: {
  115678. type?: number;
  115679. size?: number;
  115680. sizeX?: number;
  115681. sizeY?: number;
  115682. sizeZ?: number;
  115683. custom?: any;
  115684. faceUV?: Vector4[];
  115685. faceColors?: Color4[];
  115686. flat?: boolean;
  115687. sideOrientation?: number;
  115688. frontUVs?: Vector4;
  115689. backUVs?: Vector4;
  115690. }): VertexData;
  115691. /**
  115692. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  115693. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  115694. * @returns the VertexData of the Capsule
  115695. */
  115696. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  115697. /**
  115698. * Creates the VertexData for a TorusKnot
  115699. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  115700. * * radius the radius of the torus knot, optional, default 2
  115701. * * tube the thickness of the tube, optional, default 0.5
  115702. * * radialSegments the number of sides on each tube segments, optional, default 32
  115703. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  115704. * * p the number of windings around the z axis, optional, default 2
  115705. * * q the number of windings around the x axis, optional, default 3
  115706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115707. * * 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)
  115708. * * 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)
  115709. * @returns the VertexData of the Torus Knot
  115710. */
  115711. static CreateTorusKnot(options: {
  115712. radius?: number;
  115713. tube?: number;
  115714. radialSegments?: number;
  115715. tubularSegments?: number;
  115716. p?: number;
  115717. q?: number;
  115718. sideOrientation?: number;
  115719. frontUVs?: Vector4;
  115720. backUVs?: Vector4;
  115721. }): VertexData;
  115722. /**
  115723. * Compute normals for given positions and indices
  115724. * @param positions an array of vertex positions, [...., x, y, z, ......]
  115725. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  115726. * @param normals an array of vertex normals, [...., x, y, z, ......]
  115727. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  115728. * * facetNormals : optional array of facet normals (vector3)
  115729. * * facetPositions : optional array of facet positions (vector3)
  115730. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  115731. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  115732. * * bInfo : optional bounding info, required for facetPartitioning computation
  115733. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  115734. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  115735. * * useRightHandedSystem: optional boolean to for right handed system computation
  115736. * * depthSort : optional boolean to enable the facet depth sort computation
  115737. * * distanceTo : optional Vector3 to compute the facet depth from this location
  115738. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  115739. */
  115740. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  115741. facetNormals?: any;
  115742. facetPositions?: any;
  115743. facetPartitioning?: any;
  115744. ratio?: number;
  115745. bInfo?: any;
  115746. bbSize?: Vector3;
  115747. subDiv?: any;
  115748. useRightHandedSystem?: boolean;
  115749. depthSort?: boolean;
  115750. distanceTo?: Vector3;
  115751. depthSortedFacets?: any;
  115752. }): void;
  115753. /** @hidden */
  115754. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  115755. /**
  115756. * Applies VertexData created from the imported parameters to the geometry
  115757. * @param parsedVertexData the parsed data from an imported file
  115758. * @param geometry the geometry to apply the VertexData to
  115759. */
  115760. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  115761. }
  115762. }
  115763. declare module BABYLON {
  115764. /**
  115765. * Class containing static functions to help procedurally build meshes
  115766. */
  115767. export class DiscBuilder {
  115768. /**
  115769. * Creates a plane polygonal mesh. By default, this is a disc
  115770. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115771. * * 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
  115772. * * 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
  115773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115774. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115776. * @param name defines the name of the mesh
  115777. * @param options defines the options used to create the mesh
  115778. * @param scene defines the hosting scene
  115779. * @returns the plane polygonal mesh
  115780. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115781. */
  115782. static CreateDisc(name: string, options: {
  115783. radius?: number;
  115784. tessellation?: number;
  115785. arc?: number;
  115786. updatable?: boolean;
  115787. sideOrientation?: number;
  115788. frontUVs?: Vector4;
  115789. backUVs?: Vector4;
  115790. }, scene?: Nullable<Scene>): Mesh;
  115791. }
  115792. }
  115793. declare module BABYLON {
  115794. /**
  115795. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115796. *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.
  115797. * The SPS is also a particle system. It provides some methods to manage the particles.
  115798. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115799. *
  115800. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115801. */
  115802. export class SolidParticleSystem implements IDisposable {
  115803. /**
  115804. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115805. * Example : var p = SPS.particles[i];
  115806. */
  115807. particles: SolidParticle[];
  115808. /**
  115809. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115810. */
  115811. nbParticles: number;
  115812. /**
  115813. * If the particles must ever face the camera (default false). Useful for planar particles.
  115814. */
  115815. billboard: boolean;
  115816. /**
  115817. * Recompute normals when adding a shape
  115818. */
  115819. recomputeNormals: boolean;
  115820. /**
  115821. * This a counter ofr your own usage. It's not set by any SPS functions.
  115822. */
  115823. counter: number;
  115824. /**
  115825. * The SPS name. This name is also given to the underlying mesh.
  115826. */
  115827. name: string;
  115828. /**
  115829. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115830. */
  115831. mesh: Mesh;
  115832. /**
  115833. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115834. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115835. */
  115836. vars: any;
  115837. /**
  115838. * This array is populated when the SPS is set as 'pickable'.
  115839. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115840. * Each element of this array is an object `{idx: int, faceId: int}`.
  115841. * `idx` is the picked particle index in the `SPS.particles` array
  115842. * `faceId` is the picked face index counted within this particle.
  115843. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115844. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115845. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115846. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115847. */
  115848. pickedParticles: {
  115849. idx: number;
  115850. faceId: number;
  115851. }[];
  115852. /**
  115853. * This array is populated when the SPS is set as 'pickable'
  115854. * Each key of this array is a submesh index.
  115855. * Each element of this array is a second array defined like this :
  115856. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115857. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115858. * `idx` is the picked particle index in the `SPS.particles` array
  115859. * `faceId` is the picked face index counted within this particle.
  115860. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115861. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115862. */
  115863. pickedBySubMesh: {
  115864. idx: number;
  115865. faceId: number;
  115866. }[][];
  115867. /**
  115868. * This array is populated when `enableDepthSort` is set to true.
  115869. * Each element of this array is an instance of the class DepthSortedParticle.
  115870. */
  115871. depthSortedParticles: DepthSortedParticle[];
  115872. /**
  115873. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115874. * @hidden
  115875. */
  115876. _bSphereOnly: boolean;
  115877. /**
  115878. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115879. * @hidden
  115880. */
  115881. _bSphereRadiusFactor: number;
  115882. private _scene;
  115883. private _positions;
  115884. private _indices;
  115885. private _normals;
  115886. private _colors;
  115887. private _uvs;
  115888. private _indices32;
  115889. private _positions32;
  115890. private _normals32;
  115891. private _fixedNormal32;
  115892. private _colors32;
  115893. private _uvs32;
  115894. private _index;
  115895. private _updatable;
  115896. private _pickable;
  115897. private _isVisibilityBoxLocked;
  115898. private _alwaysVisible;
  115899. private _depthSort;
  115900. private _expandable;
  115901. private _shapeCounter;
  115902. private _copy;
  115903. private _color;
  115904. private _computeParticleColor;
  115905. private _computeParticleTexture;
  115906. private _computeParticleRotation;
  115907. private _computeParticleVertex;
  115908. private _computeBoundingBox;
  115909. private _depthSortParticles;
  115910. private _camera;
  115911. private _mustUnrotateFixedNormals;
  115912. private _particlesIntersect;
  115913. private _needs32Bits;
  115914. private _isNotBuilt;
  115915. private _lastParticleId;
  115916. private _idxOfId;
  115917. private _multimaterialEnabled;
  115918. private _useModelMaterial;
  115919. private _indicesByMaterial;
  115920. private _materialIndexes;
  115921. private _depthSortFunction;
  115922. private _materialSortFunction;
  115923. private _materials;
  115924. private _multimaterial;
  115925. private _materialIndexesById;
  115926. private _defaultMaterial;
  115927. private _autoUpdateSubMeshes;
  115928. private _tmpVertex;
  115929. /**
  115930. * Creates a SPS (Solid Particle System) object.
  115931. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115932. * @param scene (Scene) is the scene in which the SPS is added.
  115933. * @param options defines the options of the sps e.g.
  115934. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115935. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115936. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115937. * * 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.
  115938. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115939. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115940. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115941. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115942. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115943. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115944. */
  115945. constructor(name: string, scene: Scene, options?: {
  115946. updatable?: boolean;
  115947. isPickable?: boolean;
  115948. enableDepthSort?: boolean;
  115949. particleIntersection?: boolean;
  115950. boundingSphereOnly?: boolean;
  115951. bSphereRadiusFactor?: number;
  115952. expandable?: boolean;
  115953. useModelMaterial?: boolean;
  115954. enableMultiMaterial?: boolean;
  115955. });
  115956. /**
  115957. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115958. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115959. * @returns the created mesh
  115960. */
  115961. buildMesh(): Mesh;
  115962. /**
  115963. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115964. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115965. * Thus the particles generated from `digest()` have their property `position` set yet.
  115966. * @param mesh ( Mesh ) is the mesh to be digested
  115967. * @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
  115968. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115969. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115970. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115971. * @returns the current SPS
  115972. */
  115973. digest(mesh: Mesh, options?: {
  115974. facetNb?: number;
  115975. number?: number;
  115976. delta?: number;
  115977. storage?: [];
  115978. }): SolidParticleSystem;
  115979. /**
  115980. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115981. * @hidden
  115982. */
  115983. private _unrotateFixedNormals;
  115984. /**
  115985. * Resets the temporary working copy particle
  115986. * @hidden
  115987. */
  115988. private _resetCopy;
  115989. /**
  115990. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115991. * @param p the current index in the positions array to be updated
  115992. * @param ind the current index in the indices array
  115993. * @param shape a Vector3 array, the shape geometry
  115994. * @param positions the positions array to be updated
  115995. * @param meshInd the shape indices array
  115996. * @param indices the indices array to be updated
  115997. * @param meshUV the shape uv array
  115998. * @param uvs the uv array to be updated
  115999. * @param meshCol the shape color array
  116000. * @param colors the color array to be updated
  116001. * @param meshNor the shape normals array
  116002. * @param normals the normals array to be updated
  116003. * @param idx the particle index
  116004. * @param idxInShape the particle index in its shape
  116005. * @param options the addShape() method passed options
  116006. * @model the particle model
  116007. * @hidden
  116008. */
  116009. private _meshBuilder;
  116010. /**
  116011. * Returns a shape Vector3 array from positions float array
  116012. * @param positions float array
  116013. * @returns a vector3 array
  116014. * @hidden
  116015. */
  116016. private _posToShape;
  116017. /**
  116018. * Returns a shapeUV array from a float uvs (array deep copy)
  116019. * @param uvs as a float array
  116020. * @returns a shapeUV array
  116021. * @hidden
  116022. */
  116023. private _uvsToShapeUV;
  116024. /**
  116025. * Adds a new particle object in the particles array
  116026. * @param idx particle index in particles array
  116027. * @param id particle id
  116028. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  116029. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  116030. * @param model particle ModelShape object
  116031. * @param shapeId model shape identifier
  116032. * @param idxInShape index of the particle in the current model
  116033. * @param bInfo model bounding info object
  116034. * @param storage target storage array, if any
  116035. * @hidden
  116036. */
  116037. private _addParticle;
  116038. /**
  116039. * Adds some particles to the SPS from the model shape. Returns the shape id.
  116040. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  116041. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  116042. * @param nb (positive integer) the number of particles to be created from this model
  116043. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  116044. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  116045. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  116046. * @returns the number of shapes in the system
  116047. */
  116048. addShape(mesh: Mesh, nb: number, options?: {
  116049. positionFunction?: any;
  116050. vertexFunction?: any;
  116051. storage?: [];
  116052. }): number;
  116053. /**
  116054. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  116055. * @hidden
  116056. */
  116057. private _rebuildParticle;
  116058. /**
  116059. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  116060. * @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.
  116061. * @returns the SPS.
  116062. */
  116063. rebuildMesh(reset?: boolean): SolidParticleSystem;
  116064. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  116065. * Returns an array with the removed particles.
  116066. * 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.
  116067. * The SPS can't be empty so at least one particle needs to remain in place.
  116068. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  116069. * @param start index of the first particle to remove
  116070. * @param end index of the last particle to remove (included)
  116071. * @returns an array populated with the removed particles
  116072. */
  116073. removeParticles(start: number, end: number): SolidParticle[];
  116074. /**
  116075. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  116076. * @param solidParticleArray an array populated with Solid Particles objects
  116077. * @returns the SPS
  116078. */
  116079. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  116080. /**
  116081. * Creates a new particle and modifies the SPS mesh geometry :
  116082. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  116083. * - calls _addParticle() to populate the particle array
  116084. * factorized code from addShape() and insertParticlesFromArray()
  116085. * @param idx particle index in the particles array
  116086. * @param i particle index in its shape
  116087. * @param modelShape particle ModelShape object
  116088. * @param shape shape vertex array
  116089. * @param meshInd shape indices array
  116090. * @param meshUV shape uv array
  116091. * @param meshCol shape color array
  116092. * @param meshNor shape normals array
  116093. * @param bbInfo shape bounding info
  116094. * @param storage target particle storage
  116095. * @options addShape() passed options
  116096. * @hidden
  116097. */
  116098. private _insertNewParticle;
  116099. /**
  116100. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  116101. * This method calls `updateParticle()` for each particle of the SPS.
  116102. * For an animated SPS, it is usually called within the render loop.
  116103. * 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.
  116104. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  116105. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  116106. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  116107. * @returns the SPS.
  116108. */
  116109. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  116110. /**
  116111. * Disposes the SPS.
  116112. */
  116113. dispose(): void;
  116114. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  116115. * idx is the particle index in the SPS
  116116. * faceId is the picked face index counted within this particle.
  116117. * Returns null if the pickInfo can't identify a picked particle.
  116118. * @param pickingInfo (PickingInfo object)
  116119. * @returns {idx: number, faceId: number} or null
  116120. */
  116121. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  116122. idx: number;
  116123. faceId: number;
  116124. }>;
  116125. /**
  116126. * Returns a SolidParticle object from its identifier : particle.id
  116127. * @param id (integer) the particle Id
  116128. * @returns the searched particle or null if not found in the SPS.
  116129. */
  116130. getParticleById(id: number): Nullable<SolidParticle>;
  116131. /**
  116132. * Returns a new array populated with the particles having the passed shapeId.
  116133. * @param shapeId (integer) the shape identifier
  116134. * @returns a new solid particle array
  116135. */
  116136. getParticlesByShapeId(shapeId: number): SolidParticle[];
  116137. /**
  116138. * Populates the passed array "ref" with the particles having the passed shapeId.
  116139. * @param shapeId the shape identifier
  116140. * @returns the SPS
  116141. * @param ref
  116142. */
  116143. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  116144. /**
  116145. * Computes the required SubMeshes according the materials assigned to the particles.
  116146. * @returns the solid particle system.
  116147. * Does nothing if called before the SPS mesh is built.
  116148. */
  116149. computeSubMeshes(): SolidParticleSystem;
  116150. /**
  116151. * Sorts the solid particles by material when MultiMaterial is enabled.
  116152. * Updates the indices32 array.
  116153. * Updates the indicesByMaterial array.
  116154. * Updates the mesh indices array.
  116155. * @returns the SPS
  116156. * @hidden
  116157. */
  116158. private _sortParticlesByMaterial;
  116159. /**
  116160. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  116161. * @hidden
  116162. */
  116163. private _setMaterialIndexesById;
  116164. /**
  116165. * Returns an array with unique values of Materials from the passed array
  116166. * @param array the material array to be checked and filtered
  116167. * @hidden
  116168. */
  116169. private _filterUniqueMaterialId;
  116170. /**
  116171. * Sets a new Standard Material as _defaultMaterial if not already set.
  116172. * @hidden
  116173. */
  116174. private _setDefaultMaterial;
  116175. /**
  116176. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116177. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116178. * @returns the SPS.
  116179. */
  116180. refreshVisibleSize(): SolidParticleSystem;
  116181. /**
  116182. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116183. * @param size the size (float) of the visibility box
  116184. * note : this doesn't lock the SPS mesh bounding box.
  116185. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116186. */
  116187. setVisibilityBox(size: number): void;
  116188. /**
  116189. * Gets whether the SPS as always visible or not
  116190. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116191. */
  116192. get isAlwaysVisible(): boolean;
  116193. /**
  116194. * Sets the SPS as always visible or not
  116195. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116196. */
  116197. set isAlwaysVisible(val: boolean);
  116198. /**
  116199. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116200. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116201. */
  116202. set isVisibilityBoxLocked(val: boolean);
  116203. /**
  116204. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116205. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116206. */
  116207. get isVisibilityBoxLocked(): boolean;
  116208. /**
  116209. * Tells to `setParticles()` to compute the particle rotations or not.
  116210. * Default value : true. The SPS is faster when it's set to false.
  116211. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116212. */
  116213. set computeParticleRotation(val: boolean);
  116214. /**
  116215. * Tells to `setParticles()` to compute the particle colors or not.
  116216. * Default value : true. The SPS is faster when it's set to false.
  116217. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116218. */
  116219. set computeParticleColor(val: boolean);
  116220. set computeParticleTexture(val: boolean);
  116221. /**
  116222. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116223. * Default value : false. The SPS is faster when it's set to false.
  116224. * Note : the particle custom vertex positions aren't stored values.
  116225. */
  116226. set computeParticleVertex(val: boolean);
  116227. /**
  116228. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116229. */
  116230. set computeBoundingBox(val: boolean);
  116231. /**
  116232. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116233. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116234. * Default : `true`
  116235. */
  116236. set depthSortParticles(val: boolean);
  116237. /**
  116238. * Gets if `setParticles()` computes the particle rotations or not.
  116239. * Default value : true. The SPS is faster when it's set to false.
  116240. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116241. */
  116242. get computeParticleRotation(): boolean;
  116243. /**
  116244. * Gets if `setParticles()` computes the particle colors or not.
  116245. * Default value : true. The SPS is faster when it's set to false.
  116246. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116247. */
  116248. get computeParticleColor(): boolean;
  116249. /**
  116250. * Gets if `setParticles()` computes the particle textures or not.
  116251. * Default value : true. The SPS is faster when it's set to false.
  116252. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116253. */
  116254. get computeParticleTexture(): boolean;
  116255. /**
  116256. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116257. * Default value : false. The SPS is faster when it's set to false.
  116258. * Note : the particle custom vertex positions aren't stored values.
  116259. */
  116260. get computeParticleVertex(): boolean;
  116261. /**
  116262. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116263. */
  116264. get computeBoundingBox(): boolean;
  116265. /**
  116266. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116267. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116268. * Default : `true`
  116269. */
  116270. get depthSortParticles(): boolean;
  116271. /**
  116272. * Gets if the SPS is created as expandable at construction time.
  116273. * Default : `false`
  116274. */
  116275. get expandable(): boolean;
  116276. /**
  116277. * Gets if the SPS supports the Multi Materials
  116278. */
  116279. get multimaterialEnabled(): boolean;
  116280. /**
  116281. * Gets if the SPS uses the model materials for its own multimaterial.
  116282. */
  116283. get useModelMaterial(): boolean;
  116284. /**
  116285. * The SPS used material array.
  116286. */
  116287. get materials(): Material[];
  116288. /**
  116289. * Sets the SPS MultiMaterial from the passed materials.
  116290. * Note : the passed array is internally copied and not used then by reference.
  116291. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116292. */
  116293. setMultiMaterial(materials: Material[]): void;
  116294. /**
  116295. * The SPS computed multimaterial object
  116296. */
  116297. get multimaterial(): MultiMaterial;
  116298. set multimaterial(mm: MultiMaterial);
  116299. /**
  116300. * If the subMeshes must be updated on the next call to setParticles()
  116301. */
  116302. get autoUpdateSubMeshes(): boolean;
  116303. set autoUpdateSubMeshes(val: boolean);
  116304. /**
  116305. * This function does nothing. It may be overwritten to set all the particle first values.
  116306. * The SPS doesn't call this function, you may have to call it by your own.
  116307. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116308. */
  116309. initParticles(): void;
  116310. /**
  116311. * This function does nothing. It may be overwritten to recycle a particle.
  116312. * The SPS doesn't call this function, you may have to call it by your own.
  116313. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116314. * @param particle The particle to recycle
  116315. * @returns the recycled particle
  116316. */
  116317. recycleParticle(particle: SolidParticle): SolidParticle;
  116318. /**
  116319. * Updates a particle : this function should be overwritten by the user.
  116320. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116321. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116322. * @example : just set a particle position or velocity and recycle conditions
  116323. * @param particle The particle to update
  116324. * @returns the updated particle
  116325. */
  116326. updateParticle(particle: SolidParticle): SolidParticle;
  116327. /**
  116328. * Updates a vertex of a particle : it can be overwritten by the user.
  116329. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116330. * @param particle the current particle
  116331. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116332. * @param pt the index of the current vertex in the particle shape
  116333. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116334. * @example : just set a vertex particle position or color
  116335. * @returns the sps
  116336. */
  116337. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116338. /**
  116339. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116340. * This does nothing and may be overwritten by the user.
  116341. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116342. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116343. * @param update the boolean update value actually passed to setParticles()
  116344. */
  116345. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116346. /**
  116347. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116348. * This will be passed three parameters.
  116349. * This does nothing and may be overwritten by the user.
  116350. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116351. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116352. * @param update the boolean update value actually passed to setParticles()
  116353. */
  116354. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116355. }
  116356. }
  116357. declare module BABYLON {
  116358. /**
  116359. * Represents one particle of a solid particle system.
  116360. */
  116361. export class SolidParticle {
  116362. /**
  116363. * particle global index
  116364. */
  116365. idx: number;
  116366. /**
  116367. * particle identifier
  116368. */
  116369. id: number;
  116370. /**
  116371. * The color of the particle
  116372. */
  116373. color: Nullable<Color4>;
  116374. /**
  116375. * The world space position of the particle.
  116376. */
  116377. position: Vector3;
  116378. /**
  116379. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116380. */
  116381. rotation: Vector3;
  116382. /**
  116383. * The world space rotation quaternion of the particle.
  116384. */
  116385. rotationQuaternion: Nullable<Quaternion>;
  116386. /**
  116387. * The scaling of the particle.
  116388. */
  116389. scaling: Vector3;
  116390. /**
  116391. * The uvs of the particle.
  116392. */
  116393. uvs: Vector4;
  116394. /**
  116395. * The current speed of the particle.
  116396. */
  116397. velocity: Vector3;
  116398. /**
  116399. * The pivot point in the particle local space.
  116400. */
  116401. pivot: Vector3;
  116402. /**
  116403. * Must the particle be translated from its pivot point in its local space ?
  116404. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116405. * Default : false
  116406. */
  116407. translateFromPivot: boolean;
  116408. /**
  116409. * Is the particle active or not ?
  116410. */
  116411. alive: boolean;
  116412. /**
  116413. * Is the particle visible or not ?
  116414. */
  116415. isVisible: boolean;
  116416. /**
  116417. * Index of this particle in the global "positions" array (Internal use)
  116418. * @hidden
  116419. */
  116420. _pos: number;
  116421. /**
  116422. * @hidden Index of this particle in the global "indices" array (Internal use)
  116423. */
  116424. _ind: number;
  116425. /**
  116426. * @hidden ModelShape of this particle (Internal use)
  116427. */
  116428. _model: ModelShape;
  116429. /**
  116430. * ModelShape id of this particle
  116431. */
  116432. shapeId: number;
  116433. /**
  116434. * Index of the particle in its shape id
  116435. */
  116436. idxInShape: number;
  116437. /**
  116438. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116439. */
  116440. _modelBoundingInfo: BoundingInfo;
  116441. /**
  116442. * @hidden Particle BoundingInfo object (Internal use)
  116443. */
  116444. _boundingInfo: BoundingInfo;
  116445. /**
  116446. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116447. */
  116448. _sps: SolidParticleSystem;
  116449. /**
  116450. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116451. */
  116452. _stillInvisible: boolean;
  116453. /**
  116454. * @hidden Last computed particle rotation matrix
  116455. */
  116456. _rotationMatrix: number[];
  116457. /**
  116458. * Parent particle Id, if any.
  116459. * Default null.
  116460. */
  116461. parentId: Nullable<number>;
  116462. /**
  116463. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116464. */
  116465. materialIndex: Nullable<number>;
  116466. /**
  116467. * Custom object or properties.
  116468. */
  116469. props: Nullable<any>;
  116470. /**
  116471. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116472. * The possible values are :
  116473. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116474. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116475. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116476. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116477. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116478. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116479. * */
  116480. cullingStrategy: number;
  116481. /**
  116482. * @hidden Internal global position in the SPS.
  116483. */
  116484. _globalPosition: Vector3;
  116485. /**
  116486. * Creates a Solid Particle object.
  116487. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116488. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116489. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116490. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116491. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116492. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116493. * @param shapeId (integer) is the model shape identifier in the SPS.
  116494. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116495. * @param sps defines the sps it is associated to
  116496. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116497. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116498. */
  116499. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116500. /**
  116501. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116502. * @param target the particle target
  116503. * @returns the current particle
  116504. */
  116505. copyToRef(target: SolidParticle): SolidParticle;
  116506. /**
  116507. * Legacy support, changed scale to scaling
  116508. */
  116509. get scale(): Vector3;
  116510. /**
  116511. * Legacy support, changed scale to scaling
  116512. */
  116513. set scale(scale: Vector3);
  116514. /**
  116515. * Legacy support, changed quaternion to rotationQuaternion
  116516. */
  116517. get quaternion(): Nullable<Quaternion>;
  116518. /**
  116519. * Legacy support, changed quaternion to rotationQuaternion
  116520. */
  116521. set quaternion(q: Nullable<Quaternion>);
  116522. /**
  116523. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116524. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116525. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116526. * @returns true if it intersects
  116527. */
  116528. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116529. /**
  116530. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116531. * A particle is in the frustum if its bounding box intersects the frustum
  116532. * @param frustumPlanes defines the frustum to test
  116533. * @returns true if the particle is in the frustum planes
  116534. */
  116535. isInFrustum(frustumPlanes: Plane[]): boolean;
  116536. /**
  116537. * get the rotation matrix of the particle
  116538. * @hidden
  116539. */
  116540. getRotationMatrix(m: Matrix): void;
  116541. }
  116542. /**
  116543. * Represents the shape of the model used by one particle of a solid particle system.
  116544. * SPS internal tool, don't use it manually.
  116545. */
  116546. export class ModelShape {
  116547. /**
  116548. * The shape id
  116549. * @hidden
  116550. */
  116551. shapeID: number;
  116552. /**
  116553. * flat array of model positions (internal use)
  116554. * @hidden
  116555. */
  116556. _shape: Vector3[];
  116557. /**
  116558. * flat array of model UVs (internal use)
  116559. * @hidden
  116560. */
  116561. _shapeUV: number[];
  116562. /**
  116563. * color array of the model
  116564. * @hidden
  116565. */
  116566. _shapeColors: number[];
  116567. /**
  116568. * indices array of the model
  116569. * @hidden
  116570. */
  116571. _indices: number[];
  116572. /**
  116573. * normals array of the model
  116574. * @hidden
  116575. */
  116576. _normals: number[];
  116577. /**
  116578. * length of the shape in the model indices array (internal use)
  116579. * @hidden
  116580. */
  116581. _indicesLength: number;
  116582. /**
  116583. * Custom position function (internal use)
  116584. * @hidden
  116585. */
  116586. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116587. /**
  116588. * Custom vertex function (internal use)
  116589. * @hidden
  116590. */
  116591. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116592. /**
  116593. * Model material (internal use)
  116594. * @hidden
  116595. */
  116596. _material: Nullable<Material>;
  116597. /**
  116598. * 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.
  116599. * SPS internal tool, don't use it manually.
  116600. * @hidden
  116601. */
  116602. 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>);
  116603. }
  116604. /**
  116605. * Represents a Depth Sorted Particle in the solid particle system.
  116606. * @hidden
  116607. */
  116608. export class DepthSortedParticle {
  116609. /**
  116610. * Particle index
  116611. */
  116612. idx: number;
  116613. /**
  116614. * Index of the particle in the "indices" array
  116615. */
  116616. ind: number;
  116617. /**
  116618. * Length of the particle shape in the "indices" array
  116619. */
  116620. indicesLength: number;
  116621. /**
  116622. * Squared distance from the particle to the camera
  116623. */
  116624. sqDistance: number;
  116625. /**
  116626. * Material index when used with MultiMaterials
  116627. */
  116628. materialIndex: number;
  116629. /**
  116630. * Creates a new sorted particle
  116631. * @param materialIndex
  116632. */
  116633. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116634. }
  116635. /**
  116636. * Represents a solid particle vertex
  116637. */
  116638. export class SolidParticleVertex {
  116639. /**
  116640. * Vertex position
  116641. */
  116642. position: Vector3;
  116643. /**
  116644. * Vertex color
  116645. */
  116646. color: Color4;
  116647. /**
  116648. * Vertex UV
  116649. */
  116650. uv: Vector2;
  116651. /**
  116652. * Creates a new solid particle vertex
  116653. */
  116654. constructor();
  116655. /** Vertex x coordinate */
  116656. get x(): number;
  116657. set x(val: number);
  116658. /** Vertex y coordinate */
  116659. get y(): number;
  116660. set y(val: number);
  116661. /** Vertex z coordinate */
  116662. get z(): number;
  116663. set z(val: number);
  116664. }
  116665. }
  116666. declare module BABYLON {
  116667. /**
  116668. * @hidden
  116669. */
  116670. export class _MeshCollisionData {
  116671. _checkCollisions: boolean;
  116672. _collisionMask: number;
  116673. _collisionGroup: number;
  116674. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116675. _collider: Nullable<Collider>;
  116676. _oldPositionForCollisions: Vector3;
  116677. _diffPositionForCollisions: Vector3;
  116678. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116679. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116680. _collisionResponse: boolean;
  116681. }
  116682. }
  116683. declare module BABYLON {
  116684. /** @hidden */
  116685. class _FacetDataStorage {
  116686. facetPositions: Vector3[];
  116687. facetNormals: Vector3[];
  116688. facetPartitioning: number[][];
  116689. facetNb: number;
  116690. partitioningSubdivisions: number;
  116691. partitioningBBoxRatio: number;
  116692. facetDataEnabled: boolean;
  116693. facetParameters: any;
  116694. bbSize: Vector3;
  116695. subDiv: {
  116696. max: number;
  116697. X: number;
  116698. Y: number;
  116699. Z: number;
  116700. };
  116701. facetDepthSort: boolean;
  116702. facetDepthSortEnabled: boolean;
  116703. depthSortedIndices: IndicesArray;
  116704. depthSortedFacets: {
  116705. ind: number;
  116706. sqDistance: number;
  116707. }[];
  116708. facetDepthSortFunction: (f1: {
  116709. ind: number;
  116710. sqDistance: number;
  116711. }, f2: {
  116712. ind: number;
  116713. sqDistance: number;
  116714. }) => number;
  116715. facetDepthSortFrom: Vector3;
  116716. facetDepthSortOrigin: Vector3;
  116717. invertedMatrix: Matrix;
  116718. }
  116719. /**
  116720. * @hidden
  116721. **/
  116722. class _InternalAbstractMeshDataInfo {
  116723. _hasVertexAlpha: boolean;
  116724. _useVertexColors: boolean;
  116725. _numBoneInfluencers: number;
  116726. _applyFog: boolean;
  116727. _receiveShadows: boolean;
  116728. _facetData: _FacetDataStorage;
  116729. _visibility: number;
  116730. _skeleton: Nullable<Skeleton>;
  116731. _layerMask: number;
  116732. _computeBonesUsingShaders: boolean;
  116733. _isActive: boolean;
  116734. _onlyForInstances: boolean;
  116735. _isActiveIntermediate: boolean;
  116736. _onlyForInstancesIntermediate: boolean;
  116737. _actAsRegularMesh: boolean;
  116738. _currentLOD: Nullable<AbstractMesh>;
  116739. _currentLODIsUpToDate: boolean;
  116740. }
  116741. /**
  116742. * Class used to store all common mesh properties
  116743. */
  116744. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116745. /** No occlusion */
  116746. static OCCLUSION_TYPE_NONE: number;
  116747. /** Occlusion set to optimisitic */
  116748. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116749. /** Occlusion set to strict */
  116750. static OCCLUSION_TYPE_STRICT: number;
  116751. /** Use an accurante occlusion algorithm */
  116752. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116753. /** Use a conservative occlusion algorithm */
  116754. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116755. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116756. * Test order :
  116757. * Is the bounding sphere outside the frustum ?
  116758. * If not, are the bounding box vertices outside the frustum ?
  116759. * It not, then the cullable object is in the frustum.
  116760. */
  116761. static readonly CULLINGSTRATEGY_STANDARD: number;
  116762. /** Culling strategy : Bounding Sphere Only.
  116763. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116764. * It's also less accurate than the standard because some not visible objects can still be selected.
  116765. * Test : is the bounding sphere outside the frustum ?
  116766. * If not, then the cullable object is in the frustum.
  116767. */
  116768. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116769. /** Culling strategy : Optimistic Inclusion.
  116770. * This in an inclusion test first, then the standard exclusion test.
  116771. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116772. * 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.
  116773. * Anyway, it's as accurate as the standard strategy.
  116774. * Test :
  116775. * Is the cullable object bounding sphere center in the frustum ?
  116776. * If not, apply the default culling strategy.
  116777. */
  116778. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116779. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116780. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116781. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116782. * 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.
  116783. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116784. * Test :
  116785. * Is the cullable object bounding sphere center in the frustum ?
  116786. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116787. */
  116788. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116789. /**
  116790. * No billboard
  116791. */
  116792. static get BILLBOARDMODE_NONE(): number;
  116793. /** Billboard on X axis */
  116794. static get BILLBOARDMODE_X(): number;
  116795. /** Billboard on Y axis */
  116796. static get BILLBOARDMODE_Y(): number;
  116797. /** Billboard on Z axis */
  116798. static get BILLBOARDMODE_Z(): number;
  116799. /** Billboard on all axes */
  116800. static get BILLBOARDMODE_ALL(): number;
  116801. /** Billboard on using position instead of orientation */
  116802. static get BILLBOARDMODE_USE_POSITION(): number;
  116803. /** @hidden */
  116804. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116805. /**
  116806. * The culling strategy to use to check whether the mesh must be rendered or not.
  116807. * This value can be changed at any time and will be used on the next render mesh selection.
  116808. * The possible values are :
  116809. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116810. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116811. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116812. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116813. * Please read each static variable documentation to get details about the culling process.
  116814. * */
  116815. cullingStrategy: number;
  116816. /**
  116817. * Gets the number of facets in the mesh
  116818. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116819. */
  116820. get facetNb(): number;
  116821. /**
  116822. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116823. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116824. */
  116825. get partitioningSubdivisions(): number;
  116826. set partitioningSubdivisions(nb: number);
  116827. /**
  116828. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116829. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116830. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116831. */
  116832. get partitioningBBoxRatio(): number;
  116833. set partitioningBBoxRatio(ratio: number);
  116834. /**
  116835. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116836. * Works only for updatable meshes.
  116837. * Doesn't work with multi-materials
  116838. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116839. */
  116840. get mustDepthSortFacets(): boolean;
  116841. set mustDepthSortFacets(sort: boolean);
  116842. /**
  116843. * The location (Vector3) where the facet depth sort must be computed from.
  116844. * By default, the active camera position.
  116845. * Used only when facet depth sort is enabled
  116846. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116847. */
  116848. get facetDepthSortFrom(): Vector3;
  116849. set facetDepthSortFrom(location: Vector3);
  116850. /**
  116851. * gets a boolean indicating if facetData is enabled
  116852. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116853. */
  116854. get isFacetDataEnabled(): boolean;
  116855. /** @hidden */
  116856. _updateNonUniformScalingState(value: boolean): boolean;
  116857. /**
  116858. * An event triggered when this mesh collides with another one
  116859. */
  116860. onCollideObservable: Observable<AbstractMesh>;
  116861. /** Set a function to call when this mesh collides with another one */
  116862. set onCollide(callback: () => void);
  116863. /**
  116864. * An event triggered when the collision's position changes
  116865. */
  116866. onCollisionPositionChangeObservable: Observable<Vector3>;
  116867. /** Set a function to call when the collision's position changes */
  116868. set onCollisionPositionChange(callback: () => void);
  116869. /**
  116870. * An event triggered when material is changed
  116871. */
  116872. onMaterialChangedObservable: Observable<AbstractMesh>;
  116873. /**
  116874. * Gets or sets the orientation for POV movement & rotation
  116875. */
  116876. definedFacingForward: boolean;
  116877. /** @hidden */
  116878. _occlusionQuery: Nullable<WebGLQuery>;
  116879. /** @hidden */
  116880. _renderingGroup: Nullable<RenderingGroup>;
  116881. /**
  116882. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116883. */
  116884. get visibility(): number;
  116885. /**
  116886. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116887. */
  116888. set visibility(value: number);
  116889. /** Gets or sets the alpha index used to sort transparent meshes
  116890. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116891. */
  116892. alphaIndex: number;
  116893. /**
  116894. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116895. */
  116896. isVisible: boolean;
  116897. /**
  116898. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116899. */
  116900. isPickable: boolean;
  116901. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116902. showSubMeshesBoundingBox: boolean;
  116903. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116904. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116905. */
  116906. isBlocker: boolean;
  116907. /**
  116908. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116909. */
  116910. enablePointerMoveEvents: boolean;
  116911. private _renderingGroupId;
  116912. /**
  116913. * Specifies the rendering group id for this mesh (0 by default)
  116914. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116915. */
  116916. get renderingGroupId(): number;
  116917. set renderingGroupId(value: number);
  116918. private _material;
  116919. /** Gets or sets current material */
  116920. get material(): Nullable<Material>;
  116921. set material(value: Nullable<Material>);
  116922. /**
  116923. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116924. * @see https://doc.babylonjs.com/babylon101/shadows
  116925. */
  116926. get receiveShadows(): boolean;
  116927. set receiveShadows(value: boolean);
  116928. /** Defines color to use when rendering outline */
  116929. outlineColor: Color3;
  116930. /** Define width to use when rendering outline */
  116931. outlineWidth: number;
  116932. /** Defines color to use when rendering overlay */
  116933. overlayColor: Color3;
  116934. /** Defines alpha to use when rendering overlay */
  116935. overlayAlpha: number;
  116936. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116937. get hasVertexAlpha(): boolean;
  116938. set hasVertexAlpha(value: boolean);
  116939. /** 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) */
  116940. get useVertexColors(): boolean;
  116941. set useVertexColors(value: boolean);
  116942. /**
  116943. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116944. */
  116945. get computeBonesUsingShaders(): boolean;
  116946. set computeBonesUsingShaders(value: boolean);
  116947. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116948. get numBoneInfluencers(): number;
  116949. set numBoneInfluencers(value: number);
  116950. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116951. get applyFog(): boolean;
  116952. set applyFog(value: boolean);
  116953. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116954. useOctreeForRenderingSelection: boolean;
  116955. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116956. useOctreeForPicking: boolean;
  116957. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116958. useOctreeForCollisions: boolean;
  116959. /**
  116960. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116961. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116962. */
  116963. get layerMask(): number;
  116964. set layerMask(value: number);
  116965. /**
  116966. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116967. */
  116968. alwaysSelectAsActiveMesh: boolean;
  116969. /**
  116970. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116971. */
  116972. doNotSyncBoundingInfo: boolean;
  116973. /**
  116974. * Gets or sets the current action manager
  116975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116976. */
  116977. actionManager: Nullable<AbstractActionManager>;
  116978. private _meshCollisionData;
  116979. /**
  116980. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116981. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116982. */
  116983. ellipsoid: Vector3;
  116984. /**
  116985. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116986. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116987. */
  116988. ellipsoidOffset: Vector3;
  116989. /**
  116990. * Gets or sets a collision mask used to mask collisions (default is -1).
  116991. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116992. */
  116993. get collisionMask(): number;
  116994. set collisionMask(mask: number);
  116995. /**
  116996. * Gets or sets a collision response flag (default is true).
  116997. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116998. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116999. * to respond to the collision.
  117000. */
  117001. get collisionResponse(): boolean;
  117002. set collisionResponse(response: boolean);
  117003. /**
  117004. * Gets or sets the current collision group mask (-1 by default).
  117005. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  117006. */
  117007. get collisionGroup(): number;
  117008. set collisionGroup(mask: number);
  117009. /**
  117010. * Gets or sets current surrounding meshes (null by default).
  117011. *
  117012. * By default collision detection is tested against every mesh in the scene.
  117013. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  117014. * meshes will be tested for the collision.
  117015. *
  117016. * Note: if set to an empty array no collision will happen when this mesh is moved.
  117017. */
  117018. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  117019. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  117020. /**
  117021. * Defines edge width used when edgesRenderer is enabled
  117022. * @see https://www.babylonjs-playground.com/#10OJSG#13
  117023. */
  117024. edgesWidth: number;
  117025. /**
  117026. * Defines edge color used when edgesRenderer is enabled
  117027. * @see https://www.babylonjs-playground.com/#10OJSG#13
  117028. */
  117029. edgesColor: Color4;
  117030. /** @hidden */
  117031. _edgesRenderer: Nullable<IEdgesRenderer>;
  117032. /** @hidden */
  117033. _masterMesh: Nullable<AbstractMesh>;
  117034. /** @hidden */
  117035. _boundingInfo: Nullable<BoundingInfo>;
  117036. /** @hidden */
  117037. _renderId: number;
  117038. /**
  117039. * Gets or sets the list of subMeshes
  117040. * @see https://doc.babylonjs.com/how_to/multi_materials
  117041. */
  117042. subMeshes: SubMesh[];
  117043. /** @hidden */
  117044. _intersectionsInProgress: AbstractMesh[];
  117045. /** @hidden */
  117046. _unIndexed: boolean;
  117047. /** @hidden */
  117048. _lightSources: Light[];
  117049. /** Gets the list of lights affecting that mesh */
  117050. get lightSources(): Light[];
  117051. /** @hidden */
  117052. get _positions(): Nullable<Vector3[]>;
  117053. /** @hidden */
  117054. _waitingData: {
  117055. lods: Nullable<any>;
  117056. actions: Nullable<any>;
  117057. freezeWorldMatrix: Nullable<boolean>;
  117058. };
  117059. /** @hidden */
  117060. _bonesTransformMatrices: Nullable<Float32Array>;
  117061. /** @hidden */
  117062. _transformMatrixTexture: Nullable<RawTexture>;
  117063. /**
  117064. * Gets or sets a skeleton to apply skining transformations
  117065. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  117066. */
  117067. set skeleton(value: Nullable<Skeleton>);
  117068. get skeleton(): Nullable<Skeleton>;
  117069. /**
  117070. * An event triggered when the mesh is rebuilt.
  117071. */
  117072. onRebuildObservable: Observable<AbstractMesh>;
  117073. /**
  117074. * Creates a new AbstractMesh
  117075. * @param name defines the name of the mesh
  117076. * @param scene defines the hosting scene
  117077. */
  117078. constructor(name: string, scene?: Nullable<Scene>);
  117079. /**
  117080. * Returns the string "AbstractMesh"
  117081. * @returns "AbstractMesh"
  117082. */
  117083. getClassName(): string;
  117084. /**
  117085. * Gets a string representation of the current mesh
  117086. * @param fullDetails defines a boolean indicating if full details must be included
  117087. * @returns a string representation of the current mesh
  117088. */
  117089. toString(fullDetails?: boolean): string;
  117090. /**
  117091. * @hidden
  117092. */
  117093. protected _getEffectiveParent(): Nullable<Node>;
  117094. /** @hidden */
  117095. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117096. /** @hidden */
  117097. _rebuild(): void;
  117098. /** @hidden */
  117099. _resyncLightSources(): void;
  117100. /** @hidden */
  117101. _resyncLightSource(light: Light): void;
  117102. /** @hidden */
  117103. _unBindEffect(): void;
  117104. /** @hidden */
  117105. _removeLightSource(light: Light, dispose: boolean): void;
  117106. private _markSubMeshesAsDirty;
  117107. /** @hidden */
  117108. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  117109. /** @hidden */
  117110. _markSubMeshesAsAttributesDirty(): void;
  117111. /** @hidden */
  117112. _markSubMeshesAsMiscDirty(): void;
  117113. /**
  117114. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  117115. */
  117116. get scaling(): Vector3;
  117117. set scaling(newScaling: Vector3);
  117118. /**
  117119. * Returns true if the mesh is blocked. Implemented by child classes
  117120. */
  117121. get isBlocked(): boolean;
  117122. /**
  117123. * Returns the mesh itself by default. Implemented by child classes
  117124. * @param camera defines the camera to use to pick the right LOD level
  117125. * @returns the currentAbstractMesh
  117126. */
  117127. getLOD(camera: Camera): Nullable<AbstractMesh>;
  117128. /**
  117129. * Returns 0 by default. Implemented by child classes
  117130. * @returns an integer
  117131. */
  117132. getTotalVertices(): number;
  117133. /**
  117134. * Returns a positive integer : the total number of indices in this mesh geometry.
  117135. * @returns the numner of indices or zero if the mesh has no geometry.
  117136. */
  117137. getTotalIndices(): number;
  117138. /**
  117139. * Returns null by default. Implemented by child classes
  117140. * @returns null
  117141. */
  117142. getIndices(): Nullable<IndicesArray>;
  117143. /**
  117144. * Returns the array of the requested vertex data kind. Implemented by child classes
  117145. * @param kind defines the vertex data kind to use
  117146. * @returns null
  117147. */
  117148. getVerticesData(kind: string): Nullable<FloatArray>;
  117149. /**
  117150. * Sets the vertex data of the mesh geometry for the requested `kind`.
  117151. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  117152. * Note that a new underlying VertexBuffer object is created each call.
  117153. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  117154. * @param kind defines vertex data kind:
  117155. * * VertexBuffer.PositionKind
  117156. * * VertexBuffer.UVKind
  117157. * * VertexBuffer.UV2Kind
  117158. * * VertexBuffer.UV3Kind
  117159. * * VertexBuffer.UV4Kind
  117160. * * VertexBuffer.UV5Kind
  117161. * * VertexBuffer.UV6Kind
  117162. * * VertexBuffer.ColorKind
  117163. * * VertexBuffer.MatricesIndicesKind
  117164. * * VertexBuffer.MatricesIndicesExtraKind
  117165. * * VertexBuffer.MatricesWeightsKind
  117166. * * VertexBuffer.MatricesWeightsExtraKind
  117167. * @param data defines the data source
  117168. * @param updatable defines if the data must be flagged as updatable (or static)
  117169. * @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
  117170. * @returns the current mesh
  117171. */
  117172. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117173. /**
  117174. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117175. * If the mesh has no geometry, it is simply returned as it is.
  117176. * @param kind defines vertex data kind:
  117177. * * VertexBuffer.PositionKind
  117178. * * VertexBuffer.UVKind
  117179. * * VertexBuffer.UV2Kind
  117180. * * VertexBuffer.UV3Kind
  117181. * * VertexBuffer.UV4Kind
  117182. * * VertexBuffer.UV5Kind
  117183. * * VertexBuffer.UV6Kind
  117184. * * VertexBuffer.ColorKind
  117185. * * VertexBuffer.MatricesIndicesKind
  117186. * * VertexBuffer.MatricesIndicesExtraKind
  117187. * * VertexBuffer.MatricesWeightsKind
  117188. * * VertexBuffer.MatricesWeightsExtraKind
  117189. * @param data defines the data source
  117190. * @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
  117191. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117192. * @returns the current mesh
  117193. */
  117194. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117195. /**
  117196. * Sets the mesh indices,
  117197. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117198. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117199. * @param totalVertices Defines the total number of vertices
  117200. * @returns the current mesh
  117201. */
  117202. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117203. /**
  117204. * Gets a boolean indicating if specific vertex data is present
  117205. * @param kind defines the vertex data kind to use
  117206. * @returns true is data kind is present
  117207. */
  117208. isVerticesDataPresent(kind: string): boolean;
  117209. /**
  117210. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117211. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117212. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117213. * @returns a BoundingInfo
  117214. */
  117215. getBoundingInfo(): BoundingInfo;
  117216. /**
  117217. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117218. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117219. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117220. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117221. * @returns the current mesh
  117222. */
  117223. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117224. /**
  117225. * Overwrite the current bounding info
  117226. * @param boundingInfo defines the new bounding info
  117227. * @returns the current mesh
  117228. */
  117229. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117230. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117231. get useBones(): boolean;
  117232. /** @hidden */
  117233. _preActivate(): void;
  117234. /** @hidden */
  117235. _preActivateForIntermediateRendering(renderId: number): void;
  117236. /** @hidden */
  117237. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117238. /** @hidden */
  117239. _postActivate(): void;
  117240. /** @hidden */
  117241. _freeze(): void;
  117242. /** @hidden */
  117243. _unFreeze(): void;
  117244. /**
  117245. * Gets the current world matrix
  117246. * @returns a Matrix
  117247. */
  117248. getWorldMatrix(): Matrix;
  117249. /** @hidden */
  117250. _getWorldMatrixDeterminant(): number;
  117251. /**
  117252. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117253. */
  117254. get isAnInstance(): boolean;
  117255. /**
  117256. * Gets a boolean indicating if this mesh has instances
  117257. */
  117258. get hasInstances(): boolean;
  117259. /**
  117260. * Gets a boolean indicating if this mesh has thin instances
  117261. */
  117262. get hasThinInstances(): boolean;
  117263. /**
  117264. * Perform relative position change from the point of view of behind the front of the mesh.
  117265. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117266. * Supports definition of mesh facing forward or backward
  117267. * @param amountRight defines the distance on the right axis
  117268. * @param amountUp defines the distance on the up axis
  117269. * @param amountForward defines the distance on the forward axis
  117270. * @returns the current mesh
  117271. */
  117272. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117273. /**
  117274. * Calculate relative position change from the point of view of behind the front of the mesh.
  117275. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117276. * Supports definition of mesh facing forward or backward
  117277. * @param amountRight defines the distance on the right axis
  117278. * @param amountUp defines the distance on the up axis
  117279. * @param amountForward defines the distance on the forward axis
  117280. * @returns the new displacement vector
  117281. */
  117282. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117283. /**
  117284. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117285. * Supports definition of mesh facing forward or backward
  117286. * @param flipBack defines the flip
  117287. * @param twirlClockwise defines the twirl
  117288. * @param tiltRight defines the tilt
  117289. * @returns the current mesh
  117290. */
  117291. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117292. /**
  117293. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117294. * Supports definition of mesh facing forward or backward.
  117295. * @param flipBack defines the flip
  117296. * @param twirlClockwise defines the twirl
  117297. * @param tiltRight defines the tilt
  117298. * @returns the new rotation vector
  117299. */
  117300. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117301. /**
  117302. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117303. * This means the mesh underlying bounding box and sphere are recomputed.
  117304. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117305. * @returns the current mesh
  117306. */
  117307. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117308. /** @hidden */
  117309. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117310. /** @hidden */
  117311. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117312. /** @hidden */
  117313. _updateBoundingInfo(): AbstractMesh;
  117314. /** @hidden */
  117315. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117316. /** @hidden */
  117317. protected _afterComputeWorldMatrix(): void;
  117318. /** @hidden */
  117319. get _effectiveMesh(): AbstractMesh;
  117320. /**
  117321. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117322. * A mesh is in the frustum if its bounding box intersects the frustum
  117323. * @param frustumPlanes defines the frustum to test
  117324. * @returns true if the mesh is in the frustum planes
  117325. */
  117326. isInFrustum(frustumPlanes: Plane[]): boolean;
  117327. /**
  117328. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117329. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117330. * @param frustumPlanes defines the frustum to test
  117331. * @returns true if the mesh is completely in the frustum planes
  117332. */
  117333. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117334. /**
  117335. * True if the mesh intersects another mesh or a SolidParticle object
  117336. * @param mesh defines a target mesh or SolidParticle to test
  117337. * @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)
  117338. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117339. * @returns true if there is an intersection
  117340. */
  117341. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117342. /**
  117343. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117344. * @param point defines the point to test
  117345. * @returns true if there is an intersection
  117346. */
  117347. intersectsPoint(point: Vector3): boolean;
  117348. /**
  117349. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117350. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117351. */
  117352. get checkCollisions(): boolean;
  117353. set checkCollisions(collisionEnabled: boolean);
  117354. /**
  117355. * Gets Collider object used to compute collisions (not physics)
  117356. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117357. */
  117358. get collider(): Nullable<Collider>;
  117359. /**
  117360. * Move the mesh using collision engine
  117361. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117362. * @param displacement defines the requested displacement vector
  117363. * @returns the current mesh
  117364. */
  117365. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117366. private _onCollisionPositionChange;
  117367. /** @hidden */
  117368. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117369. /** @hidden */
  117370. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117371. /** @hidden */
  117372. _checkCollision(collider: Collider): AbstractMesh;
  117373. /** @hidden */
  117374. _generatePointsArray(): boolean;
  117375. /**
  117376. * Checks if the passed Ray intersects with the mesh
  117377. * @param ray defines the ray to use
  117378. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117379. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117380. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117381. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117382. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  117383. * @returns the picking info
  117384. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117385. */
  117386. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  117387. /**
  117388. * Clones the current mesh
  117389. * @param name defines the mesh name
  117390. * @param newParent defines the new mesh parent
  117391. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117392. * @returns the new mesh
  117393. */
  117394. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117395. /**
  117396. * Disposes all the submeshes of the current meshnp
  117397. * @returns the current mesh
  117398. */
  117399. releaseSubMeshes(): AbstractMesh;
  117400. /**
  117401. * Releases resources associated with this abstract mesh.
  117402. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117403. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117404. */
  117405. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117406. /**
  117407. * Adds the passed mesh as a child to the current mesh
  117408. * @param mesh defines the child mesh
  117409. * @returns the current mesh
  117410. */
  117411. addChild(mesh: AbstractMesh): AbstractMesh;
  117412. /**
  117413. * Removes the passed mesh from the current mesh children list
  117414. * @param mesh defines the child mesh
  117415. * @returns the current mesh
  117416. */
  117417. removeChild(mesh: AbstractMesh): AbstractMesh;
  117418. /** @hidden */
  117419. private _initFacetData;
  117420. /**
  117421. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117422. * This method can be called within the render loop.
  117423. * 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
  117424. * @returns the current mesh
  117425. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117426. */
  117427. updateFacetData(): AbstractMesh;
  117428. /**
  117429. * Returns the facetLocalNormals array.
  117430. * The normals are expressed in the mesh local spac
  117431. * @returns an array of Vector3
  117432. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117433. */
  117434. getFacetLocalNormals(): Vector3[];
  117435. /**
  117436. * Returns the facetLocalPositions array.
  117437. * The facet positions are expressed in the mesh local space
  117438. * @returns an array of Vector3
  117439. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117440. */
  117441. getFacetLocalPositions(): Vector3[];
  117442. /**
  117443. * Returns the facetLocalPartioning array
  117444. * @returns an array of array of numbers
  117445. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117446. */
  117447. getFacetLocalPartitioning(): number[][];
  117448. /**
  117449. * Returns the i-th facet position in the world system.
  117450. * This method allocates a new Vector3 per call
  117451. * @param i defines the facet index
  117452. * @returns a new Vector3
  117453. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117454. */
  117455. getFacetPosition(i: number): Vector3;
  117456. /**
  117457. * Sets the reference Vector3 with the i-th facet position in the world system
  117458. * @param i defines the facet index
  117459. * @param ref defines the target vector
  117460. * @returns the current mesh
  117461. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117462. */
  117463. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117464. /**
  117465. * Returns the i-th facet normal in the world system.
  117466. * This method allocates a new Vector3 per call
  117467. * @param i defines the facet index
  117468. * @returns a new Vector3
  117469. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117470. */
  117471. getFacetNormal(i: number): Vector3;
  117472. /**
  117473. * Sets the reference Vector3 with the i-th facet normal in the world system
  117474. * @param i defines the facet index
  117475. * @param ref defines the target vector
  117476. * @returns the current mesh
  117477. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117478. */
  117479. getFacetNormalToRef(i: number, ref: Vector3): this;
  117480. /**
  117481. * 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)
  117482. * @param x defines x coordinate
  117483. * @param y defines y coordinate
  117484. * @param z defines z coordinate
  117485. * @returns the array of facet indexes
  117486. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117487. */
  117488. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117489. /**
  117490. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117491. * @param projected sets as the (x,y,z) world projection on the facet
  117492. * @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
  117493. * @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
  117494. * @param x defines x coordinate
  117495. * @param y defines y coordinate
  117496. * @param z defines z coordinate
  117497. * @returns the face index if found (or null instead)
  117498. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117499. */
  117500. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117501. /**
  117502. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117503. * @param projected sets as the (x,y,z) local projection on the facet
  117504. * @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
  117505. * @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
  117506. * @param x defines x coordinate
  117507. * @param y defines y coordinate
  117508. * @param z defines z coordinate
  117509. * @returns the face index if found (or null instead)
  117510. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117511. */
  117512. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117513. /**
  117514. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117515. * @returns the parameters
  117516. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117517. */
  117518. getFacetDataParameters(): any;
  117519. /**
  117520. * Disables the feature FacetData and frees the related memory
  117521. * @returns the current mesh
  117522. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117523. */
  117524. disableFacetData(): AbstractMesh;
  117525. /**
  117526. * Updates the AbstractMesh indices array
  117527. * @param indices defines the data source
  117528. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117529. * @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)
  117530. * @returns the current mesh
  117531. */
  117532. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117533. /**
  117534. * Creates new normals data for the mesh
  117535. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117536. * @returns the current mesh
  117537. */
  117538. createNormals(updatable: boolean): AbstractMesh;
  117539. /**
  117540. * Align the mesh with a normal
  117541. * @param normal defines the normal to use
  117542. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117543. * @returns the current mesh
  117544. */
  117545. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117546. /** @hidden */
  117547. _checkOcclusionQuery(): boolean;
  117548. /**
  117549. * Disables the mesh edge rendering mode
  117550. * @returns the currentAbstractMesh
  117551. */
  117552. disableEdgesRendering(): AbstractMesh;
  117553. /**
  117554. * Enables the edge rendering mode on the mesh.
  117555. * This mode makes the mesh edges visible
  117556. * @param epsilon defines the maximal distance between two angles to detect a face
  117557. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117558. * @param options options to the edge renderer
  117559. * @returns the currentAbstractMesh
  117560. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117561. */
  117562. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  117563. /**
  117564. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117565. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117566. */
  117567. getConnectedParticleSystems(): IParticleSystem[];
  117568. }
  117569. }
  117570. declare module BABYLON {
  117571. /**
  117572. * Interface used to define ActionEvent
  117573. */
  117574. export interface IActionEvent {
  117575. /** The mesh or sprite that triggered the action */
  117576. source: any;
  117577. /** The X mouse cursor position at the time of the event */
  117578. pointerX: number;
  117579. /** The Y mouse cursor position at the time of the event */
  117580. pointerY: number;
  117581. /** The mesh that is currently pointed at (can be null) */
  117582. meshUnderPointer: Nullable<AbstractMesh>;
  117583. /** the original (browser) event that triggered the ActionEvent */
  117584. sourceEvent?: any;
  117585. /** additional data for the event */
  117586. additionalData?: any;
  117587. }
  117588. /**
  117589. * ActionEvent is the event being sent when an action is triggered.
  117590. */
  117591. export class ActionEvent implements IActionEvent {
  117592. /** The mesh or sprite that triggered the action */
  117593. source: any;
  117594. /** The X mouse cursor position at the time of the event */
  117595. pointerX: number;
  117596. /** The Y mouse cursor position at the time of the event */
  117597. pointerY: number;
  117598. /** The mesh that is currently pointed at (can be null) */
  117599. meshUnderPointer: Nullable<AbstractMesh>;
  117600. /** the original (browser) event that triggered the ActionEvent */
  117601. sourceEvent?: any;
  117602. /** additional data for the event */
  117603. additionalData?: any;
  117604. /**
  117605. * Creates a new ActionEvent
  117606. * @param source The mesh or sprite that triggered the action
  117607. * @param pointerX The X mouse cursor position at the time of the event
  117608. * @param pointerY The Y mouse cursor position at the time of the event
  117609. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117610. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117611. * @param additionalData additional data for the event
  117612. */
  117613. constructor(
  117614. /** The mesh or sprite that triggered the action */
  117615. source: any,
  117616. /** The X mouse cursor position at the time of the event */
  117617. pointerX: number,
  117618. /** The Y mouse cursor position at the time of the event */
  117619. pointerY: number,
  117620. /** The mesh that is currently pointed at (can be null) */
  117621. meshUnderPointer: Nullable<AbstractMesh>,
  117622. /** the original (browser) event that triggered the ActionEvent */
  117623. sourceEvent?: any,
  117624. /** additional data for the event */
  117625. additionalData?: any);
  117626. /**
  117627. * Helper function to auto-create an ActionEvent from a source mesh.
  117628. * @param source The source mesh that triggered the event
  117629. * @param evt The original (browser) event
  117630. * @param additionalData additional data for the event
  117631. * @returns the new ActionEvent
  117632. */
  117633. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117634. /**
  117635. * Helper function to auto-create an ActionEvent from a source sprite
  117636. * @param source The source sprite that triggered the event
  117637. * @param scene Scene associated with the sprite
  117638. * @param evt The original (browser) event
  117639. * @param additionalData additional data for the event
  117640. * @returns the new ActionEvent
  117641. */
  117642. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117643. /**
  117644. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117645. * @param scene the scene where the event occurred
  117646. * @param evt The original (browser) event
  117647. * @returns the new ActionEvent
  117648. */
  117649. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117650. /**
  117651. * Helper function to auto-create an ActionEvent from a primitive
  117652. * @param prim defines the target primitive
  117653. * @param pointerPos defines the pointer position
  117654. * @param evt The original (browser) event
  117655. * @param additionalData additional data for the event
  117656. * @returns the new ActionEvent
  117657. */
  117658. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117659. }
  117660. }
  117661. declare module BABYLON {
  117662. /**
  117663. * Abstract class used to decouple action Manager from scene and meshes.
  117664. * Do not instantiate.
  117665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117666. */
  117667. export abstract class AbstractActionManager implements IDisposable {
  117668. /** Gets the list of active triggers */
  117669. static Triggers: {
  117670. [key: string]: number;
  117671. };
  117672. /** Gets the cursor to use when hovering items */
  117673. hoverCursor: string;
  117674. /** Gets the list of actions */
  117675. actions: IAction[];
  117676. /**
  117677. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117678. */
  117679. isRecursive: boolean;
  117680. /**
  117681. * Releases all associated resources
  117682. */
  117683. abstract dispose(): void;
  117684. /**
  117685. * Does this action manager has pointer triggers
  117686. */
  117687. abstract get hasPointerTriggers(): boolean;
  117688. /**
  117689. * Does this action manager has pick triggers
  117690. */
  117691. abstract get hasPickTriggers(): boolean;
  117692. /**
  117693. * Process a specific trigger
  117694. * @param trigger defines the trigger to process
  117695. * @param evt defines the event details to be processed
  117696. */
  117697. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117698. /**
  117699. * Does this action manager handles actions of any of the given triggers
  117700. * @param triggers defines the triggers to be tested
  117701. * @return a boolean indicating whether one (or more) of the triggers is handled
  117702. */
  117703. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117704. /**
  117705. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117706. * speed.
  117707. * @param triggerA defines the trigger to be tested
  117708. * @param triggerB defines the trigger to be tested
  117709. * @return a boolean indicating whether one (or more) of the triggers is handled
  117710. */
  117711. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117712. /**
  117713. * Does this action manager handles actions of a given trigger
  117714. * @param trigger defines the trigger to be tested
  117715. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117716. * @return whether the trigger is handled
  117717. */
  117718. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117719. /**
  117720. * Serialize this manager to a JSON object
  117721. * @param name defines the property name to store this manager
  117722. * @returns a JSON representation of this manager
  117723. */
  117724. abstract serialize(name: string): any;
  117725. /**
  117726. * Registers an action to this action manager
  117727. * @param action defines the action to be registered
  117728. * @return the action amended (prepared) after registration
  117729. */
  117730. abstract registerAction(action: IAction): Nullable<IAction>;
  117731. /**
  117732. * Unregisters an action to this action manager
  117733. * @param action defines the action to be unregistered
  117734. * @return a boolean indicating whether the action has been unregistered
  117735. */
  117736. abstract unregisterAction(action: IAction): Boolean;
  117737. /**
  117738. * Does exist one action manager with at least one trigger
  117739. **/
  117740. static get HasTriggers(): boolean;
  117741. /**
  117742. * Does exist one action manager with at least one pick trigger
  117743. **/
  117744. static get HasPickTriggers(): boolean;
  117745. /**
  117746. * Does exist one action manager that handles actions of a given trigger
  117747. * @param trigger defines the trigger to be tested
  117748. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117749. **/
  117750. static HasSpecificTrigger(trigger: number): boolean;
  117751. }
  117752. }
  117753. declare module BABYLON {
  117754. /**
  117755. * Defines how a node can be built from a string name.
  117756. */
  117757. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117758. /**
  117759. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117760. */
  117761. export class Node implements IBehaviorAware<Node> {
  117762. /** @hidden */
  117763. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117764. private static _NodeConstructors;
  117765. /**
  117766. * Add a new node constructor
  117767. * @param type defines the type name of the node to construct
  117768. * @param constructorFunc defines the constructor function
  117769. */
  117770. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117771. /**
  117772. * Returns a node constructor based on type name
  117773. * @param type defines the type name
  117774. * @param name defines the new node name
  117775. * @param scene defines the hosting scene
  117776. * @param options defines optional options to transmit to constructors
  117777. * @returns the new constructor or null
  117778. */
  117779. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117780. /**
  117781. * Gets or sets the name of the node
  117782. */
  117783. name: string;
  117784. /**
  117785. * Gets or sets the id of the node
  117786. */
  117787. id: string;
  117788. /**
  117789. * Gets or sets the unique id of the node
  117790. */
  117791. uniqueId: number;
  117792. /**
  117793. * Gets or sets a string used to store user defined state for the node
  117794. */
  117795. state: string;
  117796. /**
  117797. * Gets or sets an object used to store user defined information for the node
  117798. */
  117799. metadata: any;
  117800. /**
  117801. * For internal use only. Please do not use.
  117802. */
  117803. reservedDataStore: any;
  117804. /**
  117805. * List of inspectable custom properties (used by the Inspector)
  117806. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117807. */
  117808. inspectableCustomProperties: IInspectable[];
  117809. private _doNotSerialize;
  117810. /**
  117811. * Gets or sets a boolean used to define if the node must be serialized
  117812. */
  117813. get doNotSerialize(): boolean;
  117814. set doNotSerialize(value: boolean);
  117815. /** @hidden */
  117816. _isDisposed: boolean;
  117817. /**
  117818. * Gets a list of Animations associated with the node
  117819. */
  117820. animations: Animation[];
  117821. protected _ranges: {
  117822. [name: string]: Nullable<AnimationRange>;
  117823. };
  117824. /**
  117825. * Callback raised when the node is ready to be used
  117826. */
  117827. onReady: Nullable<(node: Node) => void>;
  117828. private _isEnabled;
  117829. private _isParentEnabled;
  117830. private _isReady;
  117831. /** @hidden */
  117832. _currentRenderId: number;
  117833. private _parentUpdateId;
  117834. /** @hidden */
  117835. _childUpdateId: number;
  117836. /** @hidden */
  117837. _waitingParentId: Nullable<string>;
  117838. /** @hidden */
  117839. _scene: Scene;
  117840. /** @hidden */
  117841. _cache: any;
  117842. private _parentNode;
  117843. private _children;
  117844. /** @hidden */
  117845. _worldMatrix: Matrix;
  117846. /** @hidden */
  117847. _worldMatrixDeterminant: number;
  117848. /** @hidden */
  117849. _worldMatrixDeterminantIsDirty: boolean;
  117850. /** @hidden */
  117851. private _sceneRootNodesIndex;
  117852. /**
  117853. * Gets a boolean indicating if the node has been disposed
  117854. * @returns true if the node was disposed
  117855. */
  117856. isDisposed(): boolean;
  117857. /**
  117858. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117859. * @see https://doc.babylonjs.com/how_to/parenting
  117860. */
  117861. set parent(parent: Nullable<Node>);
  117862. get parent(): Nullable<Node>;
  117863. /** @hidden */
  117864. _addToSceneRootNodes(): void;
  117865. /** @hidden */
  117866. _removeFromSceneRootNodes(): void;
  117867. private _animationPropertiesOverride;
  117868. /**
  117869. * Gets or sets the animation properties override
  117870. */
  117871. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117872. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117873. /**
  117874. * Gets a string identifying the name of the class
  117875. * @returns "Node" string
  117876. */
  117877. getClassName(): string;
  117878. /** @hidden */
  117879. readonly _isNode: boolean;
  117880. /**
  117881. * An event triggered when the mesh is disposed
  117882. */
  117883. onDisposeObservable: Observable<Node>;
  117884. private _onDisposeObserver;
  117885. /**
  117886. * Sets a callback that will be raised when the node will be disposed
  117887. */
  117888. set onDispose(callback: () => void);
  117889. /**
  117890. * Creates a new Node
  117891. * @param name the name and id to be given to this node
  117892. * @param scene the scene this node will be added to
  117893. */
  117894. constructor(name: string, scene?: Nullable<Scene>);
  117895. /**
  117896. * Gets the scene of the node
  117897. * @returns a scene
  117898. */
  117899. getScene(): Scene;
  117900. /**
  117901. * Gets the engine of the node
  117902. * @returns a Engine
  117903. */
  117904. getEngine(): Engine;
  117905. private _behaviors;
  117906. /**
  117907. * Attach a behavior to the node
  117908. * @see https://doc.babylonjs.com/features/behaviour
  117909. * @param behavior defines the behavior to attach
  117910. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117911. * @returns the current Node
  117912. */
  117913. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117914. /**
  117915. * Remove an attached behavior
  117916. * @see https://doc.babylonjs.com/features/behaviour
  117917. * @param behavior defines the behavior to attach
  117918. * @returns the current Node
  117919. */
  117920. removeBehavior(behavior: Behavior<Node>): Node;
  117921. /**
  117922. * Gets the list of attached behaviors
  117923. * @see https://doc.babylonjs.com/features/behaviour
  117924. */
  117925. get behaviors(): Behavior<Node>[];
  117926. /**
  117927. * Gets an attached behavior by name
  117928. * @param name defines the name of the behavior to look for
  117929. * @see https://doc.babylonjs.com/features/behaviour
  117930. * @returns null if behavior was not found else the requested behavior
  117931. */
  117932. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117933. /**
  117934. * Returns the latest update of the World matrix
  117935. * @returns a Matrix
  117936. */
  117937. getWorldMatrix(): Matrix;
  117938. /** @hidden */
  117939. _getWorldMatrixDeterminant(): number;
  117940. /**
  117941. * Returns directly the latest state of the mesh World matrix.
  117942. * A Matrix is returned.
  117943. */
  117944. get worldMatrixFromCache(): Matrix;
  117945. /** @hidden */
  117946. _initCache(): void;
  117947. /** @hidden */
  117948. updateCache(force?: boolean): void;
  117949. /** @hidden */
  117950. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117951. /** @hidden */
  117952. _updateCache(ignoreParentClass?: boolean): void;
  117953. /** @hidden */
  117954. _isSynchronized(): boolean;
  117955. /** @hidden */
  117956. _markSyncedWithParent(): void;
  117957. /** @hidden */
  117958. isSynchronizedWithParent(): boolean;
  117959. /** @hidden */
  117960. isSynchronized(): boolean;
  117961. /**
  117962. * Is this node ready to be used/rendered
  117963. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117964. * @return true if the node is ready
  117965. */
  117966. isReady(completeCheck?: boolean): boolean;
  117967. /**
  117968. * Is this node enabled?
  117969. * 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
  117970. * @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
  117971. * @return whether this node (and its parent) is enabled
  117972. */
  117973. isEnabled(checkAncestors?: boolean): boolean;
  117974. /** @hidden */
  117975. protected _syncParentEnabledState(): void;
  117976. /**
  117977. * Set the enabled state of this node
  117978. * @param value defines the new enabled state
  117979. */
  117980. setEnabled(value: boolean): void;
  117981. /**
  117982. * Is this node a descendant of the given node?
  117983. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117984. * @param ancestor defines the parent node to inspect
  117985. * @returns a boolean indicating if this node is a descendant of the given node
  117986. */
  117987. isDescendantOf(ancestor: Node): boolean;
  117988. /** @hidden */
  117989. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117990. /**
  117991. * Will return all nodes that have this node as ascendant
  117992. * @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
  117993. * @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
  117994. * @return all children nodes of all types
  117995. */
  117996. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117997. /**
  117998. * Get all child-meshes of this node
  117999. * @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)
  118000. * @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
  118001. * @returns an array of AbstractMesh
  118002. */
  118003. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  118004. /**
  118005. * Get all direct children of this node
  118006. * @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
  118007. * @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)
  118008. * @returns an array of Node
  118009. */
  118010. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  118011. /** @hidden */
  118012. _setReady(state: boolean): void;
  118013. /**
  118014. * Get an animation by name
  118015. * @param name defines the name of the animation to look for
  118016. * @returns null if not found else the requested animation
  118017. */
  118018. getAnimationByName(name: string): Nullable<Animation>;
  118019. /**
  118020. * Creates an animation range for this node
  118021. * @param name defines the name of the range
  118022. * @param from defines the starting key
  118023. * @param to defines the end key
  118024. */
  118025. createAnimationRange(name: string, from: number, to: number): void;
  118026. /**
  118027. * Delete a specific animation range
  118028. * @param name defines the name of the range to delete
  118029. * @param deleteFrames defines if animation frames from the range must be deleted as well
  118030. */
  118031. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  118032. /**
  118033. * Get an animation range by name
  118034. * @param name defines the name of the animation range to look for
  118035. * @returns null if not found else the requested animation range
  118036. */
  118037. getAnimationRange(name: string): Nullable<AnimationRange>;
  118038. /**
  118039. * Gets the list of all animation ranges defined on this node
  118040. * @returns an array
  118041. */
  118042. getAnimationRanges(): Nullable<AnimationRange>[];
  118043. /**
  118044. * Will start the animation sequence
  118045. * @param name defines the range frames for animation sequence
  118046. * @param loop defines if the animation should loop (false by default)
  118047. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  118048. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  118049. * @returns the object created for this animation. If range does not exist, it will return null
  118050. */
  118051. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  118052. /**
  118053. * Serialize animation ranges into a JSON compatible object
  118054. * @returns serialization object
  118055. */
  118056. serializeAnimationRanges(): any;
  118057. /**
  118058. * Computes the world matrix of the node
  118059. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  118060. * @returns the world matrix
  118061. */
  118062. computeWorldMatrix(force?: boolean): Matrix;
  118063. /**
  118064. * Releases resources associated with this node.
  118065. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  118066. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  118067. */
  118068. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  118069. /**
  118070. * Parse animation range data from a serialization object and store them into a given node
  118071. * @param node defines where to store the animation ranges
  118072. * @param parsedNode defines the serialization object to read data from
  118073. * @param scene defines the hosting scene
  118074. */
  118075. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  118076. /**
  118077. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  118078. * @param includeDescendants Include bounding info from descendants as well (true by default)
  118079. * @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
  118080. * @returns the new bounding vectors
  118081. */
  118082. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  118083. min: Vector3;
  118084. max: Vector3;
  118085. };
  118086. }
  118087. }
  118088. declare module BABYLON {
  118089. /**
  118090. * @hidden
  118091. */
  118092. export class _IAnimationState {
  118093. key: number;
  118094. repeatCount: number;
  118095. workValue?: any;
  118096. loopMode?: number;
  118097. offsetValue?: any;
  118098. highLimitValue?: any;
  118099. }
  118100. /**
  118101. * Class used to store any kind of animation
  118102. */
  118103. export class Animation {
  118104. /**Name of the animation */
  118105. name: string;
  118106. /**Property to animate */
  118107. targetProperty: string;
  118108. /**The frames per second of the animation */
  118109. framePerSecond: number;
  118110. /**The data type of the animation */
  118111. dataType: number;
  118112. /**The loop mode of the animation */
  118113. loopMode?: number | undefined;
  118114. /**Specifies if blending should be enabled */
  118115. enableBlending?: boolean | undefined;
  118116. /**
  118117. * Use matrix interpolation instead of using direct key value when animating matrices
  118118. */
  118119. static AllowMatricesInterpolation: boolean;
  118120. /**
  118121. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  118122. */
  118123. static AllowMatrixDecomposeForInterpolation: boolean;
  118124. /** Define the Url to load snippets */
  118125. static SnippetUrl: string;
  118126. /** Snippet ID if the animation was created from the snippet server */
  118127. snippetId: string;
  118128. /**
  118129. * Stores the key frames of the animation
  118130. */
  118131. private _keys;
  118132. /**
  118133. * Stores the easing function of the animation
  118134. */
  118135. private _easingFunction;
  118136. /**
  118137. * @hidden Internal use only
  118138. */
  118139. _runtimeAnimations: RuntimeAnimation[];
  118140. /**
  118141. * The set of event that will be linked to this animation
  118142. */
  118143. private _events;
  118144. /**
  118145. * Stores an array of target property paths
  118146. */
  118147. targetPropertyPath: string[];
  118148. /**
  118149. * Stores the blending speed of the animation
  118150. */
  118151. blendingSpeed: number;
  118152. /**
  118153. * Stores the animation ranges for the animation
  118154. */
  118155. private _ranges;
  118156. /**
  118157. * @hidden Internal use
  118158. */
  118159. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  118160. /**
  118161. * Sets up an animation
  118162. * @param property The property to animate
  118163. * @param animationType The animation type to apply
  118164. * @param framePerSecond The frames per second of the animation
  118165. * @param easingFunction The easing function used in the animation
  118166. * @returns The created animation
  118167. */
  118168. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  118169. /**
  118170. * Create and start an animation on a node
  118171. * @param name defines the name of the global animation that will be run on all nodes
  118172. * @param node defines the root node where the animation will take place
  118173. * @param targetProperty defines property to animate
  118174. * @param framePerSecond defines the number of frame per second yo use
  118175. * @param totalFrame defines the number of frames in total
  118176. * @param from defines the initial value
  118177. * @param to defines the final value
  118178. * @param loopMode defines which loop mode you want to use (off by default)
  118179. * @param easingFunction defines the easing function to use (linear by default)
  118180. * @param onAnimationEnd defines the callback to call when animation end
  118181. * @returns the animatable created for this animation
  118182. */
  118183. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118184. /**
  118185. * Create and start an animation on a node and its descendants
  118186. * @param name defines the name of the global animation that will be run on all nodes
  118187. * @param node defines the root node where the animation will take place
  118188. * @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
  118189. * @param targetProperty defines property to animate
  118190. * @param framePerSecond defines the number of frame per second to use
  118191. * @param totalFrame defines the number of frames in total
  118192. * @param from defines the initial value
  118193. * @param to defines the final value
  118194. * @param loopMode defines which loop mode you want to use (off by default)
  118195. * @param easingFunction defines the easing function to use (linear by default)
  118196. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118197. * @returns the list of animatables created for all nodes
  118198. * @example https://www.babylonjs-playground.com/#MH0VLI
  118199. */
  118200. 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[]>;
  118201. /**
  118202. * Creates a new animation, merges it with the existing animations and starts it
  118203. * @param name Name of the animation
  118204. * @param node Node which contains the scene that begins the animations
  118205. * @param targetProperty Specifies which property to animate
  118206. * @param framePerSecond The frames per second of the animation
  118207. * @param totalFrame The total number of frames
  118208. * @param from The frame at the beginning of the animation
  118209. * @param to The frame at the end of the animation
  118210. * @param loopMode Specifies the loop mode of the animation
  118211. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118212. * @param onAnimationEnd Callback to run once the animation is complete
  118213. * @returns Nullable animation
  118214. */
  118215. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118216. /**
  118217. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118218. * @param sourceAnimation defines the Animation containing keyframes to convert
  118219. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118220. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118221. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118222. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118223. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118224. */
  118225. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118226. /**
  118227. * Transition property of an host to the target Value
  118228. * @param property The property to transition
  118229. * @param targetValue The target Value of the property
  118230. * @param host The object where the property to animate belongs
  118231. * @param scene Scene used to run the animation
  118232. * @param frameRate Framerate (in frame/s) to use
  118233. * @param transition The transition type we want to use
  118234. * @param duration The duration of the animation, in milliseconds
  118235. * @param onAnimationEnd Callback trigger at the end of the animation
  118236. * @returns Nullable animation
  118237. */
  118238. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118239. /**
  118240. * Return the array of runtime animations currently using this animation
  118241. */
  118242. get runtimeAnimations(): RuntimeAnimation[];
  118243. /**
  118244. * Specifies if any of the runtime animations are currently running
  118245. */
  118246. get hasRunningRuntimeAnimations(): boolean;
  118247. /**
  118248. * Initializes the animation
  118249. * @param name Name of the animation
  118250. * @param targetProperty Property to animate
  118251. * @param framePerSecond The frames per second of the animation
  118252. * @param dataType The data type of the animation
  118253. * @param loopMode The loop mode of the animation
  118254. * @param enableBlending Specifies if blending should be enabled
  118255. */
  118256. constructor(
  118257. /**Name of the animation */
  118258. name: string,
  118259. /**Property to animate */
  118260. targetProperty: string,
  118261. /**The frames per second of the animation */
  118262. framePerSecond: number,
  118263. /**The data type of the animation */
  118264. dataType: number,
  118265. /**The loop mode of the animation */
  118266. loopMode?: number | undefined,
  118267. /**Specifies if blending should be enabled */
  118268. enableBlending?: boolean | undefined);
  118269. /**
  118270. * Converts the animation to a string
  118271. * @param fullDetails support for multiple levels of logging within scene loading
  118272. * @returns String form of the animation
  118273. */
  118274. toString(fullDetails?: boolean): string;
  118275. /**
  118276. * Add an event to this animation
  118277. * @param event Event to add
  118278. */
  118279. addEvent(event: AnimationEvent): void;
  118280. /**
  118281. * Remove all events found at the given frame
  118282. * @param frame The frame to remove events from
  118283. */
  118284. removeEvents(frame: number): void;
  118285. /**
  118286. * Retrieves all the events from the animation
  118287. * @returns Events from the animation
  118288. */
  118289. getEvents(): AnimationEvent[];
  118290. /**
  118291. * Creates an animation range
  118292. * @param name Name of the animation range
  118293. * @param from Starting frame of the animation range
  118294. * @param to Ending frame of the animation
  118295. */
  118296. createRange(name: string, from: number, to: number): void;
  118297. /**
  118298. * Deletes an animation range by name
  118299. * @param name Name of the animation range to delete
  118300. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118301. */
  118302. deleteRange(name: string, deleteFrames?: boolean): void;
  118303. /**
  118304. * Gets the animation range by name, or null if not defined
  118305. * @param name Name of the animation range
  118306. * @returns Nullable animation range
  118307. */
  118308. getRange(name: string): Nullable<AnimationRange>;
  118309. /**
  118310. * Gets the key frames from the animation
  118311. * @returns The key frames of the animation
  118312. */
  118313. getKeys(): Array<IAnimationKey>;
  118314. /**
  118315. * Gets the highest frame rate of the animation
  118316. * @returns Highest frame rate of the animation
  118317. */
  118318. getHighestFrame(): number;
  118319. /**
  118320. * Gets the easing function of the animation
  118321. * @returns Easing function of the animation
  118322. */
  118323. getEasingFunction(): IEasingFunction;
  118324. /**
  118325. * Sets the easing function of the animation
  118326. * @param easingFunction A custom mathematical formula for animation
  118327. */
  118328. setEasingFunction(easingFunction: EasingFunction): void;
  118329. /**
  118330. * Interpolates a scalar linearly
  118331. * @param startValue Start value of the animation curve
  118332. * @param endValue End value of the animation curve
  118333. * @param gradient Scalar amount to interpolate
  118334. * @returns Interpolated scalar value
  118335. */
  118336. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118337. /**
  118338. * Interpolates a scalar cubically
  118339. * @param startValue Start value of the animation curve
  118340. * @param outTangent End tangent of the animation
  118341. * @param endValue End value of the animation curve
  118342. * @param inTangent Start tangent of the animation curve
  118343. * @param gradient Scalar amount to interpolate
  118344. * @returns Interpolated scalar value
  118345. */
  118346. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118347. /**
  118348. * Interpolates a quaternion using a spherical linear interpolation
  118349. * @param startValue Start value of the animation curve
  118350. * @param endValue End value of the animation curve
  118351. * @param gradient Scalar amount to interpolate
  118352. * @returns Interpolated quaternion value
  118353. */
  118354. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118355. /**
  118356. * Interpolates a quaternion cubically
  118357. * @param startValue Start value of the animation curve
  118358. * @param outTangent End tangent of the animation curve
  118359. * @param endValue End value of the animation curve
  118360. * @param inTangent Start tangent of the animation curve
  118361. * @param gradient Scalar amount to interpolate
  118362. * @returns Interpolated quaternion value
  118363. */
  118364. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118365. /**
  118366. * Interpolates a Vector3 linearl
  118367. * @param startValue Start value of the animation curve
  118368. * @param endValue End value of the animation curve
  118369. * @param gradient Scalar amount to interpolate
  118370. * @returns Interpolated scalar value
  118371. */
  118372. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118373. /**
  118374. * Interpolates a Vector3 cubically
  118375. * @param startValue Start value of the animation curve
  118376. * @param outTangent End tangent of the animation
  118377. * @param endValue End value of the animation curve
  118378. * @param inTangent Start tangent of the animation curve
  118379. * @param gradient Scalar amount to interpolate
  118380. * @returns InterpolatedVector3 value
  118381. */
  118382. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118383. /**
  118384. * Interpolates a Vector2 linearly
  118385. * @param startValue Start value of the animation curve
  118386. * @param endValue End value of the animation curve
  118387. * @param gradient Scalar amount to interpolate
  118388. * @returns Interpolated Vector2 value
  118389. */
  118390. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118391. /**
  118392. * Interpolates a Vector2 cubically
  118393. * @param startValue Start value of the animation curve
  118394. * @param outTangent End tangent of the animation
  118395. * @param endValue End value of the animation curve
  118396. * @param inTangent Start tangent of the animation curve
  118397. * @param gradient Scalar amount to interpolate
  118398. * @returns Interpolated Vector2 value
  118399. */
  118400. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118401. /**
  118402. * Interpolates a size linearly
  118403. * @param startValue Start value of the animation curve
  118404. * @param endValue End value of the animation curve
  118405. * @param gradient Scalar amount to interpolate
  118406. * @returns Interpolated Size value
  118407. */
  118408. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118409. /**
  118410. * Interpolates a Color3 linearly
  118411. * @param startValue Start value of the animation curve
  118412. * @param endValue End value of the animation curve
  118413. * @param gradient Scalar amount to interpolate
  118414. * @returns Interpolated Color3 value
  118415. */
  118416. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118417. /**
  118418. * Interpolates a Color4 linearly
  118419. * @param startValue Start value of the animation curve
  118420. * @param endValue End value of the animation curve
  118421. * @param gradient Scalar amount to interpolate
  118422. * @returns Interpolated Color3 value
  118423. */
  118424. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118425. /**
  118426. * @hidden Internal use only
  118427. */
  118428. _getKeyValue(value: any): any;
  118429. /**
  118430. * @hidden Internal use only
  118431. */
  118432. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118433. /**
  118434. * Defines the function to use to interpolate matrices
  118435. * @param startValue defines the start matrix
  118436. * @param endValue defines the end matrix
  118437. * @param gradient defines the gradient between both matrices
  118438. * @param result defines an optional target matrix where to store the interpolation
  118439. * @returns the interpolated matrix
  118440. */
  118441. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118442. /**
  118443. * Makes a copy of the animation
  118444. * @returns Cloned animation
  118445. */
  118446. clone(): Animation;
  118447. /**
  118448. * Sets the key frames of the animation
  118449. * @param values The animation key frames to set
  118450. */
  118451. setKeys(values: Array<IAnimationKey>): void;
  118452. /**
  118453. * Serializes the animation to an object
  118454. * @returns Serialized object
  118455. */
  118456. serialize(): any;
  118457. /**
  118458. * Float animation type
  118459. */
  118460. static readonly ANIMATIONTYPE_FLOAT: number;
  118461. /**
  118462. * Vector3 animation type
  118463. */
  118464. static readonly ANIMATIONTYPE_VECTOR3: number;
  118465. /**
  118466. * Quaternion animation type
  118467. */
  118468. static readonly ANIMATIONTYPE_QUATERNION: number;
  118469. /**
  118470. * Matrix animation type
  118471. */
  118472. static readonly ANIMATIONTYPE_MATRIX: number;
  118473. /**
  118474. * Color3 animation type
  118475. */
  118476. static readonly ANIMATIONTYPE_COLOR3: number;
  118477. /**
  118478. * Color3 animation type
  118479. */
  118480. static readonly ANIMATIONTYPE_COLOR4: number;
  118481. /**
  118482. * Vector2 animation type
  118483. */
  118484. static readonly ANIMATIONTYPE_VECTOR2: number;
  118485. /**
  118486. * Size animation type
  118487. */
  118488. static readonly ANIMATIONTYPE_SIZE: number;
  118489. /**
  118490. * Relative Loop Mode
  118491. */
  118492. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118493. /**
  118494. * Cycle Loop Mode
  118495. */
  118496. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118497. /**
  118498. * Constant Loop Mode
  118499. */
  118500. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118501. /** @hidden */
  118502. static _UniversalLerp(left: any, right: any, amount: number): any;
  118503. /**
  118504. * Parses an animation object and creates an animation
  118505. * @param parsedAnimation Parsed animation object
  118506. * @returns Animation object
  118507. */
  118508. static Parse(parsedAnimation: any): Animation;
  118509. /**
  118510. * Appends the serialized animations from the source animations
  118511. * @param source Source containing the animations
  118512. * @param destination Target to store the animations
  118513. */
  118514. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118515. /**
  118516. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118517. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118518. * @param url defines the url to load from
  118519. * @returns a promise that will resolve to the new animation or an array of animations
  118520. */
  118521. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118522. /**
  118523. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118524. * @param snippetId defines the snippet to load
  118525. * @returns a promise that will resolve to the new animation or a new array of animations
  118526. */
  118527. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118528. }
  118529. }
  118530. declare module BABYLON {
  118531. /**
  118532. * Interface containing an array of animations
  118533. */
  118534. export interface IAnimatable {
  118535. /**
  118536. * Array of animations
  118537. */
  118538. animations: Nullable<Array<Animation>>;
  118539. }
  118540. }
  118541. declare module BABYLON {
  118542. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118543. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118544. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118545. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118546. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118547. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118548. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118549. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118550. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118551. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118552. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118553. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118554. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118555. /**
  118556. * Decorator used to define property that can be serialized as reference to a camera
  118557. * @param sourceName defines the name of the property to decorate
  118558. */
  118559. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118560. /**
  118561. * Class used to help serialization objects
  118562. */
  118563. export class SerializationHelper {
  118564. /** @hidden */
  118565. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118566. /** @hidden */
  118567. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118568. /** @hidden */
  118569. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118570. /** @hidden */
  118571. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118572. /**
  118573. * Appends the serialized animations from the source animations
  118574. * @param source Source containing the animations
  118575. * @param destination Target to store the animations
  118576. */
  118577. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118578. /**
  118579. * Static function used to serialized a specific entity
  118580. * @param entity defines the entity to serialize
  118581. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118582. * @returns a JSON compatible object representing the serialization of the entity
  118583. */
  118584. static Serialize<T>(entity: T, serializationObject?: any): any;
  118585. /**
  118586. * Creates a new entity from a serialization data object
  118587. * @param creationFunction defines a function used to instanciated the new entity
  118588. * @param source defines the source serialization data
  118589. * @param scene defines the hosting scene
  118590. * @param rootUrl defines the root url for resources
  118591. * @returns a new entity
  118592. */
  118593. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118594. /**
  118595. * Clones an object
  118596. * @param creationFunction defines the function used to instanciate the new object
  118597. * @param source defines the source object
  118598. * @returns the cloned object
  118599. */
  118600. static Clone<T>(creationFunction: () => T, source: T): T;
  118601. /**
  118602. * Instanciates a new object based on a source one (some data will be shared between both object)
  118603. * @param creationFunction defines the function used to instanciate the new object
  118604. * @param source defines the source object
  118605. * @returns the new object
  118606. */
  118607. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118608. }
  118609. }
  118610. declare module BABYLON {
  118611. /**
  118612. * This is the base class of all the camera used in the application.
  118613. * @see https://doc.babylonjs.com/features/cameras
  118614. */
  118615. export class Camera extends Node {
  118616. /** @hidden */
  118617. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  118618. /**
  118619. * This is the default projection mode used by the cameras.
  118620. * It helps recreating a feeling of perspective and better appreciate depth.
  118621. * This is the best way to simulate real life cameras.
  118622. */
  118623. static readonly PERSPECTIVE_CAMERA: number;
  118624. /**
  118625. * This helps creating camera with an orthographic mode.
  118626. * 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.
  118627. */
  118628. static readonly ORTHOGRAPHIC_CAMERA: number;
  118629. /**
  118630. * This is the default FOV mode for perspective cameras.
  118631. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  118632. */
  118633. static readonly FOVMODE_VERTICAL_FIXED: number;
  118634. /**
  118635. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  118636. */
  118637. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  118638. /**
  118639. * This specifies ther is no need for a camera rig.
  118640. * Basically only one eye is rendered corresponding to the camera.
  118641. */
  118642. static readonly RIG_MODE_NONE: number;
  118643. /**
  118644. * Simulates a camera Rig with one blue eye and one red eye.
  118645. * This can be use with 3d blue and red glasses.
  118646. */
  118647. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  118648. /**
  118649. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  118650. */
  118651. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  118652. /**
  118653. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  118654. */
  118655. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  118656. /**
  118657. * Defines that both eyes of the camera will be rendered over under each other.
  118658. */
  118659. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  118660. /**
  118661. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  118662. */
  118663. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  118664. /**
  118665. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  118666. */
  118667. static readonly RIG_MODE_VR: number;
  118668. /**
  118669. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  118670. */
  118671. static readonly RIG_MODE_WEBVR: number;
  118672. /**
  118673. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  118674. */
  118675. static readonly RIG_MODE_CUSTOM: number;
  118676. /**
  118677. * Defines if by default attaching controls should prevent the default javascript event to continue.
  118678. */
  118679. static ForceAttachControlToAlwaysPreventDefault: boolean;
  118680. /**
  118681. * Define the input manager associated with the camera.
  118682. */
  118683. inputs: CameraInputsManager<Camera>;
  118684. /** @hidden */
  118685. _position: Vector3;
  118686. /**
  118687. * Define the current local position of the camera in the scene
  118688. */
  118689. get position(): Vector3;
  118690. set position(newPosition: Vector3);
  118691. protected _upVector: Vector3;
  118692. /**
  118693. * The vector the camera should consider as up.
  118694. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  118695. */
  118696. set upVector(vec: Vector3);
  118697. get upVector(): Vector3;
  118698. /**
  118699. * Define the current limit on the left side for an orthographic camera
  118700. * In scene unit
  118701. */
  118702. orthoLeft: Nullable<number>;
  118703. /**
  118704. * Define the current limit on the right side for an orthographic camera
  118705. * In scene unit
  118706. */
  118707. orthoRight: Nullable<number>;
  118708. /**
  118709. * Define the current limit on the bottom side for an orthographic camera
  118710. * In scene unit
  118711. */
  118712. orthoBottom: Nullable<number>;
  118713. /**
  118714. * Define the current limit on the top side for an orthographic camera
  118715. * In scene unit
  118716. */
  118717. orthoTop: Nullable<number>;
  118718. /**
  118719. * Field Of View is set in Radians. (default is 0.8)
  118720. */
  118721. fov: number;
  118722. /**
  118723. * Define the minimum distance the camera can see from.
  118724. * This is important to note that the depth buffer are not infinite and the closer it starts
  118725. * the more your scene might encounter depth fighting issue.
  118726. */
  118727. minZ: number;
  118728. /**
  118729. * Define the maximum distance the camera can see to.
  118730. * This is important to note that the depth buffer are not infinite and the further it end
  118731. * the more your scene might encounter depth fighting issue.
  118732. */
  118733. maxZ: number;
  118734. /**
  118735. * Define the default inertia of the camera.
  118736. * This helps giving a smooth feeling to the camera movement.
  118737. */
  118738. inertia: number;
  118739. /**
  118740. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  118741. */
  118742. mode: number;
  118743. /**
  118744. * Define whether the camera is intermediate.
  118745. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  118746. */
  118747. isIntermediate: boolean;
  118748. /**
  118749. * Define the viewport of the camera.
  118750. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  118751. */
  118752. viewport: Viewport;
  118753. /**
  118754. * Restricts the camera to viewing objects with the same layerMask.
  118755. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  118756. */
  118757. layerMask: number;
  118758. /**
  118759. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  118760. */
  118761. fovMode: number;
  118762. /**
  118763. * Rig mode of the camera.
  118764. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  118765. * This is normally controlled byt the camera themselves as internal use.
  118766. */
  118767. cameraRigMode: number;
  118768. /**
  118769. * Defines the distance between both "eyes" in case of a RIG
  118770. */
  118771. interaxialDistance: number;
  118772. /**
  118773. * Defines if stereoscopic rendering is done side by side or over under.
  118774. */
  118775. isStereoscopicSideBySide: boolean;
  118776. /**
  118777. * 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
  118778. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  118779. * else in the scene. (Eg. security camera)
  118780. *
  118781. * 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)
  118782. */
  118783. customRenderTargets: RenderTargetTexture[];
  118784. /**
  118785. * When set, the camera will render to this render target instead of the default canvas
  118786. *
  118787. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  118788. */
  118789. outputRenderTarget: Nullable<RenderTargetTexture>;
  118790. /**
  118791. * Observable triggered when the camera view matrix has changed.
  118792. */
  118793. onViewMatrixChangedObservable: Observable<Camera>;
  118794. /**
  118795. * Observable triggered when the camera Projection matrix has changed.
  118796. */
  118797. onProjectionMatrixChangedObservable: Observable<Camera>;
  118798. /**
  118799. * Observable triggered when the inputs have been processed.
  118800. */
  118801. onAfterCheckInputsObservable: Observable<Camera>;
  118802. /**
  118803. * Observable triggered when reset has been called and applied to the camera.
  118804. */
  118805. onRestoreStateObservable: Observable<Camera>;
  118806. /**
  118807. * Is this camera a part of a rig system?
  118808. */
  118809. isRigCamera: boolean;
  118810. /**
  118811. * If isRigCamera set to true this will be set with the parent camera.
  118812. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  118813. */
  118814. rigParent?: Camera;
  118815. /** @hidden */
  118816. _cameraRigParams: any;
  118817. /** @hidden */
  118818. _rigCameras: Camera[];
  118819. /** @hidden */
  118820. _rigPostProcess: Nullable<PostProcess>;
  118821. protected _webvrViewMatrix: Matrix;
  118822. /** @hidden */
  118823. _skipRendering: boolean;
  118824. /** @hidden */
  118825. _projectionMatrix: Matrix;
  118826. /** @hidden */
  118827. _postProcesses: Nullable<PostProcess>[];
  118828. /** @hidden */
  118829. _activeMeshes: SmartArray<AbstractMesh>;
  118830. protected _globalPosition: Vector3;
  118831. /** @hidden */
  118832. _computedViewMatrix: Matrix;
  118833. private _doNotComputeProjectionMatrix;
  118834. private _transformMatrix;
  118835. private _frustumPlanes;
  118836. private _refreshFrustumPlanes;
  118837. private _storedFov;
  118838. private _stateStored;
  118839. /**
  118840. * Instantiates a new camera object.
  118841. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  118842. * @see https://doc.babylonjs.com/features/cameras
  118843. * @param name Defines the name of the camera in the scene
  118844. * @param position Defines the position of the camera
  118845. * @param scene Defines the scene the camera belongs too
  118846. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  118847. */
  118848. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  118849. /**
  118850. * Store current camera state (fov, position, etc..)
  118851. * @returns the camera
  118852. */
  118853. storeState(): Camera;
  118854. /**
  118855. * Restores the camera state values if it has been stored. You must call storeState() first
  118856. */
  118857. protected _restoreStateValues(): boolean;
  118858. /**
  118859. * Restored camera state. You must call storeState() first.
  118860. * @returns true if restored and false otherwise
  118861. */
  118862. restoreState(): boolean;
  118863. /**
  118864. * Gets the class name of the camera.
  118865. * @returns the class name
  118866. */
  118867. getClassName(): string;
  118868. /** @hidden */
  118869. readonly _isCamera: boolean;
  118870. /**
  118871. * Gets a string representation of the camera useful for debug purpose.
  118872. * @param fullDetails Defines that a more verboe level of logging is required
  118873. * @returns the string representation
  118874. */
  118875. toString(fullDetails?: boolean): string;
  118876. /**
  118877. * Gets the current world space position of the camera.
  118878. */
  118879. get globalPosition(): Vector3;
  118880. /**
  118881. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  118882. * @returns the active meshe list
  118883. */
  118884. getActiveMeshes(): SmartArray<AbstractMesh>;
  118885. /**
  118886. * Check whether a mesh is part of the current active mesh list of the camera
  118887. * @param mesh Defines the mesh to check
  118888. * @returns true if active, false otherwise
  118889. */
  118890. isActiveMesh(mesh: Mesh): boolean;
  118891. /**
  118892. * Is this camera ready to be used/rendered
  118893. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  118894. * @return true if the camera is ready
  118895. */
  118896. isReady(completeCheck?: boolean): boolean;
  118897. /** @hidden */
  118898. _initCache(): void;
  118899. /** @hidden */
  118900. _updateCache(ignoreParentClass?: boolean): void;
  118901. /** @hidden */
  118902. _isSynchronized(): boolean;
  118903. /** @hidden */
  118904. _isSynchronizedViewMatrix(): boolean;
  118905. /** @hidden */
  118906. _isSynchronizedProjectionMatrix(): boolean;
  118907. /**
  118908. * Attach the input controls to a specific dom element to get the input from.
  118909. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118910. */
  118911. attachControl(noPreventDefault?: boolean): void;
  118912. /**
  118913. * Attach the input controls to a specific dom element to get the input from.
  118914. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118915. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  118916. * BACK COMPAT SIGNATURE ONLY.
  118917. */
  118918. attachControl(ignored: any, noPreventDefault?: boolean): void;
  118919. /**
  118920. * Detach the current controls from the specified dom element.
  118921. */
  118922. detachControl(): void;
  118923. /**
  118924. * Detach the current controls from the specified dom element.
  118925. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  118926. */
  118927. detachControl(ignored: any): void;
  118928. /**
  118929. * Update the camera state according to the different inputs gathered during the frame.
  118930. */
  118931. update(): void;
  118932. /** @hidden */
  118933. _checkInputs(): void;
  118934. /** @hidden */
  118935. get rigCameras(): Camera[];
  118936. /**
  118937. * Gets the post process used by the rig cameras
  118938. */
  118939. get rigPostProcess(): Nullable<PostProcess>;
  118940. /**
  118941. * Internal, gets the first post proces.
  118942. * @returns the first post process to be run on this camera.
  118943. */
  118944. _getFirstPostProcess(): Nullable<PostProcess>;
  118945. private _cascadePostProcessesToRigCams;
  118946. /**
  118947. * Attach a post process to the camera.
  118948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118949. * @param postProcess The post process to attach to the camera
  118950. * @param insertAt The position of the post process in case several of them are in use in the scene
  118951. * @returns the position the post process has been inserted at
  118952. */
  118953. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  118954. /**
  118955. * Detach a post process to the camera.
  118956. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  118957. * @param postProcess The post process to detach from the camera
  118958. */
  118959. detachPostProcess(postProcess: PostProcess): void;
  118960. /**
  118961. * Gets the current world matrix of the camera
  118962. */
  118963. getWorldMatrix(): Matrix;
  118964. /** @hidden */
  118965. _getViewMatrix(): Matrix;
  118966. /**
  118967. * Gets the current view matrix of the camera.
  118968. * @param force forces the camera to recompute the matrix without looking at the cached state
  118969. * @returns the view matrix
  118970. */
  118971. getViewMatrix(force?: boolean): Matrix;
  118972. /**
  118973. * Freeze the projection matrix.
  118974. * It will prevent the cache check of the camera projection compute and can speed up perf
  118975. * if no parameter of the camera are meant to change
  118976. * @param projection Defines manually a projection if necessary
  118977. */
  118978. freezeProjectionMatrix(projection?: Matrix): void;
  118979. /**
  118980. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  118981. */
  118982. unfreezeProjectionMatrix(): void;
  118983. /**
  118984. * Gets the current projection matrix of the camera.
  118985. * @param force forces the camera to recompute the matrix without looking at the cached state
  118986. * @returns the projection matrix
  118987. */
  118988. getProjectionMatrix(force?: boolean): Matrix;
  118989. /**
  118990. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  118991. * @returns a Matrix
  118992. */
  118993. getTransformationMatrix(): Matrix;
  118994. private _updateFrustumPlanes;
  118995. /**
  118996. * Checks if a cullable object (mesh...) is in the camera frustum
  118997. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  118998. * @param target The object to check
  118999. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  119000. * @returns true if the object is in frustum otherwise false
  119001. */
  119002. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  119003. /**
  119004. * Checks if a cullable object (mesh...) is in the camera frustum
  119005. * Unlike isInFrustum this cheks the full bounding box
  119006. * @param target The object to check
  119007. * @returns true if the object is in frustum otherwise false
  119008. */
  119009. isCompletelyInFrustum(target: ICullable): boolean;
  119010. /**
  119011. * Gets a ray in the forward direction from the camera.
  119012. * @param length Defines the length of the ray to create
  119013. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  119014. * @param origin Defines the start point of the ray which defaults to the camera position
  119015. * @returns the forward ray
  119016. */
  119017. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  119018. /**
  119019. * Gets a ray in the forward direction from the camera.
  119020. * @param refRay the ray to (re)use when setting the values
  119021. * @param length Defines the length of the ray to create
  119022. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  119023. * @param origin Defines the start point of the ray which defaults to the camera position
  119024. * @returns the forward ray
  119025. */
  119026. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  119027. /**
  119028. * Releases resources associated with this node.
  119029. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  119030. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  119031. */
  119032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  119033. /** @hidden */
  119034. _isLeftCamera: boolean;
  119035. /**
  119036. * Gets the left camera of a rig setup in case of Rigged Camera
  119037. */
  119038. get isLeftCamera(): boolean;
  119039. /** @hidden */
  119040. _isRightCamera: boolean;
  119041. /**
  119042. * Gets the right camera of a rig setup in case of Rigged Camera
  119043. */
  119044. get isRightCamera(): boolean;
  119045. /**
  119046. * Gets the left camera of a rig setup in case of Rigged Camera
  119047. */
  119048. get leftCamera(): Nullable<FreeCamera>;
  119049. /**
  119050. * Gets the right camera of a rig setup in case of Rigged Camera
  119051. */
  119052. get rightCamera(): Nullable<FreeCamera>;
  119053. /**
  119054. * Gets the left camera target of a rig setup in case of Rigged Camera
  119055. * @returns the target position
  119056. */
  119057. getLeftTarget(): Nullable<Vector3>;
  119058. /**
  119059. * Gets the right camera target of a rig setup in case of Rigged Camera
  119060. * @returns the target position
  119061. */
  119062. getRightTarget(): Nullable<Vector3>;
  119063. /**
  119064. * @hidden
  119065. */
  119066. setCameraRigMode(mode: number, rigParams: any): void;
  119067. /** @hidden */
  119068. static _setStereoscopicRigMode(camera: Camera): void;
  119069. /** @hidden */
  119070. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  119071. /** @hidden */
  119072. static _setVRRigMode(camera: Camera, rigParams: any): void;
  119073. /** @hidden */
  119074. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  119075. /** @hidden */
  119076. _getVRProjectionMatrix(): Matrix;
  119077. protected _updateCameraRotationMatrix(): void;
  119078. protected _updateWebVRCameraRotationMatrix(): void;
  119079. /**
  119080. * This function MUST be overwritten by the different WebVR cameras available.
  119081. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  119082. * @hidden
  119083. */
  119084. _getWebVRProjectionMatrix(): Matrix;
  119085. /**
  119086. * This function MUST be overwritten by the different WebVR cameras available.
  119087. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  119088. * @hidden
  119089. */
  119090. _getWebVRViewMatrix(): Matrix;
  119091. /** @hidden */
  119092. setCameraRigParameter(name: string, value: any): void;
  119093. /**
  119094. * needs to be overridden by children so sub has required properties to be copied
  119095. * @hidden
  119096. */
  119097. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  119098. /**
  119099. * May need to be overridden by children
  119100. * @hidden
  119101. */
  119102. _updateRigCameras(): void;
  119103. /** @hidden */
  119104. _setupInputs(): void;
  119105. /**
  119106. * Serialiaze the camera setup to a json represention
  119107. * @returns the JSON representation
  119108. */
  119109. serialize(): any;
  119110. /**
  119111. * Clones the current camera.
  119112. * @param name The cloned camera name
  119113. * @returns the cloned camera
  119114. */
  119115. clone(name: string): Camera;
  119116. /**
  119117. * Gets the direction of the camera relative to a given local axis.
  119118. * @param localAxis Defines the reference axis to provide a relative direction.
  119119. * @return the direction
  119120. */
  119121. getDirection(localAxis: Vector3): Vector3;
  119122. /**
  119123. * Returns the current camera absolute rotation
  119124. */
  119125. get absoluteRotation(): Quaternion;
  119126. /**
  119127. * Gets the direction of the camera relative to a given local axis into a passed vector.
  119128. * @param localAxis Defines the reference axis to provide a relative direction.
  119129. * @param result Defines the vector to store the result in
  119130. */
  119131. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  119132. /**
  119133. * Gets a camera constructor for a given camera type
  119134. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  119135. * @param name The name of the camera the result will be able to instantiate
  119136. * @param scene The scene the result will construct the camera in
  119137. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  119138. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  119139. * @returns a factory method to construc the camera
  119140. */
  119141. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  119142. /**
  119143. * Compute the world matrix of the camera.
  119144. * @returns the camera world matrix
  119145. */
  119146. computeWorldMatrix(): Matrix;
  119147. /**
  119148. * Parse a JSON and creates the camera from the parsed information
  119149. * @param parsedCamera The JSON to parse
  119150. * @param scene The scene to instantiate the camera in
  119151. * @returns the newly constructed camera
  119152. */
  119153. static Parse(parsedCamera: any, scene: Scene): Camera;
  119154. }
  119155. }
  119156. declare module BABYLON {
  119157. /**
  119158. * PostProcessManager is used to manage one or more post processes or post process pipelines
  119159. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119160. */
  119161. export class PostProcessManager {
  119162. private _scene;
  119163. private _indexBuffer;
  119164. private _vertexBuffers;
  119165. /**
  119166. * Creates a new instance PostProcess
  119167. * @param scene The scene that the post process is associated with.
  119168. */
  119169. constructor(scene: Scene);
  119170. private _prepareBuffers;
  119171. private _buildIndexBuffer;
  119172. /**
  119173. * Rebuilds the vertex buffers of the manager.
  119174. * @hidden
  119175. */
  119176. _rebuild(): void;
  119177. /**
  119178. * Prepares a frame to be run through a post process.
  119179. * @param sourceTexture The input texture to the post procesess. (default: null)
  119180. * @param postProcesses An array of post processes to be run. (default: null)
  119181. * @returns True if the post processes were able to be run.
  119182. * @hidden
  119183. */
  119184. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  119185. /**
  119186. * Manually render a set of post processes to a texture.
  119187. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  119188. * @param postProcesses An array of post processes to be run.
  119189. * @param targetTexture The target texture to render to.
  119190. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119191. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119192. * @param lodLevel defines which lod of the texture to render to
  119193. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  119194. */
  119195. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  119196. /**
  119197. * Finalize the result of the output of the postprocesses.
  119198. * @param doNotPresent If true the result will not be displayed to the screen.
  119199. * @param targetTexture The target texture to render to.
  119200. * @param faceIndex The index of the face to bind the target texture to.
  119201. * @param postProcesses The array of post processes to render.
  119202. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119203. * @hidden
  119204. */
  119205. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  119206. /**
  119207. * Disposes of the post process manager.
  119208. */
  119209. dispose(): void;
  119210. }
  119211. }
  119212. declare module BABYLON {
  119213. /**
  119214. * This Helps creating a texture that will be created from a camera in your scene.
  119215. * It is basically a dynamic texture that could be used to create special effects for instance.
  119216. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  119217. */
  119218. export class RenderTargetTexture extends Texture {
  119219. /**
  119220. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  119221. */
  119222. static readonly REFRESHRATE_RENDER_ONCE: number;
  119223. /**
  119224. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  119225. */
  119226. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  119227. /**
  119228. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  119229. * the central point of your effect and can save a lot of performances.
  119230. */
  119231. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  119232. /**
  119233. * Use this predicate to dynamically define the list of mesh you want to render.
  119234. * If set, the renderList property will be overwritten.
  119235. */
  119236. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  119237. private _renderList;
  119238. /**
  119239. * Use this list to define the list of mesh you want to render.
  119240. */
  119241. get renderList(): Nullable<Array<AbstractMesh>>;
  119242. set renderList(value: Nullable<Array<AbstractMesh>>);
  119243. /**
  119244. * Use this function to overload the renderList array at rendering time.
  119245. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  119246. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  119247. * the cube (if the RTT is a cube, else layerOrFace=0).
  119248. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  119249. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  119250. * hold dummy elements!
  119251. */
  119252. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  119253. private _hookArray;
  119254. /**
  119255. * Define if particles should be rendered in your texture.
  119256. */
  119257. renderParticles: boolean;
  119258. /**
  119259. * Define if sprites should be rendered in your texture.
  119260. */
  119261. renderSprites: boolean;
  119262. /**
  119263. * Define the camera used to render the texture.
  119264. */
  119265. activeCamera: Nullable<Camera>;
  119266. /**
  119267. * Override the mesh isReady function with your own one.
  119268. */
  119269. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  119270. /**
  119271. * Override the render function of the texture with your own one.
  119272. */
  119273. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  119274. /**
  119275. * Define if camera post processes should be use while rendering the texture.
  119276. */
  119277. useCameraPostProcesses: boolean;
  119278. /**
  119279. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  119280. */
  119281. ignoreCameraViewport: boolean;
  119282. private _postProcessManager;
  119283. private _postProcesses;
  119284. private _resizeObserver;
  119285. /**
  119286. * An event triggered when the texture is unbind.
  119287. */
  119288. onBeforeBindObservable: Observable<RenderTargetTexture>;
  119289. /**
  119290. * An event triggered when the texture is unbind.
  119291. */
  119292. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  119293. private _onAfterUnbindObserver;
  119294. /**
  119295. * Set a after unbind callback in the texture.
  119296. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  119297. */
  119298. set onAfterUnbind(callback: () => void);
  119299. /**
  119300. * An event triggered before rendering the texture
  119301. */
  119302. onBeforeRenderObservable: Observable<number>;
  119303. private _onBeforeRenderObserver;
  119304. /**
  119305. * Set a before render callback in the texture.
  119306. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  119307. */
  119308. set onBeforeRender(callback: (faceIndex: number) => void);
  119309. /**
  119310. * An event triggered after rendering the texture
  119311. */
  119312. onAfterRenderObservable: Observable<number>;
  119313. private _onAfterRenderObserver;
  119314. /**
  119315. * Set a after render callback in the texture.
  119316. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  119317. */
  119318. set onAfterRender(callback: (faceIndex: number) => void);
  119319. /**
  119320. * An event triggered after the texture clear
  119321. */
  119322. onClearObservable: Observable<Engine>;
  119323. private _onClearObserver;
  119324. /**
  119325. * Set a clear callback in the texture.
  119326. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  119327. */
  119328. set onClear(callback: (Engine: Engine) => void);
  119329. /**
  119330. * An event triggered when the texture is resized.
  119331. */
  119332. onResizeObservable: Observable<RenderTargetTexture>;
  119333. /**
  119334. * Define the clear color of the Render Target if it should be different from the scene.
  119335. */
  119336. clearColor: Color4;
  119337. protected _size: number | {
  119338. width: number;
  119339. height: number;
  119340. layers?: number;
  119341. };
  119342. protected _initialSizeParameter: number | {
  119343. width: number;
  119344. height: number;
  119345. } | {
  119346. ratio: number;
  119347. };
  119348. protected _sizeRatio: Nullable<number>;
  119349. /** @hidden */
  119350. _generateMipMaps: boolean;
  119351. protected _renderingManager: RenderingManager;
  119352. /** @hidden */
  119353. _waitingRenderList?: string[];
  119354. protected _doNotChangeAspectRatio: boolean;
  119355. protected _currentRefreshId: number;
  119356. protected _refreshRate: number;
  119357. protected _textureMatrix: Matrix;
  119358. protected _samples: number;
  119359. protected _renderTargetOptions: RenderTargetCreationOptions;
  119360. /**
  119361. * Gets render target creation options that were used.
  119362. */
  119363. get renderTargetOptions(): RenderTargetCreationOptions;
  119364. protected _onRatioRescale(): void;
  119365. /**
  119366. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  119367. * It must define where the camera used to render the texture is set
  119368. */
  119369. boundingBoxPosition: Vector3;
  119370. private _boundingBoxSize;
  119371. /**
  119372. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  119373. * When defined, the cubemap will switch to local mode
  119374. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  119375. * @example https://www.babylonjs-playground.com/#RNASML
  119376. */
  119377. set boundingBoxSize(value: Vector3);
  119378. get boundingBoxSize(): Vector3;
  119379. /**
  119380. * In case the RTT has been created with a depth texture, get the associated
  119381. * depth texture.
  119382. * Otherwise, return null.
  119383. */
  119384. get depthStencilTexture(): Nullable<InternalTexture>;
  119385. /**
  119386. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  119387. * or used a shadow, depth texture...
  119388. * @param name The friendly name of the texture
  119389. * @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)
  119390. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  119391. * @param generateMipMaps True if mip maps need to be generated after render.
  119392. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  119393. * @param type The type of the buffer in the RTT (int, half float, float...)
  119394. * @param isCube True if a cube texture needs to be created
  119395. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  119396. * @param generateDepthBuffer True to generate a depth buffer
  119397. * @param generateStencilBuffer True to generate a stencil buffer
  119398. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  119399. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  119400. * @param delayAllocation if the texture allocation should be delayed (default: false)
  119401. */
  119402. constructor(name: string, size: number | {
  119403. width: number;
  119404. height: number;
  119405. layers?: number;
  119406. } | {
  119407. ratio: number;
  119408. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  119409. /**
  119410. * Creates a depth stencil texture.
  119411. * This is only available in WebGL 2 or with the depth texture extension available.
  119412. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  119413. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  119414. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  119415. */
  119416. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  119417. private _processSizeParameter;
  119418. /**
  119419. * Define the number of samples to use in case of MSAA.
  119420. * It defaults to one meaning no MSAA has been enabled.
  119421. */
  119422. get samples(): number;
  119423. set samples(value: number);
  119424. /**
  119425. * Resets the refresh counter of the texture and start bak from scratch.
  119426. * Could be useful to regenerate the texture if it is setup to render only once.
  119427. */
  119428. resetRefreshCounter(): void;
  119429. /**
  119430. * Define the refresh rate of the texture or the rendering frequency.
  119431. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  119432. */
  119433. get refreshRate(): number;
  119434. set refreshRate(value: number);
  119435. /**
  119436. * Adds a post process to the render target rendering passes.
  119437. * @param postProcess define the post process to add
  119438. */
  119439. addPostProcess(postProcess: PostProcess): void;
  119440. /**
  119441. * Clear all the post processes attached to the render target
  119442. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  119443. */
  119444. clearPostProcesses(dispose?: boolean): void;
  119445. /**
  119446. * Remove one of the post process from the list of attached post processes to the texture
  119447. * @param postProcess define the post process to remove from the list
  119448. */
  119449. removePostProcess(postProcess: PostProcess): void;
  119450. /** @hidden */
  119451. _shouldRender(): boolean;
  119452. /**
  119453. * Gets the actual render size of the texture.
  119454. * @returns the width of the render size
  119455. */
  119456. getRenderSize(): number;
  119457. /**
  119458. * Gets the actual render width of the texture.
  119459. * @returns the width of the render size
  119460. */
  119461. getRenderWidth(): number;
  119462. /**
  119463. * Gets the actual render height of the texture.
  119464. * @returns the height of the render size
  119465. */
  119466. getRenderHeight(): number;
  119467. /**
  119468. * Gets the actual number of layers of the texture.
  119469. * @returns the number of layers
  119470. */
  119471. getRenderLayers(): number;
  119472. /**
  119473. * Get if the texture can be rescaled or not.
  119474. */
  119475. get canRescale(): boolean;
  119476. /**
  119477. * Resize the texture using a ratio.
  119478. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  119479. */
  119480. scale(ratio: number): void;
  119481. /**
  119482. * Get the texture reflection matrix used to rotate/transform the reflection.
  119483. * @returns the reflection matrix
  119484. */
  119485. getReflectionTextureMatrix(): Matrix;
  119486. /**
  119487. * Resize the texture to a new desired size.
  119488. * Be carrefull as it will recreate all the data in the new texture.
  119489. * @param size Define the new size. It can be:
  119490. * - a number for squared texture,
  119491. * - an object containing { width: number, height: number }
  119492. * - or an object containing a ratio { ratio: number }
  119493. */
  119494. resize(size: number | {
  119495. width: number;
  119496. height: number;
  119497. } | {
  119498. ratio: number;
  119499. }): void;
  119500. private _defaultRenderListPrepared;
  119501. /**
  119502. * Renders all the objects from the render list into the texture.
  119503. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  119504. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  119505. */
  119506. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  119507. private _bestReflectionRenderTargetDimension;
  119508. private _prepareRenderingManager;
  119509. /**
  119510. * @hidden
  119511. * @param faceIndex face index to bind to if this is a cubetexture
  119512. * @param layer defines the index of the texture to bind in the array
  119513. */
  119514. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  119515. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  119516. private renderToTarget;
  119517. /**
  119518. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  119519. * This allowed control for front to back rendering or reversly depending of the special needs.
  119520. *
  119521. * @param renderingGroupId The rendering group id corresponding to its index
  119522. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  119523. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  119524. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  119525. */
  119526. 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;
  119527. /**
  119528. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  119529. *
  119530. * @param renderingGroupId The rendering group id corresponding to its index
  119531. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  119532. */
  119533. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  119534. /**
  119535. * Clones the texture.
  119536. * @returns the cloned texture
  119537. */
  119538. clone(): RenderTargetTexture;
  119539. /**
  119540. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  119541. * @returns The JSON representation of the texture
  119542. */
  119543. serialize(): any;
  119544. /**
  119545. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  119546. */
  119547. disposeFramebufferObjects(): void;
  119548. /**
  119549. * Dispose the texture and release its associated resources.
  119550. */
  119551. dispose(): void;
  119552. /** @hidden */
  119553. _rebuild(): void;
  119554. /**
  119555. * Clear the info related to rendering groups preventing retention point in material dispose.
  119556. */
  119557. freeRenderingGroups(): void;
  119558. /**
  119559. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  119560. * @returns the view count
  119561. */
  119562. getViewCount(): number;
  119563. }
  119564. }
  119565. declare module BABYLON {
  119566. /**
  119567. * Options to be used when creating an effect.
  119568. */
  119569. export interface IEffectCreationOptions {
  119570. /**
  119571. * Atrributes that will be used in the shader.
  119572. */
  119573. attributes: string[];
  119574. /**
  119575. * Uniform varible names that will be set in the shader.
  119576. */
  119577. uniformsNames: string[];
  119578. /**
  119579. * Uniform buffer variable names that will be set in the shader.
  119580. */
  119581. uniformBuffersNames: string[];
  119582. /**
  119583. * Sampler texture variable names that will be set in the shader.
  119584. */
  119585. samplers: string[];
  119586. /**
  119587. * Define statements that will be set in the shader.
  119588. */
  119589. defines: any;
  119590. /**
  119591. * Possible fallbacks for this effect to improve performance when needed.
  119592. */
  119593. fallbacks: Nullable<IEffectFallbacks>;
  119594. /**
  119595. * Callback that will be called when the shader is compiled.
  119596. */
  119597. onCompiled: Nullable<(effect: Effect) => void>;
  119598. /**
  119599. * Callback that will be called if an error occurs during shader compilation.
  119600. */
  119601. onError: Nullable<(effect: Effect, errors: string) => void>;
  119602. /**
  119603. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119604. */
  119605. indexParameters?: any;
  119606. /**
  119607. * Max number of lights that can be used in the shader.
  119608. */
  119609. maxSimultaneousLights?: number;
  119610. /**
  119611. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  119612. */
  119613. transformFeedbackVaryings?: Nullable<string[]>;
  119614. /**
  119615. * 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
  119616. */
  119617. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  119618. /**
  119619. * Is this effect rendering to several color attachments ?
  119620. */
  119621. multiTarget?: boolean;
  119622. }
  119623. /**
  119624. * Effect containing vertex and fragment shader that can be executed on an object.
  119625. */
  119626. export class Effect implements IDisposable {
  119627. /**
  119628. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119629. */
  119630. static ShadersRepository: string;
  119631. /**
  119632. * Enable logging of the shader code when a compilation error occurs
  119633. */
  119634. static LogShaderCodeOnCompilationError: boolean;
  119635. /**
  119636. * Name of the effect.
  119637. */
  119638. name: any;
  119639. /**
  119640. * String container all the define statements that should be set on the shader.
  119641. */
  119642. defines: string;
  119643. /**
  119644. * Callback that will be called when the shader is compiled.
  119645. */
  119646. onCompiled: Nullable<(effect: Effect) => void>;
  119647. /**
  119648. * Callback that will be called if an error occurs during shader compilation.
  119649. */
  119650. onError: Nullable<(effect: Effect, errors: string) => void>;
  119651. /**
  119652. * Callback that will be called when effect is bound.
  119653. */
  119654. onBind: Nullable<(effect: Effect) => void>;
  119655. /**
  119656. * Unique ID of the effect.
  119657. */
  119658. uniqueId: number;
  119659. /**
  119660. * Observable that will be called when the shader is compiled.
  119661. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  119662. */
  119663. onCompileObservable: Observable<Effect>;
  119664. /**
  119665. * Observable that will be called if an error occurs during shader compilation.
  119666. */
  119667. onErrorObservable: Observable<Effect>;
  119668. /** @hidden */
  119669. _onBindObservable: Nullable<Observable<Effect>>;
  119670. /**
  119671. * @hidden
  119672. * Specifies if the effect was previously ready
  119673. */
  119674. _wasPreviouslyReady: boolean;
  119675. /**
  119676. * Observable that will be called when effect is bound.
  119677. */
  119678. get onBindObservable(): Observable<Effect>;
  119679. /** @hidden */
  119680. _bonesComputationForcedToCPU: boolean;
  119681. /** @hidden */
  119682. _multiTarget: boolean;
  119683. private static _uniqueIdSeed;
  119684. private _engine;
  119685. private _uniformBuffersNames;
  119686. private _uniformBuffersNamesList;
  119687. private _uniformsNames;
  119688. private _samplerList;
  119689. private _samplers;
  119690. private _isReady;
  119691. private _compilationError;
  119692. private _allFallbacksProcessed;
  119693. private _attributesNames;
  119694. private _attributes;
  119695. private _attributeLocationByName;
  119696. private _uniforms;
  119697. /**
  119698. * Key for the effect.
  119699. * @hidden
  119700. */
  119701. _key: string;
  119702. private _indexParameters;
  119703. private _fallbacks;
  119704. private _vertexSourceCode;
  119705. private _fragmentSourceCode;
  119706. private _vertexSourceCodeOverride;
  119707. private _fragmentSourceCodeOverride;
  119708. private _transformFeedbackVaryings;
  119709. private _rawVertexSourceCode;
  119710. private _rawFragmentSourceCode;
  119711. /**
  119712. * Compiled shader to webGL program.
  119713. * @hidden
  119714. */
  119715. _pipelineContext: Nullable<IPipelineContext>;
  119716. private _valueCache;
  119717. private static _baseCache;
  119718. /**
  119719. * Instantiates an effect.
  119720. * An effect can be used to create/manage/execute vertex and fragment shaders.
  119721. * @param baseName Name of the effect.
  119722. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  119723. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  119724. * @param samplers List of sampler variables that will be passed to the shader.
  119725. * @param engine Engine to be used to render the effect
  119726. * @param defines Define statements to be added to the shader.
  119727. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  119728. * @param onCompiled Callback that will be called when the shader is compiled.
  119729. * @param onError Callback that will be called if an error occurs during shader compilation.
  119730. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  119731. */
  119732. 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);
  119733. private _useFinalCode;
  119734. /**
  119735. * Unique key for this effect
  119736. */
  119737. get key(): string;
  119738. /**
  119739. * If the effect has been compiled and prepared.
  119740. * @returns if the effect is compiled and prepared.
  119741. */
  119742. isReady(): boolean;
  119743. private _isReadyInternal;
  119744. /**
  119745. * The engine the effect was initialized with.
  119746. * @returns the engine.
  119747. */
  119748. getEngine(): Engine;
  119749. /**
  119750. * The pipeline context for this effect
  119751. * @returns the associated pipeline context
  119752. */
  119753. getPipelineContext(): Nullable<IPipelineContext>;
  119754. /**
  119755. * The set of names of attribute variables for the shader.
  119756. * @returns An array of attribute names.
  119757. */
  119758. getAttributesNames(): string[];
  119759. /**
  119760. * Returns the attribute at the given index.
  119761. * @param index The index of the attribute.
  119762. * @returns The location of the attribute.
  119763. */
  119764. getAttributeLocation(index: number): number;
  119765. /**
  119766. * Returns the attribute based on the name of the variable.
  119767. * @param name of the attribute to look up.
  119768. * @returns the attribute location.
  119769. */
  119770. getAttributeLocationByName(name: string): number;
  119771. /**
  119772. * The number of attributes.
  119773. * @returns the numnber of attributes.
  119774. */
  119775. getAttributesCount(): number;
  119776. /**
  119777. * Gets the index of a uniform variable.
  119778. * @param uniformName of the uniform to look up.
  119779. * @returns the index.
  119780. */
  119781. getUniformIndex(uniformName: string): number;
  119782. /**
  119783. * Returns the attribute based on the name of the variable.
  119784. * @param uniformName of the uniform to look up.
  119785. * @returns the location of the uniform.
  119786. */
  119787. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119788. /**
  119789. * Returns an array of sampler variable names
  119790. * @returns The array of sampler variable names.
  119791. */
  119792. getSamplers(): string[];
  119793. /**
  119794. * Returns an array of uniform variable names
  119795. * @returns The array of uniform variable names.
  119796. */
  119797. getUniformNames(): string[];
  119798. /**
  119799. * Returns an array of uniform buffer variable names
  119800. * @returns The array of uniform buffer variable names.
  119801. */
  119802. getUniformBuffersNames(): string[];
  119803. /**
  119804. * Returns the index parameters used to create the effect
  119805. * @returns The index parameters object
  119806. */
  119807. getIndexParameters(): any;
  119808. /**
  119809. * The error from the last compilation.
  119810. * @returns the error string.
  119811. */
  119812. getCompilationError(): string;
  119813. /**
  119814. * Gets a boolean indicating that all fallbacks were used during compilation
  119815. * @returns true if all fallbacks were used
  119816. */
  119817. allFallbacksProcessed(): boolean;
  119818. /**
  119819. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119820. * @param func The callback to be used.
  119821. */
  119822. executeWhenCompiled(func: (effect: Effect) => void): void;
  119823. private _checkIsReady;
  119824. private _loadShader;
  119825. /**
  119826. * Gets the vertex shader source code of this effect
  119827. */
  119828. get vertexSourceCode(): string;
  119829. /**
  119830. * Gets the fragment shader source code of this effect
  119831. */
  119832. get fragmentSourceCode(): string;
  119833. /**
  119834. * Gets the vertex shader source code before it has been processed by the preprocessor
  119835. */
  119836. get rawVertexSourceCode(): string;
  119837. /**
  119838. * Gets the fragment shader source code before it has been processed by the preprocessor
  119839. */
  119840. get rawFragmentSourceCode(): string;
  119841. /**
  119842. * Recompiles the webGL program
  119843. * @param vertexSourceCode The source code for the vertex shader.
  119844. * @param fragmentSourceCode The source code for the fragment shader.
  119845. * @param onCompiled Callback called when completed.
  119846. * @param onError Callback called on error.
  119847. * @hidden
  119848. */
  119849. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119850. /**
  119851. * Prepares the effect
  119852. * @hidden
  119853. */
  119854. _prepareEffect(): void;
  119855. private _getShaderCodeAndErrorLine;
  119856. private _processCompilationErrors;
  119857. /**
  119858. * Checks if the effect is supported. (Must be called after compilation)
  119859. */
  119860. get isSupported(): boolean;
  119861. /**
  119862. * Binds a texture to the engine to be used as output of the shader.
  119863. * @param channel Name of the output variable.
  119864. * @param texture Texture to bind.
  119865. * @hidden
  119866. */
  119867. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119868. /**
  119869. * Sets a texture on the engine to be used in the shader.
  119870. * @param channel Name of the sampler variable.
  119871. * @param texture Texture to set.
  119872. */
  119873. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  119874. /**
  119875. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119876. * @param channel Name of the sampler variable.
  119877. * @param texture Texture to set.
  119878. */
  119879. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119880. /**
  119881. * Sets an array of textures on the engine to be used in the shader.
  119882. * @param channel Name of the variable.
  119883. * @param textures Textures to set.
  119884. */
  119885. setTextureArray(channel: string, textures: ThinTexture[]): void;
  119886. /**
  119887. * 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)
  119888. * @param channel Name of the sampler variable.
  119889. * @param postProcess Post process to get the input texture from.
  119890. */
  119891. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119892. /**
  119893. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119894. * 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)
  119895. * @param channel Name of the sampler variable.
  119896. * @param postProcess Post process to get the output texture from.
  119897. */
  119898. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119899. /** @hidden */
  119900. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119901. /** @hidden */
  119902. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119903. /** @hidden */
  119904. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119905. /** @hidden */
  119906. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119907. /**
  119908. * Binds a buffer to a uniform.
  119909. * @param buffer Buffer to bind.
  119910. * @param name Name of the uniform variable to bind to.
  119911. */
  119912. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119913. /**
  119914. * Binds block to a uniform.
  119915. * @param blockName Name of the block to bind.
  119916. * @param index Index to bind.
  119917. */
  119918. bindUniformBlock(blockName: string, index: number): void;
  119919. /**
  119920. * Sets an interger value on a uniform variable.
  119921. * @param uniformName Name of the variable.
  119922. * @param value Value to be set.
  119923. * @returns this effect.
  119924. */
  119925. setInt(uniformName: string, value: number): Effect;
  119926. /**
  119927. * Sets an int array on a uniform variable.
  119928. * @param uniformName Name of the variable.
  119929. * @param array array to be set.
  119930. * @returns this effect.
  119931. */
  119932. setIntArray(uniformName: string, array: Int32Array): Effect;
  119933. /**
  119934. * 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)
  119935. * @param uniformName Name of the variable.
  119936. * @param array array to be set.
  119937. * @returns this effect.
  119938. */
  119939. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119940. /**
  119941. * 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)
  119942. * @param uniformName Name of the variable.
  119943. * @param array array to be set.
  119944. * @returns this effect.
  119945. */
  119946. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119947. /**
  119948. * 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)
  119949. * @param uniformName Name of the variable.
  119950. * @param array array to be set.
  119951. * @returns this effect.
  119952. */
  119953. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119954. /**
  119955. * Sets an float array on a uniform variable.
  119956. * @param uniformName Name of the variable.
  119957. * @param array array to be set.
  119958. * @returns this effect.
  119959. */
  119960. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119961. /**
  119962. * 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)
  119963. * @param uniformName Name of the variable.
  119964. * @param array array to be set.
  119965. * @returns this effect.
  119966. */
  119967. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119968. /**
  119969. * 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)
  119970. * @param uniformName Name of the variable.
  119971. * @param array array to be set.
  119972. * @returns this effect.
  119973. */
  119974. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119975. /**
  119976. * 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)
  119977. * @param uniformName Name of the variable.
  119978. * @param array array to be set.
  119979. * @returns this effect.
  119980. */
  119981. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119982. /**
  119983. * Sets an array on a uniform variable.
  119984. * @param uniformName Name of the variable.
  119985. * @param array array to be set.
  119986. * @returns this effect.
  119987. */
  119988. setArray(uniformName: string, array: number[]): Effect;
  119989. /**
  119990. * 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)
  119991. * @param uniformName Name of the variable.
  119992. * @param array array to be set.
  119993. * @returns this effect.
  119994. */
  119995. setArray2(uniformName: string, array: number[]): Effect;
  119996. /**
  119997. * 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)
  119998. * @param uniformName Name of the variable.
  119999. * @param array array to be set.
  120000. * @returns this effect.
  120001. */
  120002. setArray3(uniformName: string, array: number[]): Effect;
  120003. /**
  120004. * 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)
  120005. * @param uniformName Name of the variable.
  120006. * @param array array to be set.
  120007. * @returns this effect.
  120008. */
  120009. setArray4(uniformName: string, array: number[]): Effect;
  120010. /**
  120011. * Sets matrices on a uniform variable.
  120012. * @param uniformName Name of the variable.
  120013. * @param matrices matrices to be set.
  120014. * @returns this effect.
  120015. */
  120016. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  120017. /**
  120018. * Sets matrix on a uniform variable.
  120019. * @param uniformName Name of the variable.
  120020. * @param matrix matrix to be set.
  120021. * @returns this effect.
  120022. */
  120023. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  120024. /**
  120025. * 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)
  120026. * @param uniformName Name of the variable.
  120027. * @param matrix matrix to be set.
  120028. * @returns this effect.
  120029. */
  120030. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  120031. /**
  120032. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  120033. * @param uniformName Name of the variable.
  120034. * @param matrix matrix to be set.
  120035. * @returns this effect.
  120036. */
  120037. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  120038. /**
  120039. * Sets a float on a uniform variable.
  120040. * @param uniformName Name of the variable.
  120041. * @param value value to be set.
  120042. * @returns this effect.
  120043. */
  120044. setFloat(uniformName: string, value: number): Effect;
  120045. /**
  120046. * Sets a boolean on a uniform variable.
  120047. * @param uniformName Name of the variable.
  120048. * @param bool value to be set.
  120049. * @returns this effect.
  120050. */
  120051. setBool(uniformName: string, bool: boolean): Effect;
  120052. /**
  120053. * Sets a Vector2 on a uniform variable.
  120054. * @param uniformName Name of the variable.
  120055. * @param vector2 vector2 to be set.
  120056. * @returns this effect.
  120057. */
  120058. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  120059. /**
  120060. * Sets a float2 on a uniform variable.
  120061. * @param uniformName Name of the variable.
  120062. * @param x First float in float2.
  120063. * @param y Second float in float2.
  120064. * @returns this effect.
  120065. */
  120066. setFloat2(uniformName: string, x: number, y: number): Effect;
  120067. /**
  120068. * Sets a Vector3 on a uniform variable.
  120069. * @param uniformName Name of the variable.
  120070. * @param vector3 Value to be set.
  120071. * @returns this effect.
  120072. */
  120073. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  120074. /**
  120075. * Sets a float3 on a uniform variable.
  120076. * @param uniformName Name of the variable.
  120077. * @param x First float in float3.
  120078. * @param y Second float in float3.
  120079. * @param z Third float in float3.
  120080. * @returns this effect.
  120081. */
  120082. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  120083. /**
  120084. * Sets a Vector4 on a uniform variable.
  120085. * @param uniformName Name of the variable.
  120086. * @param vector4 Value to be set.
  120087. * @returns this effect.
  120088. */
  120089. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  120090. /**
  120091. * Sets a float4 on a uniform variable.
  120092. * @param uniformName Name of the variable.
  120093. * @param x First float in float4.
  120094. * @param y Second float in float4.
  120095. * @param z Third float in float4.
  120096. * @param w Fourth float in float4.
  120097. * @returns this effect.
  120098. */
  120099. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  120100. /**
  120101. * Sets a Color3 on a uniform variable.
  120102. * @param uniformName Name of the variable.
  120103. * @param color3 Value to be set.
  120104. * @returns this effect.
  120105. */
  120106. setColor3(uniformName: string, color3: IColor3Like): Effect;
  120107. /**
  120108. * Sets a Color4 on a uniform variable.
  120109. * @param uniformName Name of the variable.
  120110. * @param color3 Value to be set.
  120111. * @param alpha Alpha value to be set.
  120112. * @returns this effect.
  120113. */
  120114. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  120115. /**
  120116. * Sets a Color4 on a uniform variable
  120117. * @param uniformName defines the name of the variable
  120118. * @param color4 defines the value to be set
  120119. * @returns this effect.
  120120. */
  120121. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  120122. /** Release all associated resources */
  120123. dispose(): void;
  120124. /**
  120125. * This function will add a new shader to the shader store
  120126. * @param name the name of the shader
  120127. * @param pixelShader optional pixel shader content
  120128. * @param vertexShader optional vertex shader content
  120129. */
  120130. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  120131. /**
  120132. * Store of each shader (The can be looked up using effect.key)
  120133. */
  120134. static ShadersStore: {
  120135. [key: string]: string;
  120136. };
  120137. /**
  120138. * Store of each included file for a shader (The can be looked up using effect.key)
  120139. */
  120140. static IncludesShadersStore: {
  120141. [key: string]: string;
  120142. };
  120143. /**
  120144. * Resets the cache of effects.
  120145. */
  120146. static ResetCache(): void;
  120147. }
  120148. }
  120149. declare module BABYLON {
  120150. /**
  120151. * Interface used to describe the capabilities of the engine relatively to the current browser
  120152. */
  120153. export interface EngineCapabilities {
  120154. /** Maximum textures units per fragment shader */
  120155. maxTexturesImageUnits: number;
  120156. /** Maximum texture units per vertex shader */
  120157. maxVertexTextureImageUnits: number;
  120158. /** Maximum textures units in the entire pipeline */
  120159. maxCombinedTexturesImageUnits: number;
  120160. /** Maximum texture size */
  120161. maxTextureSize: number;
  120162. /** Maximum texture samples */
  120163. maxSamples?: number;
  120164. /** Maximum cube texture size */
  120165. maxCubemapTextureSize: number;
  120166. /** Maximum render texture size */
  120167. maxRenderTextureSize: number;
  120168. /** Maximum number of vertex attributes */
  120169. maxVertexAttribs: number;
  120170. /** Maximum number of varyings */
  120171. maxVaryingVectors: number;
  120172. /** Maximum number of uniforms per vertex shader */
  120173. maxVertexUniformVectors: number;
  120174. /** Maximum number of uniforms per fragment shader */
  120175. maxFragmentUniformVectors: number;
  120176. /** Defines if standard derivates (dx/dy) are supported */
  120177. standardDerivatives: boolean;
  120178. /** Defines if s3tc texture compression is supported */
  120179. s3tc?: WEBGL_compressed_texture_s3tc;
  120180. /** Defines if pvrtc texture compression is supported */
  120181. pvrtc: any;
  120182. /** Defines if etc1 texture compression is supported */
  120183. etc1: any;
  120184. /** Defines if etc2 texture compression is supported */
  120185. etc2: any;
  120186. /** Defines if astc texture compression is supported */
  120187. astc: any;
  120188. /** Defines if bptc texture compression is supported */
  120189. bptc: any;
  120190. /** Defines if float textures are supported */
  120191. textureFloat: boolean;
  120192. /** Defines if vertex array objects are supported */
  120193. vertexArrayObject: boolean;
  120194. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  120195. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  120196. /** Gets the maximum level of anisotropy supported */
  120197. maxAnisotropy: number;
  120198. /** Defines if instancing is supported */
  120199. instancedArrays: boolean;
  120200. /** Defines if 32 bits indices are supported */
  120201. uintIndices: boolean;
  120202. /** Defines if high precision shaders are supported */
  120203. highPrecisionShaderSupported: boolean;
  120204. /** Defines if depth reading in the fragment shader is supported */
  120205. fragmentDepthSupported: boolean;
  120206. /** Defines if float texture linear filtering is supported*/
  120207. textureFloatLinearFiltering: boolean;
  120208. /** Defines if rendering to float textures is supported */
  120209. textureFloatRender: boolean;
  120210. /** Defines if half float textures are supported*/
  120211. textureHalfFloat: boolean;
  120212. /** Defines if half float texture linear filtering is supported*/
  120213. textureHalfFloatLinearFiltering: boolean;
  120214. /** Defines if rendering to half float textures is supported */
  120215. textureHalfFloatRender: boolean;
  120216. /** Defines if textureLOD shader command is supported */
  120217. textureLOD: boolean;
  120218. /** Defines if draw buffers extension is supported */
  120219. drawBuffersExtension: boolean;
  120220. /** Defines if depth textures are supported */
  120221. depthTextureExtension: boolean;
  120222. /** Defines if float color buffer are supported */
  120223. colorBufferFloat: boolean;
  120224. /** Gets disjoint timer query extension (null if not supported) */
  120225. timerQuery?: EXT_disjoint_timer_query;
  120226. /** Defines if timestamp can be used with timer query */
  120227. canUseTimestampForTimerQuery: boolean;
  120228. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  120229. multiview?: any;
  120230. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  120231. oculusMultiview?: any;
  120232. /** Function used to let the system compiles shaders in background */
  120233. parallelShaderCompile?: {
  120234. COMPLETION_STATUS_KHR: number;
  120235. };
  120236. /** Max number of texture samples for MSAA */
  120237. maxMSAASamples: number;
  120238. /** Defines if the blend min max extension is supported */
  120239. blendMinMax: boolean;
  120240. }
  120241. }
  120242. declare module BABYLON {
  120243. /**
  120244. * @hidden
  120245. **/
  120246. export class DepthCullingState {
  120247. private _isDepthTestDirty;
  120248. private _isDepthMaskDirty;
  120249. private _isDepthFuncDirty;
  120250. private _isCullFaceDirty;
  120251. private _isCullDirty;
  120252. private _isZOffsetDirty;
  120253. private _isFrontFaceDirty;
  120254. private _depthTest;
  120255. private _depthMask;
  120256. private _depthFunc;
  120257. private _cull;
  120258. private _cullFace;
  120259. private _zOffset;
  120260. private _frontFace;
  120261. /**
  120262. * Initializes the state.
  120263. */
  120264. constructor();
  120265. get isDirty(): boolean;
  120266. get zOffset(): number;
  120267. set zOffset(value: number);
  120268. get cullFace(): Nullable<number>;
  120269. set cullFace(value: Nullable<number>);
  120270. get cull(): Nullable<boolean>;
  120271. set cull(value: Nullable<boolean>);
  120272. get depthFunc(): Nullable<number>;
  120273. set depthFunc(value: Nullable<number>);
  120274. get depthMask(): boolean;
  120275. set depthMask(value: boolean);
  120276. get depthTest(): boolean;
  120277. set depthTest(value: boolean);
  120278. get frontFace(): Nullable<number>;
  120279. set frontFace(value: Nullable<number>);
  120280. reset(): void;
  120281. apply(gl: WebGLRenderingContext): void;
  120282. }
  120283. }
  120284. declare module BABYLON {
  120285. /**
  120286. * @hidden
  120287. **/
  120288. export class StencilState {
  120289. /** 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 */
  120290. static readonly ALWAYS: number;
  120291. /** Passed to stencilOperation to specify that stencil value must be kept */
  120292. static readonly KEEP: number;
  120293. /** Passed to stencilOperation to specify that stencil value must be replaced */
  120294. static readonly REPLACE: number;
  120295. private _isStencilTestDirty;
  120296. private _isStencilMaskDirty;
  120297. private _isStencilFuncDirty;
  120298. private _isStencilOpDirty;
  120299. private _stencilTest;
  120300. private _stencilMask;
  120301. private _stencilFunc;
  120302. private _stencilFuncRef;
  120303. private _stencilFuncMask;
  120304. private _stencilOpStencilFail;
  120305. private _stencilOpDepthFail;
  120306. private _stencilOpStencilDepthPass;
  120307. get isDirty(): boolean;
  120308. get stencilFunc(): number;
  120309. set stencilFunc(value: number);
  120310. get stencilFuncRef(): number;
  120311. set stencilFuncRef(value: number);
  120312. get stencilFuncMask(): number;
  120313. set stencilFuncMask(value: number);
  120314. get stencilOpStencilFail(): number;
  120315. set stencilOpStencilFail(value: number);
  120316. get stencilOpDepthFail(): number;
  120317. set stencilOpDepthFail(value: number);
  120318. get stencilOpStencilDepthPass(): number;
  120319. set stencilOpStencilDepthPass(value: number);
  120320. get stencilMask(): number;
  120321. set stencilMask(value: number);
  120322. get stencilTest(): boolean;
  120323. set stencilTest(value: boolean);
  120324. constructor();
  120325. reset(): void;
  120326. apply(gl: WebGLRenderingContext): void;
  120327. }
  120328. }
  120329. declare module BABYLON {
  120330. /**
  120331. * @hidden
  120332. **/
  120333. export class AlphaState {
  120334. private _isAlphaBlendDirty;
  120335. private _isBlendFunctionParametersDirty;
  120336. private _isBlendEquationParametersDirty;
  120337. private _isBlendConstantsDirty;
  120338. private _alphaBlend;
  120339. private _blendFunctionParameters;
  120340. private _blendEquationParameters;
  120341. private _blendConstants;
  120342. /**
  120343. * Initializes the state.
  120344. */
  120345. constructor();
  120346. get isDirty(): boolean;
  120347. get alphaBlend(): boolean;
  120348. set alphaBlend(value: boolean);
  120349. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  120350. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  120351. setAlphaEquationParameters(rgb: number, alpha: number): void;
  120352. reset(): void;
  120353. apply(gl: WebGLRenderingContext): void;
  120354. }
  120355. }
  120356. declare module BABYLON {
  120357. /** @hidden */
  120358. export class WebGLShaderProcessor implements IShaderProcessor {
  120359. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  120360. }
  120361. }
  120362. declare module BABYLON {
  120363. /** @hidden */
  120364. export class WebGL2ShaderProcessor implements IShaderProcessor {
  120365. attributeProcessor(attribute: string): string;
  120366. varyingProcessor(varying: string, isFragment: boolean): string;
  120367. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120368. }
  120369. }
  120370. declare module BABYLON {
  120371. /**
  120372. * Interface for attribute information associated with buffer instanciation
  120373. */
  120374. export interface InstancingAttributeInfo {
  120375. /**
  120376. * Name of the GLSL attribute
  120377. * if attribute index is not specified, this is used to retrieve the index from the effect
  120378. */
  120379. attributeName: string;
  120380. /**
  120381. * Index/offset of the attribute in the vertex shader
  120382. * if not specified, this will be computes from the name.
  120383. */
  120384. index?: number;
  120385. /**
  120386. * size of the attribute, 1, 2, 3 or 4
  120387. */
  120388. attributeSize: number;
  120389. /**
  120390. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  120391. */
  120392. offset: number;
  120393. /**
  120394. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  120395. * default to 1
  120396. */
  120397. divisor?: number;
  120398. /**
  120399. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  120400. * default is FLOAT
  120401. */
  120402. attributeType?: number;
  120403. /**
  120404. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  120405. */
  120406. normalized?: boolean;
  120407. }
  120408. }
  120409. declare module BABYLON {
  120410. interface ThinEngine {
  120411. /**
  120412. * Update a video texture
  120413. * @param texture defines the texture to update
  120414. * @param video defines the video element to use
  120415. * @param invertY defines if data must be stored with Y axis inverted
  120416. */
  120417. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  120418. }
  120419. }
  120420. declare module BABYLON {
  120421. interface ThinEngine {
  120422. /**
  120423. * Creates a dynamic texture
  120424. * @param width defines the width of the texture
  120425. * @param height defines the height of the texture
  120426. * @param generateMipMaps defines if the engine should generate the mip levels
  120427. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  120428. * @returns the dynamic texture inside an InternalTexture
  120429. */
  120430. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  120431. /**
  120432. * Update the content of a dynamic texture
  120433. * @param texture defines the texture to update
  120434. * @param source defines the source containing the data
  120435. * @param invertY defines if data must be stored with Y axis inverted
  120436. * @param premulAlpha defines if alpha is stored as premultiplied
  120437. * @param format defines the format of the data
  120438. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120439. */
  120440. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  120441. }
  120442. }
  120443. declare module BABYLON {
  120444. /**
  120445. * Settings for finer control over video usage
  120446. */
  120447. export interface VideoTextureSettings {
  120448. /**
  120449. * Applies `autoplay` to video, if specified
  120450. */
  120451. autoPlay?: boolean;
  120452. /**
  120453. * Applies `muted` to video, if specified
  120454. */
  120455. muted?: boolean;
  120456. /**
  120457. * Applies `loop` to video, if specified
  120458. */
  120459. loop?: boolean;
  120460. /**
  120461. * Automatically updates internal texture from video at every frame in the render loop
  120462. */
  120463. autoUpdateTexture: boolean;
  120464. /**
  120465. * Image src displayed during the video loading or until the user interacts with the video.
  120466. */
  120467. poster?: string;
  120468. }
  120469. /**
  120470. * If you want to display a video in your scene, this is the special texture for that.
  120471. * This special texture works similar to other textures, with the exception of a few parameters.
  120472. * @see https://doc.babylonjs.com/how_to/video_texture
  120473. */
  120474. export class VideoTexture extends Texture {
  120475. /**
  120476. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  120477. */
  120478. readonly autoUpdateTexture: boolean;
  120479. /**
  120480. * The video instance used by the texture internally
  120481. */
  120482. readonly video: HTMLVideoElement;
  120483. private _onUserActionRequestedObservable;
  120484. /**
  120485. * Event triggerd when a dom action is required by the user to play the video.
  120486. * This happens due to recent changes in browser policies preventing video to auto start.
  120487. */
  120488. get onUserActionRequestedObservable(): Observable<Texture>;
  120489. private _generateMipMaps;
  120490. private _stillImageCaptured;
  120491. private _displayingPosterTexture;
  120492. private _settings;
  120493. private _createInternalTextureOnEvent;
  120494. private _frameId;
  120495. private _currentSrc;
  120496. /**
  120497. * Creates a video texture.
  120498. * If you want to display a video in your scene, this is the special texture for that.
  120499. * This special texture works similar to other textures, with the exception of a few parameters.
  120500. * @see https://doc.babylonjs.com/how_to/video_texture
  120501. * @param name optional name, will detect from video source, if not defined
  120502. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  120503. * @param scene is obviously the current scene.
  120504. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  120505. * @param invertY is false by default but can be used to invert video on Y axis
  120506. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  120507. * @param settings allows finer control over video usage
  120508. */
  120509. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  120510. private _getName;
  120511. private _getVideo;
  120512. private _createInternalTexture;
  120513. private reset;
  120514. /**
  120515. * @hidden Internal method to initiate `update`.
  120516. */
  120517. _rebuild(): void;
  120518. /**
  120519. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  120520. */
  120521. update(): void;
  120522. /**
  120523. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  120524. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  120525. */
  120526. updateTexture(isVisible: boolean): void;
  120527. protected _updateInternalTexture: () => void;
  120528. /**
  120529. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  120530. * @param url New url.
  120531. */
  120532. updateURL(url: string): void;
  120533. /**
  120534. * Clones the texture.
  120535. * @returns the cloned texture
  120536. */
  120537. clone(): VideoTexture;
  120538. /**
  120539. * Dispose the texture and release its associated resources.
  120540. */
  120541. dispose(): void;
  120542. /**
  120543. * Creates a video texture straight from a stream.
  120544. * @param scene Define the scene the texture should be created in
  120545. * @param stream Define the stream the texture should be created from
  120546. * @returns The created video texture as a promise
  120547. */
  120548. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  120549. /**
  120550. * Creates a video texture straight from your WebCam video feed.
  120551. * @param scene Define the scene the texture should be created in
  120552. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120553. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120554. * @returns The created video texture as a promise
  120555. */
  120556. static CreateFromWebCamAsync(scene: Scene, constraints: {
  120557. minWidth: number;
  120558. maxWidth: number;
  120559. minHeight: number;
  120560. maxHeight: number;
  120561. deviceId: string;
  120562. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  120563. /**
  120564. * Creates a video texture straight from your WebCam video feed.
  120565. * @param scene Define the scene the texture should be created in
  120566. * @param onReady Define a callback to triggered once the texture will be ready
  120567. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  120568. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  120569. */
  120570. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  120571. minWidth: number;
  120572. maxWidth: number;
  120573. minHeight: number;
  120574. maxHeight: number;
  120575. deviceId: string;
  120576. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  120577. }
  120578. }
  120579. declare module BABYLON {
  120580. /**
  120581. * Defines the interface used by objects working like Scene
  120582. * @hidden
  120583. */
  120584. export interface ISceneLike {
  120585. _addPendingData(data: any): void;
  120586. _removePendingData(data: any): void;
  120587. offlineProvider: IOfflineProvider;
  120588. }
  120589. /**
  120590. * Information about the current host
  120591. */
  120592. export interface HostInformation {
  120593. /**
  120594. * Defines if the current host is a mobile
  120595. */
  120596. isMobile: boolean;
  120597. }
  120598. /** Interface defining initialization parameters for Engine class */
  120599. export interface EngineOptions extends WebGLContextAttributes {
  120600. /**
  120601. * Defines if the engine should no exceed a specified device ratio
  120602. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  120603. */
  120604. limitDeviceRatio?: number;
  120605. /**
  120606. * Defines if webvr should be enabled automatically
  120607. * @see https://doc.babylonjs.com/how_to/webvr_camera
  120608. */
  120609. autoEnableWebVR?: boolean;
  120610. /**
  120611. * Defines if webgl2 should be turned off even if supported
  120612. * @see https://doc.babylonjs.com/features/webgl2
  120613. */
  120614. disableWebGL2Support?: boolean;
  120615. /**
  120616. * Defines if webaudio should be initialized as well
  120617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  120618. */
  120619. audioEngine?: boolean;
  120620. /**
  120621. * Defines if animations should run using a deterministic lock step
  120622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120623. */
  120624. deterministicLockstep?: boolean;
  120625. /** Defines the maximum steps to use with deterministic lock step mode */
  120626. lockstepMaxSteps?: number;
  120627. /** Defines the seconds between each deterministic lock step */
  120628. timeStep?: number;
  120629. /**
  120630. * Defines that engine should ignore context lost events
  120631. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  120632. */
  120633. doNotHandleContextLost?: boolean;
  120634. /**
  120635. * Defines that engine should ignore modifying touch action attribute and style
  120636. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  120637. */
  120638. doNotHandleTouchAction?: boolean;
  120639. /**
  120640. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  120641. */
  120642. useHighPrecisionFloats?: boolean;
  120643. /**
  120644. * Make the canvas XR Compatible for XR sessions
  120645. */
  120646. xrCompatible?: boolean;
  120647. /**
  120648. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  120649. */
  120650. useHighPrecisionMatrix?: boolean;
  120651. /**
  120652. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  120653. */
  120654. failIfMajorPerformanceCaveat?: boolean;
  120655. }
  120656. /**
  120657. * The base engine class (root of all engines)
  120658. */
  120659. export class ThinEngine {
  120660. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  120661. static ExceptionList: ({
  120662. key: string;
  120663. capture: string;
  120664. captureConstraint: number;
  120665. targets: string[];
  120666. } | {
  120667. key: string;
  120668. capture: null;
  120669. captureConstraint: null;
  120670. targets: string[];
  120671. })[];
  120672. /** @hidden */
  120673. static _TextureLoaders: IInternalTextureLoader[];
  120674. /**
  120675. * Returns the current npm package of the sdk
  120676. */
  120677. static get NpmPackage(): string;
  120678. /**
  120679. * Returns the current version of the framework
  120680. */
  120681. static get Version(): string;
  120682. /**
  120683. * Returns a string describing the current engine
  120684. */
  120685. get description(): string;
  120686. /**
  120687. * Gets or sets the epsilon value used by collision engine
  120688. */
  120689. static CollisionsEpsilon: number;
  120690. /**
  120691. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  120692. */
  120693. static get ShadersRepository(): string;
  120694. static set ShadersRepository(value: string);
  120695. /** @hidden */
  120696. _shaderProcessor: IShaderProcessor;
  120697. /**
  120698. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  120699. */
  120700. forcePOTTextures: boolean;
  120701. /**
  120702. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  120703. */
  120704. isFullscreen: boolean;
  120705. /**
  120706. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  120707. */
  120708. cullBackFaces: boolean;
  120709. /**
  120710. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  120711. */
  120712. renderEvenInBackground: boolean;
  120713. /**
  120714. * Gets or sets a boolean indicating that cache can be kept between frames
  120715. */
  120716. preventCacheWipeBetweenFrames: boolean;
  120717. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  120718. validateShaderPrograms: boolean;
  120719. /**
  120720. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  120721. * This can provide greater z depth for distant objects.
  120722. */
  120723. useReverseDepthBuffer: boolean;
  120724. /**
  120725. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  120726. */
  120727. disableUniformBuffers: boolean;
  120728. /** @hidden */
  120729. _uniformBuffers: UniformBuffer[];
  120730. /**
  120731. * Gets a boolean indicating that the engine supports uniform buffers
  120732. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  120733. */
  120734. get supportsUniformBuffers(): boolean;
  120735. /** @hidden */
  120736. _gl: WebGLRenderingContext;
  120737. /** @hidden */
  120738. _webGLVersion: number;
  120739. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  120740. protected _windowIsBackground: boolean;
  120741. protected _creationOptions: EngineOptions;
  120742. protected _highPrecisionShadersAllowed: boolean;
  120743. /** @hidden */
  120744. get _shouldUseHighPrecisionShader(): boolean;
  120745. /**
  120746. * Gets a boolean indicating that only power of 2 textures are supported
  120747. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  120748. */
  120749. get needPOTTextures(): boolean;
  120750. /** @hidden */
  120751. _badOS: boolean;
  120752. /** @hidden */
  120753. _badDesktopOS: boolean;
  120754. private _hardwareScalingLevel;
  120755. /** @hidden */
  120756. _caps: EngineCapabilities;
  120757. private _isStencilEnable;
  120758. private _glVersion;
  120759. private _glRenderer;
  120760. private _glVendor;
  120761. /** @hidden */
  120762. _videoTextureSupported: boolean;
  120763. protected _renderingQueueLaunched: boolean;
  120764. protected _activeRenderLoops: (() => void)[];
  120765. /**
  120766. * Observable signaled when a context lost event is raised
  120767. */
  120768. onContextLostObservable: Observable<ThinEngine>;
  120769. /**
  120770. * Observable signaled when a context restored event is raised
  120771. */
  120772. onContextRestoredObservable: Observable<ThinEngine>;
  120773. private _onContextLost;
  120774. private _onContextRestored;
  120775. protected _contextWasLost: boolean;
  120776. /** @hidden */
  120777. _doNotHandleContextLost: boolean;
  120778. /**
  120779. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120780. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120781. */
  120782. get doNotHandleContextLost(): boolean;
  120783. set doNotHandleContextLost(value: boolean);
  120784. /**
  120785. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120786. */
  120787. disableVertexArrayObjects: boolean;
  120788. /** @hidden */
  120789. protected _colorWrite: boolean;
  120790. /** @hidden */
  120791. protected _colorWriteChanged: boolean;
  120792. /** @hidden */
  120793. protected _depthCullingState: DepthCullingState;
  120794. /** @hidden */
  120795. protected _stencilState: StencilState;
  120796. /** @hidden */
  120797. _alphaState: AlphaState;
  120798. /** @hidden */
  120799. _alphaMode: number;
  120800. /** @hidden */
  120801. _alphaEquation: number;
  120802. /** @hidden */
  120803. _internalTexturesCache: InternalTexture[];
  120804. /** @hidden */
  120805. protected _activeChannel: number;
  120806. private _currentTextureChannel;
  120807. /** @hidden */
  120808. protected _boundTexturesCache: {
  120809. [key: string]: Nullable<InternalTexture>;
  120810. };
  120811. /** @hidden */
  120812. protected _currentEffect: Nullable<Effect>;
  120813. /** @hidden */
  120814. protected _currentProgram: Nullable<WebGLProgram>;
  120815. private _compiledEffects;
  120816. private _vertexAttribArraysEnabled;
  120817. /** @hidden */
  120818. protected _cachedViewport: Nullable<IViewportLike>;
  120819. private _cachedVertexArrayObject;
  120820. /** @hidden */
  120821. protected _cachedVertexBuffers: any;
  120822. /** @hidden */
  120823. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120824. /** @hidden */
  120825. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120826. /** @hidden */
  120827. _currentRenderTarget: Nullable<InternalTexture>;
  120828. private _uintIndicesCurrentlySet;
  120829. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120830. /** @hidden */
  120831. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120832. /** @hidden */
  120833. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120834. private _currentBufferPointers;
  120835. private _currentInstanceLocations;
  120836. private _currentInstanceBuffers;
  120837. private _textureUnits;
  120838. /** @hidden */
  120839. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120840. /** @hidden */
  120841. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120842. /** @hidden */
  120843. _boundRenderFunction: any;
  120844. private _vaoRecordInProgress;
  120845. private _mustWipeVertexAttributes;
  120846. private _emptyTexture;
  120847. private _emptyCubeTexture;
  120848. private _emptyTexture3D;
  120849. private _emptyTexture2DArray;
  120850. /** @hidden */
  120851. _frameHandler: number;
  120852. private _nextFreeTextureSlots;
  120853. private _maxSimultaneousTextures;
  120854. private _activeRequests;
  120855. /** @hidden */
  120856. _transformTextureUrl: Nullable<(url: string) => string>;
  120857. /**
  120858. * Gets information about the current host
  120859. */
  120860. hostInformation: HostInformation;
  120861. protected get _supportsHardwareTextureRescaling(): boolean;
  120862. private _framebufferDimensionsObject;
  120863. /**
  120864. * sets the object from which width and height will be taken from when getting render width and height
  120865. * Will fallback to the gl object
  120866. * @param dimensions the framebuffer width and height that will be used.
  120867. */
  120868. set framebufferDimensionsObject(dimensions: Nullable<{
  120869. framebufferWidth: number;
  120870. framebufferHeight: number;
  120871. }>);
  120872. /**
  120873. * Gets the current viewport
  120874. */
  120875. get currentViewport(): Nullable<IViewportLike>;
  120876. /**
  120877. * Gets the default empty texture
  120878. */
  120879. get emptyTexture(): InternalTexture;
  120880. /**
  120881. * Gets the default empty 3D texture
  120882. */
  120883. get emptyTexture3D(): InternalTexture;
  120884. /**
  120885. * Gets the default empty 2D array texture
  120886. */
  120887. get emptyTexture2DArray(): InternalTexture;
  120888. /**
  120889. * Gets the default empty cube texture
  120890. */
  120891. get emptyCubeTexture(): InternalTexture;
  120892. /**
  120893. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120894. */
  120895. readonly premultipliedAlpha: boolean;
  120896. /**
  120897. * Observable event triggered before each texture is initialized
  120898. */
  120899. onBeforeTextureInitObservable: Observable<Texture>;
  120900. /**
  120901. * Creates a new engine
  120902. * @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
  120903. * @param antialias defines enable antialiasing (default: false)
  120904. * @param options defines further options to be sent to the getContext() function
  120905. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120906. */
  120907. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120908. private _rebuildInternalTextures;
  120909. private _rebuildEffects;
  120910. /**
  120911. * Gets a boolean indicating if all created effects are ready
  120912. * @returns true if all effects are ready
  120913. */
  120914. areAllEffectsReady(): boolean;
  120915. protected _rebuildBuffers(): void;
  120916. protected _initGLContext(): void;
  120917. /**
  120918. * Gets version of the current webGL context
  120919. */
  120920. get webGLVersion(): number;
  120921. /**
  120922. * Gets a string identifying the name of the class
  120923. * @returns "Engine" string
  120924. */
  120925. getClassName(): string;
  120926. /**
  120927. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120928. */
  120929. get isStencilEnable(): boolean;
  120930. /** @hidden */
  120931. _prepareWorkingCanvas(): void;
  120932. /**
  120933. * Reset the texture cache to empty state
  120934. */
  120935. resetTextureCache(): void;
  120936. /**
  120937. * Gets an object containing information about the current webGL context
  120938. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120939. */
  120940. getGlInfo(): {
  120941. vendor: string;
  120942. renderer: string;
  120943. version: string;
  120944. };
  120945. /**
  120946. * Defines the hardware scaling level.
  120947. * By default the hardware scaling level is computed from the window device ratio.
  120948. * 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.
  120949. * @param level defines the level to use
  120950. */
  120951. setHardwareScalingLevel(level: number): void;
  120952. /**
  120953. * Gets the current hardware scaling level.
  120954. * By default the hardware scaling level is computed from the window device ratio.
  120955. * 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.
  120956. * @returns a number indicating the current hardware scaling level
  120957. */
  120958. getHardwareScalingLevel(): number;
  120959. /**
  120960. * Gets the list of loaded textures
  120961. * @returns an array containing all loaded textures
  120962. */
  120963. getLoadedTexturesCache(): InternalTexture[];
  120964. /**
  120965. * Gets the object containing all engine capabilities
  120966. * @returns the EngineCapabilities object
  120967. */
  120968. getCaps(): EngineCapabilities;
  120969. /**
  120970. * stop executing a render loop function and remove it from the execution array
  120971. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120972. */
  120973. stopRenderLoop(renderFunction?: () => void): void;
  120974. /** @hidden */
  120975. _renderLoop(): void;
  120976. /**
  120977. * Gets the HTML canvas attached with the current webGL context
  120978. * @returns a HTML canvas
  120979. */
  120980. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120981. /**
  120982. * Gets host window
  120983. * @returns the host window object
  120984. */
  120985. getHostWindow(): Nullable<Window>;
  120986. /**
  120987. * Gets the current render width
  120988. * @param useScreen defines if screen size must be used (or the current render target if any)
  120989. * @returns a number defining the current render width
  120990. */
  120991. getRenderWidth(useScreen?: boolean): number;
  120992. /**
  120993. * Gets the current render height
  120994. * @param useScreen defines if screen size must be used (or the current render target if any)
  120995. * @returns a number defining the current render height
  120996. */
  120997. getRenderHeight(useScreen?: boolean): number;
  120998. /**
  120999. * Can be used to override the current requestAnimationFrame requester.
  121000. * @hidden
  121001. */
  121002. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  121003. /**
  121004. * Register and execute a render loop. The engine can have more than one render function
  121005. * @param renderFunction defines the function to continuously execute
  121006. */
  121007. runRenderLoop(renderFunction: () => void): void;
  121008. /**
  121009. * Clear the current render buffer or the current render target (if any is set up)
  121010. * @param color defines the color to use
  121011. * @param backBuffer defines if the back buffer must be cleared
  121012. * @param depth defines if the depth buffer must be cleared
  121013. * @param stencil defines if the stencil buffer must be cleared
  121014. */
  121015. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121016. private _viewportCached;
  121017. /** @hidden */
  121018. _viewport(x: number, y: number, width: number, height: number): void;
  121019. /**
  121020. * Set the WebGL's viewport
  121021. * @param viewport defines the viewport element to be used
  121022. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121023. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121024. */
  121025. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121026. /**
  121027. * Begin a new frame
  121028. */
  121029. beginFrame(): void;
  121030. /**
  121031. * Enf the current frame
  121032. */
  121033. endFrame(): void;
  121034. /**
  121035. * Resize the view according to the canvas' size
  121036. */
  121037. resize(): void;
  121038. /**
  121039. * Force a specific size of the canvas
  121040. * @param width defines the new canvas' width
  121041. * @param height defines the new canvas' height
  121042. * @returns true if the size was changed
  121043. */
  121044. setSize(width: number, height: number): boolean;
  121045. /**
  121046. * Binds the frame buffer to the specified texture.
  121047. * @param texture The texture to render to or null for the default canvas
  121048. * @param faceIndex The face of the texture to render to in case of cube texture
  121049. * @param requiredWidth The width of the target to render to
  121050. * @param requiredHeight The height of the target to render to
  121051. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121052. * @param lodLevel defines the lod level to bind to the frame buffer
  121053. * @param layer defines the 2d array index to bind to frame buffer to
  121054. */
  121055. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  121056. /** @hidden */
  121057. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  121058. /**
  121059. * Unbind the current render target texture from the webGL context
  121060. * @param texture defines the render target texture to unbind
  121061. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121062. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121063. */
  121064. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121065. /**
  121066. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  121067. */
  121068. flushFramebuffer(): void;
  121069. /**
  121070. * Unbind the current render target and bind the default framebuffer
  121071. */
  121072. restoreDefaultFramebuffer(): void;
  121073. /** @hidden */
  121074. protected _resetVertexBufferBinding(): void;
  121075. /**
  121076. * Creates a vertex buffer
  121077. * @param data the data for the vertex buffer
  121078. * @returns the new WebGL static buffer
  121079. */
  121080. createVertexBuffer(data: DataArray): DataBuffer;
  121081. private _createVertexBuffer;
  121082. /**
  121083. * Creates a dynamic vertex buffer
  121084. * @param data the data for the dynamic vertex buffer
  121085. * @returns the new WebGL dynamic buffer
  121086. */
  121087. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121088. protected _resetIndexBufferBinding(): void;
  121089. /**
  121090. * Creates a new index buffer
  121091. * @param indices defines the content of the index buffer
  121092. * @param updatable defines if the index buffer must be updatable
  121093. * @returns a new webGL buffer
  121094. */
  121095. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  121096. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  121097. /**
  121098. * Bind a webGL buffer to the webGL context
  121099. * @param buffer defines the buffer to bind
  121100. */
  121101. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  121102. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  121103. private bindBuffer;
  121104. /**
  121105. * update the bound buffer with the given data
  121106. * @param data defines the data to update
  121107. */
  121108. updateArrayBuffer(data: Float32Array): void;
  121109. private _vertexAttribPointer;
  121110. /** @hidden */
  121111. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  121112. private _bindVertexBuffersAttributes;
  121113. /**
  121114. * Records a vertex array object
  121115. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121116. * @param vertexBuffers defines the list of vertex buffers to store
  121117. * @param indexBuffer defines the index buffer to store
  121118. * @param effect defines the effect to store
  121119. * @returns the new vertex array object
  121120. */
  121121. recordVertexArrayObject(vertexBuffers: {
  121122. [key: string]: VertexBuffer;
  121123. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  121124. /**
  121125. * Bind a specific vertex array object
  121126. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  121127. * @param vertexArrayObject defines the vertex array object to bind
  121128. * @param indexBuffer defines the index buffer to bind
  121129. */
  121130. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  121131. /**
  121132. * Bind webGl buffers directly to the webGL context
  121133. * @param vertexBuffer defines the vertex buffer to bind
  121134. * @param indexBuffer defines the index buffer to bind
  121135. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121136. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121137. * @param effect defines the effect associated with the vertex buffer
  121138. */
  121139. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  121140. private _unbindVertexArrayObject;
  121141. /**
  121142. * Bind a list of vertex buffers to the webGL context
  121143. * @param vertexBuffers defines the list of vertex buffers to bind
  121144. * @param indexBuffer defines the index buffer to bind
  121145. * @param effect defines the effect associated with the vertex buffers
  121146. */
  121147. bindBuffers(vertexBuffers: {
  121148. [key: string]: Nullable<VertexBuffer>;
  121149. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  121150. /**
  121151. * Unbind all instance attributes
  121152. */
  121153. unbindInstanceAttributes(): void;
  121154. /**
  121155. * Release and free the memory of a vertex array object
  121156. * @param vao defines the vertex array object to delete
  121157. */
  121158. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  121159. /** @hidden */
  121160. _releaseBuffer(buffer: DataBuffer): boolean;
  121161. protected _deleteBuffer(buffer: DataBuffer): void;
  121162. /**
  121163. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  121164. * @param instancesBuffer defines the webGL buffer to update and bind
  121165. * @param data defines the data to store in the buffer
  121166. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  121167. */
  121168. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  121169. /**
  121170. * Bind the content of a webGL buffer used with instantiation
  121171. * @param instancesBuffer defines the webGL buffer to bind
  121172. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  121173. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  121174. */
  121175. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  121176. /**
  121177. * Disable the instance attribute corresponding to the name in parameter
  121178. * @param name defines the name of the attribute to disable
  121179. */
  121180. disableInstanceAttributeByName(name: string): void;
  121181. /**
  121182. * Disable the instance attribute corresponding to the location in parameter
  121183. * @param attributeLocation defines the attribute location of the attribute to disable
  121184. */
  121185. disableInstanceAttribute(attributeLocation: number): void;
  121186. /**
  121187. * Disable the attribute corresponding to the location in parameter
  121188. * @param attributeLocation defines the attribute location of the attribute to disable
  121189. */
  121190. disableAttributeByIndex(attributeLocation: number): void;
  121191. /**
  121192. * Send a draw order
  121193. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121194. * @param indexStart defines the starting index
  121195. * @param indexCount defines the number of index to draw
  121196. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121197. */
  121198. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121199. /**
  121200. * Draw a list of points
  121201. * @param verticesStart defines the index of first vertex to draw
  121202. * @param verticesCount defines the count of vertices to draw
  121203. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121204. */
  121205. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121206. /**
  121207. * Draw a list of unindexed primitives
  121208. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121209. * @param verticesStart defines the index of first vertex to draw
  121210. * @param verticesCount defines the count of vertices to draw
  121211. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121212. */
  121213. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121214. /**
  121215. * Draw a list of indexed primitives
  121216. * @param fillMode defines the primitive to use
  121217. * @param indexStart defines the starting index
  121218. * @param indexCount defines the number of index to draw
  121219. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121220. */
  121221. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121222. /**
  121223. * Draw a list of unindexed primitives
  121224. * @param fillMode defines the primitive to use
  121225. * @param verticesStart defines the index of first vertex to draw
  121226. * @param verticesCount defines the count of vertices to draw
  121227. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121228. */
  121229. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121230. private _drawMode;
  121231. /** @hidden */
  121232. protected _reportDrawCall(): void;
  121233. /** @hidden */
  121234. _releaseEffect(effect: Effect): void;
  121235. /** @hidden */
  121236. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  121237. /**
  121238. * Create a new effect (used to store vertex/fragment shaders)
  121239. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  121240. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  121241. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  121242. * @param samplers defines an array of string used to represent textures
  121243. * @param defines defines the string containing the defines to use to compile the shaders
  121244. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  121245. * @param onCompiled defines a function to call when the effect creation is successful
  121246. * @param onError defines a function to call when the effect creation has failed
  121247. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  121248. * @returns the new Effect
  121249. */
  121250. 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;
  121251. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  121252. private _compileShader;
  121253. private _compileRawShader;
  121254. /** @hidden */
  121255. _getShaderSource(shader: WebGLShader): Nullable<string>;
  121256. /**
  121257. * Directly creates a webGL program
  121258. * @param pipelineContext defines the pipeline context to attach to
  121259. * @param vertexCode defines the vertex shader code to use
  121260. * @param fragmentCode defines the fragment shader code to use
  121261. * @param context defines the webGL context to use (if not set, the current one will be used)
  121262. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121263. * @returns the new webGL program
  121264. */
  121265. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121266. /**
  121267. * Creates a webGL program
  121268. * @param pipelineContext defines the pipeline context to attach to
  121269. * @param vertexCode defines the vertex shader code to use
  121270. * @param fragmentCode defines the fragment shader code to use
  121271. * @param defines defines the string containing the defines to use to compile the shaders
  121272. * @param context defines the webGL context to use (if not set, the current one will be used)
  121273. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  121274. * @returns the new webGL program
  121275. */
  121276. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121277. /**
  121278. * Creates a new pipeline context
  121279. * @returns the new pipeline
  121280. */
  121281. createPipelineContext(): IPipelineContext;
  121282. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  121283. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  121284. /** @hidden */
  121285. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  121286. /** @hidden */
  121287. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  121288. /** @hidden */
  121289. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  121290. /**
  121291. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121292. * @param pipelineContext defines the pipeline context to use
  121293. * @param uniformsNames defines the list of uniform names
  121294. * @returns an array of webGL uniform locations
  121295. */
  121296. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121297. /**
  121298. * Gets the lsit of active attributes for a given webGL program
  121299. * @param pipelineContext defines the pipeline context to use
  121300. * @param attributesNames defines the list of attribute names to get
  121301. * @returns an array of indices indicating the offset of each attribute
  121302. */
  121303. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121304. /**
  121305. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121306. * @param effect defines the effect to activate
  121307. */
  121308. enableEffect(effect: Nullable<Effect>): void;
  121309. /**
  121310. * Set the value of an uniform to a number (int)
  121311. * @param uniform defines the webGL uniform location where to store the value
  121312. * @param value defines the int number to store
  121313. * @returns true if the value was set
  121314. */
  121315. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121316. /**
  121317. * Set the value of an uniform to an array of int32
  121318. * @param uniform defines the webGL uniform location where to store the value
  121319. * @param array defines the array of int32 to store
  121320. * @returns true if the value was set
  121321. */
  121322. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121323. /**
  121324. * Set the value of an uniform to an array of int32 (stored as vec2)
  121325. * @param uniform defines the webGL uniform location where to store the value
  121326. * @param array defines the array of int32 to store
  121327. * @returns true if the value was set
  121328. */
  121329. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121330. /**
  121331. * Set the value of an uniform to an array of int32 (stored as vec3)
  121332. * @param uniform defines the webGL uniform location where to store the value
  121333. * @param array defines the array of int32 to store
  121334. * @returns true if the value was set
  121335. */
  121336. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121337. /**
  121338. * Set the value of an uniform to an array of int32 (stored as vec4)
  121339. * @param uniform defines the webGL uniform location where to store the value
  121340. * @param array defines the array of int32 to store
  121341. * @returns true if the value was set
  121342. */
  121343. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  121344. /**
  121345. * Set the value of an uniform to an array of number
  121346. * @param uniform defines the webGL uniform location where to store the value
  121347. * @param array defines the array of number to store
  121348. * @returns true if the value was set
  121349. */
  121350. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121351. /**
  121352. * Set the value of an uniform to an array of number (stored as vec2)
  121353. * @param uniform defines the webGL uniform location where to store the value
  121354. * @param array defines the array of number to store
  121355. * @returns true if the value was set
  121356. */
  121357. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121358. /**
  121359. * Set the value of an uniform to an array of number (stored as vec3)
  121360. * @param uniform defines the webGL uniform location where to store the value
  121361. * @param array defines the array of number to store
  121362. * @returns true if the value was set
  121363. */
  121364. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121365. /**
  121366. * Set the value of an uniform to an array of number (stored as vec4)
  121367. * @param uniform defines the webGL uniform location where to store the value
  121368. * @param array defines the array of number to store
  121369. * @returns true if the value was set
  121370. */
  121371. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  121372. /**
  121373. * Set the value of an uniform to an array of float32 (stored as matrices)
  121374. * @param uniform defines the webGL uniform location where to store the value
  121375. * @param matrices defines the array of float32 to store
  121376. * @returns true if the value was set
  121377. */
  121378. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  121379. /**
  121380. * Set the value of an uniform to a matrix (3x3)
  121381. * @param uniform defines the webGL uniform location where to store the value
  121382. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121383. * @returns true if the value was set
  121384. */
  121385. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121386. /**
  121387. * Set the value of an uniform to a matrix (2x2)
  121388. * @param uniform defines the webGL uniform location where to store the value
  121389. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121390. * @returns true if the value was set
  121391. */
  121392. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  121393. /**
  121394. * Set the value of an uniform to a number (float)
  121395. * @param uniform defines the webGL uniform location where to store the value
  121396. * @param value defines the float number to store
  121397. * @returns true if the value was transfered
  121398. */
  121399. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  121400. /**
  121401. * Set the value of an uniform to a vec2
  121402. * @param uniform defines the webGL uniform location where to store the value
  121403. * @param x defines the 1st component of the value
  121404. * @param y defines the 2nd component of the value
  121405. * @returns true if the value was set
  121406. */
  121407. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  121408. /**
  121409. * Set the value of an uniform to a vec3
  121410. * @param uniform defines the webGL uniform location where to store the value
  121411. * @param x defines the 1st component of the value
  121412. * @param y defines the 2nd component of the value
  121413. * @param z defines the 3rd component of the value
  121414. * @returns true if the value was set
  121415. */
  121416. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  121417. /**
  121418. * Set the value of an uniform to a vec4
  121419. * @param uniform defines the webGL uniform location where to store the value
  121420. * @param x defines the 1st component of the value
  121421. * @param y defines the 2nd component of the value
  121422. * @param z defines the 3rd component of the value
  121423. * @param w defines the 4th component of the value
  121424. * @returns true if the value was set
  121425. */
  121426. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  121427. /**
  121428. * Apply all cached states (depth, culling, stencil and alpha)
  121429. */
  121430. applyStates(): void;
  121431. /**
  121432. * Enable or disable color writing
  121433. * @param enable defines the state to set
  121434. */
  121435. setColorWrite(enable: boolean): void;
  121436. /**
  121437. * Gets a boolean indicating if color writing is enabled
  121438. * @returns the current color writing state
  121439. */
  121440. getColorWrite(): boolean;
  121441. /**
  121442. * Gets the depth culling state manager
  121443. */
  121444. get depthCullingState(): DepthCullingState;
  121445. /**
  121446. * Gets the alpha state manager
  121447. */
  121448. get alphaState(): AlphaState;
  121449. /**
  121450. * Gets the stencil state manager
  121451. */
  121452. get stencilState(): StencilState;
  121453. /**
  121454. * Clears the list of texture accessible through engine.
  121455. * This can help preventing texture load conflict due to name collision.
  121456. */
  121457. clearInternalTexturesCache(): void;
  121458. /**
  121459. * Force the entire cache to be cleared
  121460. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121461. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121462. */
  121463. wipeCaches(bruteForce?: boolean): void;
  121464. /** @hidden */
  121465. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  121466. min: number;
  121467. mag: number;
  121468. };
  121469. /** @hidden */
  121470. _createTexture(): WebGLTexture;
  121471. /**
  121472. * Usually called from Texture.ts.
  121473. * Passed information to create a WebGLTexture
  121474. * @param url defines a value which contains one of the following:
  121475. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121476. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121477. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121478. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121479. * @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)
  121480. * @param scene needed for loading to the correct scene
  121481. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121482. * @param onLoad optional callback to be called upon successful completion
  121483. * @param onError optional callback to be called upon failure
  121484. * @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
  121485. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121486. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121487. * @param forcedExtension defines the extension to use to pick the right loader
  121488. * @param mimeType defines an optional mime type
  121489. * @param loaderOptions options to be passed to the loader
  121490. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121491. */
  121492. 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, loaderOptions?: any): InternalTexture;
  121493. /**
  121494. * Loads an image as an HTMLImageElement.
  121495. * @param input url string, ArrayBuffer, or Blob to load
  121496. * @param onLoad callback called when the image successfully loads
  121497. * @param onError callback called when the image fails to load
  121498. * @param offlineProvider offline provider for caching
  121499. * @param mimeType optional mime type
  121500. * @returns the HTMLImageElement of the loaded image
  121501. * @hidden
  121502. */
  121503. 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>;
  121504. /**
  121505. * @hidden
  121506. */
  121507. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  121508. private _unpackFlipYCached;
  121509. /**
  121510. * In case you are sharing the context with other applications, it might
  121511. * be interested to not cache the unpack flip y state to ensure a consistent
  121512. * value would be set.
  121513. */
  121514. enableUnpackFlipYCached: boolean;
  121515. /** @hidden */
  121516. _unpackFlipY(value: boolean): void;
  121517. /** @hidden */
  121518. _getUnpackAlignement(): number;
  121519. private _getTextureTarget;
  121520. /**
  121521. * Update the sampling mode of a given texture
  121522. * @param samplingMode defines the required sampling mode
  121523. * @param texture defines the texture to update
  121524. * @param generateMipMaps defines whether to generate mipmaps for the texture
  121525. */
  121526. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  121527. /**
  121528. * Update the sampling mode of a given texture
  121529. * @param texture defines the texture to update
  121530. * @param wrapU defines the texture wrap mode of the u coordinates
  121531. * @param wrapV defines the texture wrap mode of the v coordinates
  121532. * @param wrapR defines the texture wrap mode of the r coordinates
  121533. */
  121534. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  121535. /** @hidden */
  121536. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  121537. width: number;
  121538. height: number;
  121539. layers?: number;
  121540. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  121541. /** @hidden */
  121542. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121543. /** @hidden */
  121544. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  121545. /**
  121546. * Update a portion of an internal texture
  121547. * @param texture defines the texture to update
  121548. * @param imageData defines the data to store into the texture
  121549. * @param xOffset defines the x coordinates of the update rectangle
  121550. * @param yOffset defines the y coordinates of the update rectangle
  121551. * @param width defines the width of the update rectangle
  121552. * @param height defines the height of the update rectangle
  121553. * @param faceIndex defines the face index if texture is a cube (0 by default)
  121554. * @param lod defines the lod level to update (0 by default)
  121555. */
  121556. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  121557. /** @hidden */
  121558. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121559. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  121560. private _prepareWebGLTexture;
  121561. /** @hidden */
  121562. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  121563. private _getDepthStencilBuffer;
  121564. /** @hidden */
  121565. _releaseFramebufferObjects(texture: InternalTexture): void;
  121566. /** @hidden */
  121567. _releaseTexture(texture: InternalTexture): void;
  121568. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121569. protected _setProgram(program: WebGLProgram): void;
  121570. protected _boundUniforms: {
  121571. [key: number]: WebGLUniformLocation;
  121572. };
  121573. /**
  121574. * Binds an effect to the webGL context
  121575. * @param effect defines the effect to bind
  121576. */
  121577. bindSamplers(effect: Effect): void;
  121578. private _activateCurrentTexture;
  121579. /** @hidden */
  121580. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  121581. /** @hidden */
  121582. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  121583. /**
  121584. * Unbind all textures from the webGL context
  121585. */
  121586. unbindAllTextures(): void;
  121587. /**
  121588. * Sets a texture to the according uniform.
  121589. * @param channel The texture channel
  121590. * @param uniform The uniform to set
  121591. * @param texture The texture to apply
  121592. */
  121593. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  121594. private _bindSamplerUniformToChannel;
  121595. private _getTextureWrapMode;
  121596. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121597. /**
  121598. * Sets an array of texture to the webGL context
  121599. * @param channel defines the channel where the texture array must be set
  121600. * @param uniform defines the associated uniform location
  121601. * @param textures defines the array of textures to bind
  121602. */
  121603. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  121604. /** @hidden */
  121605. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  121606. private _setTextureParameterFloat;
  121607. private _setTextureParameterInteger;
  121608. /**
  121609. * Unbind all vertex attributes from the webGL context
  121610. */
  121611. unbindAllAttributes(): void;
  121612. /**
  121613. * 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
  121614. */
  121615. releaseEffects(): void;
  121616. /**
  121617. * Dispose and release all associated resources
  121618. */
  121619. dispose(): void;
  121620. /**
  121621. * Attach a new callback raised when context lost event is fired
  121622. * @param callback defines the callback to call
  121623. */
  121624. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121625. /**
  121626. * Attach a new callback raised when context restored event is fired
  121627. * @param callback defines the callback to call
  121628. */
  121629. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  121630. /**
  121631. * Get the current error code of the webGL context
  121632. * @returns the error code
  121633. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121634. */
  121635. getError(): number;
  121636. private _canRenderToFloatFramebuffer;
  121637. private _canRenderToHalfFloatFramebuffer;
  121638. private _canRenderToFramebuffer;
  121639. /** @hidden */
  121640. _getWebGLTextureType(type: number): number;
  121641. /** @hidden */
  121642. _getInternalFormat(format: number): number;
  121643. /** @hidden */
  121644. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  121645. /** @hidden */
  121646. _getRGBAMultiSampleBufferFormat(type: number): number;
  121647. /** @hidden */
  121648. _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;
  121649. /**
  121650. * Loads a file from a url
  121651. * @param url url to load
  121652. * @param onSuccess callback called when the file successfully loads
  121653. * @param onProgress callback called while file is loading (if the server supports this mode)
  121654. * @param offlineProvider defines the offline provider for caching
  121655. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  121656. * @param onError callback called when the file fails to load
  121657. * @returns a file request object
  121658. * @hidden
  121659. */
  121660. 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;
  121661. /**
  121662. * Reads pixels from the current frame buffer. Please note that this function can be slow
  121663. * @param x defines the x coordinate of the rectangle where pixels must be read
  121664. * @param y defines the y coordinate of the rectangle where pixels must be read
  121665. * @param width defines the width of the rectangle where pixels must be read
  121666. * @param height defines the height of the rectangle where pixels must be read
  121667. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  121668. * @returns a Uint8Array containing RGBA colors
  121669. */
  121670. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  121671. private static _IsSupported;
  121672. private static _HasMajorPerformanceCaveat;
  121673. /**
  121674. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121675. */
  121676. static get IsSupported(): boolean;
  121677. /**
  121678. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  121679. * @returns true if the engine can be created
  121680. * @ignorenaming
  121681. */
  121682. static isSupported(): boolean;
  121683. /**
  121684. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  121685. */
  121686. static get HasMajorPerformanceCaveat(): boolean;
  121687. /**
  121688. * Find the next highest power of two.
  121689. * @param x Number to start search from.
  121690. * @return Next highest power of two.
  121691. */
  121692. static CeilingPOT(x: number): number;
  121693. /**
  121694. * Find the next lowest power of two.
  121695. * @param x Number to start search from.
  121696. * @return Next lowest power of two.
  121697. */
  121698. static FloorPOT(x: number): number;
  121699. /**
  121700. * Find the nearest power of two.
  121701. * @param x Number to start search from.
  121702. * @return Next nearest power of two.
  121703. */
  121704. static NearestPOT(x: number): number;
  121705. /**
  121706. * Get the closest exponent of two
  121707. * @param value defines the value to approximate
  121708. * @param max defines the maximum value to return
  121709. * @param mode defines how to define the closest value
  121710. * @returns closest exponent of two of the given value
  121711. */
  121712. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  121713. /**
  121714. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  121715. * @param func - the function to be called
  121716. * @param requester - the object that will request the next frame. Falls back to window.
  121717. * @returns frame number
  121718. */
  121719. static QueueNewFrame(func: () => void, requester?: any): number;
  121720. /**
  121721. * Gets host document
  121722. * @returns the host document object
  121723. */
  121724. getHostDocument(): Nullable<Document>;
  121725. }
  121726. }
  121727. declare module BABYLON {
  121728. /**
  121729. * Defines the source of the internal texture
  121730. */
  121731. export enum InternalTextureSource {
  121732. /**
  121733. * The source of the texture data is unknown
  121734. */
  121735. Unknown = 0,
  121736. /**
  121737. * Texture data comes from an URL
  121738. */
  121739. Url = 1,
  121740. /**
  121741. * Texture data is only used for temporary storage
  121742. */
  121743. Temp = 2,
  121744. /**
  121745. * Texture data comes from raw data (ArrayBuffer)
  121746. */
  121747. Raw = 3,
  121748. /**
  121749. * Texture content is dynamic (video or dynamic texture)
  121750. */
  121751. Dynamic = 4,
  121752. /**
  121753. * Texture content is generated by rendering to it
  121754. */
  121755. RenderTarget = 5,
  121756. /**
  121757. * Texture content is part of a multi render target process
  121758. */
  121759. MultiRenderTarget = 6,
  121760. /**
  121761. * Texture data comes from a cube data file
  121762. */
  121763. Cube = 7,
  121764. /**
  121765. * Texture data comes from a raw cube data
  121766. */
  121767. CubeRaw = 8,
  121768. /**
  121769. * Texture data come from a prefiltered cube data file
  121770. */
  121771. CubePrefiltered = 9,
  121772. /**
  121773. * Texture content is raw 3D data
  121774. */
  121775. Raw3D = 10,
  121776. /**
  121777. * Texture content is raw 2D array data
  121778. */
  121779. Raw2DArray = 11,
  121780. /**
  121781. * Texture content is a depth texture
  121782. */
  121783. Depth = 12,
  121784. /**
  121785. * Texture data comes from a raw cube data encoded with RGBD
  121786. */
  121787. CubeRawRGBD = 13
  121788. }
  121789. /**
  121790. * Class used to store data associated with WebGL texture data for the engine
  121791. * This class should not be used directly
  121792. */
  121793. export class InternalTexture {
  121794. /** @hidden */
  121795. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121796. /**
  121797. * Defines if the texture is ready
  121798. */
  121799. isReady: boolean;
  121800. /**
  121801. * Defines if the texture is a cube texture
  121802. */
  121803. isCube: boolean;
  121804. /**
  121805. * Defines if the texture contains 3D data
  121806. */
  121807. is3D: boolean;
  121808. /**
  121809. * Defines if the texture contains 2D array data
  121810. */
  121811. is2DArray: boolean;
  121812. /**
  121813. * Defines if the texture contains multiview data
  121814. */
  121815. isMultiview: boolean;
  121816. /**
  121817. * Gets the URL used to load this texture
  121818. */
  121819. url: string;
  121820. /** @hidden */
  121821. _originalUrl: string;
  121822. /**
  121823. * Gets the sampling mode of the texture
  121824. */
  121825. samplingMode: number;
  121826. /**
  121827. * Gets a boolean indicating if the texture needs mipmaps generation
  121828. */
  121829. generateMipMaps: boolean;
  121830. /**
  121831. * Gets the number of samples used by the texture (WebGL2+ only)
  121832. */
  121833. samples: number;
  121834. /**
  121835. * Gets the type of the texture (int, float...)
  121836. */
  121837. type: number;
  121838. /**
  121839. * Gets the format of the texture (RGB, RGBA...)
  121840. */
  121841. format: number;
  121842. /**
  121843. * Observable called when the texture is loaded
  121844. */
  121845. onLoadedObservable: Observable<InternalTexture>;
  121846. /**
  121847. * Gets the width of the texture
  121848. */
  121849. width: number;
  121850. /**
  121851. * Gets the height of the texture
  121852. */
  121853. height: number;
  121854. /**
  121855. * Gets the depth of the texture
  121856. */
  121857. depth: number;
  121858. /**
  121859. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121860. */
  121861. baseWidth: number;
  121862. /**
  121863. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121864. */
  121865. baseHeight: number;
  121866. /**
  121867. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121868. */
  121869. baseDepth: number;
  121870. /**
  121871. * Gets a boolean indicating if the texture is inverted on Y axis
  121872. */
  121873. invertY: boolean;
  121874. /** @hidden */
  121875. _invertVScale: boolean;
  121876. /** @hidden */
  121877. _associatedChannel: number;
  121878. /** @hidden */
  121879. _source: InternalTextureSource;
  121880. /** @hidden */
  121881. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121882. /** @hidden */
  121883. _bufferView: Nullable<ArrayBufferView>;
  121884. /** @hidden */
  121885. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121886. /** @hidden */
  121887. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121888. /** @hidden */
  121889. _size: number;
  121890. /** @hidden */
  121891. _extension: string;
  121892. /** @hidden */
  121893. _files: Nullable<string[]>;
  121894. /** @hidden */
  121895. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121896. /** @hidden */
  121897. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121898. /** @hidden */
  121899. _framebuffer: Nullable<WebGLFramebuffer>;
  121900. /** @hidden */
  121901. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121902. /** @hidden */
  121903. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121904. /** @hidden */
  121905. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121906. /** @hidden */
  121907. _attachments: Nullable<number[]>;
  121908. /** @hidden */
  121909. _textureArray: Nullable<InternalTexture[]>;
  121910. /** @hidden */
  121911. _cachedCoordinatesMode: Nullable<number>;
  121912. /** @hidden */
  121913. _cachedWrapU: Nullable<number>;
  121914. /** @hidden */
  121915. _cachedWrapV: Nullable<number>;
  121916. /** @hidden */
  121917. _cachedWrapR: Nullable<number>;
  121918. /** @hidden */
  121919. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121920. /** @hidden */
  121921. _isDisabled: boolean;
  121922. /** @hidden */
  121923. _compression: Nullable<string>;
  121924. /** @hidden */
  121925. _generateStencilBuffer: boolean;
  121926. /** @hidden */
  121927. _generateDepthBuffer: boolean;
  121928. /** @hidden */
  121929. _comparisonFunction: number;
  121930. /** @hidden */
  121931. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121932. /** @hidden */
  121933. _lodGenerationScale: number;
  121934. /** @hidden */
  121935. _lodGenerationOffset: number;
  121936. /** @hidden */
  121937. _depthStencilTexture: Nullable<InternalTexture>;
  121938. /** @hidden */
  121939. _colorTextureArray: Nullable<WebGLTexture>;
  121940. /** @hidden */
  121941. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121942. /** @hidden */
  121943. _lodTextureHigh: Nullable<BaseTexture>;
  121944. /** @hidden */
  121945. _lodTextureMid: Nullable<BaseTexture>;
  121946. /** @hidden */
  121947. _lodTextureLow: Nullable<BaseTexture>;
  121948. /** @hidden */
  121949. _isRGBD: boolean;
  121950. /** @hidden */
  121951. _linearSpecularLOD: boolean;
  121952. /** @hidden */
  121953. _irradianceTexture: Nullable<BaseTexture>;
  121954. /** @hidden */
  121955. _webGLTexture: Nullable<WebGLTexture>;
  121956. /** @hidden */
  121957. _references: number;
  121958. /** @hidden */
  121959. _gammaSpace: Nullable<boolean>;
  121960. private _engine;
  121961. /**
  121962. * Gets the Engine the texture belongs to.
  121963. * @returns The babylon engine
  121964. */
  121965. getEngine(): ThinEngine;
  121966. /**
  121967. * Gets the data source type of the texture
  121968. */
  121969. get source(): InternalTextureSource;
  121970. /**
  121971. * Creates a new InternalTexture
  121972. * @param engine defines the engine to use
  121973. * @param source defines the type of data that will be used
  121974. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121975. */
  121976. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121977. /**
  121978. * Increments the number of references (ie. the number of Texture that point to it)
  121979. */
  121980. incrementReferences(): void;
  121981. /**
  121982. * Change the size of the texture (not the size of the content)
  121983. * @param width defines the new width
  121984. * @param height defines the new height
  121985. * @param depth defines the new depth (1 by default)
  121986. */
  121987. updateSize(width: int, height: int, depth?: int): void;
  121988. /** @hidden */
  121989. _rebuild(): void;
  121990. /** @hidden */
  121991. _swapAndDie(target: InternalTexture): void;
  121992. /**
  121993. * Dispose the current allocated resources
  121994. */
  121995. dispose(): void;
  121996. }
  121997. }
  121998. declare module BABYLON {
  121999. /**
  122000. * Interface used to present a loading screen while loading a scene
  122001. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122002. */
  122003. export interface ILoadingScreen {
  122004. /**
  122005. * Function called to display the loading screen
  122006. */
  122007. displayLoadingUI: () => void;
  122008. /**
  122009. * Function called to hide the loading screen
  122010. */
  122011. hideLoadingUI: () => void;
  122012. /**
  122013. * Gets or sets the color to use for the background
  122014. */
  122015. loadingUIBackgroundColor: string;
  122016. /**
  122017. * Gets or sets the text to display while loading
  122018. */
  122019. loadingUIText: string;
  122020. }
  122021. /**
  122022. * Class used for the default loading screen
  122023. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122024. */
  122025. export class DefaultLoadingScreen implements ILoadingScreen {
  122026. private _renderingCanvas;
  122027. private _loadingText;
  122028. private _loadingDivBackgroundColor;
  122029. private _loadingDiv;
  122030. private _loadingTextDiv;
  122031. /** Gets or sets the logo url to use for the default loading screen */
  122032. static DefaultLogoUrl: string;
  122033. /** Gets or sets the spinner url to use for the default loading screen */
  122034. static DefaultSpinnerUrl: string;
  122035. /**
  122036. * Creates a new default loading screen
  122037. * @param _renderingCanvas defines the canvas used to render the scene
  122038. * @param _loadingText defines the default text to display
  122039. * @param _loadingDivBackgroundColor defines the default background color
  122040. */
  122041. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  122042. /**
  122043. * Function called to display the loading screen
  122044. */
  122045. displayLoadingUI(): void;
  122046. /**
  122047. * Function called to hide the loading screen
  122048. */
  122049. hideLoadingUI(): void;
  122050. /**
  122051. * Gets or sets the text to display while loading
  122052. */
  122053. set loadingUIText(text: string);
  122054. get loadingUIText(): string;
  122055. /**
  122056. * Gets or sets the color to use for the background
  122057. */
  122058. get loadingUIBackgroundColor(): string;
  122059. set loadingUIBackgroundColor(color: string);
  122060. private _resizeLoadingUI;
  122061. }
  122062. }
  122063. declare module BABYLON {
  122064. /**
  122065. * Interface for any object that can request an animation frame
  122066. */
  122067. export interface ICustomAnimationFrameRequester {
  122068. /**
  122069. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  122070. */
  122071. renderFunction?: Function;
  122072. /**
  122073. * Called to request the next frame to render to
  122074. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  122075. */
  122076. requestAnimationFrame: Function;
  122077. /**
  122078. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  122079. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  122080. */
  122081. requestID?: number;
  122082. }
  122083. }
  122084. declare module BABYLON {
  122085. /**
  122086. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  122087. */
  122088. export class PerformanceMonitor {
  122089. private _enabled;
  122090. private _rollingFrameTime;
  122091. private _lastFrameTimeMs;
  122092. /**
  122093. * constructor
  122094. * @param frameSampleSize The number of samples required to saturate the sliding window
  122095. */
  122096. constructor(frameSampleSize?: number);
  122097. /**
  122098. * Samples current frame
  122099. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  122100. */
  122101. sampleFrame(timeMs?: number): void;
  122102. /**
  122103. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  122104. */
  122105. get averageFrameTime(): number;
  122106. /**
  122107. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  122108. */
  122109. get averageFrameTimeVariance(): number;
  122110. /**
  122111. * Returns the frame time of the most recent frame
  122112. */
  122113. get instantaneousFrameTime(): number;
  122114. /**
  122115. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  122116. */
  122117. get averageFPS(): number;
  122118. /**
  122119. * Returns the average framerate in frames per second using the most recent frame time
  122120. */
  122121. get instantaneousFPS(): number;
  122122. /**
  122123. * Returns true if enough samples have been taken to completely fill the sliding window
  122124. */
  122125. get isSaturated(): boolean;
  122126. /**
  122127. * Enables contributions to the sliding window sample set
  122128. */
  122129. enable(): void;
  122130. /**
  122131. * Disables contributions to the sliding window sample set
  122132. * Samples will not be interpolated over the disabled period
  122133. */
  122134. disable(): void;
  122135. /**
  122136. * Returns true if sampling is enabled
  122137. */
  122138. get isEnabled(): boolean;
  122139. /**
  122140. * Resets performance monitor
  122141. */
  122142. reset(): void;
  122143. }
  122144. /**
  122145. * RollingAverage
  122146. *
  122147. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  122148. */
  122149. export class RollingAverage {
  122150. /**
  122151. * Current average
  122152. */
  122153. average: number;
  122154. /**
  122155. * Current variance
  122156. */
  122157. variance: number;
  122158. protected _samples: Array<number>;
  122159. protected _sampleCount: number;
  122160. protected _pos: number;
  122161. protected _m2: number;
  122162. /**
  122163. * constructor
  122164. * @param length The number of samples required to saturate the sliding window
  122165. */
  122166. constructor(length: number);
  122167. /**
  122168. * Adds a sample to the sample set
  122169. * @param v The sample value
  122170. */
  122171. add(v: number): void;
  122172. /**
  122173. * Returns previously added values or null if outside of history or outside the sliding window domain
  122174. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  122175. * @return Value previously recorded with add() or null if outside of range
  122176. */
  122177. history(i: number): number;
  122178. /**
  122179. * Returns true if enough samples have been taken to completely fill the sliding window
  122180. * @return true if sample-set saturated
  122181. */
  122182. isSaturated(): boolean;
  122183. /**
  122184. * Resets the rolling average (equivalent to 0 samples taken so far)
  122185. */
  122186. reset(): void;
  122187. /**
  122188. * Wraps a value around the sample range boundaries
  122189. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  122190. * @return Wrapped position in sample range
  122191. */
  122192. protected _wrapPosition(i: number): number;
  122193. }
  122194. }
  122195. declare module BABYLON {
  122196. /**
  122197. * This class is used to track a performance counter which is number based.
  122198. * The user has access to many properties which give statistics of different nature.
  122199. *
  122200. * The implementer can track two kinds of Performance Counter: time and count.
  122201. * 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.
  122202. * 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.
  122203. */
  122204. export class PerfCounter {
  122205. /**
  122206. * Gets or sets a global boolean to turn on and off all the counters
  122207. */
  122208. static Enabled: boolean;
  122209. /**
  122210. * Returns the smallest value ever
  122211. */
  122212. get min(): number;
  122213. /**
  122214. * Returns the biggest value ever
  122215. */
  122216. get max(): number;
  122217. /**
  122218. * Returns the average value since the performance counter is running
  122219. */
  122220. get average(): number;
  122221. /**
  122222. * Returns the average value of the last second the counter was monitored
  122223. */
  122224. get lastSecAverage(): number;
  122225. /**
  122226. * Returns the current value
  122227. */
  122228. get current(): number;
  122229. /**
  122230. * Gets the accumulated total
  122231. */
  122232. get total(): number;
  122233. /**
  122234. * Gets the total value count
  122235. */
  122236. get count(): number;
  122237. /**
  122238. * Creates a new counter
  122239. */
  122240. constructor();
  122241. /**
  122242. * Call this method to start monitoring a new frame.
  122243. * 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.
  122244. */
  122245. fetchNewFrame(): void;
  122246. /**
  122247. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  122248. * @param newCount the count value to add to the monitored count
  122249. * @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.
  122250. */
  122251. addCount(newCount: number, fetchResult: boolean): void;
  122252. /**
  122253. * Start monitoring this performance counter
  122254. */
  122255. beginMonitoring(): void;
  122256. /**
  122257. * Compute the time lapsed since the previous beginMonitoring() call.
  122258. * @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
  122259. */
  122260. endMonitoring(newFrame?: boolean): void;
  122261. private _fetchResult;
  122262. private _startMonitoringTime;
  122263. private _min;
  122264. private _max;
  122265. private _average;
  122266. private _current;
  122267. private _totalValueCount;
  122268. private _totalAccumulated;
  122269. private _lastSecAverage;
  122270. private _lastSecAccumulated;
  122271. private _lastSecTime;
  122272. private _lastSecValueCount;
  122273. }
  122274. }
  122275. declare module BABYLON {
  122276. interface ThinEngine {
  122277. /** @hidden */
  122278. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  122279. }
  122280. }
  122281. declare module BABYLON {
  122282. /**
  122283. * Class used to work with sound analyzer using fast fourier transform (FFT)
  122284. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122285. */
  122286. export class Analyser {
  122287. /**
  122288. * Gets or sets the smoothing
  122289. * @ignorenaming
  122290. */
  122291. SMOOTHING: number;
  122292. /**
  122293. * Gets or sets the FFT table size
  122294. * @ignorenaming
  122295. */
  122296. FFT_SIZE: number;
  122297. /**
  122298. * Gets or sets the bar graph amplitude
  122299. * @ignorenaming
  122300. */
  122301. BARGRAPHAMPLITUDE: number;
  122302. /**
  122303. * Gets or sets the position of the debug canvas
  122304. * @ignorenaming
  122305. */
  122306. DEBUGCANVASPOS: {
  122307. x: number;
  122308. y: number;
  122309. };
  122310. /**
  122311. * Gets or sets the debug canvas size
  122312. * @ignorenaming
  122313. */
  122314. DEBUGCANVASSIZE: {
  122315. width: number;
  122316. height: number;
  122317. };
  122318. private _byteFreqs;
  122319. private _byteTime;
  122320. private _floatFreqs;
  122321. private _webAudioAnalyser;
  122322. private _debugCanvas;
  122323. private _debugCanvasContext;
  122324. private _scene;
  122325. private _registerFunc;
  122326. private _audioEngine;
  122327. /**
  122328. * Creates a new analyser
  122329. * @param scene defines hosting scene
  122330. */
  122331. constructor(scene: Scene);
  122332. /**
  122333. * Get the number of data values you will have to play with for the visualization
  122334. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  122335. * @returns a number
  122336. */
  122337. getFrequencyBinCount(): number;
  122338. /**
  122339. * Gets the current frequency data as a byte array
  122340. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122341. * @returns a Uint8Array
  122342. */
  122343. getByteFrequencyData(): Uint8Array;
  122344. /**
  122345. * Gets the current waveform as a byte array
  122346. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  122347. * @returns a Uint8Array
  122348. */
  122349. getByteTimeDomainData(): Uint8Array;
  122350. /**
  122351. * Gets the current frequency data as a float array
  122352. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  122353. * @returns a Float32Array
  122354. */
  122355. getFloatFrequencyData(): Float32Array;
  122356. /**
  122357. * Renders the debug canvas
  122358. */
  122359. drawDebugCanvas(): void;
  122360. /**
  122361. * Stops rendering the debug canvas and removes it
  122362. */
  122363. stopDebugCanvas(): void;
  122364. /**
  122365. * Connects two audio nodes
  122366. * @param inputAudioNode defines first node to connect
  122367. * @param outputAudioNode defines second node to connect
  122368. */
  122369. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  122370. /**
  122371. * Releases all associated resources
  122372. */
  122373. dispose(): void;
  122374. }
  122375. }
  122376. declare module BABYLON {
  122377. /**
  122378. * This represents an audio engine and it is responsible
  122379. * to play, synchronize and analyse sounds throughout the application.
  122380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122381. */
  122382. export interface IAudioEngine extends IDisposable {
  122383. /**
  122384. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  122385. */
  122386. readonly canUseWebAudio: boolean;
  122387. /**
  122388. * Gets the current AudioContext if available.
  122389. */
  122390. readonly audioContext: Nullable<AudioContext>;
  122391. /**
  122392. * The master gain node defines the global audio volume of your audio engine.
  122393. */
  122394. readonly masterGain: GainNode;
  122395. /**
  122396. * Gets whether or not mp3 are supported by your browser.
  122397. */
  122398. readonly isMP3supported: boolean;
  122399. /**
  122400. * Gets whether or not ogg are supported by your browser.
  122401. */
  122402. readonly isOGGsupported: boolean;
  122403. /**
  122404. * Defines if Babylon should emit a warning if WebAudio is not supported.
  122405. * @ignoreNaming
  122406. */
  122407. WarnedWebAudioUnsupported: boolean;
  122408. /**
  122409. * Defines if the audio engine relies on a custom unlocked button.
  122410. * In this case, the embedded button will not be displayed.
  122411. */
  122412. useCustomUnlockedButton: boolean;
  122413. /**
  122414. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  122415. */
  122416. readonly unlocked: boolean;
  122417. /**
  122418. * Event raised when audio has been unlocked on the browser.
  122419. */
  122420. onAudioUnlockedObservable: Observable<IAudioEngine>;
  122421. /**
  122422. * Event raised when audio has been locked on the browser.
  122423. */
  122424. onAudioLockedObservable: Observable<IAudioEngine>;
  122425. /**
  122426. * Flags the audio engine in Locked state.
  122427. * This happens due to new browser policies preventing audio to autoplay.
  122428. */
  122429. lock(): void;
  122430. /**
  122431. * Unlocks the audio engine once a user action has been done on the dom.
  122432. * This is helpful to resume play once browser policies have been satisfied.
  122433. */
  122434. unlock(): void;
  122435. /**
  122436. * Gets the global volume sets on the master gain.
  122437. * @returns the global volume if set or -1 otherwise
  122438. */
  122439. getGlobalVolume(): number;
  122440. /**
  122441. * Sets the global volume of your experience (sets on the master gain).
  122442. * @param newVolume Defines the new global volume of the application
  122443. */
  122444. setGlobalVolume(newVolume: number): void;
  122445. /**
  122446. * Connect the audio engine to an audio analyser allowing some amazing
  122447. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122448. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122449. * @param analyser The analyser to connect to the engine
  122450. */
  122451. connectToAnalyser(analyser: Analyser): void;
  122452. }
  122453. }
  122454. declare module BABYLON {
  122455. /**
  122456. * Defines the interface used by display changed events
  122457. */
  122458. export interface IDisplayChangedEventArgs {
  122459. /** Gets the vrDisplay object (if any) */
  122460. vrDisplay: Nullable<any>;
  122461. /** Gets a boolean indicating if webVR is supported */
  122462. vrSupported: boolean;
  122463. }
  122464. /**
  122465. * Defines the interface used by objects containing a viewport (like a camera)
  122466. */
  122467. interface IViewportOwnerLike {
  122468. /**
  122469. * Gets or sets the viewport
  122470. */
  122471. viewport: IViewportLike;
  122472. }
  122473. /**
  122474. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  122475. */
  122476. export class Engine extends ThinEngine {
  122477. /** Defines that alpha blending is disabled */
  122478. static readonly ALPHA_DISABLE: number;
  122479. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  122480. static readonly ALPHA_ADD: number;
  122481. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  122482. static readonly ALPHA_COMBINE: number;
  122483. /** Defines that alpha blending to DEST - SRC * DEST */
  122484. static readonly ALPHA_SUBTRACT: number;
  122485. /** Defines that alpha blending to SRC * DEST */
  122486. static readonly ALPHA_MULTIPLY: number;
  122487. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  122488. static readonly ALPHA_MAXIMIZED: number;
  122489. /** Defines that alpha blending to SRC + DEST */
  122490. static readonly ALPHA_ONEONE: number;
  122491. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  122492. static readonly ALPHA_PREMULTIPLIED: number;
  122493. /**
  122494. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  122495. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  122496. */
  122497. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  122498. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  122499. static readonly ALPHA_INTERPOLATE: number;
  122500. /**
  122501. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  122502. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  122503. */
  122504. static readonly ALPHA_SCREENMODE: number;
  122505. /** Defines that the ressource is not delayed*/
  122506. static readonly DELAYLOADSTATE_NONE: number;
  122507. /** Defines that the ressource was successfully delay loaded */
  122508. static readonly DELAYLOADSTATE_LOADED: number;
  122509. /** Defines that the ressource is currently delay loading */
  122510. static readonly DELAYLOADSTATE_LOADING: number;
  122511. /** Defines that the ressource is delayed and has not started loading */
  122512. static readonly DELAYLOADSTATE_NOTLOADED: number;
  122513. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  122514. static readonly NEVER: number;
  122515. /** 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 */
  122516. static readonly ALWAYS: number;
  122517. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  122518. static readonly LESS: number;
  122519. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  122520. static readonly EQUAL: number;
  122521. /** 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 */
  122522. static readonly LEQUAL: number;
  122523. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  122524. static readonly GREATER: number;
  122525. /** 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 */
  122526. static readonly GEQUAL: number;
  122527. /** 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 */
  122528. static readonly NOTEQUAL: number;
  122529. /** Passed to stencilOperation to specify that stencil value must be kept */
  122530. static readonly KEEP: number;
  122531. /** Passed to stencilOperation to specify that stencil value must be replaced */
  122532. static readonly REPLACE: number;
  122533. /** Passed to stencilOperation to specify that stencil value must be incremented */
  122534. static readonly INCR: number;
  122535. /** Passed to stencilOperation to specify that stencil value must be decremented */
  122536. static readonly DECR: number;
  122537. /** Passed to stencilOperation to specify that stencil value must be inverted */
  122538. static readonly INVERT: number;
  122539. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  122540. static readonly INCR_WRAP: number;
  122541. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  122542. static readonly DECR_WRAP: number;
  122543. /** Texture is not repeating outside of 0..1 UVs */
  122544. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  122545. /** Texture is repeating outside of 0..1 UVs */
  122546. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  122547. /** Texture is repeating and mirrored */
  122548. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  122549. /** ALPHA */
  122550. static readonly TEXTUREFORMAT_ALPHA: number;
  122551. /** LUMINANCE */
  122552. static readonly TEXTUREFORMAT_LUMINANCE: number;
  122553. /** LUMINANCE_ALPHA */
  122554. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  122555. /** RGB */
  122556. static readonly TEXTUREFORMAT_RGB: number;
  122557. /** RGBA */
  122558. static readonly TEXTUREFORMAT_RGBA: number;
  122559. /** RED */
  122560. static readonly TEXTUREFORMAT_RED: number;
  122561. /** RED (2nd reference) */
  122562. static readonly TEXTUREFORMAT_R: number;
  122563. /** RG */
  122564. static readonly TEXTUREFORMAT_RG: number;
  122565. /** RED_INTEGER */
  122566. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  122567. /** RED_INTEGER (2nd reference) */
  122568. static readonly TEXTUREFORMAT_R_INTEGER: number;
  122569. /** RG_INTEGER */
  122570. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  122571. /** RGB_INTEGER */
  122572. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  122573. /** RGBA_INTEGER */
  122574. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  122575. /** UNSIGNED_BYTE */
  122576. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  122577. /** UNSIGNED_BYTE (2nd reference) */
  122578. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  122579. /** FLOAT */
  122580. static readonly TEXTURETYPE_FLOAT: number;
  122581. /** HALF_FLOAT */
  122582. static readonly TEXTURETYPE_HALF_FLOAT: number;
  122583. /** BYTE */
  122584. static readonly TEXTURETYPE_BYTE: number;
  122585. /** SHORT */
  122586. static readonly TEXTURETYPE_SHORT: number;
  122587. /** UNSIGNED_SHORT */
  122588. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  122589. /** INT */
  122590. static readonly TEXTURETYPE_INT: number;
  122591. /** UNSIGNED_INT */
  122592. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  122593. /** UNSIGNED_SHORT_4_4_4_4 */
  122594. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  122595. /** UNSIGNED_SHORT_5_5_5_1 */
  122596. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  122597. /** UNSIGNED_SHORT_5_6_5 */
  122598. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  122599. /** UNSIGNED_INT_2_10_10_10_REV */
  122600. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  122601. /** UNSIGNED_INT_24_8 */
  122602. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  122603. /** UNSIGNED_INT_10F_11F_11F_REV */
  122604. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  122605. /** UNSIGNED_INT_5_9_9_9_REV */
  122606. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  122607. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  122608. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122609. /** nearest is mag = nearest and min = nearest and mip = linear */
  122610. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  122611. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122612. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  122613. /** Trilinear is mag = linear and min = linear and mip = linear */
  122614. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  122615. /** nearest is mag = nearest and min = nearest and mip = linear */
  122616. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  122617. /** Bilinear is mag = linear and min = linear and mip = nearest */
  122618. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  122619. /** Trilinear is mag = linear and min = linear and mip = linear */
  122620. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  122621. /** mag = nearest and min = nearest and mip = nearest */
  122622. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  122623. /** mag = nearest and min = linear and mip = nearest */
  122624. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  122625. /** mag = nearest and min = linear and mip = linear */
  122626. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  122627. /** mag = nearest and min = linear and mip = none */
  122628. static readonly TEXTURE_NEAREST_LINEAR: number;
  122629. /** mag = nearest and min = nearest and mip = none */
  122630. static readonly TEXTURE_NEAREST_NEAREST: number;
  122631. /** mag = linear and min = nearest and mip = nearest */
  122632. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  122633. /** mag = linear and min = nearest and mip = linear */
  122634. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  122635. /** mag = linear and min = linear and mip = none */
  122636. static readonly TEXTURE_LINEAR_LINEAR: number;
  122637. /** mag = linear and min = nearest and mip = none */
  122638. static readonly TEXTURE_LINEAR_NEAREST: number;
  122639. /** Explicit coordinates mode */
  122640. static readonly TEXTURE_EXPLICIT_MODE: number;
  122641. /** Spherical coordinates mode */
  122642. static readonly TEXTURE_SPHERICAL_MODE: number;
  122643. /** Planar coordinates mode */
  122644. static readonly TEXTURE_PLANAR_MODE: number;
  122645. /** Cubic coordinates mode */
  122646. static readonly TEXTURE_CUBIC_MODE: number;
  122647. /** Projection coordinates mode */
  122648. static readonly TEXTURE_PROJECTION_MODE: number;
  122649. /** Skybox coordinates mode */
  122650. static readonly TEXTURE_SKYBOX_MODE: number;
  122651. /** Inverse Cubic coordinates mode */
  122652. static readonly TEXTURE_INVCUBIC_MODE: number;
  122653. /** Equirectangular coordinates mode */
  122654. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  122655. /** Equirectangular Fixed coordinates mode */
  122656. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  122657. /** Equirectangular Fixed Mirrored coordinates mode */
  122658. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  122659. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  122660. static readonly SCALEMODE_FLOOR: number;
  122661. /** Defines that texture rescaling will look for the nearest power of 2 size */
  122662. static readonly SCALEMODE_NEAREST: number;
  122663. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  122664. static readonly SCALEMODE_CEILING: number;
  122665. /**
  122666. * Returns the current npm package of the sdk
  122667. */
  122668. static get NpmPackage(): string;
  122669. /**
  122670. * Returns the current version of the framework
  122671. */
  122672. static get Version(): string;
  122673. /** Gets the list of created engines */
  122674. static get Instances(): Engine[];
  122675. /**
  122676. * Gets the latest created engine
  122677. */
  122678. static get LastCreatedEngine(): Nullable<Engine>;
  122679. /**
  122680. * Gets the latest created scene
  122681. */
  122682. static get LastCreatedScene(): Nullable<Scene>;
  122683. /**
  122684. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122685. * @param flag defines which part of the materials must be marked as dirty
  122686. * @param predicate defines a predicate used to filter which materials should be affected
  122687. */
  122688. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122689. /**
  122690. * Method called to create the default loading screen.
  122691. * This can be overriden in your own app.
  122692. * @param canvas The rendering canvas element
  122693. * @returns The loading screen
  122694. */
  122695. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122696. /**
  122697. * Method called to create the default rescale post process on each engine.
  122698. */
  122699. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122700. /**
  122701. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122702. **/
  122703. enableOfflineSupport: boolean;
  122704. /**
  122705. * 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)
  122706. **/
  122707. disableManifestCheck: boolean;
  122708. /**
  122709. * Gets the list of created scenes
  122710. */
  122711. scenes: Scene[];
  122712. /**
  122713. * Event raised when a new scene is created
  122714. */
  122715. onNewSceneAddedObservable: Observable<Scene>;
  122716. /**
  122717. * Gets the list of created postprocesses
  122718. */
  122719. postProcesses: PostProcess[];
  122720. /**
  122721. * Gets a boolean indicating if the pointer is currently locked
  122722. */
  122723. isPointerLock: boolean;
  122724. /**
  122725. * Observable event triggered each time the rendering canvas is resized
  122726. */
  122727. onResizeObservable: Observable<Engine>;
  122728. /**
  122729. * Observable event triggered each time the canvas loses focus
  122730. */
  122731. onCanvasBlurObservable: Observable<Engine>;
  122732. /**
  122733. * Observable event triggered each time the canvas gains focus
  122734. */
  122735. onCanvasFocusObservable: Observable<Engine>;
  122736. /**
  122737. * Observable event triggered each time the canvas receives pointerout event
  122738. */
  122739. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122740. /**
  122741. * Observable raised when the engine begins a new frame
  122742. */
  122743. onBeginFrameObservable: Observable<Engine>;
  122744. /**
  122745. * If set, will be used to request the next animation frame for the render loop
  122746. */
  122747. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122748. /**
  122749. * Observable raised when the engine ends the current frame
  122750. */
  122751. onEndFrameObservable: Observable<Engine>;
  122752. /**
  122753. * Observable raised when the engine is about to compile a shader
  122754. */
  122755. onBeforeShaderCompilationObservable: Observable<Engine>;
  122756. /**
  122757. * Observable raised when the engine has jsut compiled a shader
  122758. */
  122759. onAfterShaderCompilationObservable: Observable<Engine>;
  122760. /**
  122761. * Gets the audio engine
  122762. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122763. * @ignorenaming
  122764. */
  122765. static audioEngine: IAudioEngine;
  122766. /**
  122767. * Default AudioEngine factory responsible of creating the Audio Engine.
  122768. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122769. */
  122770. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122771. /**
  122772. * Default offline support factory responsible of creating a tool used to store data locally.
  122773. * By default, this will create a Database object if the workload has been embedded.
  122774. */
  122775. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122776. private _loadingScreen;
  122777. private _pointerLockRequested;
  122778. private _rescalePostProcess;
  122779. private _deterministicLockstep;
  122780. private _lockstepMaxSteps;
  122781. private _timeStep;
  122782. protected get _supportsHardwareTextureRescaling(): boolean;
  122783. private _fps;
  122784. private _deltaTime;
  122785. /** @hidden */
  122786. _drawCalls: PerfCounter;
  122787. /** 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 */
  122788. canvasTabIndex: number;
  122789. /**
  122790. * Turn this value on if you want to pause FPS computation when in background
  122791. */
  122792. disablePerformanceMonitorInBackground: boolean;
  122793. private _performanceMonitor;
  122794. /**
  122795. * Gets the performance monitor attached to this engine
  122796. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122797. */
  122798. get performanceMonitor(): PerformanceMonitor;
  122799. private _onFocus;
  122800. private _onBlur;
  122801. private _onCanvasPointerOut;
  122802. private _onCanvasBlur;
  122803. private _onCanvasFocus;
  122804. private _onFullscreenChange;
  122805. private _onPointerLockChange;
  122806. /**
  122807. * Gets the HTML element used to attach event listeners
  122808. * @returns a HTML element
  122809. */
  122810. getInputElement(): Nullable<HTMLElement>;
  122811. /**
  122812. * Creates a new engine
  122813. * @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
  122814. * @param antialias defines enable antialiasing (default: false)
  122815. * @param options defines further options to be sent to the getContext() function
  122816. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122817. */
  122818. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122819. /**
  122820. * Gets current aspect ratio
  122821. * @param viewportOwner defines the camera to use to get the aspect ratio
  122822. * @param useScreen defines if screen size must be used (or the current render target if any)
  122823. * @returns a number defining the aspect ratio
  122824. */
  122825. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122826. /**
  122827. * Gets current screen aspect ratio
  122828. * @returns a number defining the aspect ratio
  122829. */
  122830. getScreenAspectRatio(): number;
  122831. /**
  122832. * Gets the client rect of the HTML canvas attached with the current webGL context
  122833. * @returns a client rectanglee
  122834. */
  122835. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122836. /**
  122837. * Gets the client rect of the HTML element used for events
  122838. * @returns a client rectanglee
  122839. */
  122840. getInputElementClientRect(): Nullable<ClientRect>;
  122841. /**
  122842. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122843. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122844. * @returns true if engine is in deterministic lock step mode
  122845. */
  122846. isDeterministicLockStep(): boolean;
  122847. /**
  122848. * Gets the max steps when engine is running in deterministic lock step
  122849. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122850. * @returns the max steps
  122851. */
  122852. getLockstepMaxSteps(): number;
  122853. /**
  122854. * Returns the time in ms between steps when using deterministic lock step.
  122855. * @returns time step in (ms)
  122856. */
  122857. getTimeStep(): number;
  122858. /**
  122859. * Force the mipmap generation for the given render target texture
  122860. * @param texture defines the render target texture to use
  122861. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122862. */
  122863. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122864. /** States */
  122865. /**
  122866. * Set various states to the webGL context
  122867. * @param culling defines backface culling state
  122868. * @param zOffset defines the value to apply to zOffset (0 by default)
  122869. * @param force defines if states must be applied even if cache is up to date
  122870. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122871. */
  122872. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122873. /**
  122874. * Set the z offset to apply to current rendering
  122875. * @param value defines the offset to apply
  122876. */
  122877. setZOffset(value: number): void;
  122878. /**
  122879. * Gets the current value of the zOffset
  122880. * @returns the current zOffset state
  122881. */
  122882. getZOffset(): number;
  122883. /**
  122884. * Enable or disable depth buffering
  122885. * @param enable defines the state to set
  122886. */
  122887. setDepthBuffer(enable: boolean): void;
  122888. /**
  122889. * Gets a boolean indicating if depth writing is enabled
  122890. * @returns the current depth writing state
  122891. */
  122892. getDepthWrite(): boolean;
  122893. /**
  122894. * Enable or disable depth writing
  122895. * @param enable defines the state to set
  122896. */
  122897. setDepthWrite(enable: boolean): void;
  122898. /**
  122899. * Gets a boolean indicating if stencil buffer is enabled
  122900. * @returns the current stencil buffer state
  122901. */
  122902. getStencilBuffer(): boolean;
  122903. /**
  122904. * Enable or disable the stencil buffer
  122905. * @param enable defines if the stencil buffer must be enabled or disabled
  122906. */
  122907. setStencilBuffer(enable: boolean): void;
  122908. /**
  122909. * Gets the current stencil mask
  122910. * @returns a number defining the new stencil mask to use
  122911. */
  122912. getStencilMask(): number;
  122913. /**
  122914. * Sets the current stencil mask
  122915. * @param mask defines the new stencil mask to use
  122916. */
  122917. setStencilMask(mask: number): void;
  122918. /**
  122919. * Gets the current stencil function
  122920. * @returns a number defining the stencil function to use
  122921. */
  122922. getStencilFunction(): number;
  122923. /**
  122924. * Gets the current stencil reference value
  122925. * @returns a number defining the stencil reference value to use
  122926. */
  122927. getStencilFunctionReference(): number;
  122928. /**
  122929. * Gets the current stencil mask
  122930. * @returns a number defining the stencil mask to use
  122931. */
  122932. getStencilFunctionMask(): number;
  122933. /**
  122934. * Sets the current stencil function
  122935. * @param stencilFunc defines the new stencil function to use
  122936. */
  122937. setStencilFunction(stencilFunc: number): void;
  122938. /**
  122939. * Sets the current stencil reference
  122940. * @param reference defines the new stencil reference to use
  122941. */
  122942. setStencilFunctionReference(reference: number): void;
  122943. /**
  122944. * Sets the current stencil mask
  122945. * @param mask defines the new stencil mask to use
  122946. */
  122947. setStencilFunctionMask(mask: number): void;
  122948. /**
  122949. * Gets the current stencil operation when stencil fails
  122950. * @returns a number defining stencil operation to use when stencil fails
  122951. */
  122952. getStencilOperationFail(): number;
  122953. /**
  122954. * Gets the current stencil operation when depth fails
  122955. * @returns a number defining stencil operation to use when depth fails
  122956. */
  122957. getStencilOperationDepthFail(): number;
  122958. /**
  122959. * Gets the current stencil operation when stencil passes
  122960. * @returns a number defining stencil operation to use when stencil passes
  122961. */
  122962. getStencilOperationPass(): number;
  122963. /**
  122964. * Sets the stencil operation to use when stencil fails
  122965. * @param operation defines the stencil operation to use when stencil fails
  122966. */
  122967. setStencilOperationFail(operation: number): void;
  122968. /**
  122969. * Sets the stencil operation to use when depth fails
  122970. * @param operation defines the stencil operation to use when depth fails
  122971. */
  122972. setStencilOperationDepthFail(operation: number): void;
  122973. /**
  122974. * Sets the stencil operation to use when stencil passes
  122975. * @param operation defines the stencil operation to use when stencil passes
  122976. */
  122977. setStencilOperationPass(operation: number): void;
  122978. /**
  122979. * Sets a boolean indicating if the dithering state is enabled or disabled
  122980. * @param value defines the dithering state
  122981. */
  122982. setDitheringState(value: boolean): void;
  122983. /**
  122984. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122985. * @param value defines the rasterizer state
  122986. */
  122987. setRasterizerState(value: boolean): void;
  122988. /**
  122989. * Gets the current depth function
  122990. * @returns a number defining the depth function
  122991. */
  122992. getDepthFunction(): Nullable<number>;
  122993. /**
  122994. * Sets the current depth function
  122995. * @param depthFunc defines the function to use
  122996. */
  122997. setDepthFunction(depthFunc: number): void;
  122998. /**
  122999. * Sets the current depth function to GREATER
  123000. */
  123001. setDepthFunctionToGreater(): void;
  123002. /**
  123003. * Sets the current depth function to GEQUAL
  123004. */
  123005. setDepthFunctionToGreaterOrEqual(): void;
  123006. /**
  123007. * Sets the current depth function to LESS
  123008. */
  123009. setDepthFunctionToLess(): void;
  123010. /**
  123011. * Sets the current depth function to LEQUAL
  123012. */
  123013. setDepthFunctionToLessOrEqual(): void;
  123014. private _cachedStencilBuffer;
  123015. private _cachedStencilFunction;
  123016. private _cachedStencilMask;
  123017. private _cachedStencilOperationPass;
  123018. private _cachedStencilOperationFail;
  123019. private _cachedStencilOperationDepthFail;
  123020. private _cachedStencilReference;
  123021. /**
  123022. * Caches the the state of the stencil buffer
  123023. */
  123024. cacheStencilState(): void;
  123025. /**
  123026. * Restores the state of the stencil buffer
  123027. */
  123028. restoreStencilState(): void;
  123029. /**
  123030. * Directly set the WebGL Viewport
  123031. * @param x defines the x coordinate of the viewport (in screen space)
  123032. * @param y defines the y coordinate of the viewport (in screen space)
  123033. * @param width defines the width of the viewport (in screen space)
  123034. * @param height defines the height of the viewport (in screen space)
  123035. * @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
  123036. */
  123037. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  123038. /**
  123039. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  123040. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  123041. * @param y defines the y-coordinate of the corner of the clear rectangle
  123042. * @param width defines the width of the clear rectangle
  123043. * @param height defines the height of the clear rectangle
  123044. * @param clearColor defines the clear color
  123045. */
  123046. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  123047. /**
  123048. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  123049. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  123050. * @param y defines the y-coordinate of the corner of the clear rectangle
  123051. * @param width defines the width of the clear rectangle
  123052. * @param height defines the height of the clear rectangle
  123053. */
  123054. enableScissor(x: number, y: number, width: number, height: number): void;
  123055. /**
  123056. * Disable previously set scissor test rectangle
  123057. */
  123058. disableScissor(): void;
  123059. protected _reportDrawCall(): void;
  123060. /**
  123061. * Initializes a webVR display and starts listening to display change events
  123062. * The onVRDisplayChangedObservable will be notified upon these changes
  123063. * @returns The onVRDisplayChangedObservable
  123064. */
  123065. initWebVR(): Observable<IDisplayChangedEventArgs>;
  123066. /** @hidden */
  123067. _prepareVRComponent(): void;
  123068. /** @hidden */
  123069. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  123070. /** @hidden */
  123071. _submitVRFrame(): void;
  123072. /**
  123073. * Call this function to leave webVR mode
  123074. * Will do nothing if webVR is not supported or if there is no webVR device
  123075. * @see https://doc.babylonjs.com/how_to/webvr_camera
  123076. */
  123077. disableVR(): void;
  123078. /**
  123079. * Gets a boolean indicating that the system is in VR mode and is presenting
  123080. * @returns true if VR mode is engaged
  123081. */
  123082. isVRPresenting(): boolean;
  123083. /** @hidden */
  123084. _requestVRFrame(): void;
  123085. /** @hidden */
  123086. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  123087. /**
  123088. * Gets the source code of the vertex shader associated with a specific webGL program
  123089. * @param program defines the program to use
  123090. * @returns a string containing the source code of the vertex shader associated with the program
  123091. */
  123092. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  123093. /**
  123094. * Gets the source code of the fragment shader associated with a specific webGL program
  123095. * @param program defines the program to use
  123096. * @returns a string containing the source code of the fragment shader associated with the program
  123097. */
  123098. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  123099. /**
  123100. * Sets a depth stencil texture from a render target to the according uniform.
  123101. * @param channel The texture channel
  123102. * @param uniform The uniform to set
  123103. * @param texture The render target texture containing the depth stencil texture to apply
  123104. */
  123105. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  123106. /**
  123107. * Sets a texture to the webGL context from a postprocess
  123108. * @param channel defines the channel to use
  123109. * @param postProcess defines the source postprocess
  123110. */
  123111. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  123112. /**
  123113. * Binds the output of the passed in post process to the texture channel specified
  123114. * @param channel The channel the texture should be bound to
  123115. * @param postProcess The post process which's output should be bound
  123116. */
  123117. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  123118. protected _rebuildBuffers(): void;
  123119. /** @hidden */
  123120. _renderFrame(): void;
  123121. _renderLoop(): void;
  123122. /** @hidden */
  123123. _renderViews(): boolean;
  123124. /**
  123125. * Toggle full screen mode
  123126. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123127. */
  123128. switchFullscreen(requestPointerLock: boolean): void;
  123129. /**
  123130. * Enters full screen mode
  123131. * @param requestPointerLock defines if a pointer lock should be requested from the user
  123132. */
  123133. enterFullscreen(requestPointerLock: boolean): void;
  123134. /**
  123135. * Exits full screen mode
  123136. */
  123137. exitFullscreen(): void;
  123138. /**
  123139. * Enters Pointerlock mode
  123140. */
  123141. enterPointerlock(): void;
  123142. /**
  123143. * Exits Pointerlock mode
  123144. */
  123145. exitPointerlock(): void;
  123146. /**
  123147. * Begin a new frame
  123148. */
  123149. beginFrame(): void;
  123150. /**
  123151. * Enf the current frame
  123152. */
  123153. endFrame(): void;
  123154. resize(): void;
  123155. /**
  123156. * Force a specific size of the canvas
  123157. * @param width defines the new canvas' width
  123158. * @param height defines the new canvas' height
  123159. * @returns true if the size was changed
  123160. */
  123161. setSize(width: number, height: number): boolean;
  123162. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  123163. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123164. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  123165. _releaseTexture(texture: InternalTexture): void;
  123166. /**
  123167. * @hidden
  123168. * Rescales a texture
  123169. * @param source input texutre
  123170. * @param destination destination texture
  123171. * @param scene scene to use to render the resize
  123172. * @param internalFormat format to use when resizing
  123173. * @param onComplete callback to be called when resize has completed
  123174. */
  123175. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  123176. /**
  123177. * Gets the current framerate
  123178. * @returns a number representing the framerate
  123179. */
  123180. getFps(): number;
  123181. /**
  123182. * Gets the time spent between current and previous frame
  123183. * @returns a number representing the delta time in ms
  123184. */
  123185. getDeltaTime(): number;
  123186. private _measureFps;
  123187. /** @hidden */
  123188. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  123189. /**
  123190. * Updates the sample count of a render target texture
  123191. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  123192. * @param texture defines the texture to update
  123193. * @param samples defines the sample count to set
  123194. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  123195. */
  123196. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  123197. /**
  123198. * Updates a depth texture Comparison Mode and Function.
  123199. * If the comparison Function is equal to 0, the mode will be set to none.
  123200. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  123201. * @param texture The texture to set the comparison function for
  123202. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  123203. */
  123204. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  123205. /**
  123206. * Creates a webGL buffer to use with instanciation
  123207. * @param capacity defines the size of the buffer
  123208. * @returns the webGL buffer
  123209. */
  123210. createInstancesBuffer(capacity: number): DataBuffer;
  123211. /**
  123212. * Delete a webGL buffer used with instanciation
  123213. * @param buffer defines the webGL buffer to delete
  123214. */
  123215. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  123216. private _clientWaitAsync;
  123217. /** @hidden */
  123218. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  123219. dispose(): void;
  123220. private _disableTouchAction;
  123221. /**
  123222. * Display the loading screen
  123223. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123224. */
  123225. displayLoadingUI(): void;
  123226. /**
  123227. * Hide the loading screen
  123228. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123229. */
  123230. hideLoadingUI(): void;
  123231. /**
  123232. * Gets the current loading screen object
  123233. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123234. */
  123235. get loadingScreen(): ILoadingScreen;
  123236. /**
  123237. * Sets the current loading screen object
  123238. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123239. */
  123240. set loadingScreen(loadingScreen: ILoadingScreen);
  123241. /**
  123242. * Sets the current loading screen text
  123243. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123244. */
  123245. set loadingUIText(text: string);
  123246. /**
  123247. * Sets the current loading screen background color
  123248. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123249. */
  123250. set loadingUIBackgroundColor(color: string);
  123251. /** Pointerlock and fullscreen */
  123252. /**
  123253. * Ask the browser to promote the current element to pointerlock mode
  123254. * @param element defines the DOM element to promote
  123255. */
  123256. static _RequestPointerlock(element: HTMLElement): void;
  123257. /**
  123258. * Asks the browser to exit pointerlock mode
  123259. */
  123260. static _ExitPointerlock(): void;
  123261. /**
  123262. * Ask the browser to promote the current element to fullscreen rendering mode
  123263. * @param element defines the DOM element to promote
  123264. */
  123265. static _RequestFullscreen(element: HTMLElement): void;
  123266. /**
  123267. * Asks the browser to exit fullscreen mode
  123268. */
  123269. static _ExitFullscreen(): void;
  123270. }
  123271. }
  123272. declare module BABYLON {
  123273. /**
  123274. * The engine store class is responsible to hold all the instances of Engine and Scene created
  123275. * during the life time of the application.
  123276. */
  123277. export class EngineStore {
  123278. /** Gets the list of created engines */
  123279. static Instances: Engine[];
  123280. /** @hidden */
  123281. static _LastCreatedScene: Nullable<Scene>;
  123282. /**
  123283. * Gets the latest created engine
  123284. */
  123285. static get LastCreatedEngine(): Nullable<Engine>;
  123286. /**
  123287. * Gets the latest created scene
  123288. */
  123289. static get LastCreatedScene(): Nullable<Scene>;
  123290. /**
  123291. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123292. * @ignorenaming
  123293. */
  123294. static UseFallbackTexture: boolean;
  123295. /**
  123296. * Texture content used if a texture cannot loaded
  123297. * @ignorenaming
  123298. */
  123299. static FallbackTexture: string;
  123300. }
  123301. }
  123302. declare module BABYLON {
  123303. /**
  123304. * Helper class that provides a small promise polyfill
  123305. */
  123306. export class PromisePolyfill {
  123307. /**
  123308. * Static function used to check if the polyfill is required
  123309. * If this is the case then the function will inject the polyfill to window.Promise
  123310. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  123311. */
  123312. static Apply(force?: boolean): void;
  123313. }
  123314. }
  123315. declare module BABYLON {
  123316. /**
  123317. * Interface for screenshot methods with describe argument called `size` as object with options
  123318. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  123319. */
  123320. export interface IScreenshotSize {
  123321. /**
  123322. * number in pixels for canvas height
  123323. */
  123324. height?: number;
  123325. /**
  123326. * multiplier allowing render at a higher or lower resolution
  123327. * If value is defined then height and width will be ignored and taken from camera
  123328. */
  123329. precision?: number;
  123330. /**
  123331. * number in pixels for canvas width
  123332. */
  123333. width?: number;
  123334. }
  123335. }
  123336. declare module BABYLON {
  123337. interface IColor4Like {
  123338. r: float;
  123339. g: float;
  123340. b: float;
  123341. a: float;
  123342. }
  123343. /**
  123344. * Class containing a set of static utilities functions
  123345. */
  123346. export class Tools {
  123347. /**
  123348. * Gets or sets the base URL to use to load assets
  123349. */
  123350. static get BaseUrl(): string;
  123351. static set BaseUrl(value: string);
  123352. /**
  123353. * Enable/Disable Custom HTTP Request Headers globally.
  123354. * default = false
  123355. * @see CustomRequestHeaders
  123356. */
  123357. static UseCustomRequestHeaders: boolean;
  123358. /**
  123359. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  123360. * i.e. when loading files, where the server/service expects an Authorization header
  123361. */
  123362. static CustomRequestHeaders: {
  123363. [key: string]: string;
  123364. };
  123365. /**
  123366. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  123367. */
  123368. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  123369. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  123370. /**
  123371. * Default behaviour for cors in the application.
  123372. * It can be a string if the expected behavior is identical in the entire app.
  123373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  123374. */
  123375. static get CorsBehavior(): string | ((url: string | string[]) => string);
  123376. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  123377. /**
  123378. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  123379. * @ignorenaming
  123380. */
  123381. static get UseFallbackTexture(): boolean;
  123382. static set UseFallbackTexture(value: boolean);
  123383. /**
  123384. * Use this object to register external classes like custom textures or material
  123385. * to allow the laoders to instantiate them
  123386. */
  123387. static get RegisteredExternalClasses(): {
  123388. [key: string]: Object;
  123389. };
  123390. static set RegisteredExternalClasses(classes: {
  123391. [key: string]: Object;
  123392. });
  123393. /**
  123394. * Texture content used if a texture cannot loaded
  123395. * @ignorenaming
  123396. */
  123397. static get fallbackTexture(): string;
  123398. static set fallbackTexture(value: string);
  123399. /**
  123400. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  123401. * @param u defines the coordinate on X axis
  123402. * @param v defines the coordinate on Y axis
  123403. * @param width defines the width of the source data
  123404. * @param height defines the height of the source data
  123405. * @param pixels defines the source byte array
  123406. * @param color defines the output color
  123407. */
  123408. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  123409. /**
  123410. * Interpolates between a and b via alpha
  123411. * @param a The lower value (returned when alpha = 0)
  123412. * @param b The upper value (returned when alpha = 1)
  123413. * @param alpha The interpolation-factor
  123414. * @return The mixed value
  123415. */
  123416. static Mix(a: number, b: number, alpha: number): number;
  123417. /**
  123418. * Tries to instantiate a new object from a given class name
  123419. * @param className defines the class name to instantiate
  123420. * @returns the new object or null if the system was not able to do the instantiation
  123421. */
  123422. static Instantiate(className: string): any;
  123423. /**
  123424. * Provides a slice function that will work even on IE
  123425. * @param data defines the array to slice
  123426. * @param start defines the start of the data (optional)
  123427. * @param end defines the end of the data (optional)
  123428. * @returns the new sliced array
  123429. */
  123430. static Slice<T>(data: T, start?: number, end?: number): T;
  123431. /**
  123432. * Provides a slice function that will work even on IE
  123433. * The difference between this and Slice is that this will force-convert to array
  123434. * @param data defines the array to slice
  123435. * @param start defines the start of the data (optional)
  123436. * @param end defines the end of the data (optional)
  123437. * @returns the new sliced array
  123438. */
  123439. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  123440. /**
  123441. * Polyfill for setImmediate
  123442. * @param action defines the action to execute after the current execution block
  123443. */
  123444. static SetImmediate(action: () => void): void;
  123445. /**
  123446. * Function indicating if a number is an exponent of 2
  123447. * @param value defines the value to test
  123448. * @returns true if the value is an exponent of 2
  123449. */
  123450. static IsExponentOfTwo(value: number): boolean;
  123451. private static _tmpFloatArray;
  123452. /**
  123453. * Returns the nearest 32-bit single precision float representation of a Number
  123454. * @param value A Number. If the parameter is of a different type, it will get converted
  123455. * to a number or to NaN if it cannot be converted
  123456. * @returns number
  123457. */
  123458. static FloatRound(value: number): number;
  123459. /**
  123460. * Extracts the filename from a path
  123461. * @param path defines the path to use
  123462. * @returns the filename
  123463. */
  123464. static GetFilename(path: string): string;
  123465. /**
  123466. * Extracts the "folder" part of a path (everything before the filename).
  123467. * @param uri The URI to extract the info from
  123468. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  123469. * @returns The "folder" part of the path
  123470. */
  123471. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  123472. /**
  123473. * Extracts text content from a DOM element hierarchy
  123474. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  123475. */
  123476. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  123477. /**
  123478. * Convert an angle in radians to degrees
  123479. * @param angle defines the angle to convert
  123480. * @returns the angle in degrees
  123481. */
  123482. static ToDegrees(angle: number): number;
  123483. /**
  123484. * Convert an angle in degrees to radians
  123485. * @param angle defines the angle to convert
  123486. * @returns the angle in radians
  123487. */
  123488. static ToRadians(angle: number): number;
  123489. /**
  123490. * Returns an array if obj is not an array
  123491. * @param obj defines the object to evaluate as an array
  123492. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  123493. * @returns either obj directly if obj is an array or a new array containing obj
  123494. */
  123495. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  123496. /**
  123497. * Gets the pointer prefix to use
  123498. * @param engine defines the engine we are finding the prefix for
  123499. * @returns "pointer" if touch is enabled. Else returns "mouse"
  123500. */
  123501. static GetPointerPrefix(engine: Engine): string;
  123502. /**
  123503. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  123504. * @param url define the url we are trying
  123505. * @param element define the dom element where to configure the cors policy
  123506. */
  123507. static SetCorsBehavior(url: string | string[], element: {
  123508. crossOrigin: string | null;
  123509. }): void;
  123510. /**
  123511. * Removes unwanted characters from an url
  123512. * @param url defines the url to clean
  123513. * @returns the cleaned url
  123514. */
  123515. static CleanUrl(url: string): string;
  123516. /**
  123517. * Gets or sets a function used to pre-process url before using them to load assets
  123518. */
  123519. static get PreprocessUrl(): (url: string) => string;
  123520. static set PreprocessUrl(processor: (url: string) => string);
  123521. /**
  123522. * Loads an image as an HTMLImageElement.
  123523. * @param input url string, ArrayBuffer, or Blob to load
  123524. * @param onLoad callback called when the image successfully loads
  123525. * @param onError callback called when the image fails to load
  123526. * @param offlineProvider offline provider for caching
  123527. * @param mimeType optional mime type
  123528. * @returns the HTMLImageElement of the loaded image
  123529. */
  123530. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  123531. /**
  123532. * Loads a file from a url
  123533. * @param url url string, ArrayBuffer, or Blob to load
  123534. * @param onSuccess callback called when the file successfully loads
  123535. * @param onProgress callback called while file is loading (if the server supports this mode)
  123536. * @param offlineProvider defines the offline provider for caching
  123537. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123538. * @param onError callback called when the file fails to load
  123539. * @returns a file request object
  123540. */
  123541. 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;
  123542. /**
  123543. * Loads a file from a url
  123544. * @param url the file url to load
  123545. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  123546. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  123547. */
  123548. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  123549. /**
  123550. * Load a script (identified by an url). When the url returns, the
  123551. * content of this file is added into a new script element, attached to the DOM (body element)
  123552. * @param scriptUrl defines the url of the script to laod
  123553. * @param onSuccess defines the callback called when the script is loaded
  123554. * @param onError defines the callback to call if an error occurs
  123555. * @param scriptId defines the id of the script element
  123556. */
  123557. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  123558. /**
  123559. * Load an asynchronous script (identified by an url). When the url returns, the
  123560. * content of this file is added into a new script element, attached to the DOM (body element)
  123561. * @param scriptUrl defines the url of the script to laod
  123562. * @param scriptId defines the id of the script element
  123563. * @returns a promise request object
  123564. */
  123565. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  123566. /**
  123567. * Loads a file from a blob
  123568. * @param fileToLoad defines the blob to use
  123569. * @param callback defines the callback to call when data is loaded
  123570. * @param progressCallback defines the callback to call during loading process
  123571. * @returns a file request object
  123572. */
  123573. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  123574. /**
  123575. * Reads a file from a File object
  123576. * @param file defines the file to load
  123577. * @param onSuccess defines the callback to call when data is loaded
  123578. * @param onProgress defines the callback to call during loading process
  123579. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  123580. * @param onError defines the callback to call when an error occurs
  123581. * @returns a file request object
  123582. */
  123583. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  123584. /**
  123585. * Creates a data url from a given string content
  123586. * @param content defines the content to convert
  123587. * @returns the new data url link
  123588. */
  123589. static FileAsURL(content: string): string;
  123590. /**
  123591. * Format the given number to a specific decimal format
  123592. * @param value defines the number to format
  123593. * @param decimals defines the number of decimals to use
  123594. * @returns the formatted string
  123595. */
  123596. static Format(value: number, decimals?: number): string;
  123597. /**
  123598. * Tries to copy an object by duplicating every property
  123599. * @param source defines the source object
  123600. * @param destination defines the target object
  123601. * @param doNotCopyList defines a list of properties to avoid
  123602. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  123603. */
  123604. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  123605. /**
  123606. * Gets a boolean indicating if the given object has no own property
  123607. * @param obj defines the object to test
  123608. * @returns true if object has no own property
  123609. */
  123610. static IsEmpty(obj: any): boolean;
  123611. /**
  123612. * Function used to register events at window level
  123613. * @param windowElement defines the Window object to use
  123614. * @param events defines the events to register
  123615. */
  123616. static RegisterTopRootEvents(windowElement: Window, events: {
  123617. name: string;
  123618. handler: Nullable<(e: FocusEvent) => any>;
  123619. }[]): void;
  123620. /**
  123621. * Function used to unregister events from window level
  123622. * @param windowElement defines the Window object to use
  123623. * @param events defines the events to unregister
  123624. */
  123625. static UnregisterTopRootEvents(windowElement: Window, events: {
  123626. name: string;
  123627. handler: Nullable<(e: FocusEvent) => any>;
  123628. }[]): void;
  123629. /**
  123630. * @ignore
  123631. */
  123632. static _ScreenshotCanvas: HTMLCanvasElement;
  123633. /**
  123634. * Dumps the current bound framebuffer
  123635. * @param width defines the rendering width
  123636. * @param height defines the rendering height
  123637. * @param engine defines the hosting engine
  123638. * @param successCallback defines the callback triggered once the data are available
  123639. * @param mimeType defines the mime type of the result
  123640. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  123641. */
  123642. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123643. /**
  123644. * Converts the canvas data to blob.
  123645. * This acts as a polyfill for browsers not supporting the to blob function.
  123646. * @param canvas Defines the canvas to extract the data from
  123647. * @param successCallback Defines the callback triggered once the data are available
  123648. * @param mimeType Defines the mime type of the result
  123649. */
  123650. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  123651. /**
  123652. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  123653. * @param successCallback defines the callback triggered once the data are available
  123654. * @param mimeType defines the mime type of the result
  123655. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  123656. */
  123657. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  123658. /**
  123659. * Downloads a blob in the browser
  123660. * @param blob defines the blob to download
  123661. * @param fileName defines the name of the downloaded file
  123662. */
  123663. static Download(blob: Blob, fileName: string): void;
  123664. /**
  123665. * Will return the right value of the noPreventDefault variable
  123666. * Needed to keep backwards compatibility to the old API.
  123667. *
  123668. * @param args arguments passed to the attachControl function
  123669. * @returns the correct value for noPreventDefault
  123670. */
  123671. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  123672. /**
  123673. * Captures a screenshot of the current rendering
  123674. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123675. * @param engine defines the rendering engine
  123676. * @param camera defines the source camera
  123677. * @param size This parameter can be set to a single number or to an object with the
  123678. * following (optional) properties: precision, width, height. If a single number is passed,
  123679. * it will be used for both width and height. If an object is passed, the screenshot size
  123680. * will be derived from the parameters. The precision property is a multiplier allowing
  123681. * rendering at a higher or lower resolution
  123682. * @param successCallback defines the callback receives a single parameter which contains the
  123683. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123684. * src parameter of an <img> to display it
  123685. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123686. * Check your browser for supported MIME types
  123687. */
  123688. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123689. /**
  123690. * Captures a screenshot of the current rendering
  123691. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123692. * @param engine defines the rendering engine
  123693. * @param camera defines the source camera
  123694. * @param size This parameter can be set to a single number or to an object with the
  123695. * following (optional) properties: precision, width, height. If a single number is passed,
  123696. * it will be used for both width and height. If an object is passed, the screenshot size
  123697. * will be derived from the parameters. The precision property is a multiplier allowing
  123698. * rendering at a higher or lower resolution
  123699. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123700. * Check your browser for supported MIME types
  123701. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123702. * to the src parameter of an <img> to display it
  123703. */
  123704. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123705. /**
  123706. * Generates an image screenshot from the specified camera.
  123707. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123708. * @param engine The engine to use for rendering
  123709. * @param camera The camera to use for rendering
  123710. * @param size This parameter can be set to a single number or to an object with the
  123711. * following (optional) properties: precision, width, height. If a single number is passed,
  123712. * it will be used for both width and height. If an object is passed, the screenshot size
  123713. * will be derived from the parameters. The precision property is a multiplier allowing
  123714. * rendering at a higher or lower resolution
  123715. * @param successCallback The callback receives a single parameter which contains the
  123716. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123717. * src parameter of an <img> to display it
  123718. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123719. * Check your browser for supported MIME types
  123720. * @param samples Texture samples (default: 1)
  123721. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123722. * @param fileName A name for for the downloaded file.
  123723. */
  123724. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123725. /**
  123726. * Generates an image screenshot from the specified camera.
  123727. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123728. * @param engine The engine to use for rendering
  123729. * @param camera The camera to use for rendering
  123730. * @param size This parameter can be set to a single number or to an object with the
  123731. * following (optional) properties: precision, width, height. If a single number is passed,
  123732. * it will be used for both width and height. If an object is passed, the screenshot size
  123733. * will be derived from the parameters. The precision property is a multiplier allowing
  123734. * rendering at a higher or lower resolution
  123735. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123736. * Check your browser for supported MIME types
  123737. * @param samples Texture samples (default: 1)
  123738. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123739. * @param fileName A name for for the downloaded file.
  123740. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123741. * to the src parameter of an <img> to display it
  123742. */
  123743. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123744. /**
  123745. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123746. * Be aware Math.random() could cause collisions, but:
  123747. * "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"
  123748. * @returns a pseudo random id
  123749. */
  123750. static RandomId(): string;
  123751. /**
  123752. * Test if the given uri is a base64 string
  123753. * @param uri The uri to test
  123754. * @return True if the uri is a base64 string or false otherwise
  123755. */
  123756. static IsBase64(uri: string): boolean;
  123757. /**
  123758. * Decode the given base64 uri.
  123759. * @param uri The uri to decode
  123760. * @return The decoded base64 data.
  123761. */
  123762. static DecodeBase64(uri: string): ArrayBuffer;
  123763. /**
  123764. * Gets the absolute url.
  123765. * @param url the input url
  123766. * @return the absolute url
  123767. */
  123768. static GetAbsoluteUrl(url: string): string;
  123769. /**
  123770. * No log
  123771. */
  123772. static readonly NoneLogLevel: number;
  123773. /**
  123774. * Only message logs
  123775. */
  123776. static readonly MessageLogLevel: number;
  123777. /**
  123778. * Only warning logs
  123779. */
  123780. static readonly WarningLogLevel: number;
  123781. /**
  123782. * Only error logs
  123783. */
  123784. static readonly ErrorLogLevel: number;
  123785. /**
  123786. * All logs
  123787. */
  123788. static readonly AllLogLevel: number;
  123789. /**
  123790. * Gets a value indicating the number of loading errors
  123791. * @ignorenaming
  123792. */
  123793. static get errorsCount(): number;
  123794. /**
  123795. * Callback called when a new log is added
  123796. */
  123797. static OnNewCacheEntry: (entry: string) => void;
  123798. /**
  123799. * Log a message to the console
  123800. * @param message defines the message to log
  123801. */
  123802. static Log(message: string): void;
  123803. /**
  123804. * Write a warning message to the console
  123805. * @param message defines the message to log
  123806. */
  123807. static Warn(message: string): void;
  123808. /**
  123809. * Write an error message to the console
  123810. * @param message defines the message to log
  123811. */
  123812. static Error(message: string): void;
  123813. /**
  123814. * Gets current log cache (list of logs)
  123815. */
  123816. static get LogCache(): string;
  123817. /**
  123818. * Clears the log cache
  123819. */
  123820. static ClearLogCache(): void;
  123821. /**
  123822. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123823. */
  123824. static set LogLevels(level: number);
  123825. /**
  123826. * Checks if the window object exists
  123827. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123828. */
  123829. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123830. /**
  123831. * No performance log
  123832. */
  123833. static readonly PerformanceNoneLogLevel: number;
  123834. /**
  123835. * Use user marks to log performance
  123836. */
  123837. static readonly PerformanceUserMarkLogLevel: number;
  123838. /**
  123839. * Log performance to the console
  123840. */
  123841. static readonly PerformanceConsoleLogLevel: number;
  123842. private static _performance;
  123843. /**
  123844. * Sets the current performance log level
  123845. */
  123846. static set PerformanceLogLevel(level: number);
  123847. private static _StartPerformanceCounterDisabled;
  123848. private static _EndPerformanceCounterDisabled;
  123849. private static _StartUserMark;
  123850. private static _EndUserMark;
  123851. private static _StartPerformanceConsole;
  123852. private static _EndPerformanceConsole;
  123853. /**
  123854. * Starts a performance counter
  123855. */
  123856. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123857. /**
  123858. * Ends a specific performance coutner
  123859. */
  123860. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123861. /**
  123862. * Gets either window.performance.now() if supported or Date.now() else
  123863. */
  123864. static get Now(): number;
  123865. /**
  123866. * This method will return the name of the class used to create the instance of the given object.
  123867. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123868. * @param object the object to get the class name from
  123869. * @param isType defines if the object is actually a type
  123870. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123871. */
  123872. static GetClassName(object: any, isType?: boolean): string;
  123873. /**
  123874. * Gets the first element of an array satisfying a given predicate
  123875. * @param array defines the array to browse
  123876. * @param predicate defines the predicate to use
  123877. * @returns null if not found or the element
  123878. */
  123879. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123880. /**
  123881. * This method will return the name of the full name of the class, including its owning module (if any).
  123882. * 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).
  123883. * @param object the object to get the class name from
  123884. * @param isType defines if the object is actually a type
  123885. * @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.
  123886. * @ignorenaming
  123887. */
  123888. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123889. /**
  123890. * Returns a promise that resolves after the given amount of time.
  123891. * @param delay Number of milliseconds to delay
  123892. * @returns Promise that resolves after the given amount of time
  123893. */
  123894. static DelayAsync(delay: number): Promise<void>;
  123895. /**
  123896. * Utility function to detect if the current user agent is Safari
  123897. * @returns whether or not the current user agent is safari
  123898. */
  123899. static IsSafari(): boolean;
  123900. }
  123901. /**
  123902. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123903. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123904. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123905. * @param name The name of the class, case should be preserved
  123906. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123907. */
  123908. export function className(name: string, module?: string): (target: Object) => void;
  123909. /**
  123910. * An implementation of a loop for asynchronous functions.
  123911. */
  123912. export class AsyncLoop {
  123913. /**
  123914. * Defines the number of iterations for the loop
  123915. */
  123916. iterations: number;
  123917. /**
  123918. * Defines the current index of the loop.
  123919. */
  123920. index: number;
  123921. private _done;
  123922. private _fn;
  123923. private _successCallback;
  123924. /**
  123925. * Constructor.
  123926. * @param iterations the number of iterations.
  123927. * @param func the function to run each iteration
  123928. * @param successCallback the callback that will be called upon succesful execution
  123929. * @param offset starting offset.
  123930. */
  123931. constructor(
  123932. /**
  123933. * Defines the number of iterations for the loop
  123934. */
  123935. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123936. /**
  123937. * Execute the next iteration. Must be called after the last iteration was finished.
  123938. */
  123939. executeNext(): void;
  123940. /**
  123941. * Break the loop and run the success callback.
  123942. */
  123943. breakLoop(): void;
  123944. /**
  123945. * Create and run an async loop.
  123946. * @param iterations the number of iterations.
  123947. * @param fn the function to run each iteration
  123948. * @param successCallback the callback that will be called upon succesful execution
  123949. * @param offset starting offset.
  123950. * @returns the created async loop object
  123951. */
  123952. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123953. /**
  123954. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123955. * @param iterations total number of iterations
  123956. * @param syncedIterations number of synchronous iterations in each async iteration.
  123957. * @param fn the function to call each iteration.
  123958. * @param callback a success call back that will be called when iterating stops.
  123959. * @param breakFunction a break condition (optional)
  123960. * @param timeout timeout settings for the setTimeout function. default - 0.
  123961. * @returns the created async loop object
  123962. */
  123963. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123964. }
  123965. }
  123966. declare module BABYLON {
  123967. /**
  123968. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123969. * The underlying implementation relies on an associative array to ensure the best performances.
  123970. * The value can be anything including 'null' but except 'undefined'
  123971. */
  123972. export class StringDictionary<T> {
  123973. /**
  123974. * This will clear this dictionary and copy the content from the 'source' one.
  123975. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123976. * @param source the dictionary to take the content from and copy to this dictionary
  123977. */
  123978. copyFrom(source: StringDictionary<T>): void;
  123979. /**
  123980. * Get a value based from its key
  123981. * @param key the given key to get the matching value from
  123982. * @return the value if found, otherwise undefined is returned
  123983. */
  123984. get(key: string): T | undefined;
  123985. /**
  123986. * Get a value from its key or add it if it doesn't exist.
  123987. * This method will ensure you that a given key/data will be present in the dictionary.
  123988. * @param key the given key to get the matching value from
  123989. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123990. * The factory will only be invoked if there's no data for the given key.
  123991. * @return the value corresponding to the key.
  123992. */
  123993. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123994. /**
  123995. * Get a value from its key if present in the dictionary otherwise add it
  123996. * @param key the key to get the value from
  123997. * @param val if there's no such key/value pair in the dictionary add it with this value
  123998. * @return the value corresponding to the key
  123999. */
  124000. getOrAdd(key: string, val: T): T;
  124001. /**
  124002. * Check if there's a given key in the dictionary
  124003. * @param key the key to check for
  124004. * @return true if the key is present, false otherwise
  124005. */
  124006. contains(key: string): boolean;
  124007. /**
  124008. * Add a new key and its corresponding value
  124009. * @param key the key to add
  124010. * @param value the value corresponding to the key
  124011. * @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
  124012. */
  124013. add(key: string, value: T): boolean;
  124014. /**
  124015. * Update a specific value associated to a key
  124016. * @param key defines the key to use
  124017. * @param value defines the value to store
  124018. * @returns true if the value was updated (or false if the key was not found)
  124019. */
  124020. set(key: string, value: T): boolean;
  124021. /**
  124022. * Get the element of the given key and remove it from the dictionary
  124023. * @param key defines the key to search
  124024. * @returns the value associated with the key or null if not found
  124025. */
  124026. getAndRemove(key: string): Nullable<T>;
  124027. /**
  124028. * Remove a key/value from the dictionary.
  124029. * @param key the key to remove
  124030. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  124031. */
  124032. remove(key: string): boolean;
  124033. /**
  124034. * Clear the whole content of the dictionary
  124035. */
  124036. clear(): void;
  124037. /**
  124038. * Gets the current count
  124039. */
  124040. get count(): number;
  124041. /**
  124042. * Execute a callback on each key/val of the dictionary.
  124043. * Note that you can remove any element in this dictionary in the callback implementation
  124044. * @param callback the callback to execute on a given key/value pair
  124045. */
  124046. forEach(callback: (key: string, val: T) => void): void;
  124047. /**
  124048. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  124049. * If the callback returns null or undefined the method will iterate to the next key/value pair
  124050. * Note that you can remove any element in this dictionary in the callback implementation
  124051. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  124052. * @returns the first item
  124053. */
  124054. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  124055. private _count;
  124056. private _data;
  124057. }
  124058. }
  124059. declare module BABYLON {
  124060. /** @hidden */
  124061. export interface ICollisionCoordinator {
  124062. createCollider(): Collider;
  124063. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  124064. init(scene: Scene): void;
  124065. }
  124066. /** @hidden */
  124067. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  124068. private _scene;
  124069. private _scaledPosition;
  124070. private _scaledVelocity;
  124071. private _finalPosition;
  124072. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  124073. createCollider(): Collider;
  124074. init(scene: Scene): void;
  124075. private _collideWithWorld;
  124076. }
  124077. }
  124078. declare module BABYLON {
  124079. /**
  124080. * Class used to manage all inputs for the scene.
  124081. */
  124082. export class InputManager {
  124083. /** The distance in pixel that you have to move to prevent some events */
  124084. static DragMovementThreshold: number;
  124085. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  124086. static LongPressDelay: number;
  124087. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  124088. static DoubleClickDelay: number;
  124089. /** If you need to check double click without raising a single click at first click, enable this flag */
  124090. static ExclusiveDoubleClickMode: boolean;
  124091. /** 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. */
  124092. private _alreadyAttached;
  124093. private _alreadyAttachedTo;
  124094. private _wheelEventName;
  124095. private _onPointerMove;
  124096. private _onPointerDown;
  124097. private _onPointerUp;
  124098. private _initClickEvent;
  124099. private _initActionManager;
  124100. private _delayedSimpleClick;
  124101. private _delayedSimpleClickTimeout;
  124102. private _previousDelayedSimpleClickTimeout;
  124103. private _meshPickProceed;
  124104. private _previousButtonPressed;
  124105. private _currentPickResult;
  124106. private _previousPickResult;
  124107. private _totalPointersPressed;
  124108. private _doubleClickOccured;
  124109. private _pointerOverMesh;
  124110. private _pickedDownMesh;
  124111. private _pickedUpMesh;
  124112. private _pointerX;
  124113. private _pointerY;
  124114. private _unTranslatedPointerX;
  124115. private _unTranslatedPointerY;
  124116. private _startingPointerPosition;
  124117. private _previousStartingPointerPosition;
  124118. private _startingPointerTime;
  124119. private _previousStartingPointerTime;
  124120. private _pointerCaptures;
  124121. private _meshUnderPointerId;
  124122. private _onKeyDown;
  124123. private _onKeyUp;
  124124. private _keyboardIsAttached;
  124125. private _onCanvasFocusObserver;
  124126. private _onCanvasBlurObserver;
  124127. private _scene;
  124128. /**
  124129. * Creates a new InputManager
  124130. * @param scene defines the hosting scene
  124131. */
  124132. constructor(scene: Scene);
  124133. /**
  124134. * Gets the mesh that is currently under the pointer
  124135. */
  124136. get meshUnderPointer(): Nullable<AbstractMesh>;
  124137. /**
  124138. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  124139. * @param pointerId the pointer id to use
  124140. * @returns The mesh under this pointer id or null if not found
  124141. */
  124142. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  124143. /**
  124144. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  124145. */
  124146. get unTranslatedPointer(): Vector2;
  124147. /**
  124148. * Gets or sets the current on-screen X position of the pointer
  124149. */
  124150. get pointerX(): number;
  124151. set pointerX(value: number);
  124152. /**
  124153. * Gets or sets the current on-screen Y position of the pointer
  124154. */
  124155. get pointerY(): number;
  124156. set pointerY(value: number);
  124157. private _updatePointerPosition;
  124158. private _processPointerMove;
  124159. private _setRayOnPointerInfo;
  124160. private _checkPrePointerObservable;
  124161. /**
  124162. * Use this method to simulate a pointer move on a mesh
  124163. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124164. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124165. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124166. */
  124167. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124168. /**
  124169. * Use this method to simulate a pointer down on a mesh
  124170. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124171. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124172. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124173. */
  124174. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  124175. private _processPointerDown;
  124176. /** @hidden */
  124177. _isPointerSwiping(): boolean;
  124178. /**
  124179. * Use this method to simulate a pointer up on a mesh
  124180. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124181. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124182. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124183. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124184. */
  124185. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  124186. private _processPointerUp;
  124187. /**
  124188. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124189. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124190. * @returns true if the pointer was captured
  124191. */
  124192. isPointerCaptured(pointerId?: number): boolean;
  124193. /**
  124194. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124195. * @param attachUp defines if you want to attach events to pointerup
  124196. * @param attachDown defines if you want to attach events to pointerdown
  124197. * @param attachMove defines if you want to attach events to pointermove
  124198. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  124199. */
  124200. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  124201. /**
  124202. * Detaches all event handlers
  124203. */
  124204. detachControl(): void;
  124205. /**
  124206. * Force the value of meshUnderPointer
  124207. * @param mesh defines the mesh to use
  124208. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  124209. */
  124210. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  124211. /**
  124212. * Gets the mesh under the pointer
  124213. * @returns a Mesh or null if no mesh is under the pointer
  124214. */
  124215. getPointerOverMesh(): Nullable<AbstractMesh>;
  124216. }
  124217. }
  124218. declare module BABYLON {
  124219. /**
  124220. * This class defines the direct association between an animation and a target
  124221. */
  124222. export class TargetedAnimation {
  124223. /**
  124224. * Animation to perform
  124225. */
  124226. animation: Animation;
  124227. /**
  124228. * Target to animate
  124229. */
  124230. target: any;
  124231. /**
  124232. * Returns the string "TargetedAnimation"
  124233. * @returns "TargetedAnimation"
  124234. */
  124235. getClassName(): string;
  124236. /**
  124237. * Serialize the object
  124238. * @returns the JSON object representing the current entity
  124239. */
  124240. serialize(): any;
  124241. }
  124242. /**
  124243. * Use this class to create coordinated animations on multiple targets
  124244. */
  124245. export class AnimationGroup implements IDisposable {
  124246. /** The name of the animation group */
  124247. name: string;
  124248. private _scene;
  124249. private _targetedAnimations;
  124250. private _animatables;
  124251. private _from;
  124252. private _to;
  124253. private _isStarted;
  124254. private _isPaused;
  124255. private _speedRatio;
  124256. private _loopAnimation;
  124257. private _isAdditive;
  124258. /**
  124259. * Gets or sets the unique id of the node
  124260. */
  124261. uniqueId: number;
  124262. /**
  124263. * This observable will notify when one animation have ended
  124264. */
  124265. onAnimationEndObservable: Observable<TargetedAnimation>;
  124266. /**
  124267. * Observer raised when one animation loops
  124268. */
  124269. onAnimationLoopObservable: Observable<TargetedAnimation>;
  124270. /**
  124271. * Observer raised when all animations have looped
  124272. */
  124273. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  124274. /**
  124275. * This observable will notify when all animations have ended.
  124276. */
  124277. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  124278. /**
  124279. * This observable will notify when all animations have paused.
  124280. */
  124281. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  124282. /**
  124283. * This observable will notify when all animations are playing.
  124284. */
  124285. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  124286. /**
  124287. * Gets the first frame
  124288. */
  124289. get from(): number;
  124290. /**
  124291. * Gets the last frame
  124292. */
  124293. get to(): number;
  124294. /**
  124295. * Define if the animations are started
  124296. */
  124297. get isStarted(): boolean;
  124298. /**
  124299. * Gets a value indicating that the current group is playing
  124300. */
  124301. get isPlaying(): boolean;
  124302. /**
  124303. * Gets or sets the speed ratio to use for all animations
  124304. */
  124305. get speedRatio(): number;
  124306. /**
  124307. * Gets or sets the speed ratio to use for all animations
  124308. */
  124309. set speedRatio(value: number);
  124310. /**
  124311. * Gets or sets if all animations should loop or not
  124312. */
  124313. get loopAnimation(): boolean;
  124314. set loopAnimation(value: boolean);
  124315. /**
  124316. * Gets or sets if all animations should be evaluated additively
  124317. */
  124318. get isAdditive(): boolean;
  124319. set isAdditive(value: boolean);
  124320. /**
  124321. * Gets the targeted animations for this animation group
  124322. */
  124323. get targetedAnimations(): Array<TargetedAnimation>;
  124324. /**
  124325. * returning the list of animatables controlled by this animation group.
  124326. */
  124327. get animatables(): Array<Animatable>;
  124328. /**
  124329. * Gets the list of target animations
  124330. */
  124331. get children(): TargetedAnimation[];
  124332. /**
  124333. * Instantiates a new Animation Group.
  124334. * This helps managing several animations at once.
  124335. * @see https://doc.babylonjs.com/how_to/group
  124336. * @param name Defines the name of the group
  124337. * @param scene Defines the scene the group belongs to
  124338. */
  124339. constructor(
  124340. /** The name of the animation group */
  124341. name: string, scene?: Nullable<Scene>);
  124342. /**
  124343. * Add an animation (with its target) in the group
  124344. * @param animation defines the animation we want to add
  124345. * @param target defines the target of the animation
  124346. * @returns the TargetedAnimation object
  124347. */
  124348. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  124349. /**
  124350. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  124351. * It can add constant keys at begin or end
  124352. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  124353. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  124354. * @returns the animation group
  124355. */
  124356. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  124357. private _animationLoopCount;
  124358. private _animationLoopFlags;
  124359. private _processLoop;
  124360. /**
  124361. * Start all animations on given targets
  124362. * @param loop defines if animations must loop
  124363. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  124364. * @param from defines the from key (optional)
  124365. * @param to defines the to key (optional)
  124366. * @param isAdditive defines the additive state for the resulting animatables (optional)
  124367. * @returns the current animation group
  124368. */
  124369. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  124370. /**
  124371. * Pause all animations
  124372. * @returns the animation group
  124373. */
  124374. pause(): AnimationGroup;
  124375. /**
  124376. * Play all animations to initial state
  124377. * This function will start() the animations if they were not started or will restart() them if they were paused
  124378. * @param loop defines if animations must loop
  124379. * @returns the animation group
  124380. */
  124381. play(loop?: boolean): AnimationGroup;
  124382. /**
  124383. * Reset all animations to initial state
  124384. * @returns the animation group
  124385. */
  124386. reset(): AnimationGroup;
  124387. /**
  124388. * Restart animations from key 0
  124389. * @returns the animation group
  124390. */
  124391. restart(): AnimationGroup;
  124392. /**
  124393. * Stop all animations
  124394. * @returns the animation group
  124395. */
  124396. stop(): AnimationGroup;
  124397. /**
  124398. * Set animation weight for all animatables
  124399. * @param weight defines the weight to use
  124400. * @return the animationGroup
  124401. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124402. */
  124403. setWeightForAllAnimatables(weight: number): AnimationGroup;
  124404. /**
  124405. * Synchronize and normalize all animatables with a source animatable
  124406. * @param root defines the root animatable to synchronize with
  124407. * @return the animationGroup
  124408. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  124409. */
  124410. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  124411. /**
  124412. * Goes to a specific frame in this animation group
  124413. * @param frame the frame number to go to
  124414. * @return the animationGroup
  124415. */
  124416. goToFrame(frame: number): AnimationGroup;
  124417. /**
  124418. * Dispose all associated resources
  124419. */
  124420. dispose(): void;
  124421. private _checkAnimationGroupEnded;
  124422. /**
  124423. * Clone the current animation group and returns a copy
  124424. * @param newName defines the name of the new group
  124425. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  124426. * @returns the new aniamtion group
  124427. */
  124428. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  124429. /**
  124430. * Serializes the animationGroup to an object
  124431. * @returns Serialized object
  124432. */
  124433. serialize(): any;
  124434. /**
  124435. * Returns a new AnimationGroup object parsed from the source provided.
  124436. * @param parsedAnimationGroup defines the source
  124437. * @param scene defines the scene that will receive the animationGroup
  124438. * @returns a new AnimationGroup
  124439. */
  124440. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  124441. /**
  124442. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  124443. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  124444. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  124445. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  124446. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  124447. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  124448. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  124449. */
  124450. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  124451. /**
  124452. * Returns the string "AnimationGroup"
  124453. * @returns "AnimationGroup"
  124454. */
  124455. getClassName(): string;
  124456. /**
  124457. * Creates a detailled string about the object
  124458. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  124459. * @returns a string representing the object
  124460. */
  124461. toString(fullDetails?: boolean): string;
  124462. }
  124463. }
  124464. declare module BABYLON {
  124465. /**
  124466. * Define an interface for all classes that will hold resources
  124467. */
  124468. export interface IDisposable {
  124469. /**
  124470. * Releases all held resources
  124471. */
  124472. dispose(): void;
  124473. }
  124474. /** Interface defining initialization parameters for Scene class */
  124475. export interface SceneOptions {
  124476. /**
  124477. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  124478. * It will improve performance when the number of geometries becomes important.
  124479. */
  124480. useGeometryUniqueIdsMap?: boolean;
  124481. /**
  124482. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  124483. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124484. */
  124485. useMaterialMeshMap?: boolean;
  124486. /**
  124487. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  124488. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  124489. */
  124490. useClonedMeshMap?: boolean;
  124491. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  124492. virtual?: boolean;
  124493. }
  124494. /**
  124495. * Represents a scene to be rendered by the engine.
  124496. * @see https://doc.babylonjs.com/features/scene
  124497. */
  124498. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  124499. /** The fog is deactivated */
  124500. static readonly FOGMODE_NONE: number;
  124501. /** The fog density is following an exponential function */
  124502. static readonly FOGMODE_EXP: number;
  124503. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  124504. static readonly FOGMODE_EXP2: number;
  124505. /** The fog density is following a linear function. */
  124506. static readonly FOGMODE_LINEAR: number;
  124507. /**
  124508. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  124509. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124510. */
  124511. static MinDeltaTime: number;
  124512. /**
  124513. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  124514. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124515. */
  124516. static MaxDeltaTime: number;
  124517. /**
  124518. * Factory used to create the default material.
  124519. * @param name The name of the material to create
  124520. * @param scene The scene to create the material for
  124521. * @returns The default material
  124522. */
  124523. static DefaultMaterialFactory(scene: Scene): Material;
  124524. /**
  124525. * Factory used to create the a collision coordinator.
  124526. * @returns The collision coordinator
  124527. */
  124528. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  124529. /** @hidden */
  124530. _inputManager: InputManager;
  124531. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  124532. cameraToUseForPointers: Nullable<Camera>;
  124533. /** @hidden */
  124534. readonly _isScene: boolean;
  124535. /** @hidden */
  124536. _blockEntityCollection: boolean;
  124537. /**
  124538. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  124539. */
  124540. autoClear: boolean;
  124541. /**
  124542. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  124543. */
  124544. autoClearDepthAndStencil: boolean;
  124545. /**
  124546. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  124547. */
  124548. clearColor: Color4;
  124549. /**
  124550. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  124551. */
  124552. ambientColor: Color3;
  124553. /**
  124554. * This is use to store the default BRDF lookup for PBR materials in your scene.
  124555. * It should only be one of the following (if not the default embedded one):
  124556. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124557. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  124558. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124559. * The material properties need to be setup according to the type of texture in use.
  124560. */
  124561. environmentBRDFTexture: BaseTexture;
  124562. /**
  124563. * Texture used in all pbr material as the reflection texture.
  124564. * As in the majority of the scene they are the same (exception for multi room and so on),
  124565. * this is easier to reference from here than from all the materials.
  124566. */
  124567. get environmentTexture(): Nullable<BaseTexture>;
  124568. /**
  124569. * Texture used in all pbr material as the reflection texture.
  124570. * As in the majority of the scene they are the same (exception for multi room and so on),
  124571. * this is easier to set here than in all the materials.
  124572. */
  124573. set environmentTexture(value: Nullable<BaseTexture>);
  124574. /** @hidden */
  124575. protected _environmentIntensity: number;
  124576. /**
  124577. * Intensity of the environment in all pbr material.
  124578. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124579. * As in the majority of the scene they are the same (exception for multi room and so on),
  124580. * this is easier to reference from here than from all the materials.
  124581. */
  124582. get environmentIntensity(): number;
  124583. /**
  124584. * Intensity of the environment in all pbr material.
  124585. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  124586. * As in the majority of the scene they are the same (exception for multi room and so on),
  124587. * this is easier to set here than in all the materials.
  124588. */
  124589. set environmentIntensity(value: number);
  124590. /** @hidden */
  124591. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124592. /**
  124593. * Default image processing configuration used either in the rendering
  124594. * Forward main pass or through the imageProcessingPostProcess if present.
  124595. * As in the majority of the scene they are the same (exception for multi camera),
  124596. * this is easier to reference from here than from all the materials and post process.
  124597. *
  124598. * No setter as we it is a shared configuration, you can set the values instead.
  124599. */
  124600. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124601. private _forceWireframe;
  124602. /**
  124603. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  124604. */
  124605. set forceWireframe(value: boolean);
  124606. get forceWireframe(): boolean;
  124607. private _skipFrustumClipping;
  124608. /**
  124609. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  124610. */
  124611. set skipFrustumClipping(value: boolean);
  124612. get skipFrustumClipping(): boolean;
  124613. private _forcePointsCloud;
  124614. /**
  124615. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  124616. */
  124617. set forcePointsCloud(value: boolean);
  124618. get forcePointsCloud(): boolean;
  124619. /**
  124620. * Gets or sets the active clipplane 1
  124621. */
  124622. clipPlane: Nullable<Plane>;
  124623. /**
  124624. * Gets or sets the active clipplane 2
  124625. */
  124626. clipPlane2: Nullable<Plane>;
  124627. /**
  124628. * Gets or sets the active clipplane 3
  124629. */
  124630. clipPlane3: Nullable<Plane>;
  124631. /**
  124632. * Gets or sets the active clipplane 4
  124633. */
  124634. clipPlane4: Nullable<Plane>;
  124635. /**
  124636. * Gets or sets the active clipplane 5
  124637. */
  124638. clipPlane5: Nullable<Plane>;
  124639. /**
  124640. * Gets or sets the active clipplane 6
  124641. */
  124642. clipPlane6: Nullable<Plane>;
  124643. /**
  124644. * Gets or sets a boolean indicating if animations are enabled
  124645. */
  124646. animationsEnabled: boolean;
  124647. private _animationPropertiesOverride;
  124648. /**
  124649. * Gets or sets the animation properties override
  124650. */
  124651. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  124652. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  124653. /**
  124654. * Gets or sets a boolean indicating if a constant deltatime has to be used
  124655. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  124656. */
  124657. useConstantAnimationDeltaTime: boolean;
  124658. /**
  124659. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  124660. * Please note that it requires to run a ray cast through the scene on every frame
  124661. */
  124662. constantlyUpdateMeshUnderPointer: boolean;
  124663. /**
  124664. * Defines the HTML cursor to use when hovering over interactive elements
  124665. */
  124666. hoverCursor: string;
  124667. /**
  124668. * Defines the HTML default cursor to use (empty by default)
  124669. */
  124670. defaultCursor: string;
  124671. /**
  124672. * Defines whether cursors are handled by the scene.
  124673. */
  124674. doNotHandleCursors: boolean;
  124675. /**
  124676. * This is used to call preventDefault() on pointer down
  124677. * in order to block unwanted artifacts like system double clicks
  124678. */
  124679. preventDefaultOnPointerDown: boolean;
  124680. /**
  124681. * This is used to call preventDefault() on pointer up
  124682. * in order to block unwanted artifacts like system double clicks
  124683. */
  124684. preventDefaultOnPointerUp: boolean;
  124685. /**
  124686. * Gets or sets user defined metadata
  124687. */
  124688. metadata: any;
  124689. /**
  124690. * For internal use only. Please do not use.
  124691. */
  124692. reservedDataStore: any;
  124693. /**
  124694. * Gets the name of the plugin used to load this scene (null by default)
  124695. */
  124696. loadingPluginName: string;
  124697. /**
  124698. * Use this array to add regular expressions used to disable offline support for specific urls
  124699. */
  124700. disableOfflineSupportExceptionRules: RegExp[];
  124701. /**
  124702. * An event triggered when the scene is disposed.
  124703. */
  124704. onDisposeObservable: Observable<Scene>;
  124705. private _onDisposeObserver;
  124706. /** Sets a function to be executed when this scene is disposed. */
  124707. set onDispose(callback: () => void);
  124708. /**
  124709. * An event triggered before rendering the scene (right after animations and physics)
  124710. */
  124711. onBeforeRenderObservable: Observable<Scene>;
  124712. private _onBeforeRenderObserver;
  124713. /** Sets a function to be executed before rendering this scene */
  124714. set beforeRender(callback: Nullable<() => void>);
  124715. /**
  124716. * An event triggered after rendering the scene
  124717. */
  124718. onAfterRenderObservable: Observable<Scene>;
  124719. /**
  124720. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124721. */
  124722. onAfterRenderCameraObservable: Observable<Camera>;
  124723. private _onAfterRenderObserver;
  124724. /** Sets a function to be executed after rendering this scene */
  124725. set afterRender(callback: Nullable<() => void>);
  124726. /**
  124727. * An event triggered before animating the scene
  124728. */
  124729. onBeforeAnimationsObservable: Observable<Scene>;
  124730. /**
  124731. * An event triggered after animations processing
  124732. */
  124733. onAfterAnimationsObservable: Observable<Scene>;
  124734. /**
  124735. * An event triggered before draw calls are ready to be sent
  124736. */
  124737. onBeforeDrawPhaseObservable: Observable<Scene>;
  124738. /**
  124739. * An event triggered after draw calls have been sent
  124740. */
  124741. onAfterDrawPhaseObservable: Observable<Scene>;
  124742. /**
  124743. * An event triggered when the scene is ready
  124744. */
  124745. onReadyObservable: Observable<Scene>;
  124746. /**
  124747. * An event triggered before rendering a camera
  124748. */
  124749. onBeforeCameraRenderObservable: Observable<Camera>;
  124750. private _onBeforeCameraRenderObserver;
  124751. /** Sets a function to be executed before rendering a camera*/
  124752. set beforeCameraRender(callback: () => void);
  124753. /**
  124754. * An event triggered after rendering a camera
  124755. */
  124756. onAfterCameraRenderObservable: Observable<Camera>;
  124757. private _onAfterCameraRenderObserver;
  124758. /** Sets a function to be executed after rendering a camera*/
  124759. set afterCameraRender(callback: () => void);
  124760. /**
  124761. * An event triggered when active meshes evaluation is about to start
  124762. */
  124763. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124764. /**
  124765. * An event triggered when active meshes evaluation is done
  124766. */
  124767. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124768. /**
  124769. * An event triggered when particles rendering is about to start
  124770. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124771. */
  124772. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124773. /**
  124774. * An event triggered when particles rendering is done
  124775. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124776. */
  124777. onAfterParticlesRenderingObservable: Observable<Scene>;
  124778. /**
  124779. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124780. */
  124781. onDataLoadedObservable: Observable<Scene>;
  124782. /**
  124783. * An event triggered when a camera is created
  124784. */
  124785. onNewCameraAddedObservable: Observable<Camera>;
  124786. /**
  124787. * An event triggered when a camera is removed
  124788. */
  124789. onCameraRemovedObservable: Observable<Camera>;
  124790. /**
  124791. * An event triggered when a light is created
  124792. */
  124793. onNewLightAddedObservable: Observable<Light>;
  124794. /**
  124795. * An event triggered when a light is removed
  124796. */
  124797. onLightRemovedObservable: Observable<Light>;
  124798. /**
  124799. * An event triggered when a geometry is created
  124800. */
  124801. onNewGeometryAddedObservable: Observable<Geometry>;
  124802. /**
  124803. * An event triggered when a geometry is removed
  124804. */
  124805. onGeometryRemovedObservable: Observable<Geometry>;
  124806. /**
  124807. * An event triggered when a transform node is created
  124808. */
  124809. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124810. /**
  124811. * An event triggered when a transform node is removed
  124812. */
  124813. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124814. /**
  124815. * An event triggered when a mesh is created
  124816. */
  124817. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124818. /**
  124819. * An event triggered when a mesh is removed
  124820. */
  124821. onMeshRemovedObservable: Observable<AbstractMesh>;
  124822. /**
  124823. * An event triggered when a skeleton is created
  124824. */
  124825. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124826. /**
  124827. * An event triggered when a skeleton is removed
  124828. */
  124829. onSkeletonRemovedObservable: Observable<Skeleton>;
  124830. /**
  124831. * An event triggered when a material is created
  124832. */
  124833. onNewMaterialAddedObservable: Observable<Material>;
  124834. /**
  124835. * An event triggered when a multi material is created
  124836. */
  124837. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  124838. /**
  124839. * An event triggered when a material is removed
  124840. */
  124841. onMaterialRemovedObservable: Observable<Material>;
  124842. /**
  124843. * An event triggered when a multi material is removed
  124844. */
  124845. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  124846. /**
  124847. * An event triggered when a texture is created
  124848. */
  124849. onNewTextureAddedObservable: Observable<BaseTexture>;
  124850. /**
  124851. * An event triggered when a texture is removed
  124852. */
  124853. onTextureRemovedObservable: Observable<BaseTexture>;
  124854. /**
  124855. * An event triggered when render targets are about to be rendered
  124856. * Can happen multiple times per frame.
  124857. */
  124858. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124859. /**
  124860. * An event triggered when render targets were rendered.
  124861. * Can happen multiple times per frame.
  124862. */
  124863. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124864. /**
  124865. * An event triggered before calculating deterministic simulation step
  124866. */
  124867. onBeforeStepObservable: Observable<Scene>;
  124868. /**
  124869. * An event triggered after calculating deterministic simulation step
  124870. */
  124871. onAfterStepObservable: Observable<Scene>;
  124872. /**
  124873. * An event triggered when the activeCamera property is updated
  124874. */
  124875. onActiveCameraChanged: Observable<Scene>;
  124876. /**
  124877. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124878. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124879. * 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)
  124880. */
  124881. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124882. /**
  124883. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124884. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124885. * 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)
  124886. */
  124887. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124888. /**
  124889. * This Observable will when a mesh has been imported into the scene.
  124890. */
  124891. onMeshImportedObservable: Observable<AbstractMesh>;
  124892. /**
  124893. * This Observable will when an animation file has been imported into the scene.
  124894. */
  124895. onAnimationFileImportedObservable: Observable<Scene>;
  124896. /**
  124897. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124898. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124899. */
  124900. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124901. /** @hidden */
  124902. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124903. /**
  124904. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124905. */
  124906. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124907. /**
  124908. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124909. */
  124910. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124911. /**
  124912. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124913. */
  124914. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124915. /** Callback called when a pointer move is detected */
  124916. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124917. /** Callback called when a pointer down is detected */
  124918. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124919. /** Callback called when a pointer up is detected */
  124920. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124921. /** Callback called when a pointer pick is detected */
  124922. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124923. /**
  124924. * 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).
  124925. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124926. */
  124927. onPrePointerObservable: Observable<PointerInfoPre>;
  124928. /**
  124929. * Observable event triggered each time an input event is received from the rendering canvas
  124930. */
  124931. onPointerObservable: Observable<PointerInfo>;
  124932. /**
  124933. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124934. */
  124935. get unTranslatedPointer(): Vector2;
  124936. /**
  124937. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124938. */
  124939. static get DragMovementThreshold(): number;
  124940. static set DragMovementThreshold(value: number);
  124941. /**
  124942. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124943. */
  124944. static get LongPressDelay(): number;
  124945. static set LongPressDelay(value: number);
  124946. /**
  124947. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124948. */
  124949. static get DoubleClickDelay(): number;
  124950. static set DoubleClickDelay(value: number);
  124951. /** If you need to check double click without raising a single click at first click, enable this flag */
  124952. static get ExclusiveDoubleClickMode(): boolean;
  124953. static set ExclusiveDoubleClickMode(value: boolean);
  124954. /** @hidden */
  124955. _mirroredCameraPosition: Nullable<Vector3>;
  124956. /**
  124957. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124958. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124959. */
  124960. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124961. /**
  124962. * Observable event triggered each time an keyboard event is received from the hosting window
  124963. */
  124964. onKeyboardObservable: Observable<KeyboardInfo>;
  124965. private _useRightHandedSystem;
  124966. /**
  124967. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124968. */
  124969. set useRightHandedSystem(value: boolean);
  124970. get useRightHandedSystem(): boolean;
  124971. private _timeAccumulator;
  124972. private _currentStepId;
  124973. private _currentInternalStep;
  124974. /**
  124975. * Sets the step Id used by deterministic lock step
  124976. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124977. * @param newStepId defines the step Id
  124978. */
  124979. setStepId(newStepId: number): void;
  124980. /**
  124981. * Gets the step Id used by deterministic lock step
  124982. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124983. * @returns the step Id
  124984. */
  124985. getStepId(): number;
  124986. /**
  124987. * Gets the internal step used by deterministic lock step
  124988. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124989. * @returns the internal step
  124990. */
  124991. getInternalStep(): number;
  124992. private _fogEnabled;
  124993. /**
  124994. * Gets or sets a boolean indicating if fog is enabled on this scene
  124995. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124996. * (Default is true)
  124997. */
  124998. set fogEnabled(value: boolean);
  124999. get fogEnabled(): boolean;
  125000. private _fogMode;
  125001. /**
  125002. * Gets or sets the fog mode to use
  125003. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125004. * | mode | value |
  125005. * | --- | --- |
  125006. * | FOGMODE_NONE | 0 |
  125007. * | FOGMODE_EXP | 1 |
  125008. * | FOGMODE_EXP2 | 2 |
  125009. * | FOGMODE_LINEAR | 3 |
  125010. */
  125011. set fogMode(value: number);
  125012. get fogMode(): number;
  125013. /**
  125014. * Gets or sets the fog color to use
  125015. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125016. * (Default is Color3(0.2, 0.2, 0.3))
  125017. */
  125018. fogColor: Color3;
  125019. /**
  125020. * Gets or sets the fog density to use
  125021. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125022. * (Default is 0.1)
  125023. */
  125024. fogDensity: number;
  125025. /**
  125026. * Gets or sets the fog start distance to use
  125027. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125028. * (Default is 0)
  125029. */
  125030. fogStart: number;
  125031. /**
  125032. * Gets or sets the fog end distance to use
  125033. * @see https://doc.babylonjs.com/babylon101/environment#fog
  125034. * (Default is 1000)
  125035. */
  125036. fogEnd: number;
  125037. /**
  125038. * Flag indicating that the frame buffer binding is handled by another component
  125039. */
  125040. prePass: boolean;
  125041. private _shadowsEnabled;
  125042. /**
  125043. * Gets or sets a boolean indicating if shadows are enabled on this scene
  125044. */
  125045. set shadowsEnabled(value: boolean);
  125046. get shadowsEnabled(): boolean;
  125047. private _lightsEnabled;
  125048. /**
  125049. * Gets or sets a boolean indicating if lights are enabled on this scene
  125050. */
  125051. set lightsEnabled(value: boolean);
  125052. get lightsEnabled(): boolean;
  125053. /** All of the active cameras added to this scene. */
  125054. activeCameras: Nullable<Camera[]>;
  125055. /** @hidden */
  125056. _activeCamera: Nullable<Camera>;
  125057. /** Gets or sets the current active camera */
  125058. get activeCamera(): Nullable<Camera>;
  125059. set activeCamera(value: Nullable<Camera>);
  125060. private _defaultMaterial;
  125061. /** The default material used on meshes when no material is affected */
  125062. get defaultMaterial(): Material;
  125063. /** The default material used on meshes when no material is affected */
  125064. set defaultMaterial(value: Material);
  125065. private _texturesEnabled;
  125066. /**
  125067. * Gets or sets a boolean indicating if textures are enabled on this scene
  125068. */
  125069. set texturesEnabled(value: boolean);
  125070. get texturesEnabled(): boolean;
  125071. /**
  125072. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  125073. */
  125074. physicsEnabled: boolean;
  125075. /**
  125076. * Gets or sets a boolean indicating if particles are enabled on this scene
  125077. */
  125078. particlesEnabled: boolean;
  125079. /**
  125080. * Gets or sets a boolean indicating if sprites are enabled on this scene
  125081. */
  125082. spritesEnabled: boolean;
  125083. private _skeletonsEnabled;
  125084. /**
  125085. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  125086. */
  125087. set skeletonsEnabled(value: boolean);
  125088. get skeletonsEnabled(): boolean;
  125089. /**
  125090. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  125091. */
  125092. lensFlaresEnabled: boolean;
  125093. /**
  125094. * Gets or sets a boolean indicating if collisions are enabled on this scene
  125095. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  125096. */
  125097. collisionsEnabled: boolean;
  125098. private _collisionCoordinator;
  125099. /** @hidden */
  125100. get collisionCoordinator(): ICollisionCoordinator;
  125101. /**
  125102. * Defines the gravity applied to this scene (used only for collisions)
  125103. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  125104. */
  125105. gravity: Vector3;
  125106. /**
  125107. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  125108. */
  125109. postProcessesEnabled: boolean;
  125110. /**
  125111. * Gets the current postprocess manager
  125112. */
  125113. postProcessManager: PostProcessManager;
  125114. /**
  125115. * Gets or sets a boolean indicating if render targets are enabled on this scene
  125116. */
  125117. renderTargetsEnabled: boolean;
  125118. /**
  125119. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  125120. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  125121. */
  125122. dumpNextRenderTargets: boolean;
  125123. /**
  125124. * The list of user defined render targets added to the scene
  125125. */
  125126. customRenderTargets: RenderTargetTexture[];
  125127. /**
  125128. * Defines if texture loading must be delayed
  125129. * If true, textures will only be loaded when they need to be rendered
  125130. */
  125131. useDelayedTextureLoading: boolean;
  125132. /**
  125133. * Gets the list of meshes imported to the scene through SceneLoader
  125134. */
  125135. importedMeshesFiles: String[];
  125136. /**
  125137. * Gets or sets a boolean indicating if probes are enabled on this scene
  125138. */
  125139. probesEnabled: boolean;
  125140. /**
  125141. * Gets or sets the current offline provider to use to store scene data
  125142. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  125143. */
  125144. offlineProvider: IOfflineProvider;
  125145. /**
  125146. * Gets or sets the action manager associated with the scene
  125147. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  125148. */
  125149. actionManager: AbstractActionManager;
  125150. private _meshesForIntersections;
  125151. /**
  125152. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  125153. */
  125154. proceduralTexturesEnabled: boolean;
  125155. private _engine;
  125156. private _totalVertices;
  125157. /** @hidden */
  125158. _activeIndices: PerfCounter;
  125159. /** @hidden */
  125160. _activeParticles: PerfCounter;
  125161. /** @hidden */
  125162. _activeBones: PerfCounter;
  125163. private _animationRatio;
  125164. /** @hidden */
  125165. _animationTimeLast: number;
  125166. /** @hidden */
  125167. _animationTime: number;
  125168. /**
  125169. * Gets or sets a general scale for animation speed
  125170. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  125171. */
  125172. animationTimeScale: number;
  125173. /** @hidden */
  125174. _cachedMaterial: Nullable<Material>;
  125175. /** @hidden */
  125176. _cachedEffect: Nullable<Effect>;
  125177. /** @hidden */
  125178. _cachedVisibility: Nullable<number>;
  125179. private _renderId;
  125180. private _frameId;
  125181. private _executeWhenReadyTimeoutId;
  125182. private _intermediateRendering;
  125183. private _viewUpdateFlag;
  125184. private _projectionUpdateFlag;
  125185. /** @hidden */
  125186. _toBeDisposed: Nullable<IDisposable>[];
  125187. private _activeRequests;
  125188. /** @hidden */
  125189. _pendingData: any[];
  125190. private _isDisposed;
  125191. /**
  125192. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  125193. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  125194. */
  125195. dispatchAllSubMeshesOfActiveMeshes: boolean;
  125196. private _activeMeshes;
  125197. private _processedMaterials;
  125198. private _renderTargets;
  125199. /** @hidden */
  125200. _activeParticleSystems: SmartArray<IParticleSystem>;
  125201. private _activeSkeletons;
  125202. private _softwareSkinnedMeshes;
  125203. private _renderingManager;
  125204. /** @hidden */
  125205. _activeAnimatables: Animatable[];
  125206. private _transformMatrix;
  125207. private _sceneUbo;
  125208. /** @hidden */
  125209. _viewMatrix: Matrix;
  125210. private _projectionMatrix;
  125211. /** @hidden */
  125212. _forcedViewPosition: Nullable<Vector3>;
  125213. /** @hidden */
  125214. _frustumPlanes: Plane[];
  125215. /**
  125216. * Gets the list of frustum planes (built from the active camera)
  125217. */
  125218. get frustumPlanes(): Plane[];
  125219. /**
  125220. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  125221. * This is useful if there are more lights that the maximum simulteanous authorized
  125222. */
  125223. requireLightSorting: boolean;
  125224. /** @hidden */
  125225. readonly useMaterialMeshMap: boolean;
  125226. /** @hidden */
  125227. readonly useClonedMeshMap: boolean;
  125228. private _externalData;
  125229. private _uid;
  125230. /**
  125231. * @hidden
  125232. * Backing store of defined scene components.
  125233. */
  125234. _components: ISceneComponent[];
  125235. /**
  125236. * @hidden
  125237. * Backing store of defined scene components.
  125238. */
  125239. _serializableComponents: ISceneSerializableComponent[];
  125240. /**
  125241. * List of components to register on the next registration step.
  125242. */
  125243. private _transientComponents;
  125244. /**
  125245. * Registers the transient components if needed.
  125246. */
  125247. private _registerTransientComponents;
  125248. /**
  125249. * @hidden
  125250. * Add a component to the scene.
  125251. * Note that the ccomponent could be registered on th next frame if this is called after
  125252. * the register component stage.
  125253. * @param component Defines the component to add to the scene
  125254. */
  125255. _addComponent(component: ISceneComponent): void;
  125256. /**
  125257. * @hidden
  125258. * Gets a component from the scene.
  125259. * @param name defines the name of the component to retrieve
  125260. * @returns the component or null if not present
  125261. */
  125262. _getComponent(name: string): Nullable<ISceneComponent>;
  125263. /**
  125264. * @hidden
  125265. * Defines the actions happening before camera updates.
  125266. */
  125267. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  125268. /**
  125269. * @hidden
  125270. * Defines the actions happening before clear the canvas.
  125271. */
  125272. _beforeClearStage: Stage<SimpleStageAction>;
  125273. /**
  125274. * @hidden
  125275. * Defines the actions when collecting render targets for the frame.
  125276. */
  125277. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125278. /**
  125279. * @hidden
  125280. * Defines the actions happening for one camera in the frame.
  125281. */
  125282. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  125283. /**
  125284. * @hidden
  125285. * Defines the actions happening during the per mesh ready checks.
  125286. */
  125287. _isReadyForMeshStage: Stage<MeshStageAction>;
  125288. /**
  125289. * @hidden
  125290. * Defines the actions happening before evaluate active mesh checks.
  125291. */
  125292. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  125293. /**
  125294. * @hidden
  125295. * Defines the actions happening during the evaluate sub mesh checks.
  125296. */
  125297. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  125298. /**
  125299. * @hidden
  125300. * Defines the actions happening during the active mesh stage.
  125301. */
  125302. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  125303. /**
  125304. * @hidden
  125305. * Defines the actions happening during the per camera render target step.
  125306. */
  125307. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  125308. /**
  125309. * @hidden
  125310. * Defines the actions happening just before the active camera is drawing.
  125311. */
  125312. _beforeCameraDrawStage: Stage<CameraStageAction>;
  125313. /**
  125314. * @hidden
  125315. * Defines the actions happening just before a render target is drawing.
  125316. */
  125317. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125318. /**
  125319. * @hidden
  125320. * Defines the actions happening just before a rendering group is drawing.
  125321. */
  125322. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125323. /**
  125324. * @hidden
  125325. * Defines the actions happening just before a mesh is drawing.
  125326. */
  125327. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125328. /**
  125329. * @hidden
  125330. * Defines the actions happening just after a mesh has been drawn.
  125331. */
  125332. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  125333. /**
  125334. * @hidden
  125335. * Defines the actions happening just after a rendering group has been drawn.
  125336. */
  125337. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  125338. /**
  125339. * @hidden
  125340. * Defines the actions happening just after the active camera has been drawn.
  125341. */
  125342. _afterCameraDrawStage: Stage<CameraStageAction>;
  125343. /**
  125344. * @hidden
  125345. * Defines the actions happening just after a render target has been drawn.
  125346. */
  125347. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  125348. /**
  125349. * @hidden
  125350. * Defines the actions happening just after rendering all cameras and computing intersections.
  125351. */
  125352. _afterRenderStage: Stage<SimpleStageAction>;
  125353. /**
  125354. * @hidden
  125355. * Defines the actions happening when a pointer move event happens.
  125356. */
  125357. _pointerMoveStage: Stage<PointerMoveStageAction>;
  125358. /**
  125359. * @hidden
  125360. * Defines the actions happening when a pointer down event happens.
  125361. */
  125362. _pointerDownStage: Stage<PointerUpDownStageAction>;
  125363. /**
  125364. * @hidden
  125365. * Defines the actions happening when a pointer up event happens.
  125366. */
  125367. _pointerUpStage: Stage<PointerUpDownStageAction>;
  125368. /**
  125369. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  125370. */
  125371. private geometriesByUniqueId;
  125372. /**
  125373. * Creates a new Scene
  125374. * @param engine defines the engine to use to render this scene
  125375. * @param options defines the scene options
  125376. */
  125377. constructor(engine: Engine, options?: SceneOptions);
  125378. /**
  125379. * Gets a string identifying the name of the class
  125380. * @returns "Scene" string
  125381. */
  125382. getClassName(): string;
  125383. private _defaultMeshCandidates;
  125384. /**
  125385. * @hidden
  125386. */
  125387. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  125388. private _defaultSubMeshCandidates;
  125389. /**
  125390. * @hidden
  125391. */
  125392. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  125393. /**
  125394. * Sets the default candidate providers for the scene.
  125395. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  125396. * and getCollidingSubMeshCandidates to their default function
  125397. */
  125398. setDefaultCandidateProviders(): void;
  125399. /**
  125400. * Gets the mesh that is currently under the pointer
  125401. */
  125402. get meshUnderPointer(): Nullable<AbstractMesh>;
  125403. /**
  125404. * Gets or sets the current on-screen X position of the pointer
  125405. */
  125406. get pointerX(): number;
  125407. set pointerX(value: number);
  125408. /**
  125409. * Gets or sets the current on-screen Y position of the pointer
  125410. */
  125411. get pointerY(): number;
  125412. set pointerY(value: number);
  125413. /**
  125414. * Gets the cached material (ie. the latest rendered one)
  125415. * @returns the cached material
  125416. */
  125417. getCachedMaterial(): Nullable<Material>;
  125418. /**
  125419. * Gets the cached effect (ie. the latest rendered one)
  125420. * @returns the cached effect
  125421. */
  125422. getCachedEffect(): Nullable<Effect>;
  125423. /**
  125424. * Gets the cached visibility state (ie. the latest rendered one)
  125425. * @returns the cached visibility state
  125426. */
  125427. getCachedVisibility(): Nullable<number>;
  125428. /**
  125429. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  125430. * @param material defines the current material
  125431. * @param effect defines the current effect
  125432. * @param visibility defines the current visibility state
  125433. * @returns true if one parameter is not cached
  125434. */
  125435. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  125436. /**
  125437. * Gets the engine associated with the scene
  125438. * @returns an Engine
  125439. */
  125440. getEngine(): Engine;
  125441. /**
  125442. * Gets the total number of vertices rendered per frame
  125443. * @returns the total number of vertices rendered per frame
  125444. */
  125445. getTotalVertices(): number;
  125446. /**
  125447. * Gets the performance counter for total vertices
  125448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125449. */
  125450. get totalVerticesPerfCounter(): PerfCounter;
  125451. /**
  125452. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  125453. * @returns the total number of active indices rendered per frame
  125454. */
  125455. getActiveIndices(): number;
  125456. /**
  125457. * Gets the performance counter for active indices
  125458. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125459. */
  125460. get totalActiveIndicesPerfCounter(): PerfCounter;
  125461. /**
  125462. * Gets the total number of active particles rendered per frame
  125463. * @returns the total number of active particles rendered per frame
  125464. */
  125465. getActiveParticles(): number;
  125466. /**
  125467. * Gets the performance counter for active particles
  125468. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125469. */
  125470. get activeParticlesPerfCounter(): PerfCounter;
  125471. /**
  125472. * Gets the total number of active bones rendered per frame
  125473. * @returns the total number of active bones rendered per frame
  125474. */
  125475. getActiveBones(): number;
  125476. /**
  125477. * Gets the performance counter for active bones
  125478. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  125479. */
  125480. get activeBonesPerfCounter(): PerfCounter;
  125481. /**
  125482. * Gets the array of active meshes
  125483. * @returns an array of AbstractMesh
  125484. */
  125485. getActiveMeshes(): SmartArray<AbstractMesh>;
  125486. /**
  125487. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  125488. * @returns a number
  125489. */
  125490. getAnimationRatio(): number;
  125491. /**
  125492. * Gets an unique Id for the current render phase
  125493. * @returns a number
  125494. */
  125495. getRenderId(): number;
  125496. /**
  125497. * Gets an unique Id for the current frame
  125498. * @returns a number
  125499. */
  125500. getFrameId(): number;
  125501. /** Call this function if you want to manually increment the render Id*/
  125502. incrementRenderId(): void;
  125503. private _createUbo;
  125504. /**
  125505. * Use this method to simulate a pointer move on a mesh
  125506. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125507. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125508. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125509. * @returns the current scene
  125510. */
  125511. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125512. /**
  125513. * Use this method to simulate a pointer down on a mesh
  125514. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125515. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125516. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125517. * @returns the current scene
  125518. */
  125519. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  125520. /**
  125521. * Use this method to simulate a pointer up on a mesh
  125522. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  125523. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  125524. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  125525. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  125526. * @returns the current scene
  125527. */
  125528. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  125529. /**
  125530. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  125531. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  125532. * @returns true if the pointer was captured
  125533. */
  125534. isPointerCaptured(pointerId?: number): boolean;
  125535. /**
  125536. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  125537. * @param attachUp defines if you want to attach events to pointerup
  125538. * @param attachDown defines if you want to attach events to pointerdown
  125539. * @param attachMove defines if you want to attach events to pointermove
  125540. */
  125541. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  125542. /** Detaches all event handlers*/
  125543. detachControl(): void;
  125544. /**
  125545. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  125546. * Delay loaded resources are not taking in account
  125547. * @return true if all required resources are ready
  125548. */
  125549. isReady(): boolean;
  125550. /** Resets all cached information relative to material (including effect and visibility) */
  125551. resetCachedMaterial(): void;
  125552. /**
  125553. * Registers a function to be called before every frame render
  125554. * @param func defines the function to register
  125555. */
  125556. registerBeforeRender(func: () => void): void;
  125557. /**
  125558. * Unregisters a function called before every frame render
  125559. * @param func defines the function to unregister
  125560. */
  125561. unregisterBeforeRender(func: () => void): void;
  125562. /**
  125563. * Registers a function to be called after every frame render
  125564. * @param func defines the function to register
  125565. */
  125566. registerAfterRender(func: () => void): void;
  125567. /**
  125568. * Unregisters a function called after every frame render
  125569. * @param func defines the function to unregister
  125570. */
  125571. unregisterAfterRender(func: () => void): void;
  125572. private _executeOnceBeforeRender;
  125573. /**
  125574. * The provided function will run before render once and will be disposed afterwards.
  125575. * A timeout delay can be provided so that the function will be executed in N ms.
  125576. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  125577. * @param func The function to be executed.
  125578. * @param timeout optional delay in ms
  125579. */
  125580. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  125581. /** @hidden */
  125582. _addPendingData(data: any): void;
  125583. /** @hidden */
  125584. _removePendingData(data: any): void;
  125585. /**
  125586. * Returns the number of items waiting to be loaded
  125587. * @returns the number of items waiting to be loaded
  125588. */
  125589. getWaitingItemsCount(): number;
  125590. /**
  125591. * Returns a boolean indicating if the scene is still loading data
  125592. */
  125593. get isLoading(): boolean;
  125594. /**
  125595. * Registers a function to be executed when the scene is ready
  125596. * @param {Function} func - the function to be executed
  125597. */
  125598. executeWhenReady(func: () => void): void;
  125599. /**
  125600. * Returns a promise that resolves when the scene is ready
  125601. * @returns A promise that resolves when the scene is ready
  125602. */
  125603. whenReadyAsync(): Promise<void>;
  125604. /** @hidden */
  125605. _checkIsReady(): void;
  125606. /**
  125607. * Gets all animatable attached to the scene
  125608. */
  125609. get animatables(): Animatable[];
  125610. /**
  125611. * Resets the last animation time frame.
  125612. * Useful to override when animations start running when loading a scene for the first time.
  125613. */
  125614. resetLastAnimationTimeFrame(): void;
  125615. /**
  125616. * Gets the current view matrix
  125617. * @returns a Matrix
  125618. */
  125619. getViewMatrix(): Matrix;
  125620. /**
  125621. * Gets the current projection matrix
  125622. * @returns a Matrix
  125623. */
  125624. getProjectionMatrix(): Matrix;
  125625. /**
  125626. * Gets the current transform matrix
  125627. * @returns a Matrix made of View * Projection
  125628. */
  125629. getTransformMatrix(): Matrix;
  125630. /**
  125631. * Sets the current transform matrix
  125632. * @param viewL defines the View matrix to use
  125633. * @param projectionL defines the Projection matrix to use
  125634. * @param viewR defines the right View matrix to use (if provided)
  125635. * @param projectionR defines the right Projection matrix to use (if provided)
  125636. */
  125637. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  125638. /**
  125639. * Gets the uniform buffer used to store scene data
  125640. * @returns a UniformBuffer
  125641. */
  125642. getSceneUniformBuffer(): UniformBuffer;
  125643. /**
  125644. * Gets an unique (relatively to the current scene) Id
  125645. * @returns an unique number for the scene
  125646. */
  125647. getUniqueId(): number;
  125648. /**
  125649. * Add a mesh to the list of scene's meshes
  125650. * @param newMesh defines the mesh to add
  125651. * @param recursive if all child meshes should also be added to the scene
  125652. */
  125653. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  125654. /**
  125655. * Remove a mesh for the list of scene's meshes
  125656. * @param toRemove defines the mesh to remove
  125657. * @param recursive if all child meshes should also be removed from the scene
  125658. * @returns the index where the mesh was in the mesh list
  125659. */
  125660. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  125661. /**
  125662. * Add a transform node to the list of scene's transform nodes
  125663. * @param newTransformNode defines the transform node to add
  125664. */
  125665. addTransformNode(newTransformNode: TransformNode): void;
  125666. /**
  125667. * Remove a transform node for the list of scene's transform nodes
  125668. * @param toRemove defines the transform node to remove
  125669. * @returns the index where the transform node was in the transform node list
  125670. */
  125671. removeTransformNode(toRemove: TransformNode): number;
  125672. /**
  125673. * Remove a skeleton for the list of scene's skeletons
  125674. * @param toRemove defines the skeleton to remove
  125675. * @returns the index where the skeleton was in the skeleton list
  125676. */
  125677. removeSkeleton(toRemove: Skeleton): number;
  125678. /**
  125679. * Remove a morph target for the list of scene's morph targets
  125680. * @param toRemove defines the morph target to remove
  125681. * @returns the index where the morph target was in the morph target list
  125682. */
  125683. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125684. /**
  125685. * Remove a light for the list of scene's lights
  125686. * @param toRemove defines the light to remove
  125687. * @returns the index where the light was in the light list
  125688. */
  125689. removeLight(toRemove: Light): number;
  125690. /**
  125691. * Remove a camera for the list of scene's cameras
  125692. * @param toRemove defines the camera to remove
  125693. * @returns the index where the camera was in the camera list
  125694. */
  125695. removeCamera(toRemove: Camera): number;
  125696. /**
  125697. * Remove a particle system for the list of scene's particle systems
  125698. * @param toRemove defines the particle system to remove
  125699. * @returns the index where the particle system was in the particle system list
  125700. */
  125701. removeParticleSystem(toRemove: IParticleSystem): number;
  125702. /**
  125703. * Remove a animation for the list of scene's animations
  125704. * @param toRemove defines the animation to remove
  125705. * @returns the index where the animation was in the animation list
  125706. */
  125707. removeAnimation(toRemove: Animation): number;
  125708. /**
  125709. * Will stop the animation of the given target
  125710. * @param target - the target
  125711. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125712. * @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)
  125713. */
  125714. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125715. /**
  125716. * Removes the given animation group from this scene.
  125717. * @param toRemove The animation group to remove
  125718. * @returns The index of the removed animation group
  125719. */
  125720. removeAnimationGroup(toRemove: AnimationGroup): number;
  125721. /**
  125722. * Removes the given multi-material from this scene.
  125723. * @param toRemove The multi-material to remove
  125724. * @returns The index of the removed multi-material
  125725. */
  125726. removeMultiMaterial(toRemove: MultiMaterial): number;
  125727. /**
  125728. * Removes the given material from this scene.
  125729. * @param toRemove The material to remove
  125730. * @returns The index of the removed material
  125731. */
  125732. removeMaterial(toRemove: Material): number;
  125733. /**
  125734. * Removes the given action manager from this scene.
  125735. * @param toRemove The action manager to remove
  125736. * @returns The index of the removed action manager
  125737. */
  125738. removeActionManager(toRemove: AbstractActionManager): number;
  125739. /**
  125740. * Removes the given texture from this scene.
  125741. * @param toRemove The texture to remove
  125742. * @returns The index of the removed texture
  125743. */
  125744. removeTexture(toRemove: BaseTexture): number;
  125745. /**
  125746. * Adds the given light to this scene
  125747. * @param newLight The light to add
  125748. */
  125749. addLight(newLight: Light): void;
  125750. /**
  125751. * Sorts the list list based on light priorities
  125752. */
  125753. sortLightsByPriority(): void;
  125754. /**
  125755. * Adds the given camera to this scene
  125756. * @param newCamera The camera to add
  125757. */
  125758. addCamera(newCamera: Camera): void;
  125759. /**
  125760. * Adds the given skeleton to this scene
  125761. * @param newSkeleton The skeleton to add
  125762. */
  125763. addSkeleton(newSkeleton: Skeleton): void;
  125764. /**
  125765. * Adds the given particle system to this scene
  125766. * @param newParticleSystem The particle system to add
  125767. */
  125768. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125769. /**
  125770. * Adds the given animation to this scene
  125771. * @param newAnimation The animation to add
  125772. */
  125773. addAnimation(newAnimation: Animation): void;
  125774. /**
  125775. * Adds the given animation group to this scene.
  125776. * @param newAnimationGroup The animation group to add
  125777. */
  125778. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125779. /**
  125780. * Adds the given multi-material to this scene
  125781. * @param newMultiMaterial The multi-material to add
  125782. */
  125783. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125784. /**
  125785. * Adds the given material to this scene
  125786. * @param newMaterial The material to add
  125787. */
  125788. addMaterial(newMaterial: Material): void;
  125789. /**
  125790. * Adds the given morph target to this scene
  125791. * @param newMorphTargetManager The morph target to add
  125792. */
  125793. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125794. /**
  125795. * Adds the given geometry to this scene
  125796. * @param newGeometry The geometry to add
  125797. */
  125798. addGeometry(newGeometry: Geometry): void;
  125799. /**
  125800. * Adds the given action manager to this scene
  125801. * @param newActionManager The action manager to add
  125802. */
  125803. addActionManager(newActionManager: AbstractActionManager): void;
  125804. /**
  125805. * Adds the given texture to this scene.
  125806. * @param newTexture The texture to add
  125807. */
  125808. addTexture(newTexture: BaseTexture): void;
  125809. /**
  125810. * Switch active camera
  125811. * @param newCamera defines the new active camera
  125812. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125813. */
  125814. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125815. /**
  125816. * sets the active camera of the scene using its ID
  125817. * @param id defines the camera's ID
  125818. * @return the new active camera or null if none found.
  125819. */
  125820. setActiveCameraByID(id: string): Nullable<Camera>;
  125821. /**
  125822. * sets the active camera of the scene using its name
  125823. * @param name defines the camera's name
  125824. * @returns the new active camera or null if none found.
  125825. */
  125826. setActiveCameraByName(name: string): Nullable<Camera>;
  125827. /**
  125828. * get an animation group using its name
  125829. * @param name defines the material's name
  125830. * @return the animation group or null if none found.
  125831. */
  125832. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125833. /**
  125834. * Get a material using its unique id
  125835. * @param uniqueId defines the material's unique id
  125836. * @return the material or null if none found.
  125837. */
  125838. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125839. /**
  125840. * get a material using its id
  125841. * @param id defines the material's ID
  125842. * @return the material or null if none found.
  125843. */
  125844. getMaterialByID(id: string): Nullable<Material>;
  125845. /**
  125846. * Gets a the last added material using a given id
  125847. * @param id defines the material's ID
  125848. * @return the last material with the given id or null if none found.
  125849. */
  125850. getLastMaterialByID(id: string): Nullable<Material>;
  125851. /**
  125852. * Gets a material using its name
  125853. * @param name defines the material's name
  125854. * @return the material or null if none found.
  125855. */
  125856. getMaterialByName(name: string): Nullable<Material>;
  125857. /**
  125858. * Get a texture using its unique id
  125859. * @param uniqueId defines the texture's unique id
  125860. * @return the texture or null if none found.
  125861. */
  125862. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125863. /**
  125864. * Gets a camera using its id
  125865. * @param id defines the id to look for
  125866. * @returns the camera or null if not found
  125867. */
  125868. getCameraByID(id: string): Nullable<Camera>;
  125869. /**
  125870. * Gets a camera using its unique id
  125871. * @param uniqueId defines the unique id to look for
  125872. * @returns the camera or null if not found
  125873. */
  125874. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125875. /**
  125876. * Gets a camera using its name
  125877. * @param name defines the camera's name
  125878. * @return the camera or null if none found.
  125879. */
  125880. getCameraByName(name: string): Nullable<Camera>;
  125881. /**
  125882. * Gets a bone using its id
  125883. * @param id defines the bone's id
  125884. * @return the bone or null if not found
  125885. */
  125886. getBoneByID(id: string): Nullable<Bone>;
  125887. /**
  125888. * Gets a bone using its id
  125889. * @param name defines the bone's name
  125890. * @return the bone or null if not found
  125891. */
  125892. getBoneByName(name: string): Nullable<Bone>;
  125893. /**
  125894. * Gets a light node using its name
  125895. * @param name defines the the light's name
  125896. * @return the light or null if none found.
  125897. */
  125898. getLightByName(name: string): Nullable<Light>;
  125899. /**
  125900. * Gets a light node using its id
  125901. * @param id defines the light's id
  125902. * @return the light or null if none found.
  125903. */
  125904. getLightByID(id: string): Nullable<Light>;
  125905. /**
  125906. * Gets a light node using its scene-generated unique ID
  125907. * @param uniqueId defines the light's unique id
  125908. * @return the light or null if none found.
  125909. */
  125910. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125911. /**
  125912. * Gets a particle system by id
  125913. * @param id defines the particle system id
  125914. * @return the corresponding system or null if none found
  125915. */
  125916. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125917. /**
  125918. * Gets a geometry using its ID
  125919. * @param id defines the geometry's id
  125920. * @return the geometry or null if none found.
  125921. */
  125922. getGeometryByID(id: string): Nullable<Geometry>;
  125923. private _getGeometryByUniqueID;
  125924. /**
  125925. * Add a new geometry to this scene
  125926. * @param geometry defines the geometry to be added to the scene.
  125927. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125928. * @return a boolean defining if the geometry was added or not
  125929. */
  125930. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125931. /**
  125932. * Removes an existing geometry
  125933. * @param geometry defines the geometry to be removed from the scene
  125934. * @return a boolean defining if the geometry was removed or not
  125935. */
  125936. removeGeometry(geometry: Geometry): boolean;
  125937. /**
  125938. * Gets the list of geometries attached to the scene
  125939. * @returns an array of Geometry
  125940. */
  125941. getGeometries(): Geometry[];
  125942. /**
  125943. * Gets the first added mesh found of a given ID
  125944. * @param id defines the id to search for
  125945. * @return the mesh found or null if not found at all
  125946. */
  125947. getMeshByID(id: string): Nullable<AbstractMesh>;
  125948. /**
  125949. * Gets a list of meshes using their id
  125950. * @param id defines the id to search for
  125951. * @returns a list of meshes
  125952. */
  125953. getMeshesByID(id: string): Array<AbstractMesh>;
  125954. /**
  125955. * Gets the first added transform node found of a given ID
  125956. * @param id defines the id to search for
  125957. * @return the found transform node or null if not found at all.
  125958. */
  125959. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125960. /**
  125961. * Gets a transform node with its auto-generated unique id
  125962. * @param uniqueId efines the unique id to search for
  125963. * @return the found transform node or null if not found at all.
  125964. */
  125965. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125966. /**
  125967. * Gets a list of transform nodes using their id
  125968. * @param id defines the id to search for
  125969. * @returns a list of transform nodes
  125970. */
  125971. getTransformNodesByID(id: string): Array<TransformNode>;
  125972. /**
  125973. * Gets a mesh with its auto-generated unique id
  125974. * @param uniqueId defines the unique id to search for
  125975. * @return the found mesh or null if not found at all.
  125976. */
  125977. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125978. /**
  125979. * Gets a the last added mesh using a given id
  125980. * @param id defines the id to search for
  125981. * @return the found mesh or null if not found at all.
  125982. */
  125983. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125984. /**
  125985. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125986. * @param id defines the id to search for
  125987. * @return the found node or null if not found at all
  125988. */
  125989. getLastEntryByID(id: string): Nullable<Node>;
  125990. /**
  125991. * Gets a node (Mesh, Camera, Light) using a given id
  125992. * @param id defines the id to search for
  125993. * @return the found node or null if not found at all
  125994. */
  125995. getNodeByID(id: string): Nullable<Node>;
  125996. /**
  125997. * Gets a node (Mesh, Camera, Light) using a given name
  125998. * @param name defines the name to search for
  125999. * @return the found node or null if not found at all.
  126000. */
  126001. getNodeByName(name: string): Nullable<Node>;
  126002. /**
  126003. * Gets a mesh using a given name
  126004. * @param name defines the name to search for
  126005. * @return the found mesh or null if not found at all.
  126006. */
  126007. getMeshByName(name: string): Nullable<AbstractMesh>;
  126008. /**
  126009. * Gets a transform node using a given name
  126010. * @param name defines the name to search for
  126011. * @return the found transform node or null if not found at all.
  126012. */
  126013. getTransformNodeByName(name: string): Nullable<TransformNode>;
  126014. /**
  126015. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  126016. * @param id defines the id to search for
  126017. * @return the found skeleton or null if not found at all.
  126018. */
  126019. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  126020. /**
  126021. * Gets a skeleton using a given auto generated unique id
  126022. * @param uniqueId defines the unique id to search for
  126023. * @return the found skeleton or null if not found at all.
  126024. */
  126025. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  126026. /**
  126027. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  126028. * @param id defines the id to search for
  126029. * @return the found skeleton or null if not found at all.
  126030. */
  126031. getSkeletonById(id: string): Nullable<Skeleton>;
  126032. /**
  126033. * Gets a skeleton using a given name
  126034. * @param name defines the name to search for
  126035. * @return the found skeleton or null if not found at all.
  126036. */
  126037. getSkeletonByName(name: string): Nullable<Skeleton>;
  126038. /**
  126039. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  126040. * @param id defines the id to search for
  126041. * @return the found morph target manager or null if not found at all.
  126042. */
  126043. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  126044. /**
  126045. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  126046. * @param id defines the id to search for
  126047. * @return the found morph target or null if not found at all.
  126048. */
  126049. getMorphTargetById(id: string): Nullable<MorphTarget>;
  126050. /**
  126051. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  126052. * @param name defines the name to search for
  126053. * @return the found morph target or null if not found at all.
  126054. */
  126055. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  126056. /**
  126057. * Gets a post process using a given name (if many are found, this function will pick the first one)
  126058. * @param name defines the name to search for
  126059. * @return the found post process or null if not found at all.
  126060. */
  126061. getPostProcessByName(name: string): Nullable<PostProcess>;
  126062. /**
  126063. * Gets a boolean indicating if the given mesh is active
  126064. * @param mesh defines the mesh to look for
  126065. * @returns true if the mesh is in the active list
  126066. */
  126067. isActiveMesh(mesh: AbstractMesh): boolean;
  126068. /**
  126069. * Return a unique id as a string which can serve as an identifier for the scene
  126070. */
  126071. get uid(): string;
  126072. /**
  126073. * Add an externaly attached data from its key.
  126074. * This method call will fail and return false, if such key already exists.
  126075. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  126076. * @param key the unique key that identifies the data
  126077. * @param data the data object to associate to the key for this Engine instance
  126078. * @return true if no such key were already present and the data was added successfully, false otherwise
  126079. */
  126080. addExternalData<T>(key: string, data: T): boolean;
  126081. /**
  126082. * Get an externaly attached data from its key
  126083. * @param key the unique key that identifies the data
  126084. * @return the associated data, if present (can be null), or undefined if not present
  126085. */
  126086. getExternalData<T>(key: string): Nullable<T>;
  126087. /**
  126088. * Get an externaly attached data from its key, create it using a factory if it's not already present
  126089. * @param key the unique key that identifies the data
  126090. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  126091. * @return the associated data, can be null if the factory returned null.
  126092. */
  126093. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  126094. /**
  126095. * Remove an externaly attached data from the Engine instance
  126096. * @param key the unique key that identifies the data
  126097. * @return true if the data was successfully removed, false if it doesn't exist
  126098. */
  126099. removeExternalData(key: string): boolean;
  126100. private _evaluateSubMesh;
  126101. /**
  126102. * Clear the processed materials smart array preventing retention point in material dispose.
  126103. */
  126104. freeProcessedMaterials(): void;
  126105. private _preventFreeActiveMeshesAndRenderingGroups;
  126106. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  126107. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  126108. * when disposing several meshes in a row or a hierarchy of meshes.
  126109. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  126110. */
  126111. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  126112. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  126113. /**
  126114. * Clear the active meshes smart array preventing retention point in mesh dispose.
  126115. */
  126116. freeActiveMeshes(): void;
  126117. /**
  126118. * Clear the info related to rendering groups preventing retention points during dispose.
  126119. */
  126120. freeRenderingGroups(): void;
  126121. /** @hidden */
  126122. _isInIntermediateRendering(): boolean;
  126123. /**
  126124. * Lambda returning the list of potentially active meshes.
  126125. */
  126126. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  126127. /**
  126128. * Lambda returning the list of potentially active sub meshes.
  126129. */
  126130. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  126131. /**
  126132. * Lambda returning the list of potentially intersecting sub meshes.
  126133. */
  126134. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  126135. /**
  126136. * Lambda returning the list of potentially colliding sub meshes.
  126137. */
  126138. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  126139. /** @hidden */
  126140. _activeMeshesFrozen: boolean;
  126141. private _skipEvaluateActiveMeshesCompletely;
  126142. /**
  126143. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  126144. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  126145. * @param onSuccess optional success callback
  126146. * @param onError optional error callback
  126147. * @returns the current scene
  126148. */
  126149. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  126150. /**
  126151. * Use this function to restart evaluating active meshes on every frame
  126152. * @returns the current scene
  126153. */
  126154. unfreezeActiveMeshes(): Scene;
  126155. private _evaluateActiveMeshes;
  126156. private _activeMesh;
  126157. /**
  126158. * Update the transform matrix to update from the current active camera
  126159. * @param force defines a boolean used to force the update even if cache is up to date
  126160. */
  126161. updateTransformMatrix(force?: boolean): void;
  126162. private _bindFrameBuffer;
  126163. /** @hidden */
  126164. _allowPostProcessClearColor: boolean;
  126165. /** @hidden */
  126166. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  126167. private _processSubCameras;
  126168. private _checkIntersections;
  126169. /** @hidden */
  126170. _advancePhysicsEngineStep(step: number): void;
  126171. /**
  126172. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  126173. */
  126174. getDeterministicFrameTime: () => number;
  126175. /** @hidden */
  126176. _animate(): void;
  126177. /** Execute all animations (for a frame) */
  126178. animate(): void;
  126179. /**
  126180. * Render the scene
  126181. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  126182. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  126183. */
  126184. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  126185. /**
  126186. * Freeze all materials
  126187. * A frozen material will not be updatable but should be faster to render
  126188. */
  126189. freezeMaterials(): void;
  126190. /**
  126191. * Unfreeze all materials
  126192. * A frozen material will not be updatable but should be faster to render
  126193. */
  126194. unfreezeMaterials(): void;
  126195. /**
  126196. * Releases all held ressources
  126197. */
  126198. dispose(): void;
  126199. /**
  126200. * Gets if the scene is already disposed
  126201. */
  126202. get isDisposed(): boolean;
  126203. /**
  126204. * Call this function to reduce memory footprint of the scene.
  126205. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  126206. */
  126207. clearCachedVertexData(): void;
  126208. /**
  126209. * This function will remove the local cached buffer data from texture.
  126210. * It will save memory but will prevent the texture from being rebuilt
  126211. */
  126212. cleanCachedTextureBuffer(): void;
  126213. /**
  126214. * Get the world extend vectors with an optional filter
  126215. *
  126216. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  126217. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  126218. */
  126219. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  126220. min: Vector3;
  126221. max: Vector3;
  126222. };
  126223. /**
  126224. * Creates a ray that can be used to pick in the scene
  126225. * @param x defines the x coordinate of the origin (on-screen)
  126226. * @param y defines the y coordinate of the origin (on-screen)
  126227. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126228. * @param camera defines the camera to use for the picking
  126229. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126230. * @returns a Ray
  126231. */
  126232. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  126233. /**
  126234. * Creates a ray that can be used to pick in the scene
  126235. * @param x defines the x coordinate of the origin (on-screen)
  126236. * @param y defines the y coordinate of the origin (on-screen)
  126237. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  126238. * @param result defines the ray where to store the picking ray
  126239. * @param camera defines the camera to use for the picking
  126240. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  126241. * @returns the current scene
  126242. */
  126243. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  126244. /**
  126245. * Creates a ray that can be used to pick in the scene
  126246. * @param x defines the x coordinate of the origin (on-screen)
  126247. * @param y defines the y coordinate of the origin (on-screen)
  126248. * @param camera defines the camera to use for the picking
  126249. * @returns a Ray
  126250. */
  126251. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  126252. /**
  126253. * Creates a ray that can be used to pick in the scene
  126254. * @param x defines the x coordinate of the origin (on-screen)
  126255. * @param y defines the y coordinate of the origin (on-screen)
  126256. * @param result defines the ray where to store the picking ray
  126257. * @param camera defines the camera to use for the picking
  126258. * @returns the current scene
  126259. */
  126260. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  126261. /** Launch a ray to try to pick a mesh in the scene
  126262. * @param x position on screen
  126263. * @param y position on screen
  126264. * @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
  126265. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126266. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126267. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126268. * @returns a PickingInfo
  126269. */
  126270. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126271. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  126272. * @param x position on screen
  126273. * @param y position on screen
  126274. * @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
  126275. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126276. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126277. * @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)
  126278. */
  126279. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  126280. /** Use the given ray to pick a mesh in the scene
  126281. * @param ray The ray to use to pick meshes
  126282. * @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
  126283. * @param fastCheck defines if the first intersection will be used (and not the closest)
  126284. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126285. * @returns a PickingInfo
  126286. */
  126287. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  126288. /**
  126289. * Launch a ray to try to pick a mesh in the scene
  126290. * @param x X position on screen
  126291. * @param y Y position on screen
  126292. * @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
  126293. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  126294. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126295. * @returns an array of PickingInfo
  126296. */
  126297. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126298. /**
  126299. * Launch a ray to try to pick a mesh in the scene
  126300. * @param ray Ray to use
  126301. * @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
  126302. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  126303. * @returns an array of PickingInfo
  126304. */
  126305. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  126306. /**
  126307. * Force the value of meshUnderPointer
  126308. * @param mesh defines the mesh to use
  126309. * @param pointerId optional pointer id when using more than one pointer
  126310. */
  126311. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  126312. /**
  126313. * Gets the mesh under the pointer
  126314. * @returns a Mesh or null if no mesh is under the pointer
  126315. */
  126316. getPointerOverMesh(): Nullable<AbstractMesh>;
  126317. /** @hidden */
  126318. _rebuildGeometries(): void;
  126319. /** @hidden */
  126320. _rebuildTextures(): void;
  126321. private _getByTags;
  126322. /**
  126323. * Get a list of meshes by tags
  126324. * @param tagsQuery defines the tags query to use
  126325. * @param forEach defines a predicate used to filter results
  126326. * @returns an array of Mesh
  126327. */
  126328. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  126329. /**
  126330. * Get a list of cameras by tags
  126331. * @param tagsQuery defines the tags query to use
  126332. * @param forEach defines a predicate used to filter results
  126333. * @returns an array of Camera
  126334. */
  126335. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  126336. /**
  126337. * Get a list of lights by tags
  126338. * @param tagsQuery defines the tags query to use
  126339. * @param forEach defines a predicate used to filter results
  126340. * @returns an array of Light
  126341. */
  126342. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  126343. /**
  126344. * Get a list of materials by tags
  126345. * @param tagsQuery defines the tags query to use
  126346. * @param forEach defines a predicate used to filter results
  126347. * @returns an array of Material
  126348. */
  126349. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  126350. /**
  126351. * Get a list of transform nodes by tags
  126352. * @param tagsQuery defines the tags query to use
  126353. * @param forEach defines a predicate used to filter results
  126354. * @returns an array of TransformNode
  126355. */
  126356. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  126357. /**
  126358. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  126359. * This allowed control for front to back rendering or reversly depending of the special needs.
  126360. *
  126361. * @param renderingGroupId The rendering group id corresponding to its index
  126362. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  126363. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  126364. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  126365. */
  126366. 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;
  126367. /**
  126368. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  126369. *
  126370. * @param renderingGroupId The rendering group id corresponding to its index
  126371. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126372. * @param depth Automatically clears depth between groups if true and autoClear is true.
  126373. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  126374. */
  126375. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  126376. /**
  126377. * Gets the current auto clear configuration for one rendering group of the rendering
  126378. * manager.
  126379. * @param index the rendering group index to get the information for
  126380. * @returns The auto clear setup for the requested rendering group
  126381. */
  126382. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  126383. private _blockMaterialDirtyMechanism;
  126384. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  126385. get blockMaterialDirtyMechanism(): boolean;
  126386. set blockMaterialDirtyMechanism(value: boolean);
  126387. /**
  126388. * Will flag all materials as dirty to trigger new shader compilation
  126389. * @param flag defines the flag used to specify which material part must be marked as dirty
  126390. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  126391. */
  126392. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  126393. /** @hidden */
  126394. _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;
  126395. /** @hidden */
  126396. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126397. /** @hidden */
  126398. _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;
  126399. /** @hidden */
  126400. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  126401. /** @hidden */
  126402. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  126403. /** @hidden */
  126404. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  126405. }
  126406. }
  126407. declare module BABYLON {
  126408. /**
  126409. * Set of assets to keep when moving a scene into an asset container.
  126410. */
  126411. export class KeepAssets extends AbstractScene {
  126412. }
  126413. /**
  126414. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  126415. */
  126416. export class InstantiatedEntries {
  126417. /**
  126418. * List of new root nodes (eg. nodes with no parent)
  126419. */
  126420. rootNodes: TransformNode[];
  126421. /**
  126422. * List of new skeletons
  126423. */
  126424. skeletons: Skeleton[];
  126425. /**
  126426. * List of new animation groups
  126427. */
  126428. animationGroups: AnimationGroup[];
  126429. }
  126430. /**
  126431. * Container with a set of assets that can be added or removed from a scene.
  126432. */
  126433. export class AssetContainer extends AbstractScene {
  126434. private _wasAddedToScene;
  126435. /**
  126436. * The scene the AssetContainer belongs to.
  126437. */
  126438. scene: Scene;
  126439. /**
  126440. * Instantiates an AssetContainer.
  126441. * @param scene The scene the AssetContainer belongs to.
  126442. */
  126443. constructor(scene: Scene);
  126444. /**
  126445. * Instantiate or clone all meshes and add the new ones to the scene.
  126446. * Skeletons and animation groups will all be cloned
  126447. * @param nameFunction defines an optional function used to get new names for clones
  126448. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  126449. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  126450. */
  126451. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  126452. /**
  126453. * Adds all the assets from the container to the scene.
  126454. */
  126455. addAllToScene(): void;
  126456. /**
  126457. * Removes all the assets in the container from the scene
  126458. */
  126459. removeAllFromScene(): void;
  126460. /**
  126461. * Disposes all the assets in the container
  126462. */
  126463. dispose(): void;
  126464. private _moveAssets;
  126465. /**
  126466. * Removes all the assets contained in the scene and adds them to the container.
  126467. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  126468. */
  126469. moveAllFromScene(keepAssets?: KeepAssets): void;
  126470. /**
  126471. * 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.
  126472. * @returns the root mesh
  126473. */
  126474. createRootMesh(): Mesh;
  126475. /**
  126476. * Merge animations (direct and animation groups) from this asset container into a scene
  126477. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  126478. * @param animatables set of animatables to retarget to a node from the scene
  126479. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  126480. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  126481. */
  126482. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  126483. }
  126484. }
  126485. declare module BABYLON {
  126486. /**
  126487. * Defines how the parser contract is defined.
  126488. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  126489. */
  126490. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  126491. /**
  126492. * Defines how the individual parser contract is defined.
  126493. * These parser can parse an individual asset
  126494. */
  126495. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  126496. /**
  126497. * Base class of the scene acting as a container for the different elements composing a scene.
  126498. * This class is dynamically extended by the different components of the scene increasing
  126499. * flexibility and reducing coupling
  126500. */
  126501. export abstract class AbstractScene {
  126502. /**
  126503. * Stores the list of available parsers in the application.
  126504. */
  126505. private static _BabylonFileParsers;
  126506. /**
  126507. * Stores the list of available individual parsers in the application.
  126508. */
  126509. private static _IndividualBabylonFileParsers;
  126510. /**
  126511. * Adds a parser in the list of available ones
  126512. * @param name Defines the name of the parser
  126513. * @param parser Defines the parser to add
  126514. */
  126515. static AddParser(name: string, parser: BabylonFileParser): void;
  126516. /**
  126517. * Gets a general parser from the list of avaialble ones
  126518. * @param name Defines the name of the parser
  126519. * @returns the requested parser or null
  126520. */
  126521. static GetParser(name: string): Nullable<BabylonFileParser>;
  126522. /**
  126523. * Adds n individual parser in the list of available ones
  126524. * @param name Defines the name of the parser
  126525. * @param parser Defines the parser to add
  126526. */
  126527. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  126528. /**
  126529. * Gets an individual parser from the list of avaialble ones
  126530. * @param name Defines the name of the parser
  126531. * @returns the requested parser or null
  126532. */
  126533. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  126534. /**
  126535. * Parser json data and populate both a scene and its associated container object
  126536. * @param jsonData Defines the data to parse
  126537. * @param scene Defines the scene to parse the data for
  126538. * @param container Defines the container attached to the parsing sequence
  126539. * @param rootUrl Defines the root url of the data
  126540. */
  126541. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  126542. /**
  126543. * Gets the list of root nodes (ie. nodes with no parent)
  126544. */
  126545. rootNodes: Node[];
  126546. /** All of the cameras added to this scene
  126547. * @see https://doc.babylonjs.com/babylon101/cameras
  126548. */
  126549. cameras: Camera[];
  126550. /**
  126551. * All of the lights added to this scene
  126552. * @see https://doc.babylonjs.com/babylon101/lights
  126553. */
  126554. lights: Light[];
  126555. /**
  126556. * All of the (abstract) meshes added to this scene
  126557. */
  126558. meshes: AbstractMesh[];
  126559. /**
  126560. * The list of skeletons added to the scene
  126561. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126562. */
  126563. skeletons: Skeleton[];
  126564. /**
  126565. * All of the particle systems added to this scene
  126566. * @see https://doc.babylonjs.com/babylon101/particles
  126567. */
  126568. particleSystems: IParticleSystem[];
  126569. /**
  126570. * Gets a list of Animations associated with the scene
  126571. */
  126572. animations: Animation[];
  126573. /**
  126574. * All of the animation groups added to this scene
  126575. * @see https://doc.babylonjs.com/how_to/group
  126576. */
  126577. animationGroups: AnimationGroup[];
  126578. /**
  126579. * All of the multi-materials added to this scene
  126580. * @see https://doc.babylonjs.com/how_to/multi_materials
  126581. */
  126582. multiMaterials: MultiMaterial[];
  126583. /**
  126584. * All of the materials added to this scene
  126585. * In the context of a Scene, it is not supposed to be modified manually.
  126586. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  126587. * Note also that the order of the Material within the array is not significant and might change.
  126588. * @see https://doc.babylonjs.com/babylon101/materials
  126589. */
  126590. materials: Material[];
  126591. /**
  126592. * The list of morph target managers added to the scene
  126593. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126594. */
  126595. morphTargetManagers: MorphTargetManager[];
  126596. /**
  126597. * The list of geometries used in the scene.
  126598. */
  126599. geometries: Geometry[];
  126600. /**
  126601. * All of the tranform nodes added to this scene
  126602. * In the context of a Scene, it is not supposed to be modified manually.
  126603. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126604. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126605. * @see https://doc.babylonjs.com/how_to/transformnode
  126606. */
  126607. transformNodes: TransformNode[];
  126608. /**
  126609. * ActionManagers available on the scene.
  126610. */
  126611. actionManagers: AbstractActionManager[];
  126612. /**
  126613. * Textures to keep.
  126614. */
  126615. textures: BaseTexture[];
  126616. /** @hidden */
  126617. protected _environmentTexture: Nullable<BaseTexture>;
  126618. /**
  126619. * Texture used in all pbr material as the reflection texture.
  126620. * As in the majority of the scene they are the same (exception for multi room and so on),
  126621. * this is easier to reference from here than from all the materials.
  126622. */
  126623. get environmentTexture(): Nullable<BaseTexture>;
  126624. set environmentTexture(value: Nullable<BaseTexture>);
  126625. /**
  126626. * The list of postprocesses added to the scene
  126627. */
  126628. postProcesses: PostProcess[];
  126629. /**
  126630. * @returns all meshes, lights, cameras, transformNodes and bones
  126631. */
  126632. getNodes(): Array<Node>;
  126633. }
  126634. }
  126635. declare module BABYLON {
  126636. /**
  126637. * Interface used to define options for Sound class
  126638. */
  126639. export interface ISoundOptions {
  126640. /**
  126641. * Does the sound autoplay once loaded.
  126642. */
  126643. autoplay?: boolean;
  126644. /**
  126645. * Does the sound loop after it finishes playing once.
  126646. */
  126647. loop?: boolean;
  126648. /**
  126649. * Sound's volume
  126650. */
  126651. volume?: number;
  126652. /**
  126653. * Is it a spatial sound?
  126654. */
  126655. spatialSound?: boolean;
  126656. /**
  126657. * Maximum distance to hear that sound
  126658. */
  126659. maxDistance?: number;
  126660. /**
  126661. * Uses user defined attenuation function
  126662. */
  126663. useCustomAttenuation?: boolean;
  126664. /**
  126665. * Define the roll off factor of spatial sounds.
  126666. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126667. */
  126668. rolloffFactor?: number;
  126669. /**
  126670. * Define the reference distance the sound should be heard perfectly.
  126671. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126672. */
  126673. refDistance?: number;
  126674. /**
  126675. * Define the distance attenuation model the sound will follow.
  126676. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126677. */
  126678. distanceModel?: string;
  126679. /**
  126680. * Defines the playback speed (1 by default)
  126681. */
  126682. playbackRate?: number;
  126683. /**
  126684. * Defines if the sound is from a streaming source
  126685. */
  126686. streaming?: boolean;
  126687. /**
  126688. * Defines an optional length (in seconds) inside the sound file
  126689. */
  126690. length?: number;
  126691. /**
  126692. * Defines an optional offset (in seconds) inside the sound file
  126693. */
  126694. offset?: number;
  126695. /**
  126696. * If true, URLs will not be required to state the audio file codec to use.
  126697. */
  126698. skipCodecCheck?: boolean;
  126699. }
  126700. }
  126701. declare module BABYLON {
  126702. /**
  126703. * Defines a sound that can be played in the application.
  126704. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126705. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126706. */
  126707. export class Sound {
  126708. /**
  126709. * The name of the sound in the scene.
  126710. */
  126711. name: string;
  126712. /**
  126713. * Does the sound autoplay once loaded.
  126714. */
  126715. autoplay: boolean;
  126716. /**
  126717. * Does the sound loop after it finishes playing once.
  126718. */
  126719. loop: boolean;
  126720. /**
  126721. * Does the sound use a custom attenuation curve to simulate the falloff
  126722. * happening when the source gets further away from the camera.
  126723. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126724. */
  126725. useCustomAttenuation: boolean;
  126726. /**
  126727. * The sound track id this sound belongs to.
  126728. */
  126729. soundTrackId: number;
  126730. /**
  126731. * Is this sound currently played.
  126732. */
  126733. isPlaying: boolean;
  126734. /**
  126735. * Is this sound currently paused.
  126736. */
  126737. isPaused: boolean;
  126738. /**
  126739. * Does this sound enables spatial sound.
  126740. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126741. */
  126742. spatialSound: boolean;
  126743. /**
  126744. * Define the reference distance the sound should be heard perfectly.
  126745. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126746. */
  126747. refDistance: number;
  126748. /**
  126749. * Define the roll off factor of spatial sounds.
  126750. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126751. */
  126752. rolloffFactor: number;
  126753. /**
  126754. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126755. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126756. */
  126757. maxDistance: number;
  126758. /**
  126759. * Define the distance attenuation model the sound will follow.
  126760. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126761. */
  126762. distanceModel: string;
  126763. /**
  126764. * @hidden
  126765. * Back Compat
  126766. **/
  126767. onended: () => any;
  126768. /**
  126769. * Gets or sets an object used to store user defined information for the sound.
  126770. */
  126771. metadata: any;
  126772. /**
  126773. * Observable event when the current playing sound finishes.
  126774. */
  126775. onEndedObservable: Observable<Sound>;
  126776. /**
  126777. * Gets the current time for the sound.
  126778. */
  126779. get currentTime(): number;
  126780. private _panningModel;
  126781. private _playbackRate;
  126782. private _streaming;
  126783. private _startTime;
  126784. private _startOffset;
  126785. private _position;
  126786. /** @hidden */
  126787. _positionInEmitterSpace: boolean;
  126788. private _localDirection;
  126789. private _volume;
  126790. private _isReadyToPlay;
  126791. private _isDirectional;
  126792. private _readyToPlayCallback;
  126793. private _audioBuffer;
  126794. private _soundSource;
  126795. private _streamingSource;
  126796. private _soundPanner;
  126797. private _soundGain;
  126798. private _inputAudioNode;
  126799. private _outputAudioNode;
  126800. private _coneInnerAngle;
  126801. private _coneOuterAngle;
  126802. private _coneOuterGain;
  126803. private _scene;
  126804. private _connectedTransformNode;
  126805. private _customAttenuationFunction;
  126806. private _registerFunc;
  126807. private _isOutputConnected;
  126808. private _htmlAudioElement;
  126809. private _urlType;
  126810. private _length?;
  126811. private _offset?;
  126812. /** @hidden */
  126813. static _SceneComponentInitialization: (scene: Scene) => void;
  126814. /**
  126815. * Create a sound and attach it to a scene
  126816. * @param name Name of your sound
  126817. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126818. * @param scene defines the scene the sound belongs to
  126819. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126820. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126821. */
  126822. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126823. /**
  126824. * Release the sound and its associated resources
  126825. */
  126826. dispose(): void;
  126827. /**
  126828. * Gets if the sounds is ready to be played or not.
  126829. * @returns true if ready, otherwise false
  126830. */
  126831. isReady(): boolean;
  126832. private _soundLoaded;
  126833. /**
  126834. * Sets the data of the sound from an audiobuffer
  126835. * @param audioBuffer The audioBuffer containing the data
  126836. */
  126837. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126838. /**
  126839. * Updates the current sounds options such as maxdistance, loop...
  126840. * @param options A JSON object containing values named as the object properties
  126841. */
  126842. updateOptions(options: ISoundOptions): void;
  126843. private _createSpatialParameters;
  126844. private _updateSpatialParameters;
  126845. /**
  126846. * Switch the panning model to HRTF:
  126847. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126848. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126849. */
  126850. switchPanningModelToHRTF(): void;
  126851. /**
  126852. * Switch the panning model to Equal Power:
  126853. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126855. */
  126856. switchPanningModelToEqualPower(): void;
  126857. private _switchPanningModel;
  126858. /**
  126859. * Connect this sound to a sound track audio node like gain...
  126860. * @param soundTrackAudioNode the sound track audio node to connect to
  126861. */
  126862. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126863. /**
  126864. * Transform this sound into a directional source
  126865. * @param coneInnerAngle Size of the inner cone in degree
  126866. * @param coneOuterAngle Size of the outer cone in degree
  126867. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126868. */
  126869. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126870. /**
  126871. * Gets or sets the inner angle for the directional cone.
  126872. */
  126873. get directionalConeInnerAngle(): number;
  126874. /**
  126875. * Gets or sets the inner angle for the directional cone.
  126876. */
  126877. set directionalConeInnerAngle(value: number);
  126878. /**
  126879. * Gets or sets the outer angle for the directional cone.
  126880. */
  126881. get directionalConeOuterAngle(): number;
  126882. /**
  126883. * Gets or sets the outer angle for the directional cone.
  126884. */
  126885. set directionalConeOuterAngle(value: number);
  126886. /**
  126887. * Sets the position of the emitter if spatial sound is enabled
  126888. * @param newPosition Defines the new posisiton
  126889. */
  126890. setPosition(newPosition: Vector3): void;
  126891. /**
  126892. * Sets the local direction of the emitter if spatial sound is enabled
  126893. * @param newLocalDirection Defines the new local direction
  126894. */
  126895. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126896. private _updateDirection;
  126897. /** @hidden */
  126898. updateDistanceFromListener(): void;
  126899. /**
  126900. * Sets a new custom attenuation function for the sound.
  126901. * @param callback Defines the function used for the attenuation
  126902. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126903. */
  126904. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126905. /**
  126906. * Play the sound
  126907. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126908. * @param offset (optional) Start the sound at a specific time in seconds
  126909. * @param length (optional) Sound duration (in seconds)
  126910. */
  126911. play(time?: number, offset?: number, length?: number): void;
  126912. private _onended;
  126913. /**
  126914. * Stop the sound
  126915. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126916. */
  126917. stop(time?: number): void;
  126918. /**
  126919. * Put the sound in pause
  126920. */
  126921. pause(): void;
  126922. /**
  126923. * Sets a dedicated volume for this sounds
  126924. * @param newVolume Define the new volume of the sound
  126925. * @param time Define time for gradual change to new volume
  126926. */
  126927. setVolume(newVolume: number, time?: number): void;
  126928. /**
  126929. * Set the sound play back rate
  126930. * @param newPlaybackRate Define the playback rate the sound should be played at
  126931. */
  126932. setPlaybackRate(newPlaybackRate: number): void;
  126933. /**
  126934. * Gets the volume of the sound.
  126935. * @returns the volume of the sound
  126936. */
  126937. getVolume(): number;
  126938. /**
  126939. * Attach the sound to a dedicated mesh
  126940. * @param transformNode The transform node to connect the sound with
  126941. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126942. */
  126943. attachToMesh(transformNode: TransformNode): void;
  126944. /**
  126945. * Detach the sound from the previously attached mesh
  126946. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126947. */
  126948. detachFromMesh(): void;
  126949. private _onRegisterAfterWorldMatrixUpdate;
  126950. /**
  126951. * Clone the current sound in the scene.
  126952. * @returns the new sound clone
  126953. */
  126954. clone(): Nullable<Sound>;
  126955. /**
  126956. * Gets the current underlying audio buffer containing the data
  126957. * @returns the audio buffer
  126958. */
  126959. getAudioBuffer(): Nullable<AudioBuffer>;
  126960. /**
  126961. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126962. * @returns the source node
  126963. */
  126964. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126965. /**
  126966. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126967. * @returns the gain node
  126968. */
  126969. getSoundGain(): Nullable<GainNode>;
  126970. /**
  126971. * Serializes the Sound in a JSON representation
  126972. * @returns the JSON representation of the sound
  126973. */
  126974. serialize(): any;
  126975. /**
  126976. * Parse a JSON representation of a sound to innstantiate in a given scene
  126977. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126978. * @param scene Define the scene the new parsed sound should be created in
  126979. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126980. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126981. * @returns the newly parsed sound
  126982. */
  126983. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126984. }
  126985. }
  126986. declare module BABYLON {
  126987. /**
  126988. * This defines an action helpful to play a defined sound on a triggered action.
  126989. */
  126990. export class PlaySoundAction extends Action {
  126991. private _sound;
  126992. /**
  126993. * Instantiate the action
  126994. * @param triggerOptions defines the trigger options
  126995. * @param sound defines the sound to play
  126996. * @param condition defines the trigger related conditions
  126997. */
  126998. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126999. /** @hidden */
  127000. _prepare(): void;
  127001. /**
  127002. * Execute the action and play the sound.
  127003. */
  127004. execute(): void;
  127005. /**
  127006. * Serializes the actions and its related information.
  127007. * @param parent defines the object to serialize in
  127008. * @returns the serialized object
  127009. */
  127010. serialize(parent: any): any;
  127011. }
  127012. /**
  127013. * This defines an action helpful to stop a defined sound on a triggered action.
  127014. */
  127015. export class StopSoundAction extends Action {
  127016. private _sound;
  127017. /**
  127018. * Instantiate the action
  127019. * @param triggerOptions defines the trigger options
  127020. * @param sound defines the sound to stop
  127021. * @param condition defines the trigger related conditions
  127022. */
  127023. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  127024. /** @hidden */
  127025. _prepare(): void;
  127026. /**
  127027. * Execute the action and stop the sound.
  127028. */
  127029. execute(): void;
  127030. /**
  127031. * Serializes the actions and its related information.
  127032. * @param parent defines the object to serialize in
  127033. * @returns the serialized object
  127034. */
  127035. serialize(parent: any): any;
  127036. }
  127037. }
  127038. declare module BABYLON {
  127039. /**
  127040. * This defines an action responsible to change the value of a property
  127041. * by interpolating between its current value and the newly set one once triggered.
  127042. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  127043. */
  127044. export class InterpolateValueAction extends Action {
  127045. /**
  127046. * Defines the path of the property where the value should be interpolated
  127047. */
  127048. propertyPath: string;
  127049. /**
  127050. * Defines the target value at the end of the interpolation.
  127051. */
  127052. value: any;
  127053. /**
  127054. * Defines the time it will take for the property to interpolate to the value.
  127055. */
  127056. duration: number;
  127057. /**
  127058. * Defines if the other scene animations should be stopped when the action has been triggered
  127059. */
  127060. stopOtherAnimations?: boolean;
  127061. /**
  127062. * Defines a callback raised once the interpolation animation has been done.
  127063. */
  127064. onInterpolationDone?: () => void;
  127065. /**
  127066. * Observable triggered once the interpolation animation has been done.
  127067. */
  127068. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  127069. private _target;
  127070. private _effectiveTarget;
  127071. private _property;
  127072. /**
  127073. * Instantiate the action
  127074. * @param triggerOptions defines the trigger options
  127075. * @param target defines the object containing the value to interpolate
  127076. * @param propertyPath defines the path to the property in the target object
  127077. * @param value defines the target value at the end of the interpolation
  127078. * @param duration deines the time it will take for the property to interpolate to the value.
  127079. * @param condition defines the trigger related conditions
  127080. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  127081. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  127082. */
  127083. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  127084. /** @hidden */
  127085. _prepare(): void;
  127086. /**
  127087. * Execute the action starts the value interpolation.
  127088. */
  127089. execute(): void;
  127090. /**
  127091. * Serializes the actions and its related information.
  127092. * @param parent defines the object to serialize in
  127093. * @returns the serialized object
  127094. */
  127095. serialize(parent: any): any;
  127096. }
  127097. }
  127098. declare module BABYLON {
  127099. /**
  127100. * This represents the default audio engine used in babylon.
  127101. * It is responsible to play, synchronize and analyse sounds throughout the application.
  127102. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127103. */
  127104. export class AudioEngine implements IAudioEngine {
  127105. private _audioContext;
  127106. private _audioContextInitialized;
  127107. private _muteButton;
  127108. private _hostElement;
  127109. /**
  127110. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  127111. */
  127112. canUseWebAudio: boolean;
  127113. /**
  127114. * The master gain node defines the global audio volume of your audio engine.
  127115. */
  127116. masterGain: GainNode;
  127117. /**
  127118. * Defines if Babylon should emit a warning if WebAudio is not supported.
  127119. * @ignoreNaming
  127120. */
  127121. WarnedWebAudioUnsupported: boolean;
  127122. /**
  127123. * Gets whether or not mp3 are supported by your browser.
  127124. */
  127125. isMP3supported: boolean;
  127126. /**
  127127. * Gets whether or not ogg are supported by your browser.
  127128. */
  127129. isOGGsupported: boolean;
  127130. /**
  127131. * Gets whether audio has been unlocked on the device.
  127132. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  127133. * a user interaction has happened.
  127134. */
  127135. unlocked: boolean;
  127136. /**
  127137. * Defines if the audio engine relies on a custom unlocked button.
  127138. * In this case, the embedded button will not be displayed.
  127139. */
  127140. useCustomUnlockedButton: boolean;
  127141. /**
  127142. * Event raised when audio has been unlocked on the browser.
  127143. */
  127144. onAudioUnlockedObservable: Observable<IAudioEngine>;
  127145. /**
  127146. * Event raised when audio has been locked on the browser.
  127147. */
  127148. onAudioLockedObservable: Observable<IAudioEngine>;
  127149. /**
  127150. * Gets the current AudioContext if available.
  127151. */
  127152. get audioContext(): Nullable<AudioContext>;
  127153. private _connectedAnalyser;
  127154. /**
  127155. * Instantiates a new audio engine.
  127156. *
  127157. * There should be only one per page as some browsers restrict the number
  127158. * of audio contexts you can create.
  127159. * @param hostElement defines the host element where to display the mute icon if necessary
  127160. */
  127161. constructor(hostElement?: Nullable<HTMLElement>);
  127162. /**
  127163. * Flags the audio engine in Locked state.
  127164. * This happens due to new browser policies preventing audio to autoplay.
  127165. */
  127166. lock(): void;
  127167. /**
  127168. * Unlocks the audio engine once a user action has been done on the dom.
  127169. * This is helpful to resume play once browser policies have been satisfied.
  127170. */
  127171. unlock(): void;
  127172. private _resumeAudioContext;
  127173. private _initializeAudioContext;
  127174. private _tryToRun;
  127175. private _triggerRunningState;
  127176. private _triggerSuspendedState;
  127177. private _displayMuteButton;
  127178. private _moveButtonToTopLeft;
  127179. private _onResize;
  127180. private _hideMuteButton;
  127181. /**
  127182. * Destroy and release the resources associated with the audio ccontext.
  127183. */
  127184. dispose(): void;
  127185. /**
  127186. * Gets the global volume sets on the master gain.
  127187. * @returns the global volume if set or -1 otherwise
  127188. */
  127189. getGlobalVolume(): number;
  127190. /**
  127191. * Sets the global volume of your experience (sets on the master gain).
  127192. * @param newVolume Defines the new global volume of the application
  127193. */
  127194. setGlobalVolume(newVolume: number): void;
  127195. /**
  127196. * Connect the audio engine to an audio analyser allowing some amazing
  127197. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127198. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127199. * @param analyser The analyser to connect to the engine
  127200. */
  127201. connectToAnalyser(analyser: Analyser): void;
  127202. }
  127203. }
  127204. declare module BABYLON {
  127205. /**
  127206. * Options allowed during the creation of a sound track.
  127207. */
  127208. export interface ISoundTrackOptions {
  127209. /**
  127210. * The volume the sound track should take during creation
  127211. */
  127212. volume?: number;
  127213. /**
  127214. * Define if the sound track is the main sound track of the scene
  127215. */
  127216. mainTrack?: boolean;
  127217. }
  127218. /**
  127219. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  127220. * It will be also used in a future release to apply effects on a specific track.
  127221. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127222. */
  127223. export class SoundTrack {
  127224. /**
  127225. * The unique identifier of the sound track in the scene.
  127226. */
  127227. id: number;
  127228. /**
  127229. * The list of sounds included in the sound track.
  127230. */
  127231. soundCollection: Array<Sound>;
  127232. private _outputAudioNode;
  127233. private _scene;
  127234. private _connectedAnalyser;
  127235. private _options;
  127236. private _isInitialized;
  127237. /**
  127238. * Creates a new sound track.
  127239. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  127240. * @param scene Define the scene the sound track belongs to
  127241. * @param options
  127242. */
  127243. constructor(scene: Scene, options?: ISoundTrackOptions);
  127244. private _initializeSoundTrackAudioGraph;
  127245. /**
  127246. * Release the sound track and its associated resources
  127247. */
  127248. dispose(): void;
  127249. /**
  127250. * Adds a sound to this sound track
  127251. * @param sound define the cound to add
  127252. * @ignoreNaming
  127253. */
  127254. addSound(sound: Sound): void;
  127255. /**
  127256. * Removes a sound to this sound track
  127257. * @param sound define the cound to remove
  127258. * @ignoreNaming
  127259. */
  127260. removeSound(sound: Sound): void;
  127261. /**
  127262. * Set a global volume for the full sound track.
  127263. * @param newVolume Define the new volume of the sound track
  127264. */
  127265. setVolume(newVolume: number): void;
  127266. /**
  127267. * Switch the panning model to HRTF:
  127268. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  127269. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127270. */
  127271. switchPanningModelToHRTF(): void;
  127272. /**
  127273. * Switch the panning model to Equal Power:
  127274. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  127275. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  127276. */
  127277. switchPanningModelToEqualPower(): void;
  127278. /**
  127279. * Connect the sound track to an audio analyser allowing some amazing
  127280. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  127281. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  127282. * @param analyser The analyser to connect to the engine
  127283. */
  127284. connectToAnalyser(analyser: Analyser): void;
  127285. }
  127286. }
  127287. declare module BABYLON {
  127288. interface AbstractScene {
  127289. /**
  127290. * The list of sounds used in the scene.
  127291. */
  127292. sounds: Nullable<Array<Sound>>;
  127293. }
  127294. interface Scene {
  127295. /**
  127296. * @hidden
  127297. * Backing field
  127298. */
  127299. _mainSoundTrack: SoundTrack;
  127300. /**
  127301. * The main sound track played by the scene.
  127302. * It cotains your primary collection of sounds.
  127303. */
  127304. mainSoundTrack: SoundTrack;
  127305. /**
  127306. * The list of sound tracks added to the scene
  127307. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127308. */
  127309. soundTracks: Nullable<Array<SoundTrack>>;
  127310. /**
  127311. * Gets a sound using a given name
  127312. * @param name defines the name to search for
  127313. * @return the found sound or null if not found at all.
  127314. */
  127315. getSoundByName(name: string): Nullable<Sound>;
  127316. /**
  127317. * Gets or sets if audio support is enabled
  127318. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127319. */
  127320. audioEnabled: boolean;
  127321. /**
  127322. * Gets or sets if audio will be output to headphones
  127323. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127324. */
  127325. headphone: boolean;
  127326. /**
  127327. * Gets or sets custom audio listener position provider
  127328. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  127329. */
  127330. audioListenerPositionProvider: Nullable<() => Vector3>;
  127331. /**
  127332. * Gets or sets a refresh rate when using 3D audio positioning
  127333. */
  127334. audioPositioningRefreshRate: number;
  127335. }
  127336. /**
  127337. * Defines the sound scene component responsible to manage any sounds
  127338. * in a given scene.
  127339. */
  127340. export class AudioSceneComponent implements ISceneSerializableComponent {
  127341. private static _CameraDirectionLH;
  127342. private static _CameraDirectionRH;
  127343. /**
  127344. * The component name helpfull to identify the component in the list of scene components.
  127345. */
  127346. readonly name: string;
  127347. /**
  127348. * The scene the component belongs to.
  127349. */
  127350. scene: Scene;
  127351. private _audioEnabled;
  127352. /**
  127353. * Gets whether audio is enabled or not.
  127354. * Please use related enable/disable method to switch state.
  127355. */
  127356. get audioEnabled(): boolean;
  127357. private _headphone;
  127358. /**
  127359. * Gets whether audio is outputing to headphone or not.
  127360. * Please use the according Switch methods to change output.
  127361. */
  127362. get headphone(): boolean;
  127363. /**
  127364. * Gets or sets a refresh rate when using 3D audio positioning
  127365. */
  127366. audioPositioningRefreshRate: number;
  127367. private _audioListenerPositionProvider;
  127368. /**
  127369. * Gets the current audio listener position provider
  127370. */
  127371. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  127372. /**
  127373. * Sets a custom listener position for all sounds in the scene
  127374. * By default, this is the position of the first active camera
  127375. */
  127376. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  127377. /**
  127378. * Creates a new instance of the component for the given scene
  127379. * @param scene Defines the scene to register the component in
  127380. */
  127381. constructor(scene: Scene);
  127382. /**
  127383. * Registers the component in a given scene
  127384. */
  127385. register(): void;
  127386. /**
  127387. * Rebuilds the elements related to this component in case of
  127388. * context lost for instance.
  127389. */
  127390. rebuild(): void;
  127391. /**
  127392. * Serializes the component data to the specified json object
  127393. * @param serializationObject The object to serialize to
  127394. */
  127395. serialize(serializationObject: any): void;
  127396. /**
  127397. * Adds all the elements from the container to the scene
  127398. * @param container the container holding the elements
  127399. */
  127400. addFromContainer(container: AbstractScene): void;
  127401. /**
  127402. * Removes all the elements in the container from the scene
  127403. * @param container contains the elements to remove
  127404. * @param dispose if the removed element should be disposed (default: false)
  127405. */
  127406. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127407. /**
  127408. * Disposes the component and the associated ressources.
  127409. */
  127410. dispose(): void;
  127411. /**
  127412. * Disables audio in the associated scene.
  127413. */
  127414. disableAudio(): void;
  127415. /**
  127416. * Enables audio in the associated scene.
  127417. */
  127418. enableAudio(): void;
  127419. /**
  127420. * Switch audio to headphone output.
  127421. */
  127422. switchAudioModeForHeadphones(): void;
  127423. /**
  127424. * Switch audio to normal speakers.
  127425. */
  127426. switchAudioModeForNormalSpeakers(): void;
  127427. private _cachedCameraDirection;
  127428. private _cachedCameraPosition;
  127429. private _lastCheck;
  127430. private _afterRender;
  127431. }
  127432. }
  127433. declare module BABYLON {
  127434. /**
  127435. * Wraps one or more Sound objects and selects one with random weight for playback.
  127436. */
  127437. export class WeightedSound {
  127438. /** When true a Sound will be selected and played when the current playing Sound completes. */
  127439. loop: boolean;
  127440. private _coneInnerAngle;
  127441. private _coneOuterAngle;
  127442. private _volume;
  127443. /** A Sound is currently playing. */
  127444. isPlaying: boolean;
  127445. /** A Sound is currently paused. */
  127446. isPaused: boolean;
  127447. private _sounds;
  127448. private _weights;
  127449. private _currentIndex?;
  127450. /**
  127451. * Creates a new WeightedSound from the list of sounds given.
  127452. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  127453. * @param sounds Array of Sounds that will be selected from.
  127454. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  127455. */
  127456. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  127457. /**
  127458. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  127459. */
  127460. get directionalConeInnerAngle(): number;
  127461. /**
  127462. * The size of cone in degress for a directional sound in which there will be no attenuation.
  127463. */
  127464. set directionalConeInnerAngle(value: number);
  127465. /**
  127466. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127467. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127468. */
  127469. get directionalConeOuterAngle(): number;
  127470. /**
  127471. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  127472. * Listener angles between innerAngle and outerAngle will falloff linearly.
  127473. */
  127474. set directionalConeOuterAngle(value: number);
  127475. /**
  127476. * Playback volume.
  127477. */
  127478. get volume(): number;
  127479. /**
  127480. * Playback volume.
  127481. */
  127482. set volume(value: number);
  127483. private _onended;
  127484. /**
  127485. * Suspend playback
  127486. */
  127487. pause(): void;
  127488. /**
  127489. * Stop playback
  127490. */
  127491. stop(): void;
  127492. /**
  127493. * Start playback.
  127494. * @param startOffset Position the clip head at a specific time in seconds.
  127495. */
  127496. play(startOffset?: number): void;
  127497. }
  127498. }
  127499. declare module BABYLON {
  127500. /**
  127501. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  127502. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127503. */
  127504. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  127505. /**
  127506. * Gets the name of the behavior.
  127507. */
  127508. get name(): string;
  127509. /**
  127510. * The easing function used by animations
  127511. */
  127512. static EasingFunction: BackEase;
  127513. /**
  127514. * The easing mode used by animations
  127515. */
  127516. static EasingMode: number;
  127517. /**
  127518. * The duration of the animation, in milliseconds
  127519. */
  127520. transitionDuration: number;
  127521. /**
  127522. * Length of the distance animated by the transition when lower radius is reached
  127523. */
  127524. lowerRadiusTransitionRange: number;
  127525. /**
  127526. * Length of the distance animated by the transition when upper radius is reached
  127527. */
  127528. upperRadiusTransitionRange: number;
  127529. private _autoTransitionRange;
  127530. /**
  127531. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127532. */
  127533. get autoTransitionRange(): boolean;
  127534. /**
  127535. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  127536. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  127537. */
  127538. set autoTransitionRange(value: boolean);
  127539. private _attachedCamera;
  127540. private _onAfterCheckInputsObserver;
  127541. private _onMeshTargetChangedObserver;
  127542. /**
  127543. * Initializes the behavior.
  127544. */
  127545. init(): void;
  127546. /**
  127547. * Attaches the behavior to its arc rotate camera.
  127548. * @param camera Defines the camera to attach the behavior to
  127549. */
  127550. attach(camera: ArcRotateCamera): void;
  127551. /**
  127552. * Detaches the behavior from its current arc rotate camera.
  127553. */
  127554. detach(): void;
  127555. private _radiusIsAnimating;
  127556. private _radiusBounceTransition;
  127557. private _animatables;
  127558. private _cachedWheelPrecision;
  127559. /**
  127560. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  127561. * @param radiusLimit The limit to check against.
  127562. * @return Bool to indicate if at limit.
  127563. */
  127564. private _isRadiusAtLimit;
  127565. /**
  127566. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  127567. * @param radiusDelta The delta by which to animate to. Can be negative.
  127568. */
  127569. private _applyBoundRadiusAnimation;
  127570. /**
  127571. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  127572. */
  127573. protected _clearAnimationLocks(): void;
  127574. /**
  127575. * Stops and removes all animations that have been applied to the camera
  127576. */
  127577. stopAllAnimations(): void;
  127578. }
  127579. }
  127580. declare module BABYLON {
  127581. /**
  127582. * 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.
  127583. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127584. */
  127585. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  127586. /**
  127587. * Gets the name of the behavior.
  127588. */
  127589. get name(): string;
  127590. private _mode;
  127591. private _radiusScale;
  127592. private _positionScale;
  127593. private _defaultElevation;
  127594. private _elevationReturnTime;
  127595. private _elevationReturnWaitTime;
  127596. private _zoomStopsAnimation;
  127597. private _framingTime;
  127598. /**
  127599. * The easing function used by animations
  127600. */
  127601. static EasingFunction: ExponentialEase;
  127602. /**
  127603. * The easing mode used by animations
  127604. */
  127605. static EasingMode: number;
  127606. /**
  127607. * Sets the current mode used by the behavior
  127608. */
  127609. set mode(mode: number);
  127610. /**
  127611. * Gets current mode used by the behavior.
  127612. */
  127613. get mode(): number;
  127614. /**
  127615. * Sets the scale applied to the radius (1 by default)
  127616. */
  127617. set radiusScale(radius: number);
  127618. /**
  127619. * Gets the scale applied to the radius
  127620. */
  127621. get radiusScale(): number;
  127622. /**
  127623. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127624. */
  127625. set positionScale(scale: number);
  127626. /**
  127627. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  127628. */
  127629. get positionScale(): number;
  127630. /**
  127631. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127632. * behaviour is triggered, in radians.
  127633. */
  127634. set defaultElevation(elevation: number);
  127635. /**
  127636. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  127637. * behaviour is triggered, in radians.
  127638. */
  127639. get defaultElevation(): number;
  127640. /**
  127641. * Sets the time (in milliseconds) taken to return to the default beta position.
  127642. * Negative value indicates camera should not return to default.
  127643. */
  127644. set elevationReturnTime(speed: number);
  127645. /**
  127646. * Gets the time (in milliseconds) taken to return to the default beta position.
  127647. * Negative value indicates camera should not return to default.
  127648. */
  127649. get elevationReturnTime(): number;
  127650. /**
  127651. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127652. */
  127653. set elevationReturnWaitTime(time: number);
  127654. /**
  127655. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  127656. */
  127657. get elevationReturnWaitTime(): number;
  127658. /**
  127659. * Sets the flag that indicates if user zooming should stop animation.
  127660. */
  127661. set zoomStopsAnimation(flag: boolean);
  127662. /**
  127663. * Gets the flag that indicates if user zooming should stop animation.
  127664. */
  127665. get zoomStopsAnimation(): boolean;
  127666. /**
  127667. * Sets the transition time when framing the mesh, in milliseconds
  127668. */
  127669. set framingTime(time: number);
  127670. /**
  127671. * Gets the transition time when framing the mesh, in milliseconds
  127672. */
  127673. get framingTime(): number;
  127674. /**
  127675. * Define if the behavior should automatically change the configured
  127676. * camera limits and sensibilities.
  127677. */
  127678. autoCorrectCameraLimitsAndSensibility: boolean;
  127679. private _onPrePointerObservableObserver;
  127680. private _onAfterCheckInputsObserver;
  127681. private _onMeshTargetChangedObserver;
  127682. private _attachedCamera;
  127683. private _isPointerDown;
  127684. private _lastInteractionTime;
  127685. /**
  127686. * Initializes the behavior.
  127687. */
  127688. init(): void;
  127689. /**
  127690. * Attaches the behavior to its arc rotate camera.
  127691. * @param camera Defines the camera to attach the behavior to
  127692. */
  127693. attach(camera: ArcRotateCamera): void;
  127694. /**
  127695. * Detaches the behavior from its current arc rotate camera.
  127696. */
  127697. detach(): void;
  127698. private _animatables;
  127699. private _betaIsAnimating;
  127700. private _betaTransition;
  127701. private _radiusTransition;
  127702. private _vectorTransition;
  127703. /**
  127704. * Targets the given mesh and updates zoom level accordingly.
  127705. * @param mesh The mesh to target.
  127706. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127707. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127708. */
  127709. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127710. /**
  127711. * Targets the given mesh with its children and updates zoom level accordingly.
  127712. * @param mesh The mesh to target.
  127713. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127714. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127715. */
  127716. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127717. /**
  127718. * Targets the given meshes with their children and updates zoom level accordingly.
  127719. * @param meshes The mesh to target.
  127720. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127721. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127722. */
  127723. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127724. /**
  127725. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  127726. * @param minimumWorld Determines the smaller position of the bounding box extend
  127727. * @param maximumWorld Determines the bigger position of the bounding box extend
  127728. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  127729. * @param onAnimationEnd Callback triggered at the end of the framing animation
  127730. */
  127731. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  127732. /**
  127733. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  127734. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  127735. * frustum width.
  127736. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  127737. * to fully enclose the mesh in the viewing frustum.
  127738. */
  127739. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  127740. /**
  127741. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  127742. * is automatically returned to its default position (expected to be above ground plane).
  127743. */
  127744. private _maintainCameraAboveGround;
  127745. /**
  127746. * Returns the frustum slope based on the canvas ratio and camera FOV
  127747. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  127748. */
  127749. private _getFrustumSlope;
  127750. /**
  127751. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  127752. */
  127753. private _clearAnimationLocks;
  127754. /**
  127755. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127756. */
  127757. private _applyUserInteraction;
  127758. /**
  127759. * Stops and removes all animations that have been applied to the camera
  127760. */
  127761. stopAllAnimations(): void;
  127762. /**
  127763. * Gets a value indicating if the user is moving the camera
  127764. */
  127765. get isUserIsMoving(): boolean;
  127766. /**
  127767. * The camera can move all the way towards the mesh.
  127768. */
  127769. static IgnoreBoundsSizeMode: number;
  127770. /**
  127771. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  127772. */
  127773. static FitFrustumSidesMode: number;
  127774. }
  127775. }
  127776. declare module BABYLON {
  127777. /**
  127778. * Base class for Camera Pointer Inputs.
  127779. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  127780. * for example usage.
  127781. */
  127782. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  127783. /**
  127784. * Defines the camera the input is attached to.
  127785. */
  127786. abstract camera: Camera;
  127787. /**
  127788. * Whether keyboard modifier keys are pressed at time of last mouse event.
  127789. */
  127790. protected _altKey: boolean;
  127791. protected _ctrlKey: boolean;
  127792. protected _metaKey: boolean;
  127793. protected _shiftKey: boolean;
  127794. /**
  127795. * Which mouse buttons were pressed at time of last mouse event.
  127796. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127797. */
  127798. protected _buttonsPressed: number;
  127799. /**
  127800. * Defines the buttons associated with the input to handle camera move.
  127801. */
  127802. buttons: number[];
  127803. /**
  127804. * Attach the input controls to a specific dom element to get the input from.
  127805. * @param element Defines the element the controls should be listened from
  127806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127807. */
  127808. attachControl(noPreventDefault?: boolean): void;
  127809. /**
  127810. * Detach the current controls from the specified dom element.
  127811. */
  127812. detachControl(): void;
  127813. /**
  127814. * Gets the class name of the current input.
  127815. * @returns the class name
  127816. */
  127817. getClassName(): string;
  127818. /**
  127819. * Get the friendly name associated with the input class.
  127820. * @returns the input friendly name
  127821. */
  127822. getSimpleName(): string;
  127823. /**
  127824. * Called on pointer POINTERDOUBLETAP event.
  127825. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127826. */
  127827. protected onDoubleTap(type: string): void;
  127828. /**
  127829. * Called on pointer POINTERMOVE event if only a single touch is active.
  127830. * Override this method to provide functionality.
  127831. */
  127832. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127833. /**
  127834. * Called on pointer POINTERMOVE event if multiple touches are active.
  127835. * Override this method to provide functionality.
  127836. */
  127837. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127838. /**
  127839. * Called on JS contextmenu event.
  127840. * Override this method to provide functionality.
  127841. */
  127842. protected onContextMenu(evt: PointerEvent): void;
  127843. /**
  127844. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127845. * press.
  127846. * Override this method to provide functionality.
  127847. */
  127848. protected onButtonDown(evt: PointerEvent): void;
  127849. /**
  127850. * Called each time a new POINTERUP event occurs. Ie, for each button
  127851. * release.
  127852. * Override this method to provide functionality.
  127853. */
  127854. protected onButtonUp(evt: PointerEvent): void;
  127855. /**
  127856. * Called when window becomes inactive.
  127857. * Override this method to provide functionality.
  127858. */
  127859. protected onLostFocus(): void;
  127860. private _pointerInput;
  127861. private _observer;
  127862. private _onLostFocus;
  127863. private pointA;
  127864. private pointB;
  127865. }
  127866. }
  127867. declare module BABYLON {
  127868. /**
  127869. * Manage the pointers inputs to control an arc rotate camera.
  127870. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127871. */
  127872. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127873. /**
  127874. * Defines the camera the input is attached to.
  127875. */
  127876. camera: ArcRotateCamera;
  127877. /**
  127878. * Gets the class name of the current input.
  127879. * @returns the class name
  127880. */
  127881. getClassName(): string;
  127882. /**
  127883. * Defines the buttons associated with the input to handle camera move.
  127884. */
  127885. buttons: number[];
  127886. /**
  127887. * Defines the pointer angular sensibility along the X axis or how fast is
  127888. * the camera rotating.
  127889. */
  127890. angularSensibilityX: number;
  127891. /**
  127892. * Defines the pointer angular sensibility along the Y axis or how fast is
  127893. * the camera rotating.
  127894. */
  127895. angularSensibilityY: number;
  127896. /**
  127897. * Defines the pointer pinch precision or how fast is the camera zooming.
  127898. */
  127899. pinchPrecision: number;
  127900. /**
  127901. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127902. * from 0.
  127903. * It defines the percentage of current camera.radius to use as delta when
  127904. * pinch zoom is used.
  127905. */
  127906. pinchDeltaPercentage: number;
  127907. /**
  127908. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127909. * that any object in the plane at the camera's target point will scale
  127910. * perfectly with finger motion.
  127911. * Overrides pinchDeltaPercentage and pinchPrecision.
  127912. */
  127913. useNaturalPinchZoom: boolean;
  127914. /**
  127915. * Defines the pointer panning sensibility or how fast is the camera moving.
  127916. */
  127917. panningSensibility: number;
  127918. /**
  127919. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127920. */
  127921. multiTouchPanning: boolean;
  127922. /**
  127923. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127924. * zoom (pinch) through multitouch.
  127925. */
  127926. multiTouchPanAndZoom: boolean;
  127927. /**
  127928. * Revers pinch action direction.
  127929. */
  127930. pinchInwards: boolean;
  127931. private _isPanClick;
  127932. private _twoFingerActivityCount;
  127933. private _isPinching;
  127934. /**
  127935. * Called on pointer POINTERMOVE event if only a single touch is active.
  127936. */
  127937. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127938. /**
  127939. * Called on pointer POINTERDOUBLETAP event.
  127940. */
  127941. protected onDoubleTap(type: string): void;
  127942. /**
  127943. * Called on pointer POINTERMOVE event if multiple touches are active.
  127944. */
  127945. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127946. /**
  127947. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127948. * press.
  127949. */
  127950. protected onButtonDown(evt: PointerEvent): void;
  127951. /**
  127952. * Called each time a new POINTERUP event occurs. Ie, for each button
  127953. * release.
  127954. */
  127955. protected onButtonUp(evt: PointerEvent): void;
  127956. /**
  127957. * Called when window becomes inactive.
  127958. */
  127959. protected onLostFocus(): void;
  127960. }
  127961. }
  127962. declare module BABYLON {
  127963. /**
  127964. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127966. */
  127967. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127968. /**
  127969. * Defines the camera the input is attached to.
  127970. */
  127971. camera: ArcRotateCamera;
  127972. /**
  127973. * Defines the list of key codes associated with the up action (increase alpha)
  127974. */
  127975. keysUp: number[];
  127976. /**
  127977. * Defines the list of key codes associated with the down action (decrease alpha)
  127978. */
  127979. keysDown: number[];
  127980. /**
  127981. * Defines the list of key codes associated with the left action (increase beta)
  127982. */
  127983. keysLeft: number[];
  127984. /**
  127985. * Defines the list of key codes associated with the right action (decrease beta)
  127986. */
  127987. keysRight: number[];
  127988. /**
  127989. * Defines the list of key codes associated with the reset action.
  127990. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127991. */
  127992. keysReset: number[];
  127993. /**
  127994. * Defines the panning sensibility of the inputs.
  127995. * (How fast is the camera panning)
  127996. */
  127997. panningSensibility: number;
  127998. /**
  127999. * Defines the zooming sensibility of the inputs.
  128000. * (How fast is the camera zooming)
  128001. */
  128002. zoomingSensibility: number;
  128003. /**
  128004. * Defines whether maintaining the alt key down switch the movement mode from
  128005. * orientation to zoom.
  128006. */
  128007. useAltToZoom: boolean;
  128008. /**
  128009. * Rotation speed of the camera
  128010. */
  128011. angularSpeed: number;
  128012. private _keys;
  128013. private _ctrlPressed;
  128014. private _altPressed;
  128015. private _onCanvasBlurObserver;
  128016. private _onKeyboardObserver;
  128017. private _engine;
  128018. private _scene;
  128019. /**
  128020. * Attach the input controls to a specific dom element to get the input from.
  128021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128022. */
  128023. attachControl(noPreventDefault?: boolean): void;
  128024. /**
  128025. * Detach the current controls from the specified dom element.
  128026. */
  128027. detachControl(): void;
  128028. /**
  128029. * Update the current camera state depending on the inputs that have been used this frame.
  128030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128031. */
  128032. checkInputs(): void;
  128033. /**
  128034. * Gets the class name of the current intput.
  128035. * @returns the class name
  128036. */
  128037. getClassName(): string;
  128038. /**
  128039. * Get the friendly name associated with the input class.
  128040. * @returns the input friendly name
  128041. */
  128042. getSimpleName(): string;
  128043. }
  128044. }
  128045. declare module BABYLON {
  128046. /**
  128047. * Manage the mouse wheel inputs to control an arc rotate camera.
  128048. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128049. */
  128050. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  128051. /**
  128052. * Defines the camera the input is attached to.
  128053. */
  128054. camera: ArcRotateCamera;
  128055. /**
  128056. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128057. */
  128058. wheelPrecision: number;
  128059. /**
  128060. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128061. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128062. */
  128063. wheelDeltaPercentage: number;
  128064. private _wheel;
  128065. private _observer;
  128066. private computeDeltaFromMouseWheelLegacyEvent;
  128067. /**
  128068. * Attach the input controls to a specific dom element to get the input from.
  128069. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128070. */
  128071. attachControl(noPreventDefault?: boolean): void;
  128072. /**
  128073. * Detach the current controls from the specified dom element.
  128074. */
  128075. detachControl(): void;
  128076. /**
  128077. * Gets the class name of the current intput.
  128078. * @returns the class name
  128079. */
  128080. getClassName(): string;
  128081. /**
  128082. * Get the friendly name associated with the input class.
  128083. * @returns the input friendly name
  128084. */
  128085. getSimpleName(): string;
  128086. }
  128087. }
  128088. declare module BABYLON {
  128089. /**
  128090. * Default Inputs manager for the ArcRotateCamera.
  128091. * It groups all the default supported inputs for ease of use.
  128092. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128093. */
  128094. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  128095. /**
  128096. * Instantiates a new ArcRotateCameraInputsManager.
  128097. * @param camera Defines the camera the inputs belong to
  128098. */
  128099. constructor(camera: ArcRotateCamera);
  128100. /**
  128101. * Add mouse wheel input support to the input manager.
  128102. * @returns the current input manager
  128103. */
  128104. addMouseWheel(): ArcRotateCameraInputsManager;
  128105. /**
  128106. * Add pointers input support to the input manager.
  128107. * @returns the current input manager
  128108. */
  128109. addPointers(): ArcRotateCameraInputsManager;
  128110. /**
  128111. * Add keyboard input support to the input manager.
  128112. * @returns the current input manager
  128113. */
  128114. addKeyboard(): ArcRotateCameraInputsManager;
  128115. }
  128116. }
  128117. declare module BABYLON {
  128118. /**
  128119. * This represents an orbital type of camera.
  128120. *
  128121. * 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.
  128122. * 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.
  128123. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  128124. */
  128125. export class ArcRotateCamera extends TargetCamera {
  128126. /**
  128127. * Defines the rotation angle of the camera along the longitudinal axis.
  128128. */
  128129. alpha: number;
  128130. /**
  128131. * Defines the rotation angle of the camera along the latitudinal axis.
  128132. */
  128133. beta: number;
  128134. /**
  128135. * Defines the radius of the camera from it s target point.
  128136. */
  128137. radius: number;
  128138. protected _target: Vector3;
  128139. protected _targetHost: Nullable<AbstractMesh>;
  128140. /**
  128141. * Defines the target point of the camera.
  128142. * The camera looks towards it form the radius distance.
  128143. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  128144. */
  128145. get target(): Vector3;
  128146. set target(value: Vector3);
  128147. /**
  128148. * Define the current local position of the camera in the scene
  128149. */
  128150. get position(): Vector3;
  128151. set position(newPosition: Vector3);
  128152. protected _upToYMatrix: Matrix;
  128153. protected _YToUpMatrix: Matrix;
  128154. /**
  128155. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  128156. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  128157. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  128158. */
  128159. set upVector(vec: Vector3);
  128160. get upVector(): Vector3;
  128161. /**
  128162. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  128163. */
  128164. setMatUp(): void;
  128165. /**
  128166. * Current inertia value on the longitudinal axis.
  128167. * The bigger this number the longer it will take for the camera to stop.
  128168. */
  128169. inertialAlphaOffset: number;
  128170. /**
  128171. * Current inertia value on the latitudinal axis.
  128172. * The bigger this number the longer it will take for the camera to stop.
  128173. */
  128174. inertialBetaOffset: number;
  128175. /**
  128176. * Current inertia value on the radius axis.
  128177. * The bigger this number the longer it will take for the camera to stop.
  128178. */
  128179. inertialRadiusOffset: number;
  128180. /**
  128181. * Minimum allowed angle on the longitudinal axis.
  128182. * This can help limiting how the Camera is able to move in the scene.
  128183. */
  128184. lowerAlphaLimit: Nullable<number>;
  128185. /**
  128186. * Maximum allowed angle on the longitudinal axis.
  128187. * This can help limiting how the Camera is able to move in the scene.
  128188. */
  128189. upperAlphaLimit: Nullable<number>;
  128190. /**
  128191. * Minimum allowed angle on the latitudinal axis.
  128192. * This can help limiting how the Camera is able to move in the scene.
  128193. */
  128194. lowerBetaLimit: number;
  128195. /**
  128196. * Maximum allowed angle on the latitudinal axis.
  128197. * This can help limiting how the Camera is able to move in the scene.
  128198. */
  128199. upperBetaLimit: number;
  128200. /**
  128201. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  128202. * This can help limiting how the Camera is able to move in the scene.
  128203. */
  128204. lowerRadiusLimit: Nullable<number>;
  128205. /**
  128206. * Maximum allowed distance of the camera to the target (The camera can not get further).
  128207. * This can help limiting how the Camera is able to move in the scene.
  128208. */
  128209. upperRadiusLimit: Nullable<number>;
  128210. /**
  128211. * Defines the current inertia value used during panning of the camera along the X axis.
  128212. */
  128213. inertialPanningX: number;
  128214. /**
  128215. * Defines the current inertia value used during panning of the camera along the Y axis.
  128216. */
  128217. inertialPanningY: number;
  128218. /**
  128219. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  128220. * Basically if your fingers moves away from more than this distance you will be considered
  128221. * in pinch mode.
  128222. */
  128223. pinchToPanMaxDistance: number;
  128224. /**
  128225. * Defines the maximum distance the camera can pan.
  128226. * This could help keeping the cammera always in your scene.
  128227. */
  128228. panningDistanceLimit: Nullable<number>;
  128229. /**
  128230. * Defines the target of the camera before paning.
  128231. */
  128232. panningOriginTarget: Vector3;
  128233. /**
  128234. * Defines the value of the inertia used during panning.
  128235. * 0 would mean stop inertia and one would mean no decelleration at all.
  128236. */
  128237. panningInertia: number;
  128238. /**
  128239. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  128240. */
  128241. get angularSensibilityX(): number;
  128242. set angularSensibilityX(value: number);
  128243. /**
  128244. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  128245. */
  128246. get angularSensibilityY(): number;
  128247. set angularSensibilityY(value: number);
  128248. /**
  128249. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  128250. */
  128251. get pinchPrecision(): number;
  128252. set pinchPrecision(value: number);
  128253. /**
  128254. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  128255. * It will be used instead of pinchDeltaPrecision if different from 0.
  128256. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128257. */
  128258. get pinchDeltaPercentage(): number;
  128259. set pinchDeltaPercentage(value: number);
  128260. /**
  128261. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  128262. * and pinch delta percentage.
  128263. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  128264. * that any object in the plane at the camera's target point will scale
  128265. * perfectly with finger motion.
  128266. */
  128267. get useNaturalPinchZoom(): boolean;
  128268. set useNaturalPinchZoom(value: boolean);
  128269. /**
  128270. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  128271. */
  128272. get panningSensibility(): number;
  128273. set panningSensibility(value: number);
  128274. /**
  128275. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  128276. */
  128277. get keysUp(): number[];
  128278. set keysUp(value: number[]);
  128279. /**
  128280. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  128281. */
  128282. get keysDown(): number[];
  128283. set keysDown(value: number[]);
  128284. /**
  128285. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  128286. */
  128287. get keysLeft(): number[];
  128288. set keysLeft(value: number[]);
  128289. /**
  128290. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  128291. */
  128292. get keysRight(): number[];
  128293. set keysRight(value: number[]);
  128294. /**
  128295. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  128296. */
  128297. get wheelPrecision(): number;
  128298. set wheelPrecision(value: number);
  128299. /**
  128300. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  128301. * It will be used instead of pinchDeltaPrecision if different from 0.
  128302. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  128303. */
  128304. get wheelDeltaPercentage(): number;
  128305. set wheelDeltaPercentage(value: number);
  128306. /**
  128307. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  128308. */
  128309. zoomOnFactor: number;
  128310. /**
  128311. * Defines a screen offset for the camera position.
  128312. */
  128313. targetScreenOffset: Vector2;
  128314. /**
  128315. * Allows the camera to be completely reversed.
  128316. * If false the camera can not arrive upside down.
  128317. */
  128318. allowUpsideDown: boolean;
  128319. /**
  128320. * Define if double tap/click is used to restore the previously saved state of the camera.
  128321. */
  128322. useInputToRestoreState: boolean;
  128323. /** @hidden */
  128324. _viewMatrix: Matrix;
  128325. /** @hidden */
  128326. _useCtrlForPanning: boolean;
  128327. /** @hidden */
  128328. _panningMouseButton: number;
  128329. /**
  128330. * Defines the input associated to the camera.
  128331. */
  128332. inputs: ArcRotateCameraInputsManager;
  128333. /** @hidden */
  128334. _reset: () => void;
  128335. /**
  128336. * Defines the allowed panning axis.
  128337. */
  128338. panningAxis: Vector3;
  128339. protected _localDirection: Vector3;
  128340. protected _transformedDirection: Vector3;
  128341. private _bouncingBehavior;
  128342. /**
  128343. * Gets the bouncing behavior of the camera if it has been enabled.
  128344. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128345. */
  128346. get bouncingBehavior(): Nullable<BouncingBehavior>;
  128347. /**
  128348. * Defines if the bouncing behavior of the camera is enabled on the camera.
  128349. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  128350. */
  128351. get useBouncingBehavior(): boolean;
  128352. set useBouncingBehavior(value: boolean);
  128353. private _framingBehavior;
  128354. /**
  128355. * Gets the framing behavior of the camera if it has been enabled.
  128356. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128357. */
  128358. get framingBehavior(): Nullable<FramingBehavior>;
  128359. /**
  128360. * Defines if the framing behavior of the camera is enabled on the camera.
  128361. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  128362. */
  128363. get useFramingBehavior(): boolean;
  128364. set useFramingBehavior(value: boolean);
  128365. private _autoRotationBehavior;
  128366. /**
  128367. * Gets the auto rotation behavior of the camera if it has been enabled.
  128368. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128369. */
  128370. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  128371. /**
  128372. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  128373. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128374. */
  128375. get useAutoRotationBehavior(): boolean;
  128376. set useAutoRotationBehavior(value: boolean);
  128377. /**
  128378. * Observable triggered when the mesh target has been changed on the camera.
  128379. */
  128380. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  128381. /**
  128382. * Event raised when the camera is colliding with a mesh.
  128383. */
  128384. onCollide: (collidedMesh: AbstractMesh) => void;
  128385. /**
  128386. * Defines whether the camera should check collision with the objects oh the scene.
  128387. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  128388. */
  128389. checkCollisions: boolean;
  128390. /**
  128391. * Defines the collision radius of the camera.
  128392. * This simulates a sphere around the camera.
  128393. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128394. */
  128395. collisionRadius: Vector3;
  128396. protected _collider: Collider;
  128397. protected _previousPosition: Vector3;
  128398. protected _collisionVelocity: Vector3;
  128399. protected _newPosition: Vector3;
  128400. protected _previousAlpha: number;
  128401. protected _previousBeta: number;
  128402. protected _previousRadius: number;
  128403. protected _collisionTriggered: boolean;
  128404. protected _targetBoundingCenter: Nullable<Vector3>;
  128405. private _computationVector;
  128406. /**
  128407. * Instantiates a new ArcRotateCamera in a given scene
  128408. * @param name Defines the name of the camera
  128409. * @param alpha Defines the camera rotation along the logitudinal axis
  128410. * @param beta Defines the camera rotation along the latitudinal axis
  128411. * @param radius Defines the camera distance from its target
  128412. * @param target Defines the camera target
  128413. * @param scene Defines the scene the camera belongs to
  128414. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  128415. */
  128416. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128417. /** @hidden */
  128418. _initCache(): void;
  128419. /** @hidden */
  128420. _updateCache(ignoreParentClass?: boolean): void;
  128421. protected _getTargetPosition(): Vector3;
  128422. private _storedAlpha;
  128423. private _storedBeta;
  128424. private _storedRadius;
  128425. private _storedTarget;
  128426. private _storedTargetScreenOffset;
  128427. /**
  128428. * Stores the current state of the camera (alpha, beta, radius and target)
  128429. * @returns the camera itself
  128430. */
  128431. storeState(): Camera;
  128432. /**
  128433. * @hidden
  128434. * Restored camera state. You must call storeState() first
  128435. */
  128436. _restoreStateValues(): boolean;
  128437. /** @hidden */
  128438. _isSynchronizedViewMatrix(): boolean;
  128439. /**
  128440. * Attach the input controls to a specific dom element to get the input from.
  128441. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128442. */
  128443. attachControl(noPreventDefault?: boolean): void;
  128444. /**
  128445. * Attach the input controls to a specific dom element to get the input from.
  128446. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128447. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128448. */
  128449. attachControl(ignored: any, noPreventDefault?: boolean): void;
  128450. /**
  128451. * Attached controls to the current camera.
  128452. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128453. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128454. */
  128455. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128456. /**
  128457. * Attached controls to the current camera.
  128458. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128459. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128460. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128461. */
  128462. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  128463. /**
  128464. * Attached controls to the current camera.
  128465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128466. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  128467. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  128468. */
  128469. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  128470. /**
  128471. * Detach the current controls from the specified dom element.
  128472. */
  128473. detachControl(): void;
  128474. /**
  128475. * Detach the current controls from the specified dom element.
  128476. * @param ignored defines an ignored parameter kept for backward compatibility. If you want to define the source input element, you can set engine.inputElement before calling camera.attachControl
  128477. */
  128478. detachControl(ignored: any): void;
  128479. /** @hidden */
  128480. _checkInputs(): void;
  128481. protected _checkLimits(): void;
  128482. /**
  128483. * Rebuilds angles (alpha, beta) and radius from the give position and target
  128484. */
  128485. rebuildAnglesAndRadius(): void;
  128486. /**
  128487. * Use a position to define the current camera related information like alpha, beta and radius
  128488. * @param position Defines the position to set the camera at
  128489. */
  128490. setPosition(position: Vector3): void;
  128491. /**
  128492. * Defines the target the camera should look at.
  128493. * This will automatically adapt alpha beta and radius to fit within the new target.
  128494. * @param target Defines the new target as a Vector or a mesh
  128495. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  128496. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  128497. */
  128498. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  128499. /** @hidden */
  128500. _getViewMatrix(): Matrix;
  128501. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  128502. /**
  128503. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  128504. * @param meshes Defines the mesh to zoom on
  128505. * @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)
  128506. */
  128507. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  128508. /**
  128509. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  128510. * The target will be changed but the radius
  128511. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  128512. * @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)
  128513. */
  128514. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  128515. min: Vector3;
  128516. max: Vector3;
  128517. distance: number;
  128518. }, doNotUpdateMaxZ?: boolean): void;
  128519. /**
  128520. * @override
  128521. * Override Camera.createRigCamera
  128522. */
  128523. createRigCamera(name: string, cameraIndex: number): Camera;
  128524. /**
  128525. * @hidden
  128526. * @override
  128527. * Override Camera._updateRigCameras
  128528. */
  128529. _updateRigCameras(): void;
  128530. /**
  128531. * Destroy the camera and release the current resources hold by it.
  128532. */
  128533. dispose(): void;
  128534. /**
  128535. * Gets the current object class name.
  128536. * @return the class name
  128537. */
  128538. getClassName(): string;
  128539. }
  128540. }
  128541. declare module BABYLON {
  128542. /**
  128543. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  128544. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  128545. */
  128546. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  128547. /**
  128548. * Gets the name of the behavior.
  128549. */
  128550. get name(): string;
  128551. private _zoomStopsAnimation;
  128552. private _idleRotationSpeed;
  128553. private _idleRotationWaitTime;
  128554. private _idleRotationSpinupTime;
  128555. /**
  128556. * Sets the flag that indicates if user zooming should stop animation.
  128557. */
  128558. set zoomStopsAnimation(flag: boolean);
  128559. /**
  128560. * Gets the flag that indicates if user zooming should stop animation.
  128561. */
  128562. get zoomStopsAnimation(): boolean;
  128563. /**
  128564. * Sets the default speed at which the camera rotates around the model.
  128565. */
  128566. set idleRotationSpeed(speed: number);
  128567. /**
  128568. * Gets the default speed at which the camera rotates around the model.
  128569. */
  128570. get idleRotationSpeed(): number;
  128571. /**
  128572. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  128573. */
  128574. set idleRotationWaitTime(time: number);
  128575. /**
  128576. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  128577. */
  128578. get idleRotationWaitTime(): number;
  128579. /**
  128580. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128581. */
  128582. set idleRotationSpinupTime(time: number);
  128583. /**
  128584. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  128585. */
  128586. get idleRotationSpinupTime(): number;
  128587. /**
  128588. * Gets a value indicating if the camera is currently rotating because of this behavior
  128589. */
  128590. get rotationInProgress(): boolean;
  128591. private _onPrePointerObservableObserver;
  128592. private _onAfterCheckInputsObserver;
  128593. private _attachedCamera;
  128594. private _isPointerDown;
  128595. private _lastFrameTime;
  128596. private _lastInteractionTime;
  128597. private _cameraRotationSpeed;
  128598. /**
  128599. * Initializes the behavior.
  128600. */
  128601. init(): void;
  128602. /**
  128603. * Attaches the behavior to its arc rotate camera.
  128604. * @param camera Defines the camera to attach the behavior to
  128605. */
  128606. attach(camera: ArcRotateCamera): void;
  128607. /**
  128608. * Detaches the behavior from its current arc rotate camera.
  128609. */
  128610. detach(): void;
  128611. /**
  128612. * Returns true if user is scrolling.
  128613. * @return true if user is scrolling.
  128614. */
  128615. private _userIsZooming;
  128616. private _lastFrameRadius;
  128617. private _shouldAnimationStopForInteraction;
  128618. /**
  128619. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  128620. */
  128621. private _applyUserInteraction;
  128622. private _userIsMoving;
  128623. }
  128624. }
  128625. declare module BABYLON {
  128626. /**
  128627. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  128628. */
  128629. export class AttachToBoxBehavior implements Behavior<Mesh> {
  128630. private ui;
  128631. /**
  128632. * The name of the behavior
  128633. */
  128634. name: string;
  128635. /**
  128636. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  128637. */
  128638. distanceAwayFromFace: number;
  128639. /**
  128640. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  128641. */
  128642. distanceAwayFromBottomOfFace: number;
  128643. private _faceVectors;
  128644. private _target;
  128645. private _scene;
  128646. private _onRenderObserver;
  128647. private _tmpMatrix;
  128648. private _tmpVector;
  128649. /**
  128650. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  128651. * @param ui The transform node that should be attched to the mesh
  128652. */
  128653. constructor(ui: TransformNode);
  128654. /**
  128655. * Initializes the behavior
  128656. */
  128657. init(): void;
  128658. private _closestFace;
  128659. private _zeroVector;
  128660. private _lookAtTmpMatrix;
  128661. private _lookAtToRef;
  128662. /**
  128663. * Attaches the AttachToBoxBehavior to the passed in mesh
  128664. * @param target The mesh that the specified node will be attached to
  128665. */
  128666. attach(target: Mesh): void;
  128667. /**
  128668. * Detaches the behavior from the mesh
  128669. */
  128670. detach(): void;
  128671. }
  128672. }
  128673. declare module BABYLON {
  128674. /**
  128675. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  128676. */
  128677. export class FadeInOutBehavior implements Behavior<Mesh> {
  128678. /**
  128679. * Time in milliseconds to delay before fading in (Default: 0)
  128680. */
  128681. delay: number;
  128682. /**
  128683. * Time in milliseconds for the mesh to fade in (Default: 300)
  128684. */
  128685. fadeInTime: number;
  128686. private _millisecondsPerFrame;
  128687. private _hovered;
  128688. private _hoverValue;
  128689. private _ownerNode;
  128690. /**
  128691. * Instatiates the FadeInOutBehavior
  128692. */
  128693. constructor();
  128694. /**
  128695. * The name of the behavior
  128696. */
  128697. get name(): string;
  128698. /**
  128699. * Initializes the behavior
  128700. */
  128701. init(): void;
  128702. /**
  128703. * Attaches the fade behavior on the passed in mesh
  128704. * @param ownerNode The mesh that will be faded in/out once attached
  128705. */
  128706. attach(ownerNode: Mesh): void;
  128707. /**
  128708. * Detaches the behavior from the mesh
  128709. */
  128710. detach(): void;
  128711. /**
  128712. * Triggers the mesh to begin fading in or out
  128713. * @param value if the object should fade in or out (true to fade in)
  128714. */
  128715. fadeIn(value: boolean): void;
  128716. private _update;
  128717. private _setAllVisibility;
  128718. }
  128719. }
  128720. declare module BABYLON {
  128721. /**
  128722. * Class containing a set of static utilities functions for managing Pivots
  128723. * @hidden
  128724. */
  128725. export class PivotTools {
  128726. private static _PivotCached;
  128727. private static _OldPivotPoint;
  128728. private static _PivotTranslation;
  128729. private static _PivotTmpVector;
  128730. private static _PivotPostMultiplyPivotMatrix;
  128731. /** @hidden */
  128732. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  128733. /** @hidden */
  128734. static _RestorePivotPoint(mesh: AbstractMesh): void;
  128735. }
  128736. }
  128737. declare module BABYLON {
  128738. /**
  128739. * Class containing static functions to help procedurally build meshes
  128740. */
  128741. export class PlaneBuilder {
  128742. /**
  128743. * Creates a plane mesh
  128744. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  128745. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  128746. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  128747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128750. * @param name defines the name of the mesh
  128751. * @param options defines the options used to create the mesh
  128752. * @param scene defines the hosting scene
  128753. * @returns the plane mesh
  128754. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  128755. */
  128756. static CreatePlane(name: string, options: {
  128757. size?: number;
  128758. width?: number;
  128759. height?: number;
  128760. sideOrientation?: number;
  128761. frontUVs?: Vector4;
  128762. backUVs?: Vector4;
  128763. updatable?: boolean;
  128764. sourcePlane?: Plane;
  128765. }, scene?: Nullable<Scene>): Mesh;
  128766. }
  128767. }
  128768. declare module BABYLON {
  128769. /**
  128770. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  128771. */
  128772. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  128773. private static _AnyMouseID;
  128774. /**
  128775. * Abstract mesh the behavior is set on
  128776. */
  128777. attachedNode: AbstractMesh;
  128778. private _dragPlane;
  128779. private _scene;
  128780. private _pointerObserver;
  128781. private _beforeRenderObserver;
  128782. private static _planeScene;
  128783. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  128784. /**
  128785. * 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)
  128786. */
  128787. maxDragAngle: number;
  128788. /**
  128789. * @hidden
  128790. */
  128791. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  128792. /**
  128793. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128794. */
  128795. currentDraggingPointerID: number;
  128796. /**
  128797. * The last position where the pointer hit the drag plane in world space
  128798. */
  128799. lastDragPosition: Vector3;
  128800. /**
  128801. * If the behavior is currently in a dragging state
  128802. */
  128803. dragging: boolean;
  128804. /**
  128805. * 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)
  128806. */
  128807. dragDeltaRatio: number;
  128808. /**
  128809. * If the drag plane orientation should be updated during the dragging (Default: true)
  128810. */
  128811. updateDragPlane: boolean;
  128812. private _debugMode;
  128813. private _moving;
  128814. /**
  128815. * Fires each time the attached mesh is dragged with the pointer
  128816. * * delta between last drag position and current drag position in world space
  128817. * * dragDistance along the drag axis
  128818. * * dragPlaneNormal normal of the current drag plane used during the drag
  128819. * * dragPlanePoint in world space where the drag intersects the drag plane
  128820. */
  128821. onDragObservable: Observable<{
  128822. delta: Vector3;
  128823. dragPlanePoint: Vector3;
  128824. dragPlaneNormal: Vector3;
  128825. dragDistance: number;
  128826. pointerId: number;
  128827. }>;
  128828. /**
  128829. * Fires each time a drag begins (eg. mouse down on mesh)
  128830. */
  128831. onDragStartObservable: Observable<{
  128832. dragPlanePoint: Vector3;
  128833. pointerId: number;
  128834. }>;
  128835. /**
  128836. * Fires each time a drag ends (eg. mouse release after drag)
  128837. */
  128838. onDragEndObservable: Observable<{
  128839. dragPlanePoint: Vector3;
  128840. pointerId: number;
  128841. }>;
  128842. /**
  128843. * If the attached mesh should be moved when dragged
  128844. */
  128845. moveAttached: boolean;
  128846. /**
  128847. * If the drag behavior will react to drag events (Default: true)
  128848. */
  128849. enabled: boolean;
  128850. /**
  128851. * If pointer events should start and release the drag (Default: true)
  128852. */
  128853. startAndReleaseDragOnPointerEvents: boolean;
  128854. /**
  128855. * If camera controls should be detached during the drag
  128856. */
  128857. detachCameraControls: boolean;
  128858. /**
  128859. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128860. */
  128861. useObjectOrientationForDragging: boolean;
  128862. private _options;
  128863. /**
  128864. * Gets the options used by the behavior
  128865. */
  128866. get options(): {
  128867. dragAxis?: Vector3;
  128868. dragPlaneNormal?: Vector3;
  128869. };
  128870. /**
  128871. * Sets the options used by the behavior
  128872. */
  128873. set options(options: {
  128874. dragAxis?: Vector3;
  128875. dragPlaneNormal?: Vector3;
  128876. });
  128877. /**
  128878. * Creates a pointer drag behavior that can be attached to a mesh
  128879. * @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)
  128880. */
  128881. constructor(options?: {
  128882. dragAxis?: Vector3;
  128883. dragPlaneNormal?: Vector3;
  128884. });
  128885. /**
  128886. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128887. */
  128888. validateDrag: (targetPosition: Vector3) => boolean;
  128889. /**
  128890. * The name of the behavior
  128891. */
  128892. get name(): string;
  128893. /**
  128894. * Initializes the behavior
  128895. */
  128896. init(): void;
  128897. private _tmpVector;
  128898. private _alternatePickedPoint;
  128899. private _worldDragAxis;
  128900. private _targetPosition;
  128901. private _attachedToElement;
  128902. /**
  128903. * Attaches the drag behavior the passed in mesh
  128904. * @param ownerNode The mesh that will be dragged around once attached
  128905. * @param predicate Predicate to use for pick filtering
  128906. */
  128907. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128908. /**
  128909. * Force relase the drag action by code.
  128910. */
  128911. releaseDrag(): void;
  128912. private _startDragRay;
  128913. private _lastPointerRay;
  128914. /**
  128915. * Simulates the start of a pointer drag event on the behavior
  128916. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128917. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128918. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128919. */
  128920. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128921. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128922. private _dragDelta;
  128923. protected _moveDrag(ray: Ray): void;
  128924. private _pickWithRayOnDragPlane;
  128925. private _pointA;
  128926. private _pointC;
  128927. private _localAxis;
  128928. private _lookAt;
  128929. private _updateDragPlanePosition;
  128930. /**
  128931. * Detaches the behavior from the mesh
  128932. */
  128933. detach(): void;
  128934. }
  128935. }
  128936. declare module BABYLON {
  128937. /**
  128938. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128939. */
  128940. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128941. private _dragBehaviorA;
  128942. private _dragBehaviorB;
  128943. private _startDistance;
  128944. private _initialScale;
  128945. private _targetScale;
  128946. private _ownerNode;
  128947. private _sceneRenderObserver;
  128948. /**
  128949. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128950. */
  128951. constructor();
  128952. /**
  128953. * The name of the behavior
  128954. */
  128955. get name(): string;
  128956. /**
  128957. * Initializes the behavior
  128958. */
  128959. init(): void;
  128960. private _getCurrentDistance;
  128961. /**
  128962. * Attaches the scale behavior the passed in mesh
  128963. * @param ownerNode The mesh that will be scaled around once attached
  128964. */
  128965. attach(ownerNode: Mesh): void;
  128966. /**
  128967. * Detaches the behavior from the mesh
  128968. */
  128969. detach(): void;
  128970. }
  128971. }
  128972. declare module BABYLON {
  128973. /**
  128974. * 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
  128975. */
  128976. export class SixDofDragBehavior implements Behavior<Mesh> {
  128977. private static _virtualScene;
  128978. private _ownerNode;
  128979. private _sceneRenderObserver;
  128980. private _scene;
  128981. private _targetPosition;
  128982. private _virtualOriginMesh;
  128983. private _virtualDragMesh;
  128984. private _pointerObserver;
  128985. private _moving;
  128986. private _startingOrientation;
  128987. private _attachedToElement;
  128988. /**
  128989. * 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)
  128990. */
  128991. private zDragFactor;
  128992. /**
  128993. * If the object should rotate to face the drag origin
  128994. */
  128995. rotateDraggedObject: boolean;
  128996. /**
  128997. * If the behavior is currently in a dragging state
  128998. */
  128999. dragging: boolean;
  129000. /**
  129001. * 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)
  129002. */
  129003. dragDeltaRatio: number;
  129004. /**
  129005. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  129006. */
  129007. currentDraggingPointerID: number;
  129008. /**
  129009. * If camera controls should be detached during the drag
  129010. */
  129011. detachCameraControls: boolean;
  129012. /**
  129013. * Fires each time a drag starts
  129014. */
  129015. onDragStartObservable: Observable<{}>;
  129016. /**
  129017. * Fires each time a drag happens
  129018. */
  129019. onDragObservable: Observable<void>;
  129020. /**
  129021. * Fires each time a drag ends (eg. mouse release after drag)
  129022. */
  129023. onDragEndObservable: Observable<{}>;
  129024. /**
  129025. * 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
  129026. */
  129027. constructor();
  129028. /**
  129029. * The name of the behavior
  129030. */
  129031. get name(): string;
  129032. /**
  129033. * Initializes the behavior
  129034. */
  129035. init(): void;
  129036. /**
  129037. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  129038. */
  129039. private get _pointerCamera();
  129040. /**
  129041. * Attaches the scale behavior the passed in mesh
  129042. * @param ownerNode The mesh that will be scaled around once attached
  129043. */
  129044. attach(ownerNode: Mesh): void;
  129045. /**
  129046. * Detaches the behavior from the mesh
  129047. */
  129048. detach(): void;
  129049. }
  129050. }
  129051. declare module BABYLON {
  129052. /**
  129053. * Class used to apply inverse kinematics to bones
  129054. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  129055. */
  129056. export class BoneIKController {
  129057. private static _tmpVecs;
  129058. private static _tmpQuat;
  129059. private static _tmpMats;
  129060. /**
  129061. * Gets or sets the target mesh
  129062. */
  129063. targetMesh: AbstractMesh;
  129064. /** Gets or sets the mesh used as pole */
  129065. poleTargetMesh: AbstractMesh;
  129066. /**
  129067. * Gets or sets the bone used as pole
  129068. */
  129069. poleTargetBone: Nullable<Bone>;
  129070. /**
  129071. * Gets or sets the target position
  129072. */
  129073. targetPosition: Vector3;
  129074. /**
  129075. * Gets or sets the pole target position
  129076. */
  129077. poleTargetPosition: Vector3;
  129078. /**
  129079. * Gets or sets the pole target local offset
  129080. */
  129081. poleTargetLocalOffset: Vector3;
  129082. /**
  129083. * Gets or sets the pole angle
  129084. */
  129085. poleAngle: number;
  129086. /**
  129087. * Gets or sets the mesh associated with the controller
  129088. */
  129089. mesh: AbstractMesh;
  129090. /**
  129091. * 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)
  129092. */
  129093. slerpAmount: number;
  129094. private _bone1Quat;
  129095. private _bone1Mat;
  129096. private _bone2Ang;
  129097. private _bone1;
  129098. private _bone2;
  129099. private _bone1Length;
  129100. private _bone2Length;
  129101. private _maxAngle;
  129102. private _maxReach;
  129103. private _rightHandedSystem;
  129104. private _bendAxis;
  129105. private _slerping;
  129106. private _adjustRoll;
  129107. /**
  129108. * Gets or sets maximum allowed angle
  129109. */
  129110. get maxAngle(): number;
  129111. set maxAngle(value: number);
  129112. /**
  129113. * Creates a new BoneIKController
  129114. * @param mesh defines the mesh to control
  129115. * @param bone defines the bone to control
  129116. * @param options defines options to set up the controller
  129117. */
  129118. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  129119. targetMesh?: AbstractMesh;
  129120. poleTargetMesh?: AbstractMesh;
  129121. poleTargetBone?: Bone;
  129122. poleTargetLocalOffset?: Vector3;
  129123. poleAngle?: number;
  129124. bendAxis?: Vector3;
  129125. maxAngle?: number;
  129126. slerpAmount?: number;
  129127. });
  129128. private _setMaxAngle;
  129129. /**
  129130. * Force the controller to update the bones
  129131. */
  129132. update(): void;
  129133. }
  129134. }
  129135. declare module BABYLON {
  129136. /**
  129137. * Class used to make a bone look toward a point in space
  129138. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  129139. */
  129140. export class BoneLookController {
  129141. private static _tmpVecs;
  129142. private static _tmpQuat;
  129143. private static _tmpMats;
  129144. /**
  129145. * The target Vector3 that the bone will look at
  129146. */
  129147. target: Vector3;
  129148. /**
  129149. * The mesh that the bone is attached to
  129150. */
  129151. mesh: AbstractMesh;
  129152. /**
  129153. * The bone that will be looking to the target
  129154. */
  129155. bone: Bone;
  129156. /**
  129157. * The up axis of the coordinate system that is used when the bone is rotated
  129158. */
  129159. upAxis: Vector3;
  129160. /**
  129161. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  129162. */
  129163. upAxisSpace: Space;
  129164. /**
  129165. * Used to make an adjustment to the yaw of the bone
  129166. */
  129167. adjustYaw: number;
  129168. /**
  129169. * Used to make an adjustment to the pitch of the bone
  129170. */
  129171. adjustPitch: number;
  129172. /**
  129173. * Used to make an adjustment to the roll of the bone
  129174. */
  129175. adjustRoll: number;
  129176. /**
  129177. * 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)
  129178. */
  129179. slerpAmount: number;
  129180. private _minYaw;
  129181. private _maxYaw;
  129182. private _minPitch;
  129183. private _maxPitch;
  129184. private _minYawSin;
  129185. private _minYawCos;
  129186. private _maxYawSin;
  129187. private _maxYawCos;
  129188. private _midYawConstraint;
  129189. private _minPitchTan;
  129190. private _maxPitchTan;
  129191. private _boneQuat;
  129192. private _slerping;
  129193. private _transformYawPitch;
  129194. private _transformYawPitchInv;
  129195. private _firstFrameSkipped;
  129196. private _yawRange;
  129197. private _fowardAxis;
  129198. /**
  129199. * Gets or sets the minimum yaw angle that the bone can look to
  129200. */
  129201. get minYaw(): number;
  129202. set minYaw(value: number);
  129203. /**
  129204. * Gets or sets the maximum yaw angle that the bone can look to
  129205. */
  129206. get maxYaw(): number;
  129207. set maxYaw(value: number);
  129208. /**
  129209. * Gets or sets the minimum pitch angle that the bone can look to
  129210. */
  129211. get minPitch(): number;
  129212. set minPitch(value: number);
  129213. /**
  129214. * Gets or sets the maximum pitch angle that the bone can look to
  129215. */
  129216. get maxPitch(): number;
  129217. set maxPitch(value: number);
  129218. /**
  129219. * Create a BoneLookController
  129220. * @param mesh the mesh that the bone belongs to
  129221. * @param bone the bone that will be looking to the target
  129222. * @param target the target Vector3 to look at
  129223. * @param options optional settings:
  129224. * * maxYaw: the maximum angle the bone will yaw to
  129225. * * minYaw: the minimum angle the bone will yaw to
  129226. * * maxPitch: the maximum angle the bone will pitch to
  129227. * * minPitch: the minimum angle the bone will yaw to
  129228. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  129229. * * upAxis: the up axis of the coordinate system
  129230. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  129231. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  129232. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  129233. * * adjustYaw: used to make an adjustment to the yaw of the bone
  129234. * * adjustPitch: used to make an adjustment to the pitch of the bone
  129235. * * adjustRoll: used to make an adjustment to the roll of the bone
  129236. **/
  129237. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  129238. maxYaw?: number;
  129239. minYaw?: number;
  129240. maxPitch?: number;
  129241. minPitch?: number;
  129242. slerpAmount?: number;
  129243. upAxis?: Vector3;
  129244. upAxisSpace?: Space;
  129245. yawAxis?: Vector3;
  129246. pitchAxis?: Vector3;
  129247. adjustYaw?: number;
  129248. adjustPitch?: number;
  129249. adjustRoll?: number;
  129250. });
  129251. /**
  129252. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  129253. */
  129254. update(): void;
  129255. private _getAngleDiff;
  129256. private _getAngleBetween;
  129257. private _isAngleBetween;
  129258. }
  129259. }
  129260. declare module BABYLON {
  129261. /**
  129262. * Manage the gamepad inputs to control an arc rotate camera.
  129263. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129264. */
  129265. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  129266. /**
  129267. * Defines the camera the input is attached to.
  129268. */
  129269. camera: ArcRotateCamera;
  129270. /**
  129271. * Defines the gamepad the input is gathering event from.
  129272. */
  129273. gamepad: Nullable<Gamepad>;
  129274. /**
  129275. * Defines the gamepad rotation sensiblity.
  129276. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129277. */
  129278. gamepadRotationSensibility: number;
  129279. /**
  129280. * Defines the gamepad move sensiblity.
  129281. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129282. */
  129283. gamepadMoveSensibility: number;
  129284. private _yAxisScale;
  129285. /**
  129286. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129287. */
  129288. get invertYAxis(): boolean;
  129289. set invertYAxis(value: boolean);
  129290. private _onGamepadConnectedObserver;
  129291. private _onGamepadDisconnectedObserver;
  129292. /**
  129293. * Attach the input controls to a specific dom element to get the input from.
  129294. */
  129295. attachControl(): void;
  129296. /**
  129297. * Detach the current controls from the specified dom element.
  129298. */
  129299. detachControl(): void;
  129300. /**
  129301. * Update the current camera state depending on the inputs that have been used this frame.
  129302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129303. */
  129304. checkInputs(): void;
  129305. /**
  129306. * Gets the class name of the current intput.
  129307. * @returns the class name
  129308. */
  129309. getClassName(): string;
  129310. /**
  129311. * Get the friendly name associated with the input class.
  129312. * @returns the input friendly name
  129313. */
  129314. getSimpleName(): string;
  129315. }
  129316. }
  129317. declare module BABYLON {
  129318. interface ArcRotateCameraInputsManager {
  129319. /**
  129320. * Add orientation input support to the input manager.
  129321. * @returns the current input manager
  129322. */
  129323. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  129324. }
  129325. /**
  129326. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  129327. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129328. */
  129329. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  129330. /**
  129331. * Defines the camera the input is attached to.
  129332. */
  129333. camera: ArcRotateCamera;
  129334. /**
  129335. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  129336. */
  129337. alphaCorrection: number;
  129338. /**
  129339. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  129340. */
  129341. gammaCorrection: number;
  129342. private _alpha;
  129343. private _gamma;
  129344. private _dirty;
  129345. private _deviceOrientationHandler;
  129346. /**
  129347. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  129348. */
  129349. constructor();
  129350. /**
  129351. * Attach the input controls to a specific dom element to get the input from.
  129352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129353. */
  129354. attachControl(noPreventDefault?: boolean): void;
  129355. /** @hidden */
  129356. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  129357. /**
  129358. * Update the current camera state depending on the inputs that have been used this frame.
  129359. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129360. */
  129361. checkInputs(): void;
  129362. /**
  129363. * Detach the current controls from the specified dom element.
  129364. */
  129365. detachControl(): void;
  129366. /**
  129367. * Gets the class name of the current intput.
  129368. * @returns the class name
  129369. */
  129370. getClassName(): string;
  129371. /**
  129372. * Get the friendly name associated with the input class.
  129373. * @returns the input friendly name
  129374. */
  129375. getSimpleName(): string;
  129376. }
  129377. }
  129378. declare module BABYLON {
  129379. /**
  129380. * Listen to mouse events to control the camera.
  129381. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129382. */
  129383. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  129384. /**
  129385. * Defines the camera the input is attached to.
  129386. */
  129387. camera: FlyCamera;
  129388. /**
  129389. * Defines if touch is enabled. (Default is true.)
  129390. */
  129391. touchEnabled: boolean;
  129392. /**
  129393. * Defines the buttons associated with the input to handle camera rotation.
  129394. */
  129395. buttons: number[];
  129396. /**
  129397. * Assign buttons for Yaw control.
  129398. */
  129399. buttonsYaw: number[];
  129400. /**
  129401. * Assign buttons for Pitch control.
  129402. */
  129403. buttonsPitch: number[];
  129404. /**
  129405. * Assign buttons for Roll control.
  129406. */
  129407. buttonsRoll: number[];
  129408. /**
  129409. * Detect if any button is being pressed while mouse is moved.
  129410. * -1 = Mouse locked.
  129411. * 0 = Left button.
  129412. * 1 = Middle Button.
  129413. * 2 = Right Button.
  129414. */
  129415. activeButton: number;
  129416. /**
  129417. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  129418. * Higher values reduce its sensitivity.
  129419. */
  129420. angularSensibility: number;
  129421. private _observer;
  129422. private _rollObserver;
  129423. private previousPosition;
  129424. private noPreventDefault;
  129425. private element;
  129426. /**
  129427. * Listen to mouse events to control the camera.
  129428. * @param touchEnabled Define if touch is enabled. (Default is true.)
  129429. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129430. */
  129431. constructor(touchEnabled?: boolean);
  129432. /**
  129433. * Attach the mouse control to the HTML DOM element.
  129434. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  129435. */
  129436. attachControl(noPreventDefault?: boolean): void;
  129437. /**
  129438. * Detach the current controls from the specified dom element.
  129439. */
  129440. detachControl(): void;
  129441. /**
  129442. * Gets the class name of the current input.
  129443. * @returns the class name.
  129444. */
  129445. getClassName(): string;
  129446. /**
  129447. * Get the friendly name associated with the input class.
  129448. * @returns the input's friendly name.
  129449. */
  129450. getSimpleName(): string;
  129451. private _pointerInput;
  129452. private _onMouseMove;
  129453. /**
  129454. * Rotate camera by mouse offset.
  129455. */
  129456. private rotateCamera;
  129457. }
  129458. }
  129459. declare module BABYLON {
  129460. /**
  129461. * Default Inputs manager for the FlyCamera.
  129462. * It groups all the default supported inputs for ease of use.
  129463. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129464. */
  129465. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  129466. /**
  129467. * Instantiates a new FlyCameraInputsManager.
  129468. * @param camera Defines the camera the inputs belong to.
  129469. */
  129470. constructor(camera: FlyCamera);
  129471. /**
  129472. * Add keyboard input support to the input manager.
  129473. * @returns the new FlyCameraKeyboardMoveInput().
  129474. */
  129475. addKeyboard(): FlyCameraInputsManager;
  129476. /**
  129477. * Add mouse input support to the input manager.
  129478. * @param touchEnabled Enable touch screen support.
  129479. * @returns the new FlyCameraMouseInput().
  129480. */
  129481. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  129482. }
  129483. }
  129484. declare module BABYLON {
  129485. /**
  129486. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129487. * such as in a 3D Space Shooter or a Flight Simulator.
  129488. */
  129489. export class FlyCamera extends TargetCamera {
  129490. /**
  129491. * Define the collision ellipsoid of the camera.
  129492. * This is helpful for simulating a camera body, like a player's body.
  129493. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  129494. */
  129495. ellipsoid: Vector3;
  129496. /**
  129497. * Define an offset for the position of the ellipsoid around the camera.
  129498. * This can be helpful if the camera is attached away from the player's body center,
  129499. * such as at its head.
  129500. */
  129501. ellipsoidOffset: Vector3;
  129502. /**
  129503. * Enable or disable collisions of the camera with the rest of the scene objects.
  129504. */
  129505. checkCollisions: boolean;
  129506. /**
  129507. * Enable or disable gravity on the camera.
  129508. */
  129509. applyGravity: boolean;
  129510. /**
  129511. * Define the current direction the camera is moving to.
  129512. */
  129513. cameraDirection: Vector3;
  129514. /**
  129515. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  129516. * This overrides and empties cameraRotation.
  129517. */
  129518. rotationQuaternion: Quaternion;
  129519. /**
  129520. * Track Roll to maintain the wanted Rolling when looking around.
  129521. */
  129522. _trackRoll: number;
  129523. /**
  129524. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  129525. */
  129526. rollCorrect: number;
  129527. /**
  129528. * Mimic a banked turn, Rolling the camera when Yawing.
  129529. * It's recommended to use rollCorrect = 10 for faster banking correction.
  129530. */
  129531. bankedTurn: boolean;
  129532. /**
  129533. * Limit in radians for how much Roll banking will add. (Default: 90°)
  129534. */
  129535. bankedTurnLimit: number;
  129536. /**
  129537. * Value of 0 disables the banked Roll.
  129538. * Value of 1 is equal to the Yaw angle in radians.
  129539. */
  129540. bankedTurnMultiplier: number;
  129541. /**
  129542. * The inputs manager loads all the input sources, such as keyboard and mouse.
  129543. */
  129544. inputs: FlyCameraInputsManager;
  129545. /**
  129546. * Gets the input sensibility for mouse input.
  129547. * Higher values reduce sensitivity.
  129548. */
  129549. get angularSensibility(): number;
  129550. /**
  129551. * Sets the input sensibility for a mouse input.
  129552. * Higher values reduce sensitivity.
  129553. */
  129554. set angularSensibility(value: number);
  129555. /**
  129556. * Get the keys for camera movement forward.
  129557. */
  129558. get keysForward(): number[];
  129559. /**
  129560. * Set the keys for camera movement forward.
  129561. */
  129562. set keysForward(value: number[]);
  129563. /**
  129564. * Get the keys for camera movement backward.
  129565. */
  129566. get keysBackward(): number[];
  129567. set keysBackward(value: number[]);
  129568. /**
  129569. * Get the keys for camera movement up.
  129570. */
  129571. get keysUp(): number[];
  129572. /**
  129573. * Set the keys for camera movement up.
  129574. */
  129575. set keysUp(value: number[]);
  129576. /**
  129577. * Get the keys for camera movement down.
  129578. */
  129579. get keysDown(): number[];
  129580. /**
  129581. * Set the keys for camera movement down.
  129582. */
  129583. set keysDown(value: number[]);
  129584. /**
  129585. * Get the keys for camera movement left.
  129586. */
  129587. get keysLeft(): number[];
  129588. /**
  129589. * Set the keys for camera movement left.
  129590. */
  129591. set keysLeft(value: number[]);
  129592. /**
  129593. * Set the keys for camera movement right.
  129594. */
  129595. get keysRight(): number[];
  129596. /**
  129597. * Set the keys for camera movement right.
  129598. */
  129599. set keysRight(value: number[]);
  129600. /**
  129601. * Event raised when the camera collides with a mesh in the scene.
  129602. */
  129603. onCollide: (collidedMesh: AbstractMesh) => void;
  129604. private _collider;
  129605. private _needMoveForGravity;
  129606. private _oldPosition;
  129607. private _diffPosition;
  129608. private _newPosition;
  129609. /** @hidden */
  129610. _localDirection: Vector3;
  129611. /** @hidden */
  129612. _transformedDirection: Vector3;
  129613. /**
  129614. * Instantiates a FlyCamera.
  129615. * This is a flying camera, designed for 3D movement and rotation in all directions,
  129616. * such as in a 3D Space Shooter or a Flight Simulator.
  129617. * @param name Define the name of the camera in the scene.
  129618. * @param position Define the starting position of the camera in the scene.
  129619. * @param scene Define the scene the camera belongs to.
  129620. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  129621. */
  129622. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  129623. /**
  129624. * Attach the input controls to a specific dom element to get the input from.
  129625. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129626. */
  129627. attachControl(noPreventDefault?: boolean): void;
  129628. /**
  129629. * Detach a control from the HTML DOM element.
  129630. * The camera will stop reacting to that input.
  129631. */
  129632. detachControl(): void;
  129633. private _collisionMask;
  129634. /**
  129635. * Get the mask that the camera ignores in collision events.
  129636. */
  129637. get collisionMask(): number;
  129638. /**
  129639. * Set the mask that the camera ignores in collision events.
  129640. */
  129641. set collisionMask(mask: number);
  129642. /** @hidden */
  129643. _collideWithWorld(displacement: Vector3): void;
  129644. /** @hidden */
  129645. private _onCollisionPositionChange;
  129646. /** @hidden */
  129647. _checkInputs(): void;
  129648. /** @hidden */
  129649. _decideIfNeedsToMove(): boolean;
  129650. /** @hidden */
  129651. _updatePosition(): void;
  129652. /**
  129653. * Restore the Roll to its target value at the rate specified.
  129654. * @param rate - Higher means slower restoring.
  129655. * @hidden
  129656. */
  129657. restoreRoll(rate: number): void;
  129658. /**
  129659. * Destroy the camera and release the current resources held by it.
  129660. */
  129661. dispose(): void;
  129662. /**
  129663. * Get the current object class name.
  129664. * @returns the class name.
  129665. */
  129666. getClassName(): string;
  129667. }
  129668. }
  129669. declare module BABYLON {
  129670. /**
  129671. * Listen to keyboard events to control the camera.
  129672. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129673. */
  129674. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  129675. /**
  129676. * Defines the camera the input is attached to.
  129677. */
  129678. camera: FlyCamera;
  129679. /**
  129680. * The list of keyboard keys used to control the forward move of the camera.
  129681. */
  129682. keysForward: number[];
  129683. /**
  129684. * The list of keyboard keys used to control the backward move of the camera.
  129685. */
  129686. keysBackward: number[];
  129687. /**
  129688. * The list of keyboard keys used to control the forward move of the camera.
  129689. */
  129690. keysUp: number[];
  129691. /**
  129692. * The list of keyboard keys used to control the backward move of the camera.
  129693. */
  129694. keysDown: number[];
  129695. /**
  129696. * The list of keyboard keys used to control the right strafe move of the camera.
  129697. */
  129698. keysRight: number[];
  129699. /**
  129700. * The list of keyboard keys used to control the left strafe move of the camera.
  129701. */
  129702. keysLeft: number[];
  129703. private _keys;
  129704. private _onCanvasBlurObserver;
  129705. private _onKeyboardObserver;
  129706. private _engine;
  129707. private _scene;
  129708. /**
  129709. * Attach the input controls to a specific dom element to get the input from.
  129710. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129711. */
  129712. attachControl(noPreventDefault?: boolean): void;
  129713. /**
  129714. * Detach the current controls from the specified dom element.
  129715. */
  129716. detachControl(): void;
  129717. /**
  129718. * Gets the class name of the current intput.
  129719. * @returns the class name
  129720. */
  129721. getClassName(): string;
  129722. /** @hidden */
  129723. _onLostFocus(e: FocusEvent): void;
  129724. /**
  129725. * Get the friendly name associated with the input class.
  129726. * @returns the input friendly name
  129727. */
  129728. getSimpleName(): string;
  129729. /**
  129730. * Update the current camera state depending on the inputs that have been used this frame.
  129731. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129732. */
  129733. checkInputs(): void;
  129734. }
  129735. }
  129736. declare module BABYLON {
  129737. /**
  129738. * Manage the mouse wheel inputs to control a follow camera.
  129739. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129740. */
  129741. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  129742. /**
  129743. * Defines the camera the input is attached to.
  129744. */
  129745. camera: FollowCamera;
  129746. /**
  129747. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  129748. */
  129749. axisControlRadius: boolean;
  129750. /**
  129751. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  129752. */
  129753. axisControlHeight: boolean;
  129754. /**
  129755. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  129756. */
  129757. axisControlRotation: boolean;
  129758. /**
  129759. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  129760. * relation to mouseWheel events.
  129761. */
  129762. wheelPrecision: number;
  129763. /**
  129764. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  129765. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  129766. */
  129767. wheelDeltaPercentage: number;
  129768. private _wheel;
  129769. private _observer;
  129770. /**
  129771. * Attach the input controls to a specific dom element to get the input from.
  129772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129773. */
  129774. attachControl(noPreventDefault?: boolean): void;
  129775. /**
  129776. * Detach the current controls from the specified dom element.
  129777. */
  129778. detachControl(): void;
  129779. /**
  129780. * Gets the class name of the current intput.
  129781. * @returns the class name
  129782. */
  129783. getClassName(): string;
  129784. /**
  129785. * Get the friendly name associated with the input class.
  129786. * @returns the input friendly name
  129787. */
  129788. getSimpleName(): string;
  129789. }
  129790. }
  129791. declare module BABYLON {
  129792. /**
  129793. * Manage the pointers inputs to control an follow camera.
  129794. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129795. */
  129796. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  129797. /**
  129798. * Defines the camera the input is attached to.
  129799. */
  129800. camera: FollowCamera;
  129801. /**
  129802. * Gets the class name of the current input.
  129803. * @returns the class name
  129804. */
  129805. getClassName(): string;
  129806. /**
  129807. * Defines the pointer angular sensibility along the X axis or how fast is
  129808. * the camera rotating.
  129809. * A negative number will reverse the axis direction.
  129810. */
  129811. angularSensibilityX: number;
  129812. /**
  129813. * Defines the pointer angular sensibility along the Y axis or how fast is
  129814. * the camera rotating.
  129815. * A negative number will reverse the axis direction.
  129816. */
  129817. angularSensibilityY: number;
  129818. /**
  129819. * Defines the pointer pinch precision or how fast is the camera zooming.
  129820. * A negative number will reverse the axis direction.
  129821. */
  129822. pinchPrecision: number;
  129823. /**
  129824. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129825. * from 0.
  129826. * It defines the percentage of current camera.radius to use as delta when
  129827. * pinch zoom is used.
  129828. */
  129829. pinchDeltaPercentage: number;
  129830. /**
  129831. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129832. */
  129833. axisXControlRadius: boolean;
  129834. /**
  129835. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129836. */
  129837. axisXControlHeight: boolean;
  129838. /**
  129839. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129840. */
  129841. axisXControlRotation: boolean;
  129842. /**
  129843. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129844. */
  129845. axisYControlRadius: boolean;
  129846. /**
  129847. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129848. */
  129849. axisYControlHeight: boolean;
  129850. /**
  129851. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129852. */
  129853. axisYControlRotation: boolean;
  129854. /**
  129855. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129856. */
  129857. axisPinchControlRadius: boolean;
  129858. /**
  129859. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129860. */
  129861. axisPinchControlHeight: boolean;
  129862. /**
  129863. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129864. */
  129865. axisPinchControlRotation: boolean;
  129866. /**
  129867. * Log error messages if basic misconfiguration has occurred.
  129868. */
  129869. warningEnable: boolean;
  129870. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129871. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129872. private _warningCounter;
  129873. private _warning;
  129874. }
  129875. }
  129876. declare module BABYLON {
  129877. /**
  129878. * Default Inputs manager for the FollowCamera.
  129879. * It groups all the default supported inputs for ease of use.
  129880. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129881. */
  129882. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129883. /**
  129884. * Instantiates a new FollowCameraInputsManager.
  129885. * @param camera Defines the camera the inputs belong to
  129886. */
  129887. constructor(camera: FollowCamera);
  129888. /**
  129889. * Add keyboard input support to the input manager.
  129890. * @returns the current input manager
  129891. */
  129892. addKeyboard(): FollowCameraInputsManager;
  129893. /**
  129894. * Add mouse wheel input support to the input manager.
  129895. * @returns the current input manager
  129896. */
  129897. addMouseWheel(): FollowCameraInputsManager;
  129898. /**
  129899. * Add pointers input support to the input manager.
  129900. * @returns the current input manager
  129901. */
  129902. addPointers(): FollowCameraInputsManager;
  129903. /**
  129904. * Add orientation input support to the input manager.
  129905. * @returns the current input manager
  129906. */
  129907. addVRDeviceOrientation(): FollowCameraInputsManager;
  129908. }
  129909. }
  129910. declare module BABYLON {
  129911. /**
  129912. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129913. * an arc rotate version arcFollowCamera are available.
  129914. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129915. */
  129916. export class FollowCamera extends TargetCamera {
  129917. /**
  129918. * Distance the follow camera should follow an object at
  129919. */
  129920. radius: number;
  129921. /**
  129922. * Minimum allowed distance of the camera to the axis of rotation
  129923. * (The camera can not get closer).
  129924. * This can help limiting how the Camera is able to move in the scene.
  129925. */
  129926. lowerRadiusLimit: Nullable<number>;
  129927. /**
  129928. * Maximum allowed distance of the camera to the axis of rotation
  129929. * (The camera can not get further).
  129930. * This can help limiting how the Camera is able to move in the scene.
  129931. */
  129932. upperRadiusLimit: Nullable<number>;
  129933. /**
  129934. * Define a rotation offset between the camera and the object it follows
  129935. */
  129936. rotationOffset: number;
  129937. /**
  129938. * Minimum allowed angle to camera position relative to target object.
  129939. * This can help limiting how the Camera is able to move in the scene.
  129940. */
  129941. lowerRotationOffsetLimit: Nullable<number>;
  129942. /**
  129943. * Maximum allowed angle to camera position relative to target object.
  129944. * This can help limiting how the Camera is able to move in the scene.
  129945. */
  129946. upperRotationOffsetLimit: Nullable<number>;
  129947. /**
  129948. * Define a height offset between the camera and the object it follows.
  129949. * It can help following an object from the top (like a car chaing a plane)
  129950. */
  129951. heightOffset: number;
  129952. /**
  129953. * Minimum allowed height of camera position relative to target object.
  129954. * This can help limiting how the Camera is able to move in the scene.
  129955. */
  129956. lowerHeightOffsetLimit: Nullable<number>;
  129957. /**
  129958. * Maximum allowed height of camera position relative to target object.
  129959. * This can help limiting how the Camera is able to move in the scene.
  129960. */
  129961. upperHeightOffsetLimit: Nullable<number>;
  129962. /**
  129963. * Define how fast the camera can accelerate to follow it s target.
  129964. */
  129965. cameraAcceleration: number;
  129966. /**
  129967. * Define the speed limit of the camera following an object.
  129968. */
  129969. maxCameraSpeed: number;
  129970. /**
  129971. * Define the target of the camera.
  129972. */
  129973. lockedTarget: Nullable<AbstractMesh>;
  129974. /**
  129975. * Defines the input associated with the camera.
  129976. */
  129977. inputs: FollowCameraInputsManager;
  129978. /**
  129979. * Instantiates the follow camera.
  129980. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129981. * @param name Define the name of the camera in the scene
  129982. * @param position Define the position of the camera
  129983. * @param scene Define the scene the camera belong to
  129984. * @param lockedTarget Define the target of the camera
  129985. */
  129986. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129987. private _follow;
  129988. /**
  129989. * Attach the input controls to a specific dom element to get the input from.
  129990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129991. */
  129992. attachControl(noPreventDefault?: boolean): void;
  129993. /**
  129994. * Detach the current controls from the specified dom element.
  129995. */
  129996. detachControl(): void;
  129997. /** @hidden */
  129998. _checkInputs(): void;
  129999. private _checkLimits;
  130000. /**
  130001. * Gets the camera class name.
  130002. * @returns the class name
  130003. */
  130004. getClassName(): string;
  130005. }
  130006. /**
  130007. * Arc Rotate version of the follow camera.
  130008. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  130009. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130010. */
  130011. export class ArcFollowCamera extends TargetCamera {
  130012. /** The longitudinal angle of the camera */
  130013. alpha: number;
  130014. /** The latitudinal angle of the camera */
  130015. beta: number;
  130016. /** The radius of the camera from its target */
  130017. radius: number;
  130018. private _cartesianCoordinates;
  130019. /** Define the camera target (the mesh it should follow) */
  130020. private _meshTarget;
  130021. /**
  130022. * Instantiates a new ArcFollowCamera
  130023. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  130024. * @param name Define the name of the camera
  130025. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  130026. * @param beta Define the rotation angle of the camera around the elevation axis
  130027. * @param radius Define the radius of the camera from its target point
  130028. * @param target Define the target of the camera
  130029. * @param scene Define the scene the camera belongs to
  130030. */
  130031. constructor(name: string,
  130032. /** The longitudinal angle of the camera */
  130033. alpha: number,
  130034. /** The latitudinal angle of the camera */
  130035. beta: number,
  130036. /** The radius of the camera from its target */
  130037. radius: number,
  130038. /** Define the camera target (the mesh it should follow) */
  130039. target: Nullable<AbstractMesh>, scene: Scene);
  130040. private _follow;
  130041. /** @hidden */
  130042. _checkInputs(): void;
  130043. /**
  130044. * Returns the class name of the object.
  130045. * It is mostly used internally for serialization purposes.
  130046. */
  130047. getClassName(): string;
  130048. }
  130049. }
  130050. declare module BABYLON {
  130051. /**
  130052. * Manage the keyboard inputs to control the movement of a follow camera.
  130053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130054. */
  130055. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  130056. /**
  130057. * Defines the camera the input is attached to.
  130058. */
  130059. camera: FollowCamera;
  130060. /**
  130061. * Defines the list of key codes associated with the up action (increase heightOffset)
  130062. */
  130063. keysHeightOffsetIncr: number[];
  130064. /**
  130065. * Defines the list of key codes associated with the down action (decrease heightOffset)
  130066. */
  130067. keysHeightOffsetDecr: number[];
  130068. /**
  130069. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  130070. */
  130071. keysHeightOffsetModifierAlt: boolean;
  130072. /**
  130073. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  130074. */
  130075. keysHeightOffsetModifierCtrl: boolean;
  130076. /**
  130077. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  130078. */
  130079. keysHeightOffsetModifierShift: boolean;
  130080. /**
  130081. * Defines the list of key codes associated with the left action (increase rotationOffset)
  130082. */
  130083. keysRotationOffsetIncr: number[];
  130084. /**
  130085. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  130086. */
  130087. keysRotationOffsetDecr: number[];
  130088. /**
  130089. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  130090. */
  130091. keysRotationOffsetModifierAlt: boolean;
  130092. /**
  130093. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  130094. */
  130095. keysRotationOffsetModifierCtrl: boolean;
  130096. /**
  130097. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  130098. */
  130099. keysRotationOffsetModifierShift: boolean;
  130100. /**
  130101. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  130102. */
  130103. keysRadiusIncr: number[];
  130104. /**
  130105. * Defines the list of key codes associated with the zoom-out action (increase radius)
  130106. */
  130107. keysRadiusDecr: number[];
  130108. /**
  130109. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  130110. */
  130111. keysRadiusModifierAlt: boolean;
  130112. /**
  130113. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  130114. */
  130115. keysRadiusModifierCtrl: boolean;
  130116. /**
  130117. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  130118. */
  130119. keysRadiusModifierShift: boolean;
  130120. /**
  130121. * Defines the rate of change of heightOffset.
  130122. */
  130123. heightSensibility: number;
  130124. /**
  130125. * Defines the rate of change of rotationOffset.
  130126. */
  130127. rotationSensibility: number;
  130128. /**
  130129. * Defines the rate of change of radius.
  130130. */
  130131. radiusSensibility: number;
  130132. private _keys;
  130133. private _ctrlPressed;
  130134. private _altPressed;
  130135. private _shiftPressed;
  130136. private _onCanvasBlurObserver;
  130137. private _onKeyboardObserver;
  130138. private _engine;
  130139. private _scene;
  130140. /**
  130141. * Attach the input controls to a specific dom element to get the input from.
  130142. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  130143. */
  130144. attachControl(noPreventDefault?: boolean): void;
  130145. /**
  130146. * Detach the current controls from the specified dom element.
  130147. */
  130148. detachControl(): void;
  130149. /**
  130150. * Update the current camera state depending on the inputs that have been used this frame.
  130151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130152. */
  130153. checkInputs(): void;
  130154. /**
  130155. * Gets the class name of the current input.
  130156. * @returns the class name
  130157. */
  130158. getClassName(): string;
  130159. /**
  130160. * Get the friendly name associated with the input class.
  130161. * @returns the input friendly name
  130162. */
  130163. getSimpleName(): string;
  130164. /**
  130165. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130166. * allow modification of the heightOffset value.
  130167. */
  130168. private _modifierHeightOffset;
  130169. /**
  130170. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130171. * allow modification of the rotationOffset value.
  130172. */
  130173. private _modifierRotationOffset;
  130174. /**
  130175. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  130176. * allow modification of the radius value.
  130177. */
  130178. private _modifierRadius;
  130179. }
  130180. }
  130181. declare module BABYLON {
  130182. interface FreeCameraInputsManager {
  130183. /**
  130184. * @hidden
  130185. */
  130186. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  130187. /**
  130188. * Add orientation input support to the input manager.
  130189. * @returns the current input manager
  130190. */
  130191. addDeviceOrientation(): FreeCameraInputsManager;
  130192. }
  130193. /**
  130194. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  130195. * Screen rotation is taken into account.
  130196. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130197. */
  130198. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  130199. private _camera;
  130200. private _screenOrientationAngle;
  130201. private _constantTranform;
  130202. private _screenQuaternion;
  130203. private _alpha;
  130204. private _beta;
  130205. private _gamma;
  130206. /**
  130207. * Can be used to detect if a device orientation sensor is available on a device
  130208. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  130209. * @returns a promise that will resolve on orientation change
  130210. */
  130211. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  130212. /**
  130213. * @hidden
  130214. */
  130215. _onDeviceOrientationChangedObservable: Observable<void>;
  130216. /**
  130217. * Instantiates a new input
  130218. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130219. */
  130220. constructor();
  130221. /**
  130222. * Define the camera controlled by the input.
  130223. */
  130224. get camera(): FreeCamera;
  130225. set camera(camera: FreeCamera);
  130226. /**
  130227. * Attach the input controls to a specific dom element to get the input from.
  130228. */
  130229. attachControl(): void;
  130230. private _orientationChanged;
  130231. private _deviceOrientation;
  130232. /**
  130233. * Detach the current controls from the specified dom element.
  130234. */
  130235. detachControl(): void;
  130236. /**
  130237. * Update the current camera state depending on the inputs that have been used this frame.
  130238. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130239. */
  130240. checkInputs(): void;
  130241. /**
  130242. * Gets the class name of the current intput.
  130243. * @returns the class name
  130244. */
  130245. getClassName(): string;
  130246. /**
  130247. * Get the friendly name associated with the input class.
  130248. * @returns the input friendly name
  130249. */
  130250. getSimpleName(): string;
  130251. }
  130252. }
  130253. declare module BABYLON {
  130254. /**
  130255. * Manage the gamepad inputs to control a free camera.
  130256. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130257. */
  130258. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  130259. /**
  130260. * Define the camera the input is attached to.
  130261. */
  130262. camera: FreeCamera;
  130263. /**
  130264. * Define the Gamepad controlling the input
  130265. */
  130266. gamepad: Nullable<Gamepad>;
  130267. /**
  130268. * Defines the gamepad rotation sensiblity.
  130269. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130270. */
  130271. gamepadAngularSensibility: number;
  130272. /**
  130273. * Defines the gamepad move sensiblity.
  130274. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130275. */
  130276. gamepadMoveSensibility: number;
  130277. private _yAxisScale;
  130278. /**
  130279. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  130280. */
  130281. get invertYAxis(): boolean;
  130282. set invertYAxis(value: boolean);
  130283. private _onGamepadConnectedObserver;
  130284. private _onGamepadDisconnectedObserver;
  130285. private _cameraTransform;
  130286. private _deltaTransform;
  130287. private _vector3;
  130288. private _vector2;
  130289. /**
  130290. * Attach the input controls to a specific dom element to get the input from.
  130291. */
  130292. attachControl(): void;
  130293. /**
  130294. * Detach the current controls from the specified dom element.
  130295. */
  130296. detachControl(): void;
  130297. /**
  130298. * Update the current camera state depending on the inputs that have been used this frame.
  130299. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130300. */
  130301. checkInputs(): void;
  130302. /**
  130303. * Gets the class name of the current intput.
  130304. * @returns the class name
  130305. */
  130306. getClassName(): string;
  130307. /**
  130308. * Get the friendly name associated with the input class.
  130309. * @returns the input friendly name
  130310. */
  130311. getSimpleName(): string;
  130312. }
  130313. }
  130314. declare module BABYLON {
  130315. /**
  130316. * Defines the potential axis of a Joystick
  130317. */
  130318. export enum JoystickAxis {
  130319. /** X axis */
  130320. X = 0,
  130321. /** Y axis */
  130322. Y = 1,
  130323. /** Z axis */
  130324. Z = 2
  130325. }
  130326. /**
  130327. * Represents the different customization options available
  130328. * for VirtualJoystick
  130329. */
  130330. interface VirtualJoystickCustomizations {
  130331. /**
  130332. * Size of the joystick's puck
  130333. */
  130334. puckSize: number;
  130335. /**
  130336. * Size of the joystick's container
  130337. */
  130338. containerSize: number;
  130339. /**
  130340. * Color of the joystick && puck
  130341. */
  130342. color: string;
  130343. /**
  130344. * Image URL for the joystick's puck
  130345. */
  130346. puckImage?: string;
  130347. /**
  130348. * Image URL for the joystick's container
  130349. */
  130350. containerImage?: string;
  130351. /**
  130352. * Defines the unmoving position of the joystick container
  130353. */
  130354. position?: {
  130355. x: number;
  130356. y: number;
  130357. };
  130358. /**
  130359. * Defines whether or not the joystick container is always visible
  130360. */
  130361. alwaysVisible: boolean;
  130362. /**
  130363. * Defines whether or not to limit the movement of the puck to the joystick's container
  130364. */
  130365. limitToContainer: boolean;
  130366. }
  130367. /**
  130368. * Class used to define virtual joystick (used in touch mode)
  130369. */
  130370. export class VirtualJoystick {
  130371. /**
  130372. * Gets or sets a boolean indicating that left and right values must be inverted
  130373. */
  130374. reverseLeftRight: boolean;
  130375. /**
  130376. * Gets or sets a boolean indicating that up and down values must be inverted
  130377. */
  130378. reverseUpDown: boolean;
  130379. /**
  130380. * Gets the offset value for the position (ie. the change of the position value)
  130381. */
  130382. deltaPosition: Vector3;
  130383. /**
  130384. * Gets a boolean indicating if the virtual joystick was pressed
  130385. */
  130386. pressed: boolean;
  130387. /**
  130388. * Canvas the virtual joystick will render onto, default z-index of this is 5
  130389. */
  130390. static Canvas: Nullable<HTMLCanvasElement>;
  130391. /**
  130392. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  130393. */
  130394. limitToContainer: boolean;
  130395. private static _globalJoystickIndex;
  130396. private static _alwaysVisibleSticks;
  130397. private static vjCanvasContext;
  130398. private static vjCanvasWidth;
  130399. private static vjCanvasHeight;
  130400. private static halfWidth;
  130401. private static _GetDefaultOptions;
  130402. private _action;
  130403. private _axisTargetedByLeftAndRight;
  130404. private _axisTargetedByUpAndDown;
  130405. private _joystickSensibility;
  130406. private _inversedSensibility;
  130407. private _joystickPointerID;
  130408. private _joystickColor;
  130409. private _joystickPointerPos;
  130410. private _joystickPreviousPointerPos;
  130411. private _joystickPointerStartPos;
  130412. private _deltaJoystickVector;
  130413. private _leftJoystick;
  130414. private _touches;
  130415. private _joystickPosition;
  130416. private _alwaysVisible;
  130417. private _puckImage;
  130418. private _containerImage;
  130419. private _joystickPuckSize;
  130420. private _joystickContainerSize;
  130421. private _clearPuckSize;
  130422. private _clearContainerSize;
  130423. private _clearPuckSizeOffset;
  130424. private _clearContainerSizeOffset;
  130425. private _onPointerDownHandlerRef;
  130426. private _onPointerMoveHandlerRef;
  130427. private _onPointerUpHandlerRef;
  130428. private _onResize;
  130429. /**
  130430. * Creates a new virtual joystick
  130431. * @param leftJoystick defines that the joystick is for left hand (false by default)
  130432. * @param customizations Defines the options we want to customize the VirtualJoystick
  130433. */
  130434. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  130435. /**
  130436. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  130437. * @param newJoystickSensibility defines the new sensibility
  130438. */
  130439. setJoystickSensibility(newJoystickSensibility: number): void;
  130440. private _onPointerDown;
  130441. private _onPointerMove;
  130442. private _onPointerUp;
  130443. /**
  130444. * Change the color of the virtual joystick
  130445. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  130446. */
  130447. setJoystickColor(newColor: string): void;
  130448. /**
  130449. * Size of the joystick's container
  130450. */
  130451. set containerSize(newSize: number);
  130452. get containerSize(): number;
  130453. /**
  130454. * Size of the joystick's puck
  130455. */
  130456. set puckSize(newSize: number);
  130457. get puckSize(): number;
  130458. /**
  130459. * Clears the set position of the joystick
  130460. */
  130461. clearPosition(): void;
  130462. /**
  130463. * Defines whether or not the joystick container is always visible
  130464. */
  130465. set alwaysVisible(value: boolean);
  130466. get alwaysVisible(): boolean;
  130467. /**
  130468. * Sets the constant position of the Joystick container
  130469. * @param x X axis coordinate
  130470. * @param y Y axis coordinate
  130471. */
  130472. setPosition(x: number, y: number): void;
  130473. /**
  130474. * Defines a callback to call when the joystick is touched
  130475. * @param action defines the callback
  130476. */
  130477. setActionOnTouch(action: () => any): void;
  130478. /**
  130479. * Defines which axis you'd like to control for left & right
  130480. * @param axis defines the axis to use
  130481. */
  130482. setAxisForLeftRight(axis: JoystickAxis): void;
  130483. /**
  130484. * Defines which axis you'd like to control for up & down
  130485. * @param axis defines the axis to use
  130486. */
  130487. setAxisForUpDown(axis: JoystickAxis): void;
  130488. /**
  130489. * Clears the canvas from the previous puck / container draw
  130490. */
  130491. private _clearPreviousDraw;
  130492. /**
  130493. * Loads `urlPath` to be used for the container's image
  130494. * @param urlPath defines the urlPath of an image to use
  130495. */
  130496. setContainerImage(urlPath: string): void;
  130497. /**
  130498. * Loads `urlPath` to be used for the puck's image
  130499. * @param urlPath defines the urlPath of an image to use
  130500. */
  130501. setPuckImage(urlPath: string): void;
  130502. /**
  130503. * Draws the Virtual Joystick's container
  130504. */
  130505. private _drawContainer;
  130506. /**
  130507. * Draws the Virtual Joystick's puck
  130508. */
  130509. private _drawPuck;
  130510. private _drawVirtualJoystick;
  130511. /**
  130512. * Release internal HTML canvas
  130513. */
  130514. releaseCanvas(): void;
  130515. }
  130516. }
  130517. declare module BABYLON {
  130518. interface FreeCameraInputsManager {
  130519. /**
  130520. * Add virtual joystick input support to the input manager.
  130521. * @returns the current input manager
  130522. */
  130523. addVirtualJoystick(): FreeCameraInputsManager;
  130524. }
  130525. /**
  130526. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  130527. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  130528. */
  130529. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  130530. /**
  130531. * Defines the camera the input is attached to.
  130532. */
  130533. camera: FreeCamera;
  130534. private _leftjoystick;
  130535. private _rightjoystick;
  130536. /**
  130537. * Gets the left stick of the virtual joystick.
  130538. * @returns The virtual Joystick
  130539. */
  130540. getLeftJoystick(): VirtualJoystick;
  130541. /**
  130542. * Gets the right stick of the virtual joystick.
  130543. * @returns The virtual Joystick
  130544. */
  130545. getRightJoystick(): VirtualJoystick;
  130546. /**
  130547. * Update the current camera state depending on the inputs that have been used this frame.
  130548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  130549. */
  130550. checkInputs(): void;
  130551. /**
  130552. * Attach the input controls to a specific dom element to get the input from.
  130553. */
  130554. attachControl(): void;
  130555. /**
  130556. * Detach the current controls from the specified dom element.
  130557. */
  130558. detachControl(): void;
  130559. /**
  130560. * Gets the class name of the current intput.
  130561. * @returns the class name
  130562. */
  130563. getClassName(): string;
  130564. /**
  130565. * Get the friendly name associated with the input class.
  130566. * @returns the input friendly name
  130567. */
  130568. getSimpleName(): string;
  130569. }
  130570. }
  130571. declare module BABYLON {
  130572. /**
  130573. * This represents a FPS type of camera controlled by touch.
  130574. * This is like a universal camera minus the Gamepad controls.
  130575. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130576. */
  130577. export class TouchCamera extends FreeCamera {
  130578. /**
  130579. * Defines the touch sensibility for rotation.
  130580. * The higher the faster.
  130581. */
  130582. get touchAngularSensibility(): number;
  130583. set touchAngularSensibility(value: number);
  130584. /**
  130585. * Defines the touch sensibility for move.
  130586. * The higher the faster.
  130587. */
  130588. get touchMoveSensibility(): number;
  130589. set touchMoveSensibility(value: number);
  130590. /**
  130591. * Instantiates a new touch camera.
  130592. * This represents a FPS type of camera controlled by touch.
  130593. * This is like a universal camera minus the Gamepad controls.
  130594. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130595. * @param name Define the name of the camera in the scene
  130596. * @param position Define the start position of the camera in the scene
  130597. * @param scene Define the scene the camera belongs to
  130598. */
  130599. constructor(name: string, position: Vector3, scene: Scene);
  130600. /**
  130601. * Gets the current object class name.
  130602. * @return the class name
  130603. */
  130604. getClassName(): string;
  130605. /** @hidden */
  130606. _setupInputs(): void;
  130607. }
  130608. }
  130609. declare module BABYLON {
  130610. /**
  130611. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  130612. * being tilted forward or back and left or right.
  130613. */
  130614. export class DeviceOrientationCamera extends FreeCamera {
  130615. private _initialQuaternion;
  130616. private _quaternionCache;
  130617. private _tmpDragQuaternion;
  130618. private _disablePointerInputWhenUsingDeviceOrientation;
  130619. /**
  130620. * Creates a new device orientation camera
  130621. * @param name The name of the camera
  130622. * @param position The start position camera
  130623. * @param scene The scene the camera belongs to
  130624. */
  130625. constructor(name: string, position: Vector3, scene: Scene);
  130626. /**
  130627. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  130628. */
  130629. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  130630. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  130631. private _dragFactor;
  130632. /**
  130633. * Enabled turning on the y axis when the orientation sensor is active
  130634. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  130635. */
  130636. enableHorizontalDragging(dragFactor?: number): void;
  130637. /**
  130638. * Gets the current instance class name ("DeviceOrientationCamera").
  130639. * This helps avoiding instanceof at run time.
  130640. * @returns the class name
  130641. */
  130642. getClassName(): string;
  130643. /**
  130644. * @hidden
  130645. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  130646. */
  130647. _checkInputs(): void;
  130648. /**
  130649. * Reset the camera to its default orientation on the specified axis only.
  130650. * @param axis The axis to reset
  130651. */
  130652. resetToCurrentRotation(axis?: Axis): void;
  130653. }
  130654. }
  130655. declare module BABYLON {
  130656. /**
  130657. * Defines supported buttons for XBox360 compatible gamepads
  130658. */
  130659. export enum Xbox360Button {
  130660. /** A */
  130661. A = 0,
  130662. /** B */
  130663. B = 1,
  130664. /** X */
  130665. X = 2,
  130666. /** Y */
  130667. Y = 3,
  130668. /** Left button */
  130669. LB = 4,
  130670. /** Right button */
  130671. RB = 5,
  130672. /** Back */
  130673. Back = 8,
  130674. /** Start */
  130675. Start = 9,
  130676. /** Left stick */
  130677. LeftStick = 10,
  130678. /** Right stick */
  130679. RightStick = 11
  130680. }
  130681. /** Defines values for XBox360 DPad */
  130682. export enum Xbox360Dpad {
  130683. /** Up */
  130684. Up = 12,
  130685. /** Down */
  130686. Down = 13,
  130687. /** Left */
  130688. Left = 14,
  130689. /** Right */
  130690. Right = 15
  130691. }
  130692. /**
  130693. * Defines a XBox360 gamepad
  130694. */
  130695. export class Xbox360Pad extends Gamepad {
  130696. private _leftTrigger;
  130697. private _rightTrigger;
  130698. private _onlefttriggerchanged;
  130699. private _onrighttriggerchanged;
  130700. private _onbuttondown;
  130701. private _onbuttonup;
  130702. private _ondpaddown;
  130703. private _ondpadup;
  130704. /** Observable raised when a button is pressed */
  130705. onButtonDownObservable: Observable<Xbox360Button>;
  130706. /** Observable raised when a button is released */
  130707. onButtonUpObservable: Observable<Xbox360Button>;
  130708. /** Observable raised when a pad is pressed */
  130709. onPadDownObservable: Observable<Xbox360Dpad>;
  130710. /** Observable raised when a pad is released */
  130711. onPadUpObservable: Observable<Xbox360Dpad>;
  130712. private _buttonA;
  130713. private _buttonB;
  130714. private _buttonX;
  130715. private _buttonY;
  130716. private _buttonBack;
  130717. private _buttonStart;
  130718. private _buttonLB;
  130719. private _buttonRB;
  130720. private _buttonLeftStick;
  130721. private _buttonRightStick;
  130722. private _dPadUp;
  130723. private _dPadDown;
  130724. private _dPadLeft;
  130725. private _dPadRight;
  130726. private _isXboxOnePad;
  130727. /**
  130728. * Creates a new XBox360 gamepad object
  130729. * @param id defines the id of this gamepad
  130730. * @param index defines its index
  130731. * @param gamepad defines the internal HTML gamepad object
  130732. * @param xboxOne defines if it is a XBox One gamepad
  130733. */
  130734. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  130735. /**
  130736. * Defines the callback to call when left trigger is pressed
  130737. * @param callback defines the callback to use
  130738. */
  130739. onlefttriggerchanged(callback: (value: number) => void): void;
  130740. /**
  130741. * Defines the callback to call when right trigger is pressed
  130742. * @param callback defines the callback to use
  130743. */
  130744. onrighttriggerchanged(callback: (value: number) => void): void;
  130745. /**
  130746. * Gets the left trigger value
  130747. */
  130748. get leftTrigger(): number;
  130749. /**
  130750. * Sets the left trigger value
  130751. */
  130752. set leftTrigger(newValue: number);
  130753. /**
  130754. * Gets the right trigger value
  130755. */
  130756. get rightTrigger(): number;
  130757. /**
  130758. * Sets the right trigger value
  130759. */
  130760. set rightTrigger(newValue: number);
  130761. /**
  130762. * Defines the callback to call when a button is pressed
  130763. * @param callback defines the callback to use
  130764. */
  130765. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  130766. /**
  130767. * Defines the callback to call when a button is released
  130768. * @param callback defines the callback to use
  130769. */
  130770. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  130771. /**
  130772. * Defines the callback to call when a pad is pressed
  130773. * @param callback defines the callback to use
  130774. */
  130775. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  130776. /**
  130777. * Defines the callback to call when a pad is released
  130778. * @param callback defines the callback to use
  130779. */
  130780. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  130781. private _setButtonValue;
  130782. private _setDPadValue;
  130783. /**
  130784. * Gets the value of the `A` button
  130785. */
  130786. get buttonA(): number;
  130787. /**
  130788. * Sets the value of the `A` button
  130789. */
  130790. set buttonA(value: number);
  130791. /**
  130792. * Gets the value of the `B` button
  130793. */
  130794. get buttonB(): number;
  130795. /**
  130796. * Sets the value of the `B` button
  130797. */
  130798. set buttonB(value: number);
  130799. /**
  130800. * Gets the value of the `X` button
  130801. */
  130802. get buttonX(): number;
  130803. /**
  130804. * Sets the value of the `X` button
  130805. */
  130806. set buttonX(value: number);
  130807. /**
  130808. * Gets the value of the `Y` button
  130809. */
  130810. get buttonY(): number;
  130811. /**
  130812. * Sets the value of the `Y` button
  130813. */
  130814. set buttonY(value: number);
  130815. /**
  130816. * Gets the value of the `Start` button
  130817. */
  130818. get buttonStart(): number;
  130819. /**
  130820. * Sets the value of the `Start` button
  130821. */
  130822. set buttonStart(value: number);
  130823. /**
  130824. * Gets the value of the `Back` button
  130825. */
  130826. get buttonBack(): number;
  130827. /**
  130828. * Sets the value of the `Back` button
  130829. */
  130830. set buttonBack(value: number);
  130831. /**
  130832. * Gets the value of the `Left` button
  130833. */
  130834. get buttonLB(): number;
  130835. /**
  130836. * Sets the value of the `Left` button
  130837. */
  130838. set buttonLB(value: number);
  130839. /**
  130840. * Gets the value of the `Right` button
  130841. */
  130842. get buttonRB(): number;
  130843. /**
  130844. * Sets the value of the `Right` button
  130845. */
  130846. set buttonRB(value: number);
  130847. /**
  130848. * Gets the value of the Left joystick
  130849. */
  130850. get buttonLeftStick(): number;
  130851. /**
  130852. * Sets the value of the Left joystick
  130853. */
  130854. set buttonLeftStick(value: number);
  130855. /**
  130856. * Gets the value of the Right joystick
  130857. */
  130858. get buttonRightStick(): number;
  130859. /**
  130860. * Sets the value of the Right joystick
  130861. */
  130862. set buttonRightStick(value: number);
  130863. /**
  130864. * Gets the value of D-pad up
  130865. */
  130866. get dPadUp(): number;
  130867. /**
  130868. * Sets the value of D-pad up
  130869. */
  130870. set dPadUp(value: number);
  130871. /**
  130872. * Gets the value of D-pad down
  130873. */
  130874. get dPadDown(): number;
  130875. /**
  130876. * Sets the value of D-pad down
  130877. */
  130878. set dPadDown(value: number);
  130879. /**
  130880. * Gets the value of D-pad left
  130881. */
  130882. get dPadLeft(): number;
  130883. /**
  130884. * Sets the value of D-pad left
  130885. */
  130886. set dPadLeft(value: number);
  130887. /**
  130888. * Gets the value of D-pad right
  130889. */
  130890. get dPadRight(): number;
  130891. /**
  130892. * Sets the value of D-pad right
  130893. */
  130894. set dPadRight(value: number);
  130895. /**
  130896. * Force the gamepad to synchronize with device values
  130897. */
  130898. update(): void;
  130899. /**
  130900. * Disposes the gamepad
  130901. */
  130902. dispose(): void;
  130903. }
  130904. }
  130905. declare module BABYLON {
  130906. /**
  130907. * Defines supported buttons for DualShock compatible gamepads
  130908. */
  130909. export enum DualShockButton {
  130910. /** Cross */
  130911. Cross = 0,
  130912. /** Circle */
  130913. Circle = 1,
  130914. /** Square */
  130915. Square = 2,
  130916. /** Triangle */
  130917. Triangle = 3,
  130918. /** L1 */
  130919. L1 = 4,
  130920. /** R1 */
  130921. R1 = 5,
  130922. /** Share */
  130923. Share = 8,
  130924. /** Options */
  130925. Options = 9,
  130926. /** Left stick */
  130927. LeftStick = 10,
  130928. /** Right stick */
  130929. RightStick = 11
  130930. }
  130931. /** Defines values for DualShock DPad */
  130932. export enum DualShockDpad {
  130933. /** Up */
  130934. Up = 12,
  130935. /** Down */
  130936. Down = 13,
  130937. /** Left */
  130938. Left = 14,
  130939. /** Right */
  130940. Right = 15
  130941. }
  130942. /**
  130943. * Defines a DualShock gamepad
  130944. */
  130945. export class DualShockPad extends Gamepad {
  130946. private _leftTrigger;
  130947. private _rightTrigger;
  130948. private _onlefttriggerchanged;
  130949. private _onrighttriggerchanged;
  130950. private _onbuttondown;
  130951. private _onbuttonup;
  130952. private _ondpaddown;
  130953. private _ondpadup;
  130954. /** Observable raised when a button is pressed */
  130955. onButtonDownObservable: Observable<DualShockButton>;
  130956. /** Observable raised when a button is released */
  130957. onButtonUpObservable: Observable<DualShockButton>;
  130958. /** Observable raised when a pad is pressed */
  130959. onPadDownObservable: Observable<DualShockDpad>;
  130960. /** Observable raised when a pad is released */
  130961. onPadUpObservable: Observable<DualShockDpad>;
  130962. private _buttonCross;
  130963. private _buttonCircle;
  130964. private _buttonSquare;
  130965. private _buttonTriangle;
  130966. private _buttonShare;
  130967. private _buttonOptions;
  130968. private _buttonL1;
  130969. private _buttonR1;
  130970. private _buttonLeftStick;
  130971. private _buttonRightStick;
  130972. private _dPadUp;
  130973. private _dPadDown;
  130974. private _dPadLeft;
  130975. private _dPadRight;
  130976. /**
  130977. * Creates a new DualShock gamepad object
  130978. * @param id defines the id of this gamepad
  130979. * @param index defines its index
  130980. * @param gamepad defines the internal HTML gamepad object
  130981. */
  130982. constructor(id: string, index: number, gamepad: any);
  130983. /**
  130984. * Defines the callback to call when left trigger is pressed
  130985. * @param callback defines the callback to use
  130986. */
  130987. onlefttriggerchanged(callback: (value: number) => void): void;
  130988. /**
  130989. * Defines the callback to call when right trigger is pressed
  130990. * @param callback defines the callback to use
  130991. */
  130992. onrighttriggerchanged(callback: (value: number) => void): void;
  130993. /**
  130994. * Gets the left trigger value
  130995. */
  130996. get leftTrigger(): number;
  130997. /**
  130998. * Sets the left trigger value
  130999. */
  131000. set leftTrigger(newValue: number);
  131001. /**
  131002. * Gets the right trigger value
  131003. */
  131004. get rightTrigger(): number;
  131005. /**
  131006. * Sets the right trigger value
  131007. */
  131008. set rightTrigger(newValue: number);
  131009. /**
  131010. * Defines the callback to call when a button is pressed
  131011. * @param callback defines the callback to use
  131012. */
  131013. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  131014. /**
  131015. * Defines the callback to call when a button is released
  131016. * @param callback defines the callback to use
  131017. */
  131018. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  131019. /**
  131020. * Defines the callback to call when a pad is pressed
  131021. * @param callback defines the callback to use
  131022. */
  131023. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  131024. /**
  131025. * Defines the callback to call when a pad is released
  131026. * @param callback defines the callback to use
  131027. */
  131028. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  131029. private _setButtonValue;
  131030. private _setDPadValue;
  131031. /**
  131032. * Gets the value of the `Cross` button
  131033. */
  131034. get buttonCross(): number;
  131035. /**
  131036. * Sets the value of the `Cross` button
  131037. */
  131038. set buttonCross(value: number);
  131039. /**
  131040. * Gets the value of the `Circle` button
  131041. */
  131042. get buttonCircle(): number;
  131043. /**
  131044. * Sets the value of the `Circle` button
  131045. */
  131046. set buttonCircle(value: number);
  131047. /**
  131048. * Gets the value of the `Square` button
  131049. */
  131050. get buttonSquare(): number;
  131051. /**
  131052. * Sets the value of the `Square` button
  131053. */
  131054. set buttonSquare(value: number);
  131055. /**
  131056. * Gets the value of the `Triangle` button
  131057. */
  131058. get buttonTriangle(): number;
  131059. /**
  131060. * Sets the value of the `Triangle` button
  131061. */
  131062. set buttonTriangle(value: number);
  131063. /**
  131064. * Gets the value of the `Options` button
  131065. */
  131066. get buttonOptions(): number;
  131067. /**
  131068. * Sets the value of the `Options` button
  131069. */
  131070. set buttonOptions(value: number);
  131071. /**
  131072. * Gets the value of the `Share` button
  131073. */
  131074. get buttonShare(): number;
  131075. /**
  131076. * Sets the value of the `Share` button
  131077. */
  131078. set buttonShare(value: number);
  131079. /**
  131080. * Gets the value of the `L1` button
  131081. */
  131082. get buttonL1(): number;
  131083. /**
  131084. * Sets the value of the `L1` button
  131085. */
  131086. set buttonL1(value: number);
  131087. /**
  131088. * Gets the value of the `R1` button
  131089. */
  131090. get buttonR1(): number;
  131091. /**
  131092. * Sets the value of the `R1` button
  131093. */
  131094. set buttonR1(value: number);
  131095. /**
  131096. * Gets the value of the Left joystick
  131097. */
  131098. get buttonLeftStick(): number;
  131099. /**
  131100. * Sets the value of the Left joystick
  131101. */
  131102. set buttonLeftStick(value: number);
  131103. /**
  131104. * Gets the value of the Right joystick
  131105. */
  131106. get buttonRightStick(): number;
  131107. /**
  131108. * Sets the value of the Right joystick
  131109. */
  131110. set buttonRightStick(value: number);
  131111. /**
  131112. * Gets the value of D-pad up
  131113. */
  131114. get dPadUp(): number;
  131115. /**
  131116. * Sets the value of D-pad up
  131117. */
  131118. set dPadUp(value: number);
  131119. /**
  131120. * Gets the value of D-pad down
  131121. */
  131122. get dPadDown(): number;
  131123. /**
  131124. * Sets the value of D-pad down
  131125. */
  131126. set dPadDown(value: number);
  131127. /**
  131128. * Gets the value of D-pad left
  131129. */
  131130. get dPadLeft(): number;
  131131. /**
  131132. * Sets the value of D-pad left
  131133. */
  131134. set dPadLeft(value: number);
  131135. /**
  131136. * Gets the value of D-pad right
  131137. */
  131138. get dPadRight(): number;
  131139. /**
  131140. * Sets the value of D-pad right
  131141. */
  131142. set dPadRight(value: number);
  131143. /**
  131144. * Force the gamepad to synchronize with device values
  131145. */
  131146. update(): void;
  131147. /**
  131148. * Disposes the gamepad
  131149. */
  131150. dispose(): void;
  131151. }
  131152. }
  131153. declare module BABYLON {
  131154. /**
  131155. * Manager for handling gamepads
  131156. */
  131157. export class GamepadManager {
  131158. private _scene?;
  131159. private _babylonGamepads;
  131160. private _oneGamepadConnected;
  131161. /** @hidden */
  131162. _isMonitoring: boolean;
  131163. private _gamepadEventSupported;
  131164. private _gamepadSupport?;
  131165. /**
  131166. * observable to be triggered when the gamepad controller has been connected
  131167. */
  131168. onGamepadConnectedObservable: Observable<Gamepad>;
  131169. /**
  131170. * observable to be triggered when the gamepad controller has been disconnected
  131171. */
  131172. onGamepadDisconnectedObservable: Observable<Gamepad>;
  131173. private _onGamepadConnectedEvent;
  131174. private _onGamepadDisconnectedEvent;
  131175. /**
  131176. * Initializes the gamepad manager
  131177. * @param _scene BabylonJS scene
  131178. */
  131179. constructor(_scene?: Scene | undefined);
  131180. /**
  131181. * The gamepads in the game pad manager
  131182. */
  131183. get gamepads(): Gamepad[];
  131184. /**
  131185. * Get the gamepad controllers based on type
  131186. * @param type The type of gamepad controller
  131187. * @returns Nullable gamepad
  131188. */
  131189. getGamepadByType(type?: number): Nullable<Gamepad>;
  131190. /**
  131191. * Disposes the gamepad manager
  131192. */
  131193. dispose(): void;
  131194. private _addNewGamepad;
  131195. private _startMonitoringGamepads;
  131196. private _stopMonitoringGamepads;
  131197. /** @hidden */
  131198. _checkGamepadsStatus(): void;
  131199. private _updateGamepadObjects;
  131200. }
  131201. }
  131202. declare module BABYLON {
  131203. interface Scene {
  131204. /** @hidden */
  131205. _gamepadManager: Nullable<GamepadManager>;
  131206. /**
  131207. * Gets the gamepad manager associated with the scene
  131208. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  131209. */
  131210. gamepadManager: GamepadManager;
  131211. }
  131212. /**
  131213. * Interface representing a free camera inputs manager
  131214. */
  131215. interface FreeCameraInputsManager {
  131216. /**
  131217. * Adds gamepad input support to the FreeCameraInputsManager.
  131218. * @returns the FreeCameraInputsManager
  131219. */
  131220. addGamepad(): FreeCameraInputsManager;
  131221. }
  131222. /**
  131223. * Interface representing an arc rotate camera inputs manager
  131224. */
  131225. interface ArcRotateCameraInputsManager {
  131226. /**
  131227. * Adds gamepad input support to the ArcRotateCamera InputManager.
  131228. * @returns the camera inputs manager
  131229. */
  131230. addGamepad(): ArcRotateCameraInputsManager;
  131231. }
  131232. /**
  131233. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  131234. */
  131235. export class GamepadSystemSceneComponent implements ISceneComponent {
  131236. /**
  131237. * The component name helpfull to identify the component in the list of scene components.
  131238. */
  131239. readonly name: string;
  131240. /**
  131241. * The scene the component belongs to.
  131242. */
  131243. scene: Scene;
  131244. /**
  131245. * Creates a new instance of the component for the given scene
  131246. * @param scene Defines the scene to register the component in
  131247. */
  131248. constructor(scene: Scene);
  131249. /**
  131250. * Registers the component in a given scene
  131251. */
  131252. register(): void;
  131253. /**
  131254. * Rebuilds the elements related to this component in case of
  131255. * context lost for instance.
  131256. */
  131257. rebuild(): void;
  131258. /**
  131259. * Disposes the component and the associated ressources
  131260. */
  131261. dispose(): void;
  131262. private _beforeCameraUpdate;
  131263. }
  131264. }
  131265. declare module BABYLON {
  131266. /**
  131267. * 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,
  131268. * which still works and will still be found in many Playgrounds.
  131269. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131270. */
  131271. export class UniversalCamera extends TouchCamera {
  131272. /**
  131273. * Defines the gamepad rotation sensiblity.
  131274. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  131275. */
  131276. get gamepadAngularSensibility(): number;
  131277. set gamepadAngularSensibility(value: number);
  131278. /**
  131279. * Defines the gamepad move sensiblity.
  131280. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  131281. */
  131282. get gamepadMoveSensibility(): number;
  131283. set gamepadMoveSensibility(value: number);
  131284. /**
  131285. * 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,
  131286. * which still works and will still be found in many Playgrounds.
  131287. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131288. * @param name Define the name of the camera in the scene
  131289. * @param position Define the start position of the camera in the scene
  131290. * @param scene Define the scene the camera belongs to
  131291. */
  131292. constructor(name: string, position: Vector3, scene: Scene);
  131293. /**
  131294. * Gets the current object class name.
  131295. * @return the class name
  131296. */
  131297. getClassName(): string;
  131298. }
  131299. }
  131300. declare module BABYLON {
  131301. /**
  131302. * This represents a FPS type of camera. This is only here for back compat purpose.
  131303. * Please use the UniversalCamera instead as both are identical.
  131304. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131305. */
  131306. export class GamepadCamera extends UniversalCamera {
  131307. /**
  131308. * Instantiates a new Gamepad Camera
  131309. * This represents a FPS type of camera. This is only here for back compat purpose.
  131310. * Please use the UniversalCamera instead as both are identical.
  131311. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  131312. * @param name Define the name of the camera in the scene
  131313. * @param position Define the start position of the camera in the scene
  131314. * @param scene Define the scene the camera belongs to
  131315. */
  131316. constructor(name: string, position: Vector3, scene: Scene);
  131317. /**
  131318. * Gets the current object class name.
  131319. * @return the class name
  131320. */
  131321. getClassName(): string;
  131322. }
  131323. }
  131324. declare module BABYLON {
  131325. /** @hidden */
  131326. export var passPixelShader: {
  131327. name: string;
  131328. shader: string;
  131329. };
  131330. }
  131331. declare module BABYLON {
  131332. /** @hidden */
  131333. export var passCubePixelShader: {
  131334. name: string;
  131335. shader: string;
  131336. };
  131337. }
  131338. declare module BABYLON {
  131339. /**
  131340. * PassPostProcess which produces an output the same as it's input
  131341. */
  131342. export class PassPostProcess extends PostProcess {
  131343. /**
  131344. * Gets a string identifying the name of the class
  131345. * @returns "PassPostProcess" string
  131346. */
  131347. getClassName(): string;
  131348. /**
  131349. * Creates the PassPostProcess
  131350. * @param name The name of the effect.
  131351. * @param options The required width/height ratio to downsize to before computing the render pass.
  131352. * @param camera The camera to apply the render pass to.
  131353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131354. * @param engine The engine which the post process will be applied. (default: current engine)
  131355. * @param reusable If the post process can be reused on the same frame. (default: false)
  131356. * @param textureType The type of texture to be used when performing the post processing.
  131357. * @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)
  131358. */
  131359. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131360. /** @hidden */
  131361. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  131362. }
  131363. /**
  131364. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  131365. */
  131366. export class PassCubePostProcess extends PostProcess {
  131367. private _face;
  131368. /**
  131369. * Gets or sets the cube face to display.
  131370. * * 0 is +X
  131371. * * 1 is -X
  131372. * * 2 is +Y
  131373. * * 3 is -Y
  131374. * * 4 is +Z
  131375. * * 5 is -Z
  131376. */
  131377. get face(): number;
  131378. set face(value: number);
  131379. /**
  131380. * Gets a string identifying the name of the class
  131381. * @returns "PassCubePostProcess" string
  131382. */
  131383. getClassName(): string;
  131384. /**
  131385. * Creates the PassCubePostProcess
  131386. * @param name The name of the effect.
  131387. * @param options The required width/height ratio to downsize to before computing the render pass.
  131388. * @param camera The camera to apply the render pass to.
  131389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  131390. * @param engine The engine which the post process will be applied. (default: current engine)
  131391. * @param reusable If the post process can be reused on the same frame. (default: false)
  131392. * @param textureType The type of texture to be used when performing the post processing.
  131393. * @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)
  131394. */
  131395. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  131396. /** @hidden */
  131397. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  131398. }
  131399. }
  131400. declare module BABYLON {
  131401. /** @hidden */
  131402. export var anaglyphPixelShader: {
  131403. name: string;
  131404. shader: string;
  131405. };
  131406. }
  131407. declare module BABYLON {
  131408. /**
  131409. * Postprocess used to generate anaglyphic rendering
  131410. */
  131411. export class AnaglyphPostProcess extends PostProcess {
  131412. private _passedProcess;
  131413. /**
  131414. * Gets a string identifying the name of the class
  131415. * @returns "AnaglyphPostProcess" string
  131416. */
  131417. getClassName(): string;
  131418. /**
  131419. * Creates a new AnaglyphPostProcess
  131420. * @param name defines postprocess name
  131421. * @param options defines creation options or target ratio scale
  131422. * @param rigCameras defines cameras using this postprocess
  131423. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  131424. * @param engine defines hosting engine
  131425. * @param reusable defines if the postprocess will be reused multiple times per frame
  131426. */
  131427. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  131428. }
  131429. }
  131430. declare module BABYLON {
  131431. /**
  131432. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  131433. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131434. */
  131435. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  131436. /**
  131437. * Creates a new AnaglyphArcRotateCamera
  131438. * @param name defines camera name
  131439. * @param alpha defines alpha angle (in radians)
  131440. * @param beta defines beta angle (in radians)
  131441. * @param radius defines radius
  131442. * @param target defines camera target
  131443. * @param interaxialDistance defines distance between each color axis
  131444. * @param scene defines the hosting scene
  131445. */
  131446. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  131447. /**
  131448. * Gets camera class name
  131449. * @returns AnaglyphArcRotateCamera
  131450. */
  131451. getClassName(): string;
  131452. }
  131453. }
  131454. declare module BABYLON {
  131455. /**
  131456. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  131457. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131458. */
  131459. export class AnaglyphFreeCamera extends FreeCamera {
  131460. /**
  131461. * Creates a new AnaglyphFreeCamera
  131462. * @param name defines camera name
  131463. * @param position defines initial position
  131464. * @param interaxialDistance defines distance between each color axis
  131465. * @param scene defines the hosting scene
  131466. */
  131467. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131468. /**
  131469. * Gets camera class name
  131470. * @returns AnaglyphFreeCamera
  131471. */
  131472. getClassName(): string;
  131473. }
  131474. }
  131475. declare module BABYLON {
  131476. /**
  131477. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  131478. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131479. */
  131480. export class AnaglyphGamepadCamera extends GamepadCamera {
  131481. /**
  131482. * Creates a new AnaglyphGamepadCamera
  131483. * @param name defines camera name
  131484. * @param position defines initial position
  131485. * @param interaxialDistance defines distance between each color axis
  131486. * @param scene defines the hosting scene
  131487. */
  131488. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131489. /**
  131490. * Gets camera class name
  131491. * @returns AnaglyphGamepadCamera
  131492. */
  131493. getClassName(): string;
  131494. }
  131495. }
  131496. declare module BABYLON {
  131497. /**
  131498. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  131499. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  131500. */
  131501. export class AnaglyphUniversalCamera extends UniversalCamera {
  131502. /**
  131503. * Creates a new AnaglyphUniversalCamera
  131504. * @param name defines camera name
  131505. * @param position defines initial position
  131506. * @param interaxialDistance defines distance between each color axis
  131507. * @param scene defines the hosting scene
  131508. */
  131509. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  131510. /**
  131511. * Gets camera class name
  131512. * @returns AnaglyphUniversalCamera
  131513. */
  131514. getClassName(): string;
  131515. }
  131516. }
  131517. declare module BABYLON {
  131518. /**
  131519. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  131520. * @see https://doc.babylonjs.com/features/cameras
  131521. */
  131522. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  131523. /**
  131524. * Creates a new StereoscopicArcRotateCamera
  131525. * @param name defines camera name
  131526. * @param alpha defines alpha angle (in radians)
  131527. * @param beta defines beta angle (in radians)
  131528. * @param radius defines radius
  131529. * @param target defines camera target
  131530. * @param interaxialDistance defines distance between each color axis
  131531. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131532. * @param scene defines the hosting scene
  131533. */
  131534. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131535. /**
  131536. * Gets camera class name
  131537. * @returns StereoscopicArcRotateCamera
  131538. */
  131539. getClassName(): string;
  131540. }
  131541. }
  131542. declare module BABYLON {
  131543. /**
  131544. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  131545. * @see https://doc.babylonjs.com/features/cameras
  131546. */
  131547. export class StereoscopicFreeCamera extends FreeCamera {
  131548. /**
  131549. * Creates a new StereoscopicFreeCamera
  131550. * @param name defines camera name
  131551. * @param position defines initial position
  131552. * @param interaxialDistance defines distance between each color axis
  131553. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131554. * @param scene defines the hosting scene
  131555. */
  131556. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131557. /**
  131558. * Gets camera class name
  131559. * @returns StereoscopicFreeCamera
  131560. */
  131561. getClassName(): string;
  131562. }
  131563. }
  131564. declare module BABYLON {
  131565. /**
  131566. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  131567. * @see https://doc.babylonjs.com/features/cameras
  131568. */
  131569. export class StereoscopicGamepadCamera extends GamepadCamera {
  131570. /**
  131571. * Creates a new StereoscopicGamepadCamera
  131572. * @param name defines camera name
  131573. * @param position defines initial position
  131574. * @param interaxialDistance defines distance between each color axis
  131575. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131576. * @param scene defines the hosting scene
  131577. */
  131578. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131579. /**
  131580. * Gets camera class name
  131581. * @returns StereoscopicGamepadCamera
  131582. */
  131583. getClassName(): string;
  131584. }
  131585. }
  131586. declare module BABYLON {
  131587. /**
  131588. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  131589. * @see https://doc.babylonjs.com/features/cameras
  131590. */
  131591. export class StereoscopicUniversalCamera extends UniversalCamera {
  131592. /**
  131593. * Creates a new StereoscopicUniversalCamera
  131594. * @param name defines camera name
  131595. * @param position defines initial position
  131596. * @param interaxialDistance defines distance between each color axis
  131597. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  131598. * @param scene defines the hosting scene
  131599. */
  131600. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  131601. /**
  131602. * Gets camera class name
  131603. * @returns StereoscopicUniversalCamera
  131604. */
  131605. getClassName(): string;
  131606. }
  131607. }
  131608. declare module BABYLON {
  131609. /**
  131610. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  131611. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131612. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131613. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131614. */
  131615. export class VirtualJoysticksCamera extends FreeCamera {
  131616. /**
  131617. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  131618. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  131619. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  131620. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  131621. * @param name Define the name of the camera in the scene
  131622. * @param position Define the start position of the camera in the scene
  131623. * @param scene Define the scene the camera belongs to
  131624. */
  131625. constructor(name: string, position: Vector3, scene: Scene);
  131626. /**
  131627. * Gets the current object class name.
  131628. * @return the class name
  131629. */
  131630. getClassName(): string;
  131631. }
  131632. }
  131633. declare module BABYLON {
  131634. /**
  131635. * This represents all the required metrics to create a VR camera.
  131636. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  131637. */
  131638. export class VRCameraMetrics {
  131639. /**
  131640. * Define the horizontal resolution off the screen.
  131641. */
  131642. hResolution: number;
  131643. /**
  131644. * Define the vertical resolution off the screen.
  131645. */
  131646. vResolution: number;
  131647. /**
  131648. * Define the horizontal screen size.
  131649. */
  131650. hScreenSize: number;
  131651. /**
  131652. * Define the vertical screen size.
  131653. */
  131654. vScreenSize: number;
  131655. /**
  131656. * Define the vertical screen center position.
  131657. */
  131658. vScreenCenter: number;
  131659. /**
  131660. * Define the distance of the eyes to the screen.
  131661. */
  131662. eyeToScreenDistance: number;
  131663. /**
  131664. * Define the distance between both lenses
  131665. */
  131666. lensSeparationDistance: number;
  131667. /**
  131668. * Define the distance between both viewer's eyes.
  131669. */
  131670. interpupillaryDistance: number;
  131671. /**
  131672. * Define the distortion factor of the VR postprocess.
  131673. * Please, touch with care.
  131674. */
  131675. distortionK: number[];
  131676. /**
  131677. * Define the chromatic aberration correction factors for the VR post process.
  131678. */
  131679. chromaAbCorrection: number[];
  131680. /**
  131681. * Define the scale factor of the post process.
  131682. * The smaller the better but the slower.
  131683. */
  131684. postProcessScaleFactor: number;
  131685. /**
  131686. * Define an offset for the lens center.
  131687. */
  131688. lensCenterOffset: number;
  131689. /**
  131690. * Define if the current vr camera should compensate the distortion of the lense or not.
  131691. */
  131692. compensateDistortion: boolean;
  131693. /**
  131694. * Defines if multiview should be enabled when rendering (Default: false)
  131695. */
  131696. multiviewEnabled: boolean;
  131697. /**
  131698. * Gets the rendering aspect ratio based on the provided resolutions.
  131699. */
  131700. get aspectRatio(): number;
  131701. /**
  131702. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  131703. */
  131704. get aspectRatioFov(): number;
  131705. /**
  131706. * @hidden
  131707. */
  131708. get leftHMatrix(): Matrix;
  131709. /**
  131710. * @hidden
  131711. */
  131712. get rightHMatrix(): Matrix;
  131713. /**
  131714. * @hidden
  131715. */
  131716. get leftPreViewMatrix(): Matrix;
  131717. /**
  131718. * @hidden
  131719. */
  131720. get rightPreViewMatrix(): Matrix;
  131721. /**
  131722. * Get the default VRMetrics based on the most generic setup.
  131723. * @returns the default vr metrics
  131724. */
  131725. static GetDefault(): VRCameraMetrics;
  131726. }
  131727. }
  131728. declare module BABYLON {
  131729. /** @hidden */
  131730. export var vrDistortionCorrectionPixelShader: {
  131731. name: string;
  131732. shader: string;
  131733. };
  131734. }
  131735. declare module BABYLON {
  131736. /**
  131737. * VRDistortionCorrectionPostProcess used for mobile VR
  131738. */
  131739. export class VRDistortionCorrectionPostProcess extends PostProcess {
  131740. private _isRightEye;
  131741. private _distortionFactors;
  131742. private _postProcessScaleFactor;
  131743. private _lensCenterOffset;
  131744. private _scaleIn;
  131745. private _scaleFactor;
  131746. private _lensCenter;
  131747. /**
  131748. * Gets a string identifying the name of the class
  131749. * @returns "VRDistortionCorrectionPostProcess" string
  131750. */
  131751. getClassName(): string;
  131752. /**
  131753. * Initializes the VRDistortionCorrectionPostProcess
  131754. * @param name The name of the effect.
  131755. * @param camera The camera to apply the render pass to.
  131756. * @param isRightEye If this is for the right eye distortion
  131757. * @param vrMetrics All the required metrics for the VR camera
  131758. */
  131759. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  131760. }
  131761. }
  131762. declare module BABYLON {
  131763. /**
  131764. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  131765. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131766. */
  131767. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  131768. /**
  131769. * Creates a new VRDeviceOrientationArcRotateCamera
  131770. * @param name defines camera name
  131771. * @param alpha defines the camera rotation along the logitudinal axis
  131772. * @param beta defines the camera rotation along the latitudinal axis
  131773. * @param radius defines the camera distance from its target
  131774. * @param target defines the camera target
  131775. * @param scene defines the scene the camera belongs to
  131776. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131777. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131778. */
  131779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131780. /**
  131781. * Gets camera class name
  131782. * @returns VRDeviceOrientationArcRotateCamera
  131783. */
  131784. getClassName(): string;
  131785. }
  131786. }
  131787. declare module BABYLON {
  131788. /**
  131789. * Camera used to simulate VR rendering (based on FreeCamera)
  131790. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131791. */
  131792. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  131793. /**
  131794. * Creates a new VRDeviceOrientationFreeCamera
  131795. * @param name defines camera name
  131796. * @param position defines the start position of the camera
  131797. * @param scene defines the scene the camera belongs to
  131798. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131799. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131800. */
  131801. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131802. /**
  131803. * Gets camera class name
  131804. * @returns VRDeviceOrientationFreeCamera
  131805. */
  131806. getClassName(): string;
  131807. }
  131808. }
  131809. declare module BABYLON {
  131810. /**
  131811. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131812. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131813. */
  131814. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131815. /**
  131816. * Creates a new VRDeviceOrientationGamepadCamera
  131817. * @param name defines camera name
  131818. * @param position defines the start position of the camera
  131819. * @param scene defines the scene the camera belongs to
  131820. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131821. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131822. */
  131823. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131824. /**
  131825. * Gets camera class name
  131826. * @returns VRDeviceOrientationGamepadCamera
  131827. */
  131828. getClassName(): string;
  131829. }
  131830. }
  131831. declare module BABYLON {
  131832. /**
  131833. * A class extending Texture allowing drawing on a texture
  131834. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131835. */
  131836. export class DynamicTexture extends Texture {
  131837. private _generateMipMaps;
  131838. private _canvas;
  131839. private _context;
  131840. /**
  131841. * Creates a DynamicTexture
  131842. * @param name defines the name of the texture
  131843. * @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
  131844. * @param scene defines the scene where you want the texture
  131845. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131846. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131847. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131848. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131849. */
  131850. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131851. /**
  131852. * Get the current class name of the texture useful for serialization or dynamic coding.
  131853. * @returns "DynamicTexture"
  131854. */
  131855. getClassName(): string;
  131856. /**
  131857. * Gets the current state of canRescale
  131858. */
  131859. get canRescale(): boolean;
  131860. private _recreate;
  131861. /**
  131862. * Scales the texture
  131863. * @param ratio the scale factor to apply to both width and height
  131864. */
  131865. scale(ratio: number): void;
  131866. /**
  131867. * Resizes the texture
  131868. * @param width the new width
  131869. * @param height the new height
  131870. */
  131871. scaleTo(width: number, height: number): void;
  131872. /**
  131873. * Gets the context of the canvas used by the texture
  131874. * @returns the canvas context of the dynamic texture
  131875. */
  131876. getContext(): CanvasRenderingContext2D;
  131877. /**
  131878. * Clears the texture
  131879. */
  131880. clear(): void;
  131881. /**
  131882. * Updates the texture
  131883. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131884. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131885. */
  131886. update(invertY?: boolean, premulAlpha?: boolean): void;
  131887. /**
  131888. * Draws text onto the texture
  131889. * @param text defines the text to be drawn
  131890. * @param x defines the placement of the text from the left
  131891. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131892. * @param font defines the font to be used with font-style, font-size, font-name
  131893. * @param color defines the color used for the text
  131894. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131895. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131896. * @param update defines whether texture is immediately update (default is true)
  131897. */
  131898. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131899. /**
  131900. * Clones the texture
  131901. * @returns the clone of the texture.
  131902. */
  131903. clone(): DynamicTexture;
  131904. /**
  131905. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131906. * @returns a serialized dynamic texture object
  131907. */
  131908. serialize(): any;
  131909. private _IsCanvasElement;
  131910. /** @hidden */
  131911. _rebuild(): void;
  131912. }
  131913. }
  131914. declare module BABYLON {
  131915. /**
  131916. * Class containing static functions to help procedurally build meshes
  131917. */
  131918. export class GroundBuilder {
  131919. /**
  131920. * Creates a ground mesh
  131921. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131922. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131924. * @param name defines the name of the mesh
  131925. * @param options defines the options used to create the mesh
  131926. * @param scene defines the hosting scene
  131927. * @returns the ground mesh
  131928. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131929. */
  131930. static CreateGround(name: string, options: {
  131931. width?: number;
  131932. height?: number;
  131933. subdivisions?: number;
  131934. subdivisionsX?: number;
  131935. subdivisionsY?: number;
  131936. updatable?: boolean;
  131937. }, scene: any): Mesh;
  131938. /**
  131939. * Creates a tiled ground mesh
  131940. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131941. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131942. * * 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
  131943. * * 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
  131944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131945. * @param name defines the name of the mesh
  131946. * @param options defines the options used to create the mesh
  131947. * @param scene defines the hosting scene
  131948. * @returns the tiled ground mesh
  131949. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131950. */
  131951. static CreateTiledGround(name: string, options: {
  131952. xmin: number;
  131953. zmin: number;
  131954. xmax: number;
  131955. zmax: number;
  131956. subdivisions?: {
  131957. w: number;
  131958. h: number;
  131959. };
  131960. precision?: {
  131961. w: number;
  131962. h: number;
  131963. };
  131964. updatable?: boolean;
  131965. }, scene?: Nullable<Scene>): Mesh;
  131966. /**
  131967. * Creates a ground mesh from a height map
  131968. * * The parameter `url` sets the URL of the height map image resource.
  131969. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131970. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131971. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131972. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131973. * * 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.
  131974. * * 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).
  131975. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131977. * @param name defines the name of the mesh
  131978. * @param url defines the url to the height map
  131979. * @param options defines the options used to create the mesh
  131980. * @param scene defines the hosting scene
  131981. * @returns the ground mesh
  131982. * @see https://doc.babylonjs.com/babylon101/height_map
  131983. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131984. */
  131985. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131986. width?: number;
  131987. height?: number;
  131988. subdivisions?: number;
  131989. minHeight?: number;
  131990. maxHeight?: number;
  131991. colorFilter?: Color3;
  131992. alphaFilter?: number;
  131993. updatable?: boolean;
  131994. onReady?: (mesh: GroundMesh) => void;
  131995. }, scene?: Nullable<Scene>): GroundMesh;
  131996. }
  131997. }
  131998. declare module BABYLON {
  131999. /**
  132000. * Class containing static functions to help procedurally build meshes
  132001. */
  132002. export class TorusBuilder {
  132003. /**
  132004. * Creates a torus mesh
  132005. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  132006. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  132007. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  132008. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132011. * @param name defines the name of the mesh
  132012. * @param options defines the options used to create the mesh
  132013. * @param scene defines the hosting scene
  132014. * @returns the torus mesh
  132015. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  132016. */
  132017. static CreateTorus(name: string, options: {
  132018. diameter?: number;
  132019. thickness?: number;
  132020. tessellation?: number;
  132021. updatable?: boolean;
  132022. sideOrientation?: number;
  132023. frontUVs?: Vector4;
  132024. backUVs?: Vector4;
  132025. }, scene: any): Mesh;
  132026. }
  132027. }
  132028. declare module BABYLON {
  132029. /**
  132030. * Class containing static functions to help procedurally build meshes
  132031. */
  132032. export class CylinderBuilder {
  132033. /**
  132034. * Creates a cylinder or a cone mesh
  132035. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  132036. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  132037. * * 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.
  132038. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  132039. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  132040. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  132041. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  132042. * * 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).
  132043. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  132044. * * 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).
  132045. * * 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
  132046. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  132047. * * 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
  132048. * * 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.
  132049. * * If `enclose` is false, a ring surface is one element.
  132050. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  132051. * * 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
  132052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  132055. * @param name defines the name of the mesh
  132056. * @param options defines the options used to create the mesh
  132057. * @param scene defines the hosting scene
  132058. * @returns the cylinder mesh
  132059. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  132060. */
  132061. static CreateCylinder(name: string, options: {
  132062. height?: number;
  132063. diameterTop?: number;
  132064. diameterBottom?: number;
  132065. diameter?: number;
  132066. tessellation?: number;
  132067. subdivisions?: number;
  132068. arc?: number;
  132069. faceColors?: Color4[];
  132070. faceUV?: Vector4[];
  132071. updatable?: boolean;
  132072. hasRings?: boolean;
  132073. enclose?: boolean;
  132074. cap?: number;
  132075. sideOrientation?: number;
  132076. frontUVs?: Vector4;
  132077. backUVs?: Vector4;
  132078. }, scene: any): Mesh;
  132079. }
  132080. }
  132081. declare module BABYLON {
  132082. /**
  132083. * States of the webXR experience
  132084. */
  132085. export enum WebXRState {
  132086. /**
  132087. * Transitioning to being in XR mode
  132088. */
  132089. ENTERING_XR = 0,
  132090. /**
  132091. * Transitioning to non XR mode
  132092. */
  132093. EXITING_XR = 1,
  132094. /**
  132095. * In XR mode and presenting
  132096. */
  132097. IN_XR = 2,
  132098. /**
  132099. * Not entered XR mode
  132100. */
  132101. NOT_IN_XR = 3
  132102. }
  132103. /**
  132104. * The state of the XR camera's tracking
  132105. */
  132106. export enum WebXRTrackingState {
  132107. /**
  132108. * No transformation received, device is not being tracked
  132109. */
  132110. NOT_TRACKING = 0,
  132111. /**
  132112. * Tracking lost - using emulated position
  132113. */
  132114. TRACKING_LOST = 1,
  132115. /**
  132116. * Transformation tracking works normally
  132117. */
  132118. TRACKING = 2
  132119. }
  132120. /**
  132121. * Abstraction of the XR render target
  132122. */
  132123. export interface WebXRRenderTarget extends IDisposable {
  132124. /**
  132125. * xrpresent context of the canvas which can be used to display/mirror xr content
  132126. */
  132127. canvasContext: WebGLRenderingContext;
  132128. /**
  132129. * xr layer for the canvas
  132130. */
  132131. xrLayer: Nullable<XRWebGLLayer>;
  132132. /**
  132133. * Initializes the xr layer for the session
  132134. * @param xrSession xr session
  132135. * @returns a promise that will resolve once the XR Layer has been created
  132136. */
  132137. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132138. }
  132139. }
  132140. declare module BABYLON {
  132141. /**
  132142. * COnfiguration object for WebXR output canvas
  132143. */
  132144. export class WebXRManagedOutputCanvasOptions {
  132145. /**
  132146. * An optional canvas in case you wish to create it yourself and provide it here.
  132147. * If not provided, a new canvas will be created
  132148. */
  132149. canvasElement?: HTMLCanvasElement;
  132150. /**
  132151. * Options for this XR Layer output
  132152. */
  132153. canvasOptions?: XRWebGLLayerInit;
  132154. /**
  132155. * CSS styling for a newly created canvas (if not provided)
  132156. */
  132157. newCanvasCssStyle?: string;
  132158. /**
  132159. * Get the default values of the configuration object
  132160. * @param engine defines the engine to use (can be null)
  132161. * @returns default values of this configuration object
  132162. */
  132163. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  132164. }
  132165. /**
  132166. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  132167. */
  132168. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  132169. private _options;
  132170. private _canvas;
  132171. private _engine;
  132172. private _originalCanvasSize;
  132173. /**
  132174. * Rendering context of the canvas which can be used to display/mirror xr content
  132175. */
  132176. canvasContext: WebGLRenderingContext;
  132177. /**
  132178. * xr layer for the canvas
  132179. */
  132180. xrLayer: Nullable<XRWebGLLayer>;
  132181. /**
  132182. * Obseervers registered here will be triggered when the xr layer was initialized
  132183. */
  132184. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  132185. /**
  132186. * Initializes the canvas to be added/removed upon entering/exiting xr
  132187. * @param _xrSessionManager The XR Session manager
  132188. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  132189. */
  132190. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  132191. /**
  132192. * Disposes of the object
  132193. */
  132194. dispose(): void;
  132195. /**
  132196. * Initializes the xr layer for the session
  132197. * @param xrSession xr session
  132198. * @returns a promise that will resolve once the XR Layer has been created
  132199. */
  132200. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  132201. private _addCanvas;
  132202. private _removeCanvas;
  132203. private _setCanvasSize;
  132204. private _setManagedOutputCanvas;
  132205. }
  132206. }
  132207. declare module BABYLON {
  132208. /**
  132209. * Manages an XRSession to work with Babylon's engine
  132210. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  132211. */
  132212. export class WebXRSessionManager implements IDisposable {
  132213. /** The scene which the session should be created for */
  132214. scene: Scene;
  132215. private _referenceSpace;
  132216. private _rttProvider;
  132217. private _sessionEnded;
  132218. private _xrNavigator;
  132219. private baseLayer;
  132220. /**
  132221. * The base reference space from which the session started. good if you want to reset your
  132222. * reference space
  132223. */
  132224. baseReferenceSpace: XRReferenceSpace;
  132225. /**
  132226. * Current XR frame
  132227. */
  132228. currentFrame: Nullable<XRFrame>;
  132229. /** WebXR timestamp updated every frame */
  132230. currentTimestamp: number;
  132231. /**
  132232. * Used just in case of a failure to initialize an immersive session.
  132233. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  132234. */
  132235. defaultHeightCompensation: number;
  132236. /**
  132237. * Fires every time a new xrFrame arrives which can be used to update the camera
  132238. */
  132239. onXRFrameObservable: Observable<XRFrame>;
  132240. /**
  132241. * Fires when the reference space changed
  132242. */
  132243. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  132244. /**
  132245. * Fires when the xr session is ended either by the device or manually done
  132246. */
  132247. onXRSessionEnded: Observable<any>;
  132248. /**
  132249. * Fires when the xr session is ended either by the device or manually done
  132250. */
  132251. onXRSessionInit: Observable<XRSession>;
  132252. /**
  132253. * Underlying xr session
  132254. */
  132255. session: XRSession;
  132256. /**
  132257. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  132258. * or get the offset the player is currently at.
  132259. */
  132260. viewerReferenceSpace: XRReferenceSpace;
  132261. /**
  132262. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  132263. * @param scene The scene which the session should be created for
  132264. */
  132265. constructor(
  132266. /** The scene which the session should be created for */
  132267. scene: Scene);
  132268. /**
  132269. * The current reference space used in this session. This reference space can constantly change!
  132270. * It is mainly used to offset the camera's position.
  132271. */
  132272. get referenceSpace(): XRReferenceSpace;
  132273. /**
  132274. * Set a new reference space and triggers the observable
  132275. */
  132276. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  132277. /**
  132278. * Disposes of the session manager
  132279. */
  132280. dispose(): void;
  132281. /**
  132282. * Stops the xrSession and restores the render loop
  132283. * @returns Promise which resolves after it exits XR
  132284. */
  132285. exitXRAsync(): Promise<void>;
  132286. /**
  132287. * Gets the correct render target texture to be rendered this frame for this eye
  132288. * @param eye the eye for which to get the render target
  132289. * @returns the render target for the specified eye
  132290. */
  132291. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  132292. /**
  132293. * Creates a WebXRRenderTarget object for the XR session
  132294. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  132295. * @param options optional options to provide when creating a new render target
  132296. * @returns a WebXR render target to which the session can render
  132297. */
  132298. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  132299. /**
  132300. * Initializes the manager
  132301. * After initialization enterXR can be called to start an XR session
  132302. * @returns Promise which resolves after it is initialized
  132303. */
  132304. initializeAsync(): Promise<void>;
  132305. /**
  132306. * Initializes an xr session
  132307. * @param xrSessionMode mode to initialize
  132308. * @param xrSessionInit defines optional and required values to pass to the session builder
  132309. * @returns a promise which will resolve once the session has been initialized
  132310. */
  132311. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  132312. /**
  132313. * Checks if a session would be supported for the creation options specified
  132314. * @param sessionMode session mode to check if supported eg. immersive-vr
  132315. * @returns A Promise that resolves to true if supported and false if not
  132316. */
  132317. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132318. /**
  132319. * Resets the reference space to the one started the session
  132320. */
  132321. resetReferenceSpace(): void;
  132322. /**
  132323. * Starts rendering to the xr layer
  132324. */
  132325. runXRRenderLoop(): void;
  132326. /**
  132327. * Sets the reference space on the xr session
  132328. * @param referenceSpaceType space to set
  132329. * @returns a promise that will resolve once the reference space has been set
  132330. */
  132331. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  132332. /**
  132333. * Updates the render state of the session
  132334. * @param state state to set
  132335. * @returns a promise that resolves once the render state has been updated
  132336. */
  132337. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  132338. /**
  132339. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  132340. * @param sessionMode defines the session to test
  132341. * @returns a promise with boolean as final value
  132342. */
  132343. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  132344. private _createRenderTargetTexture;
  132345. }
  132346. }
  132347. declare module BABYLON {
  132348. /**
  132349. * WebXR Camera which holds the views for the xrSession
  132350. * @see https://doc.babylonjs.com/how_to/webxr_camera
  132351. */
  132352. export class WebXRCamera extends FreeCamera {
  132353. private _xrSessionManager;
  132354. private _firstFrame;
  132355. private _referenceQuaternion;
  132356. private _referencedPosition;
  132357. private _xrInvPositionCache;
  132358. private _xrInvQuaternionCache;
  132359. private _trackingState;
  132360. /**
  132361. * Observable raised before camera teleportation
  132362. */
  132363. onBeforeCameraTeleport: Observable<Vector3>;
  132364. /**
  132365. * Observable raised after camera teleportation
  132366. */
  132367. onAfterCameraTeleport: Observable<Vector3>;
  132368. /**
  132369. * Notifies when the camera's tracking state has changed.
  132370. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  132371. */
  132372. onTrackingStateChanged: Observable<WebXRTrackingState>;
  132373. /**
  132374. * Should position compensation execute on first frame.
  132375. * This is used when copying the position from a native (non XR) camera
  132376. */
  132377. compensateOnFirstFrame: boolean;
  132378. /**
  132379. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  132380. * @param name the name of the camera
  132381. * @param scene the scene to add the camera to
  132382. * @param _xrSessionManager a constructed xr session manager
  132383. */
  132384. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  132385. /**
  132386. * Get the current XR tracking state of the camera
  132387. */
  132388. get trackingState(): WebXRTrackingState;
  132389. private _setTrackingState;
  132390. /**
  132391. * Return the user's height, unrelated to the current ground.
  132392. * This will be the y position of this camera, when ground level is 0.
  132393. */
  132394. get realWorldHeight(): number;
  132395. /** @hidden */
  132396. _updateForDualEyeDebugging(): void;
  132397. /**
  132398. * Sets this camera's transformation based on a non-vr camera
  132399. * @param otherCamera the non-vr camera to copy the transformation from
  132400. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  132401. */
  132402. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  132403. /**
  132404. * Gets the current instance class name ("WebXRCamera").
  132405. * @returns the class name
  132406. */
  132407. getClassName(): string;
  132408. private _rotate180;
  132409. private _updateFromXRSession;
  132410. private _updateNumberOfRigCameras;
  132411. private _updateReferenceSpace;
  132412. private _updateReferenceSpaceOffset;
  132413. }
  132414. }
  132415. declare module BABYLON {
  132416. /**
  132417. * Defining the interface required for a (webxr) feature
  132418. */
  132419. export interface IWebXRFeature extends IDisposable {
  132420. /**
  132421. * Is this feature attached
  132422. */
  132423. attached: boolean;
  132424. /**
  132425. * Should auto-attach be disabled?
  132426. */
  132427. disableAutoAttach: boolean;
  132428. /**
  132429. * Attach the feature to the session
  132430. * Will usually be called by the features manager
  132431. *
  132432. * @param force should attachment be forced (even when already attached)
  132433. * @returns true if successful.
  132434. */
  132435. attach(force?: boolean): boolean;
  132436. /**
  132437. * Detach the feature from the session
  132438. * Will usually be called by the features manager
  132439. *
  132440. * @returns true if successful.
  132441. */
  132442. detach(): boolean;
  132443. /**
  132444. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  132445. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  132446. *
  132447. * @returns whether or not the feature is compatible in this environment
  132448. */
  132449. isCompatible(): boolean;
  132450. /**
  132451. * Was this feature disposed;
  132452. */
  132453. isDisposed: boolean;
  132454. /**
  132455. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  132456. */
  132457. xrNativeFeatureName?: string;
  132458. /**
  132459. * A list of (Babylon WebXR) features this feature depends on
  132460. */
  132461. dependsOn?: string[];
  132462. }
  132463. /**
  132464. * A list of the currently available features without referencing them
  132465. */
  132466. export class WebXRFeatureName {
  132467. /**
  132468. * The name of the anchor system feature
  132469. */
  132470. static readonly ANCHOR_SYSTEM: string;
  132471. /**
  132472. * The name of the background remover feature
  132473. */
  132474. static readonly BACKGROUND_REMOVER: string;
  132475. /**
  132476. * The name of the hit test feature
  132477. */
  132478. static readonly HIT_TEST: string;
  132479. /**
  132480. * physics impostors for xr controllers feature
  132481. */
  132482. static readonly PHYSICS_CONTROLLERS: string;
  132483. /**
  132484. * The name of the plane detection feature
  132485. */
  132486. static readonly PLANE_DETECTION: string;
  132487. /**
  132488. * The name of the pointer selection feature
  132489. */
  132490. static readonly POINTER_SELECTION: string;
  132491. /**
  132492. * The name of the teleportation feature
  132493. */
  132494. static readonly TELEPORTATION: string;
  132495. /**
  132496. * The name of the feature points feature.
  132497. */
  132498. static readonly FEATURE_POINTS: string;
  132499. /**
  132500. * The name of the hand tracking feature.
  132501. */
  132502. static readonly HAND_TRACKING: string;
  132503. }
  132504. /**
  132505. * Defining the constructor of a feature. Used to register the modules.
  132506. */
  132507. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  132508. /**
  132509. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  132510. * It is mainly used in AR sessions.
  132511. *
  132512. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  132513. */
  132514. export class WebXRFeaturesManager implements IDisposable {
  132515. private _xrSessionManager;
  132516. private static readonly _AvailableFeatures;
  132517. private _features;
  132518. /**
  132519. * constructs a new features manages.
  132520. *
  132521. * @param _xrSessionManager an instance of WebXRSessionManager
  132522. */
  132523. constructor(_xrSessionManager: WebXRSessionManager);
  132524. /**
  132525. * Used to register a module. After calling this function a developer can use this feature in the scene.
  132526. * Mainly used internally.
  132527. *
  132528. * @param featureName the name of the feature to register
  132529. * @param constructorFunction the function used to construct the module
  132530. * @param version the (babylon) version of the module
  132531. * @param stable is that a stable version of this module
  132532. */
  132533. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  132534. /**
  132535. * Returns a constructor of a specific feature.
  132536. *
  132537. * @param featureName the name of the feature to construct
  132538. * @param version the version of the feature to load
  132539. * @param xrSessionManager the xrSessionManager. Used to construct the module
  132540. * @param options optional options provided to the module.
  132541. * @returns a function that, when called, will return a new instance of this feature
  132542. */
  132543. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  132544. /**
  132545. * Can be used to return the list of features currently registered
  132546. *
  132547. * @returns an Array of available features
  132548. */
  132549. static GetAvailableFeatures(): string[];
  132550. /**
  132551. * Gets the versions available for a specific feature
  132552. * @param featureName the name of the feature
  132553. * @returns an array with the available versions
  132554. */
  132555. static GetAvailableVersions(featureName: string): string[];
  132556. /**
  132557. * Return the latest unstable version of this feature
  132558. * @param featureName the name of the feature to search
  132559. * @returns the version number. if not found will return -1
  132560. */
  132561. static GetLatestVersionOfFeature(featureName: string): number;
  132562. /**
  132563. * Return the latest stable version of this feature
  132564. * @param featureName the name of the feature to search
  132565. * @returns the version number. if not found will return -1
  132566. */
  132567. static GetStableVersionOfFeature(featureName: string): number;
  132568. /**
  132569. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  132570. * Can be used during a session to start a feature
  132571. * @param featureName the name of feature to attach
  132572. */
  132573. attachFeature(featureName: string): void;
  132574. /**
  132575. * Can be used inside a session or when the session ends to detach a specific feature
  132576. * @param featureName the name of the feature to detach
  132577. */
  132578. detachFeature(featureName: string): void;
  132579. /**
  132580. * Used to disable an already-enabled feature
  132581. * The feature will be disposed and will be recreated once enabled.
  132582. * @param featureName the feature to disable
  132583. * @returns true if disable was successful
  132584. */
  132585. disableFeature(featureName: string | {
  132586. Name: string;
  132587. }): boolean;
  132588. /**
  132589. * dispose this features manager
  132590. */
  132591. dispose(): void;
  132592. /**
  132593. * 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.
  132594. * 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.
  132595. *
  132596. * @param featureName the name of the feature to load or the class of the feature
  132597. * @param version optional version to load. if not provided the latest version will be enabled
  132598. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  132599. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  132600. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  132601. * @returns a new constructed feature or throws an error if feature not found.
  132602. */
  132603. enableFeature(featureName: string | {
  132604. Name: string;
  132605. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  132606. /**
  132607. * get the implementation of an enabled feature.
  132608. * @param featureName the name of the feature to load
  132609. * @returns the feature class, if found
  132610. */
  132611. getEnabledFeature(featureName: string): IWebXRFeature;
  132612. /**
  132613. * Get the list of enabled features
  132614. * @returns an array of enabled features
  132615. */
  132616. getEnabledFeatures(): string[];
  132617. /**
  132618. * This function will exten the session creation configuration object with enabled features.
  132619. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  132620. * according to the defined "required" variable, provided during enableFeature call
  132621. * @param xrSessionInit the xr Session init object to extend
  132622. *
  132623. * @returns an extended XRSessionInit object
  132624. */
  132625. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  132626. }
  132627. }
  132628. declare module BABYLON {
  132629. /**
  132630. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  132631. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  132632. */
  132633. export class WebXRExperienceHelper implements IDisposable {
  132634. private scene;
  132635. private _nonVRCamera;
  132636. private _originalSceneAutoClear;
  132637. private _supported;
  132638. /**
  132639. * Camera used to render xr content
  132640. */
  132641. camera: WebXRCamera;
  132642. /** A features manager for this xr session */
  132643. featuresManager: WebXRFeaturesManager;
  132644. /**
  132645. * Observers registered here will be triggered after the camera's initial transformation is set
  132646. * This can be used to set a different ground level or an extra rotation.
  132647. *
  132648. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  132649. * to the position set after this observable is done executing.
  132650. */
  132651. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  132652. /**
  132653. * Fires when the state of the experience helper has changed
  132654. */
  132655. onStateChangedObservable: Observable<WebXRState>;
  132656. /** Session manager used to keep track of xr session */
  132657. sessionManager: WebXRSessionManager;
  132658. /**
  132659. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  132660. */
  132661. state: WebXRState;
  132662. /**
  132663. * Creates a WebXRExperienceHelper
  132664. * @param scene The scene the helper should be created in
  132665. */
  132666. private constructor();
  132667. /**
  132668. * Creates the experience helper
  132669. * @param scene the scene to attach the experience helper to
  132670. * @returns a promise for the experience helper
  132671. */
  132672. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  132673. /**
  132674. * Disposes of the experience helper
  132675. */
  132676. dispose(): void;
  132677. /**
  132678. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  132679. * @param sessionMode options for the XR session
  132680. * @param referenceSpaceType frame of reference of the XR session
  132681. * @param renderTarget the output canvas that will be used to enter XR mode
  132682. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  132683. * @returns promise that resolves after xr mode has entered
  132684. */
  132685. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  132686. /**
  132687. * Exits XR mode and returns the scene to its original state
  132688. * @returns promise that resolves after xr mode has exited
  132689. */
  132690. exitXRAsync(): Promise<void>;
  132691. private _nonXRToXRCamera;
  132692. private _setState;
  132693. }
  132694. }
  132695. declare module BABYLON {
  132696. /**
  132697. * X-Y values for axes in WebXR
  132698. */
  132699. export interface IWebXRMotionControllerAxesValue {
  132700. /**
  132701. * The value of the x axis
  132702. */
  132703. x: number;
  132704. /**
  132705. * The value of the y-axis
  132706. */
  132707. y: number;
  132708. }
  132709. /**
  132710. * changed / previous values for the values of this component
  132711. */
  132712. export interface IWebXRMotionControllerComponentChangesValues<T> {
  132713. /**
  132714. * current (this frame) value
  132715. */
  132716. current: T;
  132717. /**
  132718. * previous (last change) value
  132719. */
  132720. previous: T;
  132721. }
  132722. /**
  132723. * Represents changes in the component between current frame and last values recorded
  132724. */
  132725. export interface IWebXRMotionControllerComponentChanges {
  132726. /**
  132727. * will be populated with previous and current values if axes changed
  132728. */
  132729. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  132730. /**
  132731. * will be populated with previous and current values if pressed changed
  132732. */
  132733. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132734. /**
  132735. * will be populated with previous and current values if touched changed
  132736. */
  132737. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  132738. /**
  132739. * will be populated with previous and current values if value changed
  132740. */
  132741. value?: IWebXRMotionControllerComponentChangesValues<number>;
  132742. }
  132743. /**
  132744. * This class represents a single component (for example button or thumbstick) of a motion controller
  132745. */
  132746. export class WebXRControllerComponent implements IDisposable {
  132747. /**
  132748. * the id of this component
  132749. */
  132750. id: string;
  132751. /**
  132752. * the type of the component
  132753. */
  132754. type: MotionControllerComponentType;
  132755. private _buttonIndex;
  132756. private _axesIndices;
  132757. private _axes;
  132758. private _changes;
  132759. private _currentValue;
  132760. private _hasChanges;
  132761. private _pressed;
  132762. private _touched;
  132763. /**
  132764. * button component type
  132765. */
  132766. static BUTTON_TYPE: MotionControllerComponentType;
  132767. /**
  132768. * squeeze component type
  132769. */
  132770. static SQUEEZE_TYPE: MotionControllerComponentType;
  132771. /**
  132772. * Thumbstick component type
  132773. */
  132774. static THUMBSTICK_TYPE: MotionControllerComponentType;
  132775. /**
  132776. * Touchpad component type
  132777. */
  132778. static TOUCHPAD_TYPE: MotionControllerComponentType;
  132779. /**
  132780. * trigger component type
  132781. */
  132782. static TRIGGER_TYPE: MotionControllerComponentType;
  132783. /**
  132784. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  132785. * the axes data changes
  132786. */
  132787. onAxisValueChangedObservable: Observable<{
  132788. x: number;
  132789. y: number;
  132790. }>;
  132791. /**
  132792. * Observers registered here will be triggered when the state of a button changes
  132793. * State change is either pressed / touched / value
  132794. */
  132795. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132796. /**
  132797. * Creates a new component for a motion controller.
  132798. * It is created by the motion controller itself
  132799. *
  132800. * @param id the id of this component
  132801. * @param type the type of the component
  132802. * @param _buttonIndex index in the buttons array of the gamepad
  132803. * @param _axesIndices indices of the values in the axes array of the gamepad
  132804. */
  132805. constructor(
  132806. /**
  132807. * the id of this component
  132808. */
  132809. id: string,
  132810. /**
  132811. * the type of the component
  132812. */
  132813. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132814. /**
  132815. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132816. */
  132817. get axes(): IWebXRMotionControllerAxesValue;
  132818. /**
  132819. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132820. */
  132821. get changes(): IWebXRMotionControllerComponentChanges;
  132822. /**
  132823. * Return whether or not the component changed the last frame
  132824. */
  132825. get hasChanges(): boolean;
  132826. /**
  132827. * is the button currently pressed
  132828. */
  132829. get pressed(): boolean;
  132830. /**
  132831. * is the button currently touched
  132832. */
  132833. get touched(): boolean;
  132834. /**
  132835. * Get the current value of this component
  132836. */
  132837. get value(): number;
  132838. /**
  132839. * Dispose this component
  132840. */
  132841. dispose(): void;
  132842. /**
  132843. * Are there axes correlating to this component
  132844. * @return true is axes data is available
  132845. */
  132846. isAxes(): boolean;
  132847. /**
  132848. * Is this component a button (hence - pressable)
  132849. * @returns true if can be pressed
  132850. */
  132851. isButton(): boolean;
  132852. /**
  132853. * update this component using the gamepad object it is in. Called on every frame
  132854. * @param nativeController the native gamepad controller object
  132855. */
  132856. update(nativeController: IMinimalMotionControllerObject): void;
  132857. }
  132858. }
  132859. declare module BABYLON {
  132860. /**
  132861. * Type used for the success callback of ImportMesh
  132862. */
  132863. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  132864. /**
  132865. * Interface used for the result of ImportMeshAsync
  132866. */
  132867. export interface ISceneLoaderAsyncResult {
  132868. /**
  132869. * The array of loaded meshes
  132870. */
  132871. readonly meshes: AbstractMesh[];
  132872. /**
  132873. * The array of loaded particle systems
  132874. */
  132875. readonly particleSystems: IParticleSystem[];
  132876. /**
  132877. * The array of loaded skeletons
  132878. */
  132879. readonly skeletons: Skeleton[];
  132880. /**
  132881. * The array of loaded animation groups
  132882. */
  132883. readonly animationGroups: AnimationGroup[];
  132884. /**
  132885. * The array of loaded transform nodes
  132886. */
  132887. readonly transformNodes: TransformNode[];
  132888. /**
  132889. * The array of loaded geometries
  132890. */
  132891. readonly geometries: Geometry[];
  132892. /**
  132893. * The array of loaded lights
  132894. */
  132895. readonly lights: Light[];
  132896. }
  132897. /**
  132898. * Interface used to represent data loading progression
  132899. */
  132900. export interface ISceneLoaderProgressEvent {
  132901. /**
  132902. * Defines if data length to load can be evaluated
  132903. */
  132904. readonly lengthComputable: boolean;
  132905. /**
  132906. * Defines the loaded data length
  132907. */
  132908. readonly loaded: number;
  132909. /**
  132910. * Defines the data length to load
  132911. */
  132912. readonly total: number;
  132913. }
  132914. /**
  132915. * Interface used by SceneLoader plugins to define supported file extensions
  132916. */
  132917. export interface ISceneLoaderPluginExtensions {
  132918. /**
  132919. * Defines the list of supported extensions
  132920. */
  132921. [extension: string]: {
  132922. isBinary: boolean;
  132923. };
  132924. }
  132925. /**
  132926. * Interface used by SceneLoader plugin factory
  132927. */
  132928. export interface ISceneLoaderPluginFactory {
  132929. /**
  132930. * Defines the name of the factory
  132931. */
  132932. name: string;
  132933. /**
  132934. * Function called to create a new plugin
  132935. * @return the new plugin
  132936. */
  132937. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132938. /**
  132939. * The callback that returns true if the data can be directly loaded.
  132940. * @param data string containing the file data
  132941. * @returns if the data can be loaded directly
  132942. */
  132943. canDirectLoad?(data: string): boolean;
  132944. }
  132945. /**
  132946. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132947. */
  132948. export interface ISceneLoaderPluginBase {
  132949. /**
  132950. * The friendly name of this plugin.
  132951. */
  132952. name: string;
  132953. /**
  132954. * The file extensions supported by this plugin.
  132955. */
  132956. extensions: string | ISceneLoaderPluginExtensions;
  132957. /**
  132958. * The callback called when loading from a url.
  132959. * @param scene scene loading this url
  132960. * @param url url to load
  132961. * @param onSuccess callback called when the file successfully loads
  132962. * @param onProgress callback called while file is loading (if the server supports this mode)
  132963. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132964. * @param onError callback called when the file fails to load
  132965. * @returns a file request object
  132966. */
  132967. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132968. /**
  132969. * The callback called when loading from a file object.
  132970. * @param scene scene loading this file
  132971. * @param file defines the file to load
  132972. * @param onSuccess defines the callback to call when data is loaded
  132973. * @param onProgress defines the callback to call during loading process
  132974. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132975. * @param onError defines the callback to call when an error occurs
  132976. * @returns a file request object
  132977. */
  132978. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132979. /**
  132980. * The callback that returns true if the data can be directly loaded.
  132981. * @param data string containing the file data
  132982. * @returns if the data can be loaded directly
  132983. */
  132984. canDirectLoad?(data: string): boolean;
  132985. /**
  132986. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132987. * @param scene scene loading this data
  132988. * @param data string containing the data
  132989. * @returns data to pass to the plugin
  132990. */
  132991. directLoad?(scene: Scene, data: string): any;
  132992. /**
  132993. * The callback that allows custom handling of the root url based on the response url.
  132994. * @param rootUrl the original root url
  132995. * @param responseURL the response url if available
  132996. * @returns the new root url
  132997. */
  132998. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132999. }
  133000. /**
  133001. * Interface used to define a SceneLoader plugin
  133002. */
  133003. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  133004. /**
  133005. * Import meshes into a scene.
  133006. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133007. * @param scene The scene to import into
  133008. * @param data The data to import
  133009. * @param rootUrl The root url for scene and resources
  133010. * @param meshes The meshes array to import into
  133011. * @param particleSystems The particle systems array to import into
  133012. * @param skeletons The skeletons array to import into
  133013. * @param onError The callback when import fails
  133014. * @returns True if successful or false otherwise
  133015. */
  133016. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  133017. /**
  133018. * Load into a scene.
  133019. * @param scene The scene to load into
  133020. * @param data The data to import
  133021. * @param rootUrl The root url for scene and resources
  133022. * @param onError The callback when import fails
  133023. * @returns True if successful or false otherwise
  133024. */
  133025. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  133026. /**
  133027. * Load into an asset container.
  133028. * @param scene The scene to load into
  133029. * @param data The data to import
  133030. * @param rootUrl The root url for scene and resources
  133031. * @param onError The callback when import fails
  133032. * @returns The loaded asset container
  133033. */
  133034. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  133035. }
  133036. /**
  133037. * Interface used to define an async SceneLoader plugin
  133038. */
  133039. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  133040. /**
  133041. * Import meshes into a scene.
  133042. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133043. * @param scene The scene to import into
  133044. * @param data The data to import
  133045. * @param rootUrl The root url for scene and resources
  133046. * @param onProgress The callback when the load progresses
  133047. * @param fileName Defines the name of the file to load
  133048. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  133049. */
  133050. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  133051. /**
  133052. * Load into a scene.
  133053. * @param scene The scene to load into
  133054. * @param data The data to import
  133055. * @param rootUrl The root url for scene and resources
  133056. * @param onProgress The callback when the load progresses
  133057. * @param fileName Defines the name of the file to load
  133058. * @returns Nothing
  133059. */
  133060. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  133061. /**
  133062. * Load into an asset container.
  133063. * @param scene The scene to load into
  133064. * @param data The data to import
  133065. * @param rootUrl The root url for scene and resources
  133066. * @param onProgress The callback when the load progresses
  133067. * @param fileName Defines the name of the file to load
  133068. * @returns The loaded asset container
  133069. */
  133070. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  133071. }
  133072. /**
  133073. * Mode that determines how to handle old animation groups before loading new ones.
  133074. */
  133075. export enum SceneLoaderAnimationGroupLoadingMode {
  133076. /**
  133077. * Reset all old animations to initial state then dispose them.
  133078. */
  133079. Clean = 0,
  133080. /**
  133081. * Stop all old animations.
  133082. */
  133083. Stop = 1,
  133084. /**
  133085. * Restart old animations from first frame.
  133086. */
  133087. Sync = 2,
  133088. /**
  133089. * Old animations remains untouched.
  133090. */
  133091. NoSync = 3
  133092. }
  133093. /**
  133094. * Defines a plugin registered by the SceneLoader
  133095. */
  133096. interface IRegisteredPlugin {
  133097. /**
  133098. * Defines the plugin to use
  133099. */
  133100. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  133101. /**
  133102. * Defines if the plugin supports binary data
  133103. */
  133104. isBinary: boolean;
  133105. }
  133106. /**
  133107. * Class used to load scene from various file formats using registered plugins
  133108. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  133109. */
  133110. export class SceneLoader {
  133111. /**
  133112. * No logging while loading
  133113. */
  133114. static readonly NO_LOGGING: number;
  133115. /**
  133116. * Minimal logging while loading
  133117. */
  133118. static readonly MINIMAL_LOGGING: number;
  133119. /**
  133120. * Summary logging while loading
  133121. */
  133122. static readonly SUMMARY_LOGGING: number;
  133123. /**
  133124. * Detailled logging while loading
  133125. */
  133126. static readonly DETAILED_LOGGING: number;
  133127. /**
  133128. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  133129. */
  133130. static get ForceFullSceneLoadingForIncremental(): boolean;
  133131. static set ForceFullSceneLoadingForIncremental(value: boolean);
  133132. /**
  133133. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  133134. */
  133135. static get ShowLoadingScreen(): boolean;
  133136. static set ShowLoadingScreen(value: boolean);
  133137. /**
  133138. * Defines the current logging level (while loading the scene)
  133139. * @ignorenaming
  133140. */
  133141. static get loggingLevel(): number;
  133142. static set loggingLevel(value: number);
  133143. /**
  133144. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  133145. */
  133146. static get CleanBoneMatrixWeights(): boolean;
  133147. static set CleanBoneMatrixWeights(value: boolean);
  133148. /**
  133149. * Event raised when a plugin is used to load a scene
  133150. */
  133151. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  133152. private static _registeredPlugins;
  133153. private static _showingLoadingScreen;
  133154. /**
  133155. * Gets the default plugin (used to load Babylon files)
  133156. * @returns the .babylon plugin
  133157. */
  133158. static GetDefaultPlugin(): IRegisteredPlugin;
  133159. private static _GetPluginForExtension;
  133160. private static _GetPluginForDirectLoad;
  133161. private static _GetPluginForFilename;
  133162. private static _GetDirectLoad;
  133163. private static _LoadData;
  133164. private static _GetFileInfo;
  133165. /**
  133166. * Gets a plugin that can load the given extension
  133167. * @param extension defines the extension to load
  133168. * @returns a plugin or null if none works
  133169. */
  133170. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  133171. /**
  133172. * Gets a boolean indicating that the given extension can be loaded
  133173. * @param extension defines the extension to load
  133174. * @returns true if the extension is supported
  133175. */
  133176. static IsPluginForExtensionAvailable(extension: string): boolean;
  133177. /**
  133178. * Adds a new plugin to the list of registered plugins
  133179. * @param plugin defines the plugin to add
  133180. */
  133181. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  133182. /**
  133183. * Import meshes into a scene
  133184. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133185. * @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)
  133186. * @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)
  133187. * @param scene the instance of BABYLON.Scene to append to
  133188. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  133189. * @param onProgress a callback with a progress event for each file being loaded
  133190. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133191. * @param pluginExtension the extension used to determine the plugin
  133192. * @returns The loaded plugin
  133193. */
  133194. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<SceneLoaderSuccessCallback>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  133195. /**
  133196. * Import meshes into a scene
  133197. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  133198. * @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)
  133199. * @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)
  133200. * @param scene the instance of BABYLON.Scene to append to
  133201. * @param onProgress a callback with a progress event for each file being loaded
  133202. * @param pluginExtension the extension used to determine the plugin
  133203. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  133204. */
  133205. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  133206. /**
  133207. * Load a scene
  133208. * @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)
  133209. * @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)
  133210. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133211. * @param onSuccess a callback with the scene when import succeeds
  133212. * @param onProgress a callback with a progress event for each file being loaded
  133213. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133214. * @param pluginExtension the extension used to determine the plugin
  133215. * @returns The loaded plugin
  133216. */
  133217. 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>;
  133218. /**
  133219. * Load a scene
  133220. * @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)
  133221. * @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)
  133222. * @param engine is the instance of BABYLON.Engine to use to create the scene
  133223. * @param onProgress a callback with a progress event for each file being loaded
  133224. * @param pluginExtension the extension used to determine the plugin
  133225. * @returns The loaded scene
  133226. */
  133227. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133228. /**
  133229. * Append a scene
  133230. * @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)
  133231. * @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)
  133232. * @param scene is the instance of BABYLON.Scene to append to
  133233. * @param onSuccess a callback with the scene when import succeeds
  133234. * @param onProgress a callback with a progress event for each file being loaded
  133235. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133236. * @param pluginExtension the extension used to determine the plugin
  133237. * @returns The loaded plugin
  133238. */
  133239. 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>;
  133240. /**
  133241. * Append a scene
  133242. * @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)
  133243. * @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)
  133244. * @param scene is the instance of BABYLON.Scene to append to
  133245. * @param onProgress a callback with a progress event for each file being loaded
  133246. * @param pluginExtension the extension used to determine the plugin
  133247. * @returns The given scene
  133248. */
  133249. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  133250. /**
  133251. * Load a scene into an asset container
  133252. * @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)
  133253. * @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)
  133254. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133255. * @param onSuccess a callback with the scene when import succeeds
  133256. * @param onProgress a callback with a progress event for each file being loaded
  133257. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133258. * @param pluginExtension the extension used to determine the plugin
  133259. * @returns The loaded plugin
  133260. */
  133261. 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>;
  133262. /**
  133263. * Load a scene into an asset container
  133264. * @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)
  133265. * @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)
  133266. * @param scene is the instance of Scene to append to
  133267. * @param onProgress a callback with a progress event for each file being loaded
  133268. * @param pluginExtension the extension used to determine the plugin
  133269. * @returns The loaded asset container
  133270. */
  133271. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  133272. /**
  133273. * Import animations from a file into a scene
  133274. * @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)
  133275. * @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)
  133276. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133277. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133278. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133279. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133280. * @param onSuccess a callback with the scene when import succeeds
  133281. * @param onProgress a callback with a progress event for each file being loaded
  133282. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133283. * @param pluginExtension the extension used to determine the plugin
  133284. */
  133285. 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;
  133286. /**
  133287. * Import animations from a file into a scene
  133288. * @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)
  133289. * @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)
  133290. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  133291. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  133292. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  133293. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  133294. * @param onSuccess a callback with the scene when import succeeds
  133295. * @param onProgress a callback with a progress event for each file being loaded
  133296. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  133297. * @param pluginExtension the extension used to determine the plugin
  133298. * @returns the updated scene with imported animations
  133299. */
  133300. 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>;
  133301. }
  133302. }
  133303. declare module BABYLON {
  133304. /**
  133305. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  133306. */
  133307. export type MotionControllerHandedness = "none" | "left" | "right";
  133308. /**
  133309. * The type of components available in motion controllers.
  133310. * This is not the name of the component.
  133311. */
  133312. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  133313. /**
  133314. * The state of a controller component
  133315. */
  133316. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  133317. /**
  133318. * The schema of motion controller layout.
  133319. * No object will be initialized using this interface
  133320. * This is used just to define the profile.
  133321. */
  133322. export interface IMotionControllerLayout {
  133323. /**
  133324. * Path to load the assets. Usually relative to the base path
  133325. */
  133326. assetPath: string;
  133327. /**
  133328. * Available components (unsorted)
  133329. */
  133330. components: {
  133331. /**
  133332. * A map of component Ids
  133333. */
  133334. [componentId: string]: {
  133335. /**
  133336. * The type of input the component outputs
  133337. */
  133338. type: MotionControllerComponentType;
  133339. /**
  133340. * The indices of this component in the gamepad object
  133341. */
  133342. gamepadIndices: {
  133343. /**
  133344. * Index of button
  133345. */
  133346. button?: number;
  133347. /**
  133348. * If available, index of x-axis
  133349. */
  133350. xAxis?: number;
  133351. /**
  133352. * If available, index of y-axis
  133353. */
  133354. yAxis?: number;
  133355. };
  133356. /**
  133357. * The mesh's root node name
  133358. */
  133359. rootNodeName: string;
  133360. /**
  133361. * Animation definitions for this model
  133362. */
  133363. visualResponses: {
  133364. [stateKey: string]: {
  133365. /**
  133366. * What property will be animated
  133367. */
  133368. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  133369. /**
  133370. * What states influence this visual response
  133371. */
  133372. states: MotionControllerComponentStateType[];
  133373. /**
  133374. * Type of animation - movement or visibility
  133375. */
  133376. valueNodeProperty: "transform" | "visibility";
  133377. /**
  133378. * Base node name to move. Its position will be calculated according to the min and max nodes
  133379. */
  133380. valueNodeName?: string;
  133381. /**
  133382. * Minimum movement node
  133383. */
  133384. minNodeName?: string;
  133385. /**
  133386. * Max movement node
  133387. */
  133388. maxNodeName?: string;
  133389. };
  133390. };
  133391. /**
  133392. * If touch enabled, what is the name of node to display user feedback
  133393. */
  133394. touchPointNodeName?: string;
  133395. };
  133396. };
  133397. /**
  133398. * Is it xr standard mapping or not
  133399. */
  133400. gamepadMapping: "" | "xr-standard";
  133401. /**
  133402. * Base root node of this entire model
  133403. */
  133404. rootNodeName: string;
  133405. /**
  133406. * Defines the main button component id
  133407. */
  133408. selectComponentId: string;
  133409. }
  133410. /**
  133411. * A definition for the layout map in the input profile
  133412. */
  133413. export interface IMotionControllerLayoutMap {
  133414. /**
  133415. * Layouts with handedness type as a key
  133416. */
  133417. [handedness: string]: IMotionControllerLayout;
  133418. }
  133419. /**
  133420. * The XR Input profile schema
  133421. * Profiles can be found here:
  133422. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  133423. */
  133424. export interface IMotionControllerProfile {
  133425. /**
  133426. * fallback profiles for this profileId
  133427. */
  133428. fallbackProfileIds: string[];
  133429. /**
  133430. * The layout map, with handedness as key
  133431. */
  133432. layouts: IMotionControllerLayoutMap;
  133433. /**
  133434. * The id of this profile
  133435. * correlates to the profile(s) in the xrInput.profiles array
  133436. */
  133437. profileId: string;
  133438. }
  133439. /**
  133440. * A helper-interface for the 3 meshes needed for controller button animation
  133441. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  133442. */
  133443. export interface IMotionControllerButtonMeshMap {
  133444. /**
  133445. * the mesh that defines the pressed value mesh position.
  133446. * This is used to find the max-position of this button
  133447. */
  133448. pressedMesh: AbstractMesh;
  133449. /**
  133450. * the mesh that defines the unpressed value mesh position.
  133451. * This is used to find the min (or initial) position of this button
  133452. */
  133453. unpressedMesh: AbstractMesh;
  133454. /**
  133455. * The mesh that will be changed when value changes
  133456. */
  133457. valueMesh: AbstractMesh;
  133458. }
  133459. /**
  133460. * A helper-interface for the 3 meshes needed for controller axis animation.
  133461. * This will be expanded when touchpad animations are fully supported
  133462. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  133463. */
  133464. export interface IMotionControllerMeshMap {
  133465. /**
  133466. * the mesh that defines the maximum value mesh position.
  133467. */
  133468. maxMesh?: AbstractMesh;
  133469. /**
  133470. * the mesh that defines the minimum value mesh position.
  133471. */
  133472. minMesh?: AbstractMesh;
  133473. /**
  133474. * The mesh that will be changed when axis value changes
  133475. */
  133476. valueMesh?: AbstractMesh;
  133477. }
  133478. /**
  133479. * The elements needed for change-detection of the gamepad objects in motion controllers
  133480. */
  133481. export interface IMinimalMotionControllerObject {
  133482. /**
  133483. * Available axes of this controller
  133484. */
  133485. axes: number[];
  133486. /**
  133487. * An array of available buttons
  133488. */
  133489. buttons: Array<{
  133490. /**
  133491. * Value of the button/trigger
  133492. */
  133493. value: number;
  133494. /**
  133495. * If the button/trigger is currently touched
  133496. */
  133497. touched: boolean;
  133498. /**
  133499. * If the button/trigger is currently pressed
  133500. */
  133501. pressed: boolean;
  133502. }>;
  133503. /**
  133504. * EXPERIMENTAL haptic support.
  133505. */
  133506. hapticActuators?: Array<{
  133507. pulse: (value: number, duration: number) => Promise<boolean>;
  133508. }>;
  133509. }
  133510. /**
  133511. * An Abstract Motion controller
  133512. * This class receives an xrInput and a profile layout and uses those to initialize the components
  133513. * Each component has an observable to check for changes in value and state
  133514. */
  133515. export abstract class WebXRAbstractMotionController implements IDisposable {
  133516. protected scene: Scene;
  133517. protected layout: IMotionControllerLayout;
  133518. /**
  133519. * The gamepad object correlating to this controller
  133520. */
  133521. gamepadObject: IMinimalMotionControllerObject;
  133522. /**
  133523. * handedness (left/right/none) of this controller
  133524. */
  133525. handedness: MotionControllerHandedness;
  133526. private _initComponent;
  133527. private _modelReady;
  133528. /**
  133529. * A map of components (WebXRControllerComponent) in this motion controller
  133530. * Components have a ComponentType and can also have both button and axis definitions
  133531. */
  133532. readonly components: {
  133533. [id: string]: WebXRControllerComponent;
  133534. };
  133535. /**
  133536. * Disable the model's animation. Can be set at any time.
  133537. */
  133538. disableAnimation: boolean;
  133539. /**
  133540. * Observers registered here will be triggered when the model of this controller is done loading
  133541. */
  133542. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  133543. /**
  133544. * The profile id of this motion controller
  133545. */
  133546. abstract profileId: string;
  133547. /**
  133548. * The root mesh of the model. It is null if the model was not yet initialized
  133549. */
  133550. rootMesh: Nullable<AbstractMesh>;
  133551. /**
  133552. * constructs a new abstract motion controller
  133553. * @param scene the scene to which the model of the controller will be added
  133554. * @param layout The profile layout to load
  133555. * @param gamepadObject The gamepad object correlating to this controller
  133556. * @param handedness handedness (left/right/none) of this controller
  133557. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  133558. */
  133559. constructor(scene: Scene, layout: IMotionControllerLayout,
  133560. /**
  133561. * The gamepad object correlating to this controller
  133562. */
  133563. gamepadObject: IMinimalMotionControllerObject,
  133564. /**
  133565. * handedness (left/right/none) of this controller
  133566. */
  133567. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  133568. /**
  133569. * Dispose this controller, the model mesh and all its components
  133570. */
  133571. dispose(): void;
  133572. /**
  133573. * Returns all components of specific type
  133574. * @param type the type to search for
  133575. * @return an array of components with this type
  133576. */
  133577. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  133578. /**
  133579. * get a component based an its component id as defined in layout.components
  133580. * @param id the id of the component
  133581. * @returns the component correlates to the id or undefined if not found
  133582. */
  133583. getComponent(id: string): WebXRControllerComponent;
  133584. /**
  133585. * Get the list of components available in this motion controller
  133586. * @returns an array of strings correlating to available components
  133587. */
  133588. getComponentIds(): string[];
  133589. /**
  133590. * Get the first component of specific type
  133591. * @param type type of component to find
  133592. * @return a controller component or null if not found
  133593. */
  133594. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  133595. /**
  133596. * Get the main (Select) component of this controller as defined in the layout
  133597. * @returns the main component of this controller
  133598. */
  133599. getMainComponent(): WebXRControllerComponent;
  133600. /**
  133601. * Loads the model correlating to this controller
  133602. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  133603. * @returns A promise fulfilled with the result of the model loading
  133604. */
  133605. loadModel(): Promise<boolean>;
  133606. /**
  133607. * Update this model using the current XRFrame
  133608. * @param xrFrame the current xr frame to use and update the model
  133609. */
  133610. updateFromXRFrame(xrFrame: XRFrame): void;
  133611. /**
  133612. * Backwards compatibility due to a deeply-integrated typo
  133613. */
  133614. get handness(): XREye;
  133615. /**
  133616. * Pulse (vibrate) this controller
  133617. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  133618. * Consecutive calls to this function will cancel the last pulse call
  133619. *
  133620. * @param value the strength of the pulse in 0.0...1.0 range
  133621. * @param duration Duration of the pulse in milliseconds
  133622. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  133623. * @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
  133624. */
  133625. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  133626. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133627. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  133628. /**
  133629. * Moves the axis on the controller mesh based on its current state
  133630. * @param axis the index of the axis
  133631. * @param axisValue the value of the axis which determines the meshes new position
  133632. * @hidden
  133633. */
  133634. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  133635. /**
  133636. * Update the model itself with the current frame data
  133637. * @param xrFrame the frame to use for updating the model mesh
  133638. */
  133639. protected updateModel(xrFrame: XRFrame): void;
  133640. /**
  133641. * Get the filename and path for this controller's model
  133642. * @returns a map of filename and path
  133643. */
  133644. protected abstract _getFilenameAndPath(): {
  133645. filename: string;
  133646. path: string;
  133647. };
  133648. /**
  133649. * This function is called before the mesh is loaded. It checks for loading constraints.
  133650. * For example, this function can check if the GLB loader is available
  133651. * If this function returns false, the generic controller will be loaded instead
  133652. * @returns Is the client ready to load the mesh
  133653. */
  133654. protected abstract _getModelLoadingConstraints(): boolean;
  133655. /**
  133656. * This function will be called after the model was successfully loaded and can be used
  133657. * for mesh transformations before it is available for the user
  133658. * @param meshes the loaded meshes
  133659. */
  133660. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  133661. /**
  133662. * Set the root mesh for this controller. Important for the WebXR controller class
  133663. * @param meshes the loaded meshes
  133664. */
  133665. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  133666. /**
  133667. * A function executed each frame that updates the mesh (if needed)
  133668. * @param xrFrame the current xrFrame
  133669. */
  133670. protected abstract _updateModel(xrFrame: XRFrame): void;
  133671. private _getGenericFilenameAndPath;
  133672. private _getGenericParentMesh;
  133673. }
  133674. }
  133675. declare module BABYLON {
  133676. /**
  133677. * A generic trigger-only motion controller for WebXR
  133678. */
  133679. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  133680. /**
  133681. * Static version of the profile id of this controller
  133682. */
  133683. static ProfileId: string;
  133684. profileId: string;
  133685. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  133686. protected _getFilenameAndPath(): {
  133687. filename: string;
  133688. path: string;
  133689. };
  133690. protected _getModelLoadingConstraints(): boolean;
  133691. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  133692. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133693. protected _updateModel(): void;
  133694. }
  133695. }
  133696. declare module BABYLON {
  133697. /**
  133698. * Class containing static functions to help procedurally build meshes
  133699. */
  133700. export class SphereBuilder {
  133701. /**
  133702. * Creates a sphere mesh
  133703. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  133704. * * 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`)
  133705. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  133706. * * 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
  133707. * * 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)
  133708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133709. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133711. * @param name defines the name of the mesh
  133712. * @param options defines the options used to create the mesh
  133713. * @param scene defines the hosting scene
  133714. * @returns the sphere mesh
  133715. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  133716. */
  133717. static CreateSphere(name: string, options: {
  133718. segments?: number;
  133719. diameter?: number;
  133720. diameterX?: number;
  133721. diameterY?: number;
  133722. diameterZ?: number;
  133723. arc?: number;
  133724. slice?: number;
  133725. sideOrientation?: number;
  133726. frontUVs?: Vector4;
  133727. backUVs?: Vector4;
  133728. updatable?: boolean;
  133729. }, scene?: Nullable<Scene>): Mesh;
  133730. }
  133731. }
  133732. declare module BABYLON {
  133733. /**
  133734. * A profiled motion controller has its profile loaded from an online repository.
  133735. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  133736. */
  133737. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  133738. private _repositoryUrl;
  133739. private _buttonMeshMapping;
  133740. private _touchDots;
  133741. /**
  133742. * The profile ID of this controller. Will be populated when the controller initializes.
  133743. */
  133744. profileId: string;
  133745. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  133746. dispose(): void;
  133747. protected _getFilenameAndPath(): {
  133748. filename: string;
  133749. path: string;
  133750. };
  133751. protected _getModelLoadingConstraints(): boolean;
  133752. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  133753. protected _setRootMesh(meshes: AbstractMesh[]): void;
  133754. protected _updateModel(_xrFrame: XRFrame): void;
  133755. }
  133756. }
  133757. declare module BABYLON {
  133758. /**
  133759. * A construction function type to create a new controller based on an xrInput object
  133760. */
  133761. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  133762. /**
  133763. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  133764. *
  133765. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  133766. * it should be replaced with auto-loaded controllers.
  133767. *
  133768. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  133769. */
  133770. export class WebXRMotionControllerManager {
  133771. private static _AvailableControllers;
  133772. private static _Fallbacks;
  133773. private static _ProfileLoadingPromises;
  133774. private static _ProfilesList;
  133775. /**
  133776. * The base URL of the online controller repository. Can be changed at any time.
  133777. */
  133778. static BaseRepositoryUrl: string;
  133779. /**
  133780. * Which repository gets priority - local or online
  133781. */
  133782. static PrioritizeOnlineRepository: boolean;
  133783. /**
  133784. * Use the online repository, or use only locally-defined controllers
  133785. */
  133786. static UseOnlineRepository: boolean;
  133787. /**
  133788. * Clear the cache used for profile loading and reload when requested again
  133789. */
  133790. static ClearProfilesCache(): void;
  133791. /**
  133792. * Register the default fallbacks.
  133793. * This function is called automatically when this file is imported.
  133794. */
  133795. static DefaultFallbacks(): void;
  133796. /**
  133797. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  133798. * @param profileId the profile to which a fallback needs to be found
  133799. * @return an array with corresponding fallback profiles
  133800. */
  133801. static FindFallbackWithProfileId(profileId: string): string[];
  133802. /**
  133803. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  133804. * The order of search:
  133805. *
  133806. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  133807. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  133808. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  133809. * 4) return the generic trigger controller if none were found
  133810. *
  133811. * @param xrInput the xrInput to which a new controller is initialized
  133812. * @param scene the scene to which the model will be added
  133813. * @param forceProfile force a certain profile for this controller
  133814. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  133815. */
  133816. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  133817. /**
  133818. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  133819. *
  133820. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  133821. *
  133822. * @param type the profile type to register
  133823. * @param constructFunction the function to be called when loading this profile
  133824. */
  133825. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133826. /**
  133827. * Register a fallback to a specific profile.
  133828. * @param profileId the profileId that will receive the fallbacks
  133829. * @param fallbacks A list of fallback profiles
  133830. */
  133831. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133832. /**
  133833. * Will update the list of profiles available in the repository
  133834. * @return a promise that resolves to a map of profiles available online
  133835. */
  133836. static UpdateProfilesList(): Promise<{
  133837. [profile: string]: string;
  133838. }>;
  133839. private static _LoadProfileFromRepository;
  133840. private static _LoadProfilesFromAvailableControllers;
  133841. }
  133842. }
  133843. declare module BABYLON {
  133844. /**
  133845. * Configuration options for the WebXR controller creation
  133846. */
  133847. export interface IWebXRControllerOptions {
  133848. /**
  133849. * Should the controller mesh be animated when a user interacts with it
  133850. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133851. */
  133852. disableMotionControllerAnimation?: boolean;
  133853. /**
  133854. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133855. */
  133856. doNotLoadControllerMesh?: boolean;
  133857. /**
  133858. * Force a specific controller type for this controller.
  133859. * This can be used when creating your own profile or when testing different controllers
  133860. */
  133861. forceControllerProfile?: string;
  133862. /**
  133863. * Defines a rendering group ID for meshes that will be loaded.
  133864. * This is for the default controllers only.
  133865. */
  133866. renderingGroupId?: number;
  133867. }
  133868. /**
  133869. * Represents an XR controller
  133870. */
  133871. export class WebXRInputSource {
  133872. private _scene;
  133873. /** The underlying input source for the controller */
  133874. inputSource: XRInputSource;
  133875. private _options;
  133876. private _tmpVector;
  133877. private _uniqueId;
  133878. private _disposed;
  133879. /**
  133880. * 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
  133881. */
  133882. grip?: AbstractMesh;
  133883. /**
  133884. * If available, this is the gamepad object related to this controller.
  133885. * Using this object it is possible to get click events and trackpad changes of the
  133886. * webxr controller that is currently being used.
  133887. */
  133888. motionController?: WebXRAbstractMotionController;
  133889. /**
  133890. * Event that fires when the controller is removed/disposed.
  133891. * The object provided as event data is this controller, after associated assets were disposed.
  133892. * uniqueId is still available.
  133893. */
  133894. onDisposeObservable: Observable<WebXRInputSource>;
  133895. /**
  133896. * Will be triggered when the mesh associated with the motion controller is done loading.
  133897. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133898. * A shortened version of controller -> motion controller -> on mesh loaded.
  133899. */
  133900. onMeshLoadedObservable: Observable<AbstractMesh>;
  133901. /**
  133902. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133903. */
  133904. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133905. /**
  133906. * Pointer which can be used to select objects or attach a visible laser to
  133907. */
  133908. pointer: AbstractMesh;
  133909. /**
  133910. * Creates the input source object
  133911. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133912. * @param _scene the scene which the controller should be associated to
  133913. * @param inputSource the underlying input source for the controller
  133914. * @param _options options for this controller creation
  133915. */
  133916. constructor(_scene: Scene,
  133917. /** The underlying input source for the controller */
  133918. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133919. /**
  133920. * Get this controllers unique id
  133921. */
  133922. get uniqueId(): string;
  133923. /**
  133924. * Disposes of the object
  133925. */
  133926. dispose(): void;
  133927. /**
  133928. * Gets a world space ray coming from the pointer or grip
  133929. * @param result the resulting ray
  133930. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133931. */
  133932. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133933. /**
  133934. * Updates the controller pose based on the given XRFrame
  133935. * @param xrFrame xr frame to update the pose with
  133936. * @param referenceSpace reference space to use
  133937. */
  133938. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133939. }
  133940. }
  133941. declare module BABYLON {
  133942. /**
  133943. * The schema for initialization options of the XR Input class
  133944. */
  133945. export interface IWebXRInputOptions {
  133946. /**
  133947. * If set to true no model will be automatically loaded
  133948. */
  133949. doNotLoadControllerMeshes?: boolean;
  133950. /**
  133951. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133952. * If not found, the xr input profile data will be used.
  133953. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133954. */
  133955. forceInputProfile?: string;
  133956. /**
  133957. * Do not send a request to the controller repository to load the profile.
  133958. *
  133959. * Instead, use the controllers available in babylon itself.
  133960. */
  133961. disableOnlineControllerRepository?: boolean;
  133962. /**
  133963. * A custom URL for the controllers repository
  133964. */
  133965. customControllersRepositoryURL?: string;
  133966. /**
  133967. * Should the controller model's components not move according to the user input
  133968. */
  133969. disableControllerAnimation?: boolean;
  133970. /**
  133971. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133972. */
  133973. controllerOptions?: IWebXRControllerOptions;
  133974. }
  133975. /**
  133976. * XR input used to track XR inputs such as controllers/rays
  133977. */
  133978. export class WebXRInput implements IDisposable {
  133979. /**
  133980. * the xr session manager for this session
  133981. */
  133982. xrSessionManager: WebXRSessionManager;
  133983. /**
  133984. * the WebXR camera for this session. Mainly used for teleportation
  133985. */
  133986. xrCamera: WebXRCamera;
  133987. private readonly options;
  133988. /**
  133989. * XR controllers being tracked
  133990. */
  133991. controllers: Array<WebXRInputSource>;
  133992. private _frameObserver;
  133993. private _sessionEndedObserver;
  133994. private _sessionInitObserver;
  133995. /**
  133996. * Event when a controller has been connected/added
  133997. */
  133998. onControllerAddedObservable: Observable<WebXRInputSource>;
  133999. /**
  134000. * Event when a controller has been removed/disconnected
  134001. */
  134002. onControllerRemovedObservable: Observable<WebXRInputSource>;
  134003. /**
  134004. * Initializes the WebXRInput
  134005. * @param xrSessionManager the xr session manager for this session
  134006. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  134007. * @param options = initialization options for this xr input
  134008. */
  134009. constructor(
  134010. /**
  134011. * the xr session manager for this session
  134012. */
  134013. xrSessionManager: WebXRSessionManager,
  134014. /**
  134015. * the WebXR camera for this session. Mainly used for teleportation
  134016. */
  134017. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  134018. private _onInputSourcesChange;
  134019. private _addAndRemoveControllers;
  134020. /**
  134021. * Disposes of the object
  134022. */
  134023. dispose(): void;
  134024. }
  134025. }
  134026. declare module BABYLON {
  134027. /**
  134028. * This is the base class for all WebXR features.
  134029. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  134030. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  134031. */
  134032. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  134033. protected _xrSessionManager: WebXRSessionManager;
  134034. private _attached;
  134035. private _removeOnDetach;
  134036. /**
  134037. * Is this feature disposed?
  134038. */
  134039. isDisposed: boolean;
  134040. /**
  134041. * Should auto-attach be disabled?
  134042. */
  134043. disableAutoAttach: boolean;
  134044. /**
  134045. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  134046. */
  134047. xrNativeFeatureName: string;
  134048. /**
  134049. * Construct a new (abstract) WebXR feature
  134050. * @param _xrSessionManager the xr session manager for this feature
  134051. */
  134052. constructor(_xrSessionManager: WebXRSessionManager);
  134053. /**
  134054. * Is this feature attached
  134055. */
  134056. get attached(): boolean;
  134057. /**
  134058. * attach this feature
  134059. *
  134060. * @param force should attachment be forced (even when already attached)
  134061. * @returns true if successful, false is failed or already attached
  134062. */
  134063. attach(force?: boolean): boolean;
  134064. /**
  134065. * detach this feature.
  134066. *
  134067. * @returns true if successful, false if failed or already detached
  134068. */
  134069. detach(): boolean;
  134070. /**
  134071. * Dispose this feature and all of the resources attached
  134072. */
  134073. dispose(): void;
  134074. /**
  134075. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  134076. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  134077. *
  134078. * @returns whether or not the feature is compatible in this environment
  134079. */
  134080. isCompatible(): boolean;
  134081. /**
  134082. * This is used to register callbacks that will automatically be removed when detach is called.
  134083. * @param observable the observable to which the observer will be attached
  134084. * @param callback the callback to register
  134085. */
  134086. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  134087. /**
  134088. * Code in this function will be executed on each xrFrame received from the browser.
  134089. * This function will not execute after the feature is detached.
  134090. * @param _xrFrame the current frame
  134091. */
  134092. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  134093. }
  134094. }
  134095. declare module BABYLON {
  134096. /**
  134097. * Renders a layer on top of an existing scene
  134098. */
  134099. export class UtilityLayerRenderer implements IDisposable {
  134100. /** the original scene that will be rendered on top of */
  134101. originalScene: Scene;
  134102. private _pointerCaptures;
  134103. private _lastPointerEvents;
  134104. private static _DefaultUtilityLayer;
  134105. private static _DefaultKeepDepthUtilityLayer;
  134106. private _sharedGizmoLight;
  134107. private _renderCamera;
  134108. /**
  134109. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  134110. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  134111. * @returns the camera that is used when rendering the utility layer
  134112. */
  134113. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  134114. /**
  134115. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  134116. * @param cam the camera that should be used when rendering the utility layer
  134117. */
  134118. setRenderCamera(cam: Nullable<Camera>): void;
  134119. /**
  134120. * @hidden
  134121. * Light which used by gizmos to get light shading
  134122. */
  134123. _getSharedGizmoLight(): HemisphericLight;
  134124. /**
  134125. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  134126. */
  134127. pickUtilitySceneFirst: boolean;
  134128. /**
  134129. * 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)
  134130. */
  134131. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  134132. /**
  134133. * 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)
  134134. */
  134135. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  134136. /**
  134137. * The scene that is rendered on top of the original scene
  134138. */
  134139. utilityLayerScene: Scene;
  134140. /**
  134141. * If the utility layer should automatically be rendered on top of existing scene
  134142. */
  134143. shouldRender: boolean;
  134144. /**
  134145. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  134146. */
  134147. onlyCheckPointerDownEvents: boolean;
  134148. /**
  134149. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  134150. */
  134151. processAllEvents: boolean;
  134152. /**
  134153. * Observable raised when the pointer move from the utility layer scene to the main scene
  134154. */
  134155. onPointerOutObservable: Observable<number>;
  134156. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  134157. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  134158. private _afterRenderObserver;
  134159. private _sceneDisposeObserver;
  134160. private _originalPointerObserver;
  134161. /**
  134162. * Instantiates a UtilityLayerRenderer
  134163. * @param originalScene the original scene that will be rendered on top of
  134164. * @param handleEvents boolean indicating if the utility layer should handle events
  134165. */
  134166. constructor(
  134167. /** the original scene that will be rendered on top of */
  134168. originalScene: Scene, handleEvents?: boolean);
  134169. private _notifyObservers;
  134170. /**
  134171. * Renders the utility layers scene on top of the original scene
  134172. */
  134173. render(): void;
  134174. /**
  134175. * Disposes of the renderer
  134176. */
  134177. dispose(): void;
  134178. private _updateCamera;
  134179. }
  134180. }
  134181. declare module BABYLON {
  134182. /**
  134183. * Options interface for the pointer selection module
  134184. */
  134185. export interface IWebXRControllerPointerSelectionOptions {
  134186. /**
  134187. * if provided, this scene will be used to render meshes.
  134188. */
  134189. customUtilityLayerScene?: Scene;
  134190. /**
  134191. * 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)
  134192. * If not disabled, the last picked point will be used to execute a pointer up event
  134193. * If disabled, pointer up event will be triggered right after the pointer down event.
  134194. * Used in screen and gaze target ray mode only
  134195. */
  134196. disablePointerUpOnTouchOut: boolean;
  134197. /**
  134198. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  134199. */
  134200. forceGazeMode: boolean;
  134201. /**
  134202. * 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
  134203. * to start a new countdown to the pointer down event.
  134204. * Defaults to 1.
  134205. */
  134206. gazeModePointerMovedFactor?: number;
  134207. /**
  134208. * Different button type to use instead of the main component
  134209. */
  134210. overrideButtonId?: string;
  134211. /**
  134212. * use this rendering group id for the meshes (optional)
  134213. */
  134214. renderingGroupId?: number;
  134215. /**
  134216. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  134217. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  134218. * 3000 means 3 seconds between pointing at something and selecting it
  134219. */
  134220. timeToSelect?: number;
  134221. /**
  134222. * Should meshes created here be added to a utility layer or the main scene
  134223. */
  134224. useUtilityLayer?: boolean;
  134225. /**
  134226. * Optional WebXR camera to be used for gaze selection
  134227. */
  134228. gazeCamera?: WebXRCamera;
  134229. /**
  134230. * the xr input to use with this pointer selection
  134231. */
  134232. xrInput: WebXRInput;
  134233. /**
  134234. * Should the scene pointerX and pointerY update be disabled
  134235. * This is required for fullscreen AR GUI, but might slow down other experiences.
  134236. * Disable in VR, if not needed.
  134237. * The first rig camera (left eye) will be used to calculate the projection
  134238. */
  134239. disableScenePointerVectorUpdate: boolean;
  134240. /**
  134241. * Enable pointer selection on all controllers instead of switching between them
  134242. */
  134243. enablePointerSelectionOnAllControllers?: boolean;
  134244. /**
  134245. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  134246. * If switch is enabled, it will still allow the user to switch between the different controllers
  134247. */
  134248. preferredHandedness?: XRHandedness;
  134249. /**
  134250. * Disable switching the pointer selection from one controller to the other.
  134251. * If the preferred hand is set it will be fixed on this hand, and if not it will be fixed on the first controller added to the scene
  134252. */
  134253. disableSwitchOnClick?: boolean;
  134254. /**
  134255. * The maximum distance of the pointer selection feature. Defaults to 100.
  134256. */
  134257. maxPointerDistance?: number;
  134258. }
  134259. /**
  134260. * A module that will enable pointer selection for motion controllers of XR Input Sources
  134261. */
  134262. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  134263. private readonly _options;
  134264. private static _idCounter;
  134265. private _attachController;
  134266. private _controllers;
  134267. private _scene;
  134268. private _tmpVectorForPickCompare;
  134269. private _attachedController;
  134270. /**
  134271. * The module's name
  134272. */
  134273. static readonly Name: string;
  134274. /**
  134275. * The (Babylon) version of this module.
  134276. * This is an integer representing the implementation version.
  134277. * This number does not correspond to the WebXR specs version
  134278. */
  134279. static readonly Version: number;
  134280. /**
  134281. * Disable lighting on the laser pointer (so it will always be visible)
  134282. */
  134283. disablePointerLighting: boolean;
  134284. /**
  134285. * Disable lighting on the selection mesh (so it will always be visible)
  134286. */
  134287. disableSelectionMeshLighting: boolean;
  134288. /**
  134289. * Should the laser pointer be displayed
  134290. */
  134291. displayLaserPointer: boolean;
  134292. /**
  134293. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  134294. */
  134295. displaySelectionMesh: boolean;
  134296. /**
  134297. * This color will be set to the laser pointer when selection is triggered
  134298. */
  134299. laserPointerPickedColor: Color3;
  134300. /**
  134301. * Default color of the laser pointer
  134302. */
  134303. laserPointerDefaultColor: Color3;
  134304. /**
  134305. * default color of the selection ring
  134306. */
  134307. selectionMeshDefaultColor: Color3;
  134308. /**
  134309. * This color will be applied to the selection ring when selection is triggered
  134310. */
  134311. selectionMeshPickedColor: Color3;
  134312. /**
  134313. * Optional filter to be used for ray selection. This predicate shares behavior with
  134314. * scene.pointerMovePredicate which takes priority if it is also assigned.
  134315. */
  134316. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134317. /**
  134318. * constructs a new background remover module
  134319. * @param _xrSessionManager the session manager for this module
  134320. * @param _options read-only options to be used in this module
  134321. */
  134322. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  134323. /**
  134324. * attach this feature
  134325. * Will usually be called by the features manager
  134326. *
  134327. * @returns true if successful.
  134328. */
  134329. attach(): boolean;
  134330. /**
  134331. * detach this feature.
  134332. * Will usually be called by the features manager
  134333. *
  134334. * @returns true if successful.
  134335. */
  134336. detach(): boolean;
  134337. /**
  134338. * Will get the mesh under a specific pointer.
  134339. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  134340. * @param controllerId the controllerId to check
  134341. * @returns The mesh under pointer or null if no mesh is under the pointer
  134342. */
  134343. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  134344. /**
  134345. * Get the xr controller that correlates to the pointer id in the pointer event
  134346. *
  134347. * @param id the pointer id to search for
  134348. * @returns the controller that correlates to this id or null if not found
  134349. */
  134350. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  134351. private _identityMatrix;
  134352. private _screenCoordinatesRef;
  134353. private _viewportRef;
  134354. protected _onXRFrame(_xrFrame: XRFrame): void;
  134355. private _attachGazeMode;
  134356. private _attachScreenRayMode;
  134357. private _attachTrackedPointerRayMode;
  134358. private _convertNormalToDirectionOfRay;
  134359. private _detachController;
  134360. private _generateNewMeshPair;
  134361. private _pickingMoved;
  134362. private _updatePointerDistance;
  134363. /** @hidden */
  134364. get lasterPointerDefaultColor(): Color3;
  134365. }
  134366. }
  134367. declare module BABYLON {
  134368. /**
  134369. * Button which can be used to enter a different mode of XR
  134370. */
  134371. export class WebXREnterExitUIButton {
  134372. /** button element */
  134373. element: HTMLElement;
  134374. /** XR initialization options for the button */
  134375. sessionMode: XRSessionMode;
  134376. /** Reference space type */
  134377. referenceSpaceType: XRReferenceSpaceType;
  134378. /**
  134379. * Creates a WebXREnterExitUIButton
  134380. * @param element button element
  134381. * @param sessionMode XR initialization session mode
  134382. * @param referenceSpaceType the type of reference space to be used
  134383. */
  134384. constructor(
  134385. /** button element */
  134386. element: HTMLElement,
  134387. /** XR initialization options for the button */
  134388. sessionMode: XRSessionMode,
  134389. /** Reference space type */
  134390. referenceSpaceType: XRReferenceSpaceType);
  134391. /**
  134392. * Extendable function which can be used to update the button's visuals when the state changes
  134393. * @param activeButton the current active button in the UI
  134394. */
  134395. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  134396. }
  134397. /**
  134398. * Options to create the webXR UI
  134399. */
  134400. export class WebXREnterExitUIOptions {
  134401. /**
  134402. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  134403. */
  134404. customButtons?: Array<WebXREnterExitUIButton>;
  134405. /**
  134406. * A reference space type to use when creating the default button.
  134407. * Default is local-floor
  134408. */
  134409. referenceSpaceType?: XRReferenceSpaceType;
  134410. /**
  134411. * Context to enter xr with
  134412. */
  134413. renderTarget?: Nullable<WebXRRenderTarget>;
  134414. /**
  134415. * A session mode to use when creating the default button.
  134416. * Default is immersive-vr
  134417. */
  134418. sessionMode?: XRSessionMode;
  134419. /**
  134420. * A list of optional features to init the session with
  134421. */
  134422. optionalFeatures?: string[];
  134423. /**
  134424. * A list of optional features to init the session with
  134425. */
  134426. requiredFeatures?: string[];
  134427. /**
  134428. * If defined, this function will be executed if the UI encounters an error when entering XR
  134429. */
  134430. onError?: (error: any) => void;
  134431. }
  134432. /**
  134433. * UI to allow the user to enter/exit XR mode
  134434. */
  134435. export class WebXREnterExitUI implements IDisposable {
  134436. private scene;
  134437. /** version of the options passed to this UI */
  134438. options: WebXREnterExitUIOptions;
  134439. private _activeButton;
  134440. private _buttons;
  134441. /**
  134442. * The HTML Div Element to which buttons are added.
  134443. */
  134444. readonly overlay: HTMLDivElement;
  134445. /**
  134446. * Fired every time the active button is changed.
  134447. *
  134448. * When xr is entered via a button that launches xr that button will be the callback parameter
  134449. *
  134450. * When exiting xr the callback parameter will be null)
  134451. */
  134452. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  134453. /**
  134454. *
  134455. * @param scene babylon scene object to use
  134456. * @param options (read-only) version of the options passed to this UI
  134457. */
  134458. private constructor();
  134459. /**
  134460. * Creates UI to allow the user to enter/exit XR mode
  134461. * @param scene the scene to add the ui to
  134462. * @param helper the xr experience helper to enter/exit xr with
  134463. * @param options options to configure the UI
  134464. * @returns the created ui
  134465. */
  134466. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  134467. /**
  134468. * Disposes of the XR UI component
  134469. */
  134470. dispose(): void;
  134471. private _updateButtons;
  134472. }
  134473. }
  134474. declare module BABYLON {
  134475. /**
  134476. * Class containing static functions to help procedurally build meshes
  134477. */
  134478. export class LinesBuilder {
  134479. /**
  134480. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134481. * * 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
  134482. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134483. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134484. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134485. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134486. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134487. * * 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
  134488. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134491. * @param name defines the name of the new line system
  134492. * @param options defines the options used to create the line system
  134493. * @param scene defines the hosting scene
  134494. * @returns a new line system mesh
  134495. */
  134496. static CreateLineSystem(name: string, options: {
  134497. lines: Vector3[][];
  134498. updatable?: boolean;
  134499. instance?: Nullable<LinesMesh>;
  134500. colors?: Nullable<Color4[][]>;
  134501. useVertexAlpha?: boolean;
  134502. }, scene: Nullable<Scene>): LinesMesh;
  134503. /**
  134504. * Creates a line mesh
  134505. * 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
  134506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134507. * * The parameter `points` is an array successive Vector3
  134508. * * 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
  134509. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134510. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134511. * * When updating an instance, remember that only point positions can change, not the number of points
  134512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134513. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134514. * @param name defines the name of the new line system
  134515. * @param options defines the options used to create the line system
  134516. * @param scene defines the hosting scene
  134517. * @returns a new line mesh
  134518. */
  134519. static CreateLines(name: string, options: {
  134520. points: Vector3[];
  134521. updatable?: boolean;
  134522. instance?: Nullable<LinesMesh>;
  134523. colors?: Color4[];
  134524. useVertexAlpha?: boolean;
  134525. }, scene?: Nullable<Scene>): LinesMesh;
  134526. /**
  134527. * Creates a dashed line mesh
  134528. * * 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
  134529. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134530. * * The parameter `points` is an array successive Vector3
  134531. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134532. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134533. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134534. * * 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
  134535. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134536. * * When updating an instance, remember that only point positions can change, not the number of points
  134537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134538. * @param name defines the name of the mesh
  134539. * @param options defines the options used to create the mesh
  134540. * @param scene defines the hosting scene
  134541. * @returns the dashed line mesh
  134542. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134543. */
  134544. static CreateDashedLines(name: string, options: {
  134545. points: Vector3[];
  134546. dashSize?: number;
  134547. gapSize?: number;
  134548. dashNb?: number;
  134549. updatable?: boolean;
  134550. instance?: LinesMesh;
  134551. useVertexAlpha?: boolean;
  134552. }, scene?: Nullable<Scene>): LinesMesh;
  134553. }
  134554. }
  134555. declare module BABYLON {
  134556. /**
  134557. * Construction options for a timer
  134558. */
  134559. export interface ITimerOptions<T> {
  134560. /**
  134561. * Time-to-end
  134562. */
  134563. timeout: number;
  134564. /**
  134565. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  134566. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  134567. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  134568. */
  134569. contextObservable: Observable<T>;
  134570. /**
  134571. * Optional parameters when adding an observer to the observable
  134572. */
  134573. observableParameters?: {
  134574. mask?: number;
  134575. insertFirst?: boolean;
  134576. scope?: any;
  134577. };
  134578. /**
  134579. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  134580. */
  134581. breakCondition?: (data?: ITimerData<T>) => boolean;
  134582. /**
  134583. * Will be triggered when the time condition has met
  134584. */
  134585. onEnded?: (data: ITimerData<any>) => void;
  134586. /**
  134587. * Will be triggered when the break condition has met (prematurely ended)
  134588. */
  134589. onAborted?: (data: ITimerData<any>) => void;
  134590. /**
  134591. * Optional function to execute on each tick (or count)
  134592. */
  134593. onTick?: (data: ITimerData<any>) => void;
  134594. }
  134595. /**
  134596. * An interface defining the data sent by the timer
  134597. */
  134598. export interface ITimerData<T> {
  134599. /**
  134600. * When did it start
  134601. */
  134602. startTime: number;
  134603. /**
  134604. * Time now
  134605. */
  134606. currentTime: number;
  134607. /**
  134608. * Time passed since started
  134609. */
  134610. deltaTime: number;
  134611. /**
  134612. * How much is completed, in [0.0...1.0].
  134613. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  134614. */
  134615. completeRate: number;
  134616. /**
  134617. * What the registered observable sent in the last count
  134618. */
  134619. payload: T;
  134620. }
  134621. /**
  134622. * The current state of the timer
  134623. */
  134624. export enum TimerState {
  134625. /**
  134626. * Timer initialized, not yet started
  134627. */
  134628. INIT = 0,
  134629. /**
  134630. * Timer started and counting
  134631. */
  134632. STARTED = 1,
  134633. /**
  134634. * Timer ended (whether aborted or time reached)
  134635. */
  134636. ENDED = 2
  134637. }
  134638. /**
  134639. * A simple version of the timer. Will take options and start the timer immediately after calling it
  134640. *
  134641. * @param options options with which to initialize this timer
  134642. */
  134643. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  134644. /**
  134645. * An advanced implementation of a timer class
  134646. */
  134647. export class AdvancedTimer<T = any> implements IDisposable {
  134648. /**
  134649. * Will notify each time the timer calculates the remaining time
  134650. */
  134651. onEachCountObservable: Observable<ITimerData<T>>;
  134652. /**
  134653. * Will trigger when the timer was aborted due to the break condition
  134654. */
  134655. onTimerAbortedObservable: Observable<ITimerData<T>>;
  134656. /**
  134657. * Will trigger when the timer ended successfully
  134658. */
  134659. onTimerEndedObservable: Observable<ITimerData<T>>;
  134660. /**
  134661. * Will trigger when the timer state has changed
  134662. */
  134663. onStateChangedObservable: Observable<TimerState>;
  134664. private _observer;
  134665. private _contextObservable;
  134666. private _observableParameters;
  134667. private _startTime;
  134668. private _timer;
  134669. private _state;
  134670. private _breakCondition;
  134671. private _timeToEnd;
  134672. private _breakOnNextTick;
  134673. /**
  134674. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  134675. * @param options construction options for this advanced timer
  134676. */
  134677. constructor(options: ITimerOptions<T>);
  134678. /**
  134679. * set a breaking condition for this timer. Default is to never break during count
  134680. * @param predicate the new break condition. Returns true to break, false otherwise
  134681. */
  134682. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  134683. /**
  134684. * Reset ALL associated observables in this advanced timer
  134685. */
  134686. clearObservables(): void;
  134687. /**
  134688. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  134689. *
  134690. * @param timeToEnd how much time to measure until timer ended
  134691. */
  134692. start(timeToEnd?: number): void;
  134693. /**
  134694. * Will force a stop on the next tick.
  134695. */
  134696. stop(): void;
  134697. /**
  134698. * Dispose this timer, clearing all resources
  134699. */
  134700. dispose(): void;
  134701. private _setState;
  134702. private _tick;
  134703. private _stop;
  134704. }
  134705. }
  134706. declare module BABYLON {
  134707. /**
  134708. * The options container for the teleportation module
  134709. */
  134710. export interface IWebXRTeleportationOptions {
  134711. /**
  134712. * if provided, this scene will be used to render meshes.
  134713. */
  134714. customUtilityLayerScene?: Scene;
  134715. /**
  134716. * Values to configure the default target mesh
  134717. */
  134718. defaultTargetMeshOptions?: {
  134719. /**
  134720. * Fill color of the teleportation area
  134721. */
  134722. teleportationFillColor?: string;
  134723. /**
  134724. * Border color for the teleportation area
  134725. */
  134726. teleportationBorderColor?: string;
  134727. /**
  134728. * Disable the mesh's animation sequence
  134729. */
  134730. disableAnimation?: boolean;
  134731. /**
  134732. * Disable lighting on the material or the ring and arrow
  134733. */
  134734. disableLighting?: boolean;
  134735. /**
  134736. * Override the default material of the torus and arrow
  134737. */
  134738. torusArrowMaterial?: Material;
  134739. };
  134740. /**
  134741. * A list of meshes to use as floor meshes.
  134742. * Meshes can be added and removed after initializing the feature using the
  134743. * addFloorMesh and removeFloorMesh functions
  134744. * If empty, rotation will still work
  134745. */
  134746. floorMeshes?: AbstractMesh[];
  134747. /**
  134748. * use this rendering group id for the meshes (optional)
  134749. */
  134750. renderingGroupId?: number;
  134751. /**
  134752. * Should teleportation move only to snap points
  134753. */
  134754. snapPointsOnly?: boolean;
  134755. /**
  134756. * An array of points to which the teleportation will snap to.
  134757. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  134758. */
  134759. snapPositions?: Vector3[];
  134760. /**
  134761. * How close should the teleportation ray be in order to snap to position.
  134762. * Default to 0.8 units (meters)
  134763. */
  134764. snapToPositionRadius?: number;
  134765. /**
  134766. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  134767. * If you want to support rotation, make sure your mesh has a direction indicator.
  134768. *
  134769. * When left untouched, the default mesh will be initialized.
  134770. */
  134771. teleportationTargetMesh?: AbstractMesh;
  134772. /**
  134773. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  134774. */
  134775. timeToTeleport?: number;
  134776. /**
  134777. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  134778. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  134779. */
  134780. useMainComponentOnly?: boolean;
  134781. /**
  134782. * Should meshes created here be added to a utility layer or the main scene
  134783. */
  134784. useUtilityLayer?: boolean;
  134785. /**
  134786. * Babylon XR Input class for controller
  134787. */
  134788. xrInput: WebXRInput;
  134789. /**
  134790. * Meshes that the teleportation ray cannot go through
  134791. */
  134792. pickBlockerMeshes?: AbstractMesh[];
  134793. /**
  134794. * Should teleport work only on a specific hand?
  134795. */
  134796. forceHandedness?: XRHandedness;
  134797. /**
  134798. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  134799. */
  134800. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  134801. }
  134802. /**
  134803. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  134804. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  134805. * the input of the attached controllers.
  134806. */
  134807. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  134808. private _options;
  134809. private _controllers;
  134810. private _currentTeleportationControllerId;
  134811. private _floorMeshes;
  134812. private _quadraticBezierCurve;
  134813. private _selectionFeature;
  134814. private _snapToPositions;
  134815. private _snappedToPoint;
  134816. private _teleportationRingMaterial?;
  134817. private _tmpRay;
  134818. private _tmpVector;
  134819. private _tmpQuaternion;
  134820. /**
  134821. * The module's name
  134822. */
  134823. static readonly Name: string;
  134824. /**
  134825. * The (Babylon) version of this module.
  134826. * This is an integer representing the implementation version.
  134827. * This number does not correspond to the webxr specs version
  134828. */
  134829. static readonly Version: number;
  134830. /**
  134831. * Is movement backwards enabled
  134832. */
  134833. backwardsMovementEnabled: boolean;
  134834. /**
  134835. * Distance to travel when moving backwards
  134836. */
  134837. backwardsTeleportationDistance: number;
  134838. /**
  134839. * The distance from the user to the inspection point in the direction of the controller
  134840. * A higher number will allow the user to move further
  134841. * defaults to 5 (meters, in xr units)
  134842. */
  134843. parabolicCheckRadius: number;
  134844. /**
  134845. * Should the module support parabolic ray on top of direct ray
  134846. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134847. * Very helpful when moving between floors / different heights
  134848. */
  134849. parabolicRayEnabled: boolean;
  134850. /**
  134851. * The second type of ray - straight line.
  134852. * Should it be enabled or should the parabolic line be the only one.
  134853. */
  134854. straightRayEnabled: boolean;
  134855. /**
  134856. * How much rotation should be applied when rotating right and left
  134857. */
  134858. rotationAngle: number;
  134859. private _rotationEnabled;
  134860. /**
  134861. * Is rotation enabled when moving forward?
  134862. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134863. */
  134864. get rotationEnabled(): boolean;
  134865. /**
  134866. * Sets wether rotation is enabled or not
  134867. * @param enabled is rotation enabled when teleportation is shown
  134868. */
  134869. set rotationEnabled(enabled: boolean);
  134870. /**
  134871. * Exposes the currently set teleportation target mesh.
  134872. */
  134873. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  134874. /**
  134875. * constructs a new anchor system
  134876. * @param _xrSessionManager an instance of WebXRSessionManager
  134877. * @param _options configuration object for this feature
  134878. */
  134879. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134880. /**
  134881. * Get the snapPointsOnly flag
  134882. */
  134883. get snapPointsOnly(): boolean;
  134884. /**
  134885. * Sets the snapPointsOnly flag
  134886. * @param snapToPoints should teleportation be exclusively to snap points
  134887. */
  134888. set snapPointsOnly(snapToPoints: boolean);
  134889. /**
  134890. * Add a new mesh to the floor meshes array
  134891. * @param mesh the mesh to use as floor mesh
  134892. */
  134893. addFloorMesh(mesh: AbstractMesh): void;
  134894. /**
  134895. * Add a new snap-to point to fix teleportation to this position
  134896. * @param newSnapPoint The new Snap-To point
  134897. */
  134898. addSnapPoint(newSnapPoint: Vector3): void;
  134899. attach(): boolean;
  134900. detach(): boolean;
  134901. dispose(): void;
  134902. /**
  134903. * Remove a mesh from the floor meshes array
  134904. * @param mesh the mesh to remove
  134905. */
  134906. removeFloorMesh(mesh: AbstractMesh): void;
  134907. /**
  134908. * Remove a mesh from the floor meshes array using its name
  134909. * @param name the mesh name to remove
  134910. */
  134911. removeFloorMeshByName(name: string): void;
  134912. /**
  134913. * 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
  134914. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134915. * @returns was the point found and removed or not
  134916. */
  134917. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134918. /**
  134919. * This function sets a selection feature that will be disabled when
  134920. * the forward ray is shown and will be reattached when hidden.
  134921. * This is used to remove the selection rays when moving.
  134922. * @param selectionFeature the feature to disable when forward movement is enabled
  134923. */
  134924. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134925. protected _onXRFrame(_xrFrame: XRFrame): void;
  134926. private _attachController;
  134927. private _createDefaultTargetMesh;
  134928. private _detachController;
  134929. private _findClosestSnapPointWithRadius;
  134930. private _setTargetMeshPosition;
  134931. private _setTargetMeshVisibility;
  134932. private _showParabolicPath;
  134933. private _teleportForward;
  134934. }
  134935. }
  134936. declare module BABYLON {
  134937. /**
  134938. * Options for the default xr helper
  134939. */
  134940. export class WebXRDefaultExperienceOptions {
  134941. /**
  134942. * Enable or disable default UI to enter XR
  134943. */
  134944. disableDefaultUI?: boolean;
  134945. /**
  134946. * Should teleportation not initialize. defaults to false.
  134947. */
  134948. disableTeleportation?: boolean;
  134949. /**
  134950. * Floor meshes that will be used for teleport
  134951. */
  134952. floorMeshes?: Array<AbstractMesh>;
  134953. /**
  134954. * If set to true, the first frame will not be used to reset position
  134955. * The first frame is mainly used when copying transformation from the old camera
  134956. * Mainly used in AR
  134957. */
  134958. ignoreNativeCameraTransformation?: boolean;
  134959. /**
  134960. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134961. */
  134962. inputOptions?: IWebXRInputOptions;
  134963. /**
  134964. * optional configuration for the output canvas
  134965. */
  134966. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134967. /**
  134968. * optional UI options. This can be used among other to change session mode and reference space type
  134969. */
  134970. uiOptions?: WebXREnterExitUIOptions;
  134971. /**
  134972. * When loading teleportation and pointer select, use stable versions instead of latest.
  134973. */
  134974. useStablePlugins?: boolean;
  134975. /**
  134976. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134977. */
  134978. renderingGroupId?: number;
  134979. /**
  134980. * A list of optional features to init the session with
  134981. * If set to true, all features we support will be added
  134982. */
  134983. optionalFeatures?: boolean | string[];
  134984. }
  134985. /**
  134986. * Default experience which provides a similar setup to the previous webVRExperience
  134987. */
  134988. export class WebXRDefaultExperience {
  134989. /**
  134990. * Base experience
  134991. */
  134992. baseExperience: WebXRExperienceHelper;
  134993. /**
  134994. * Enables ui for entering/exiting xr
  134995. */
  134996. enterExitUI: WebXREnterExitUI;
  134997. /**
  134998. * Input experience extension
  134999. */
  135000. input: WebXRInput;
  135001. /**
  135002. * Enables laser pointer and selection
  135003. */
  135004. pointerSelection: WebXRControllerPointerSelection;
  135005. /**
  135006. * Default target xr should render to
  135007. */
  135008. renderTarget: WebXRRenderTarget;
  135009. /**
  135010. * Enables teleportation
  135011. */
  135012. teleportation: WebXRMotionControllerTeleportation;
  135013. private constructor();
  135014. /**
  135015. * Creates the default xr experience
  135016. * @param scene scene
  135017. * @param options options for basic configuration
  135018. * @returns resulting WebXRDefaultExperience
  135019. */
  135020. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  135021. /**
  135022. * DIsposes of the experience helper
  135023. */
  135024. dispose(): void;
  135025. }
  135026. }
  135027. declare module BABYLON {
  135028. /**
  135029. * Options to modify the vr teleportation behavior.
  135030. */
  135031. export interface VRTeleportationOptions {
  135032. /**
  135033. * The name of the mesh which should be used as the teleportation floor. (default: null)
  135034. */
  135035. floorMeshName?: string;
  135036. /**
  135037. * A list of meshes to be used as the teleportation floor. (default: empty)
  135038. */
  135039. floorMeshes?: Mesh[];
  135040. /**
  135041. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  135042. */
  135043. teleportationMode?: number;
  135044. /**
  135045. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  135046. */
  135047. teleportationTime?: number;
  135048. /**
  135049. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  135050. */
  135051. teleportationSpeed?: number;
  135052. /**
  135053. * The easing function used in the animation or null for Linear. (default CircleEase)
  135054. */
  135055. easingFunction?: EasingFunction;
  135056. }
  135057. /**
  135058. * Options to modify the vr experience helper's behavior.
  135059. */
  135060. export interface VRExperienceHelperOptions extends WebVROptions {
  135061. /**
  135062. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  135063. */
  135064. createDeviceOrientationCamera?: boolean;
  135065. /**
  135066. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  135067. */
  135068. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  135069. /**
  135070. * Uses the main button on the controller to toggle the laser casted. (default: true)
  135071. */
  135072. laserToggle?: boolean;
  135073. /**
  135074. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  135075. */
  135076. floorMeshes?: Mesh[];
  135077. /**
  135078. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  135079. */
  135080. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  135081. /**
  135082. * Defines if WebXR should be used instead of WebVR (if available)
  135083. */
  135084. useXR?: boolean;
  135085. }
  135086. /**
  135087. * Event containing information after VR has been entered
  135088. */
  135089. export class OnAfterEnteringVRObservableEvent {
  135090. /**
  135091. * If entering vr was successful
  135092. */
  135093. success: boolean;
  135094. }
  135095. /**
  135096. * Helps to quickly add VR support to an existing scene.
  135097. * See https://doc.babylonjs.com/how_to/webvr_helper
  135098. */
  135099. export class VRExperienceHelper {
  135100. /** Options to modify the vr experience helper's behavior. */
  135101. webVROptions: VRExperienceHelperOptions;
  135102. private _scene;
  135103. private _position;
  135104. private _btnVR;
  135105. private _btnVRDisplayed;
  135106. private _webVRsupported;
  135107. private _webVRready;
  135108. private _webVRrequesting;
  135109. private _webVRpresenting;
  135110. private _hasEnteredVR;
  135111. private _fullscreenVRpresenting;
  135112. private _inputElement;
  135113. private _webVRCamera;
  135114. private _vrDeviceOrientationCamera;
  135115. private _deviceOrientationCamera;
  135116. private _existingCamera;
  135117. private _onKeyDown;
  135118. private _onVrDisplayPresentChange;
  135119. private _onVRDisplayChanged;
  135120. private _onVRRequestPresentStart;
  135121. private _onVRRequestPresentComplete;
  135122. /**
  135123. * 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)
  135124. */
  135125. enableGazeEvenWhenNoPointerLock: boolean;
  135126. /**
  135127. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  135128. */
  135129. exitVROnDoubleTap: boolean;
  135130. /**
  135131. * Observable raised right before entering VR.
  135132. */
  135133. onEnteringVRObservable: Observable<VRExperienceHelper>;
  135134. /**
  135135. * Observable raised when entering VR has completed.
  135136. */
  135137. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  135138. /**
  135139. * Observable raised when exiting VR.
  135140. */
  135141. onExitingVRObservable: Observable<VRExperienceHelper>;
  135142. /**
  135143. * Observable raised when controller mesh is loaded.
  135144. */
  135145. onControllerMeshLoadedObservable: Observable<WebVRController>;
  135146. /** Return this.onEnteringVRObservable
  135147. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  135148. */
  135149. get onEnteringVR(): Observable<VRExperienceHelper>;
  135150. /** Return this.onExitingVRObservable
  135151. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  135152. */
  135153. get onExitingVR(): Observable<VRExperienceHelper>;
  135154. /** Return this.onControllerMeshLoadedObservable
  135155. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  135156. */
  135157. get onControllerMeshLoaded(): Observable<WebVRController>;
  135158. private _rayLength;
  135159. private _useCustomVRButton;
  135160. private _teleportationRequested;
  135161. private _teleportActive;
  135162. private _floorMeshName;
  135163. private _floorMeshesCollection;
  135164. private _teleportationMode;
  135165. private _teleportationTime;
  135166. private _teleportationSpeed;
  135167. private _teleportationEasing;
  135168. private _rotationAllowed;
  135169. private _teleportBackwardsVector;
  135170. private _teleportationTarget;
  135171. private _isDefaultTeleportationTarget;
  135172. private _postProcessMove;
  135173. private _teleportationFillColor;
  135174. private _teleportationBorderColor;
  135175. private _rotationAngle;
  135176. private _haloCenter;
  135177. private _cameraGazer;
  135178. private _padSensibilityUp;
  135179. private _padSensibilityDown;
  135180. private _leftController;
  135181. private _rightController;
  135182. private _gazeColor;
  135183. private _laserColor;
  135184. private _pickedLaserColor;
  135185. private _pickedGazeColor;
  135186. /**
  135187. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  135188. */
  135189. onNewMeshSelected: Observable<AbstractMesh>;
  135190. /**
  135191. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  135192. * This observable will provide the mesh and the controller used to select the mesh
  135193. */
  135194. onMeshSelectedWithController: Observable<{
  135195. mesh: AbstractMesh;
  135196. controller: WebVRController;
  135197. }>;
  135198. /**
  135199. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  135200. */
  135201. onNewMeshPicked: Observable<PickingInfo>;
  135202. private _circleEase;
  135203. /**
  135204. * Observable raised before camera teleportation
  135205. */
  135206. onBeforeCameraTeleport: Observable<Vector3>;
  135207. /**
  135208. * Observable raised after camera teleportation
  135209. */
  135210. onAfterCameraTeleport: Observable<Vector3>;
  135211. /**
  135212. * Observable raised when current selected mesh gets unselected
  135213. */
  135214. onSelectedMeshUnselected: Observable<AbstractMesh>;
  135215. private _raySelectionPredicate;
  135216. /**
  135217. * To be optionaly changed by user to define custom ray selection
  135218. */
  135219. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  135220. /**
  135221. * To be optionaly changed by user to define custom selection logic (after ray selection)
  135222. */
  135223. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  135224. /**
  135225. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  135226. */
  135227. teleportationEnabled: boolean;
  135228. private _defaultHeight;
  135229. private _teleportationInitialized;
  135230. private _interactionsEnabled;
  135231. private _interactionsRequested;
  135232. private _displayGaze;
  135233. private _displayLaserPointer;
  135234. /**
  135235. * The mesh used to display where the user is going to teleport.
  135236. */
  135237. get teleportationTarget(): Mesh;
  135238. /**
  135239. * Sets the mesh to be used to display where the user is going to teleport.
  135240. */
  135241. set teleportationTarget(value: Mesh);
  135242. /**
  135243. * 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
  135244. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  135245. * See https://doc.babylonjs.com/resources/baking_transformations
  135246. */
  135247. get gazeTrackerMesh(): Mesh;
  135248. set gazeTrackerMesh(value: Mesh);
  135249. /**
  135250. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  135251. */
  135252. updateGazeTrackerScale: boolean;
  135253. /**
  135254. * If the gaze trackers color should be updated when selecting meshes
  135255. */
  135256. updateGazeTrackerColor: boolean;
  135257. /**
  135258. * If the controller laser color should be updated when selecting meshes
  135259. */
  135260. updateControllerLaserColor: boolean;
  135261. /**
  135262. * The gaze tracking mesh corresponding to the left controller
  135263. */
  135264. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  135265. /**
  135266. * The gaze tracking mesh corresponding to the right controller
  135267. */
  135268. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  135269. /**
  135270. * If the ray of the gaze should be displayed.
  135271. */
  135272. get displayGaze(): boolean;
  135273. /**
  135274. * Sets if the ray of the gaze should be displayed.
  135275. */
  135276. set displayGaze(value: boolean);
  135277. /**
  135278. * If the ray of the LaserPointer should be displayed.
  135279. */
  135280. get displayLaserPointer(): boolean;
  135281. /**
  135282. * Sets if the ray of the LaserPointer should be displayed.
  135283. */
  135284. set displayLaserPointer(value: boolean);
  135285. /**
  135286. * The deviceOrientationCamera used as the camera when not in VR.
  135287. */
  135288. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  135289. /**
  135290. * Based on the current WebVR support, returns the current VR camera used.
  135291. */
  135292. get currentVRCamera(): Nullable<Camera>;
  135293. /**
  135294. * The webVRCamera which is used when in VR.
  135295. */
  135296. get webVRCamera(): WebVRFreeCamera;
  135297. /**
  135298. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  135299. */
  135300. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  135301. /**
  135302. * The html button that is used to trigger entering into VR.
  135303. */
  135304. get vrButton(): Nullable<HTMLButtonElement>;
  135305. private get _teleportationRequestInitiated();
  135306. /**
  135307. * Defines whether or not Pointer lock should be requested when switching to
  135308. * full screen.
  135309. */
  135310. requestPointerLockOnFullScreen: boolean;
  135311. /**
  135312. * If asking to force XR, this will be populated with the default xr experience
  135313. */
  135314. xr: WebXRDefaultExperience;
  135315. /**
  135316. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  135317. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  135318. */
  135319. xrTestDone: boolean;
  135320. /**
  135321. * Instantiates a VRExperienceHelper.
  135322. * Helps to quickly add VR support to an existing scene.
  135323. * @param scene The scene the VRExperienceHelper belongs to.
  135324. * @param webVROptions Options to modify the vr experience helper's behavior.
  135325. */
  135326. constructor(scene: Scene,
  135327. /** Options to modify the vr experience helper's behavior. */
  135328. webVROptions?: VRExperienceHelperOptions);
  135329. private completeVRInit;
  135330. private _onDefaultMeshLoaded;
  135331. private _onResize;
  135332. private _onFullscreenChange;
  135333. /**
  135334. * Gets a value indicating if we are currently in VR mode.
  135335. */
  135336. get isInVRMode(): boolean;
  135337. private onVrDisplayPresentChange;
  135338. private onVRDisplayChanged;
  135339. private moveButtonToBottomRight;
  135340. private displayVRButton;
  135341. private updateButtonVisibility;
  135342. private _cachedAngularSensibility;
  135343. /**
  135344. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  135345. * Otherwise, will use the fullscreen API.
  135346. */
  135347. enterVR(): void;
  135348. /**
  135349. * Attempt to exit VR, or fullscreen.
  135350. */
  135351. exitVR(): void;
  135352. /**
  135353. * The position of the vr experience helper.
  135354. */
  135355. get position(): Vector3;
  135356. /**
  135357. * Sets the position of the vr experience helper.
  135358. */
  135359. set position(value: Vector3);
  135360. /**
  135361. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  135362. */
  135363. enableInteractions(): void;
  135364. private get _noControllerIsActive();
  135365. private beforeRender;
  135366. private _isTeleportationFloor;
  135367. /**
  135368. * Adds a floor mesh to be used for teleportation.
  135369. * @param floorMesh the mesh to be used for teleportation.
  135370. */
  135371. addFloorMesh(floorMesh: Mesh): void;
  135372. /**
  135373. * Removes a floor mesh from being used for teleportation.
  135374. * @param floorMesh the mesh to be removed.
  135375. */
  135376. removeFloorMesh(floorMesh: Mesh): void;
  135377. /**
  135378. * Enables interactions and teleportation using the VR controllers and gaze.
  135379. * @param vrTeleportationOptions options to modify teleportation behavior.
  135380. */
  135381. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  135382. private _onNewGamepadConnected;
  135383. private _tryEnableInteractionOnController;
  135384. private _onNewGamepadDisconnected;
  135385. private _enableInteractionOnController;
  135386. private _checkTeleportWithRay;
  135387. private _checkRotate;
  135388. private _checkTeleportBackwards;
  135389. private _enableTeleportationOnController;
  135390. private _createTeleportationCircles;
  135391. private _displayTeleportationTarget;
  135392. private _hideTeleportationTarget;
  135393. private _rotateCamera;
  135394. private _moveTeleportationSelectorTo;
  135395. private _workingVector;
  135396. private _workingQuaternion;
  135397. private _workingMatrix;
  135398. /**
  135399. * Time Constant Teleportation Mode
  135400. */
  135401. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  135402. /**
  135403. * Speed Constant Teleportation Mode
  135404. */
  135405. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  135406. /**
  135407. * Teleports the users feet to the desired location
  135408. * @param location The location where the user's feet should be placed
  135409. */
  135410. teleportCamera(location: Vector3): void;
  135411. private _convertNormalToDirectionOfRay;
  135412. private _castRayAndSelectObject;
  135413. private _notifySelectedMeshUnselected;
  135414. /**
  135415. * Permanently set new colors for the laser pointer
  135416. * @param color the new laser color
  135417. * @param pickedColor the new laser color when picked mesh detected
  135418. */
  135419. setLaserColor(color: Color3, pickedColor?: Color3): void;
  135420. /**
  135421. * Set lighting enabled / disabled on the laser pointer of both controllers
  135422. * @param enabled should the lighting be enabled on the laser pointer
  135423. */
  135424. setLaserLightingState(enabled?: boolean): void;
  135425. /**
  135426. * Permanently set new colors for the gaze pointer
  135427. * @param color the new gaze color
  135428. * @param pickedColor the new gaze color when picked mesh detected
  135429. */
  135430. setGazeColor(color: Color3, pickedColor?: Color3): void;
  135431. /**
  135432. * Sets the color of the laser ray from the vr controllers.
  135433. * @param color new color for the ray.
  135434. */
  135435. changeLaserColor(color: Color3): void;
  135436. /**
  135437. * Sets the color of the ray from the vr headsets gaze.
  135438. * @param color new color for the ray.
  135439. */
  135440. changeGazeColor(color: Color3): void;
  135441. /**
  135442. * Exits VR and disposes of the vr experience helper
  135443. */
  135444. dispose(): void;
  135445. /**
  135446. * Gets the name of the VRExperienceHelper class
  135447. * @returns "VRExperienceHelper"
  135448. */
  135449. getClassName(): string;
  135450. }
  135451. }
  135452. declare module BABYLON {
  135453. /**
  135454. * Contains an array of blocks representing the octree
  135455. */
  135456. export interface IOctreeContainer<T> {
  135457. /**
  135458. * Blocks within the octree
  135459. */
  135460. blocks: Array<OctreeBlock<T>>;
  135461. }
  135462. /**
  135463. * Class used to store a cell in an octree
  135464. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135465. */
  135466. export class OctreeBlock<T> {
  135467. /**
  135468. * Gets the content of the current block
  135469. */
  135470. entries: T[];
  135471. /**
  135472. * Gets the list of block children
  135473. */
  135474. blocks: Array<OctreeBlock<T>>;
  135475. private _depth;
  135476. private _maxDepth;
  135477. private _capacity;
  135478. private _minPoint;
  135479. private _maxPoint;
  135480. private _boundingVectors;
  135481. private _creationFunc;
  135482. /**
  135483. * Creates a new block
  135484. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  135485. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  135486. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135487. * @param depth defines the current depth of this block in the octree
  135488. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  135489. * @param creationFunc defines a callback to call when an element is added to the block
  135490. */
  135491. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  135492. /**
  135493. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  135494. */
  135495. get capacity(): number;
  135496. /**
  135497. * Gets the minimum vector (in world space) of the block's bounding box
  135498. */
  135499. get minPoint(): Vector3;
  135500. /**
  135501. * Gets the maximum vector (in world space) of the block's bounding box
  135502. */
  135503. get maxPoint(): Vector3;
  135504. /**
  135505. * Add a new element to this block
  135506. * @param entry defines the element to add
  135507. */
  135508. addEntry(entry: T): void;
  135509. /**
  135510. * Remove an element from this block
  135511. * @param entry defines the element to remove
  135512. */
  135513. removeEntry(entry: T): void;
  135514. /**
  135515. * Add an array of elements to this block
  135516. * @param entries defines the array of elements to add
  135517. */
  135518. addEntries(entries: T[]): void;
  135519. /**
  135520. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  135521. * @param frustumPlanes defines the frustum planes to test
  135522. * @param selection defines the array to store current content if selection is positive
  135523. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135524. */
  135525. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135526. /**
  135527. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  135528. * @param sphereCenter defines the bounding sphere center
  135529. * @param sphereRadius defines the bounding sphere radius
  135530. * @param selection defines the array to store current content if selection is positive
  135531. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135532. */
  135533. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  135534. /**
  135535. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  135536. * @param ray defines the ray to test with
  135537. * @param selection defines the array to store current content if selection is positive
  135538. */
  135539. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  135540. /**
  135541. * Subdivide the content into child blocks (this block will then be empty)
  135542. */
  135543. createInnerBlocks(): void;
  135544. /**
  135545. * @hidden
  135546. */
  135547. 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;
  135548. }
  135549. }
  135550. declare module BABYLON {
  135551. /**
  135552. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  135553. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135554. */
  135555. export class Octree<T> {
  135556. /** 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.) */
  135557. maxDepth: number;
  135558. /**
  135559. * Blocks within the octree containing objects
  135560. */
  135561. blocks: Array<OctreeBlock<T>>;
  135562. /**
  135563. * Content stored in the octree
  135564. */
  135565. dynamicContent: T[];
  135566. private _maxBlockCapacity;
  135567. private _selectionContent;
  135568. private _creationFunc;
  135569. /**
  135570. * Creates a octree
  135571. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135572. * @param creationFunc function to be used to instatiate the octree
  135573. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  135574. * @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.)
  135575. */
  135576. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  135577. /** 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.) */
  135578. maxDepth?: number);
  135579. /**
  135580. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  135581. * @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);
  135582. * @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);
  135583. * @param entries meshes to be added to the octree blocks
  135584. */
  135585. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  135586. /**
  135587. * Adds a mesh to the octree
  135588. * @param entry Mesh to add to the octree
  135589. */
  135590. addMesh(entry: T): void;
  135591. /**
  135592. * Remove an element from the octree
  135593. * @param entry defines the element to remove
  135594. */
  135595. removeMesh(entry: T): void;
  135596. /**
  135597. * Selects an array of meshes within the frustum
  135598. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  135599. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  135600. * @returns array of meshes within the frustum
  135601. */
  135602. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  135603. /**
  135604. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  135605. * @param sphereCenter defines the bounding sphere center
  135606. * @param sphereRadius defines the bounding sphere radius
  135607. * @param allowDuplicate defines if the selection array can contains duplicated entries
  135608. * @returns an array of objects that intersect the sphere
  135609. */
  135610. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  135611. /**
  135612. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  135613. * @param ray defines the ray to test with
  135614. * @returns array of intersected objects
  135615. */
  135616. intersectsRay(ray: Ray): SmartArray<T>;
  135617. /**
  135618. * Adds a mesh into the octree block if it intersects the block
  135619. */
  135620. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  135621. /**
  135622. * Adds a submesh into the octree block if it intersects the block
  135623. */
  135624. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  135625. }
  135626. }
  135627. declare module BABYLON {
  135628. interface Scene {
  135629. /**
  135630. * @hidden
  135631. * Backing Filed
  135632. */
  135633. _selectionOctree: Octree<AbstractMesh>;
  135634. /**
  135635. * Gets the octree used to boost mesh selection (picking)
  135636. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135637. */
  135638. selectionOctree: Octree<AbstractMesh>;
  135639. /**
  135640. * Creates or updates the octree used to boost selection (picking)
  135641. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135642. * @param maxCapacity defines the maximum capacity per leaf
  135643. * @param maxDepth defines the maximum depth of the octree
  135644. * @returns an octree of AbstractMesh
  135645. */
  135646. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  135647. }
  135648. interface AbstractMesh {
  135649. /**
  135650. * @hidden
  135651. * Backing Field
  135652. */
  135653. _submeshesOctree: Octree<SubMesh>;
  135654. /**
  135655. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  135656. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  135657. * @param maxCapacity defines the maximum size of each block (64 by default)
  135658. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  135659. * @returns the new octree
  135660. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  135661. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  135662. */
  135663. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  135664. }
  135665. /**
  135666. * Defines the octree scene component responsible to manage any octrees
  135667. * in a given scene.
  135668. */
  135669. export class OctreeSceneComponent {
  135670. /**
  135671. * The component name help to identify the component in the list of scene components.
  135672. */
  135673. readonly name: string;
  135674. /**
  135675. * The scene the component belongs to.
  135676. */
  135677. scene: Scene;
  135678. /**
  135679. * Indicates if the meshes have been checked to make sure they are isEnabled()
  135680. */
  135681. readonly checksIsEnabled: boolean;
  135682. /**
  135683. * Creates a new instance of the component for the given scene
  135684. * @param scene Defines the scene to register the component in
  135685. */
  135686. constructor(scene: Scene);
  135687. /**
  135688. * Registers the component in a given scene
  135689. */
  135690. register(): void;
  135691. /**
  135692. * Return the list of active meshes
  135693. * @returns the list of active meshes
  135694. */
  135695. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  135696. /**
  135697. * Return the list of active sub meshes
  135698. * @param mesh The mesh to get the candidates sub meshes from
  135699. * @returns the list of active sub meshes
  135700. */
  135701. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  135702. private _tempRay;
  135703. /**
  135704. * Return the list of sub meshes intersecting with a given local ray
  135705. * @param mesh defines the mesh to find the submesh for
  135706. * @param localRay defines the ray in local space
  135707. * @returns the list of intersecting sub meshes
  135708. */
  135709. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  135710. /**
  135711. * Return the list of sub meshes colliding with a collider
  135712. * @param mesh defines the mesh to find the submesh for
  135713. * @param collider defines the collider to evaluate the collision against
  135714. * @returns the list of colliding sub meshes
  135715. */
  135716. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  135717. /**
  135718. * Rebuilds the elements related to this component in case of
  135719. * context lost for instance.
  135720. */
  135721. rebuild(): void;
  135722. /**
  135723. * Disposes the component and the associated ressources.
  135724. */
  135725. dispose(): void;
  135726. }
  135727. }
  135728. declare module BABYLON {
  135729. /**
  135730. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  135731. */
  135732. export interface GizmoAxisCache {
  135733. /** Mesh used to runder the Gizmo */
  135734. gizmoMeshes: Mesh[];
  135735. /** Mesh used to detect user interaction with Gizmo */
  135736. colliderMeshes: Mesh[];
  135737. /** Material used to inicate color of gizmo mesh */
  135738. material: StandardMaterial;
  135739. /** Material used to inicate hover state of the Gizmo */
  135740. hoverMaterial: StandardMaterial;
  135741. /** Material used to inicate disabled state of the Gizmo */
  135742. disableMaterial: StandardMaterial;
  135743. /** Used to indicate Active state of the Gizmo */
  135744. active: boolean;
  135745. }
  135746. /**
  135747. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  135748. */
  135749. export class Gizmo implements IDisposable {
  135750. /** The utility layer the gizmo will be added to */
  135751. gizmoLayer: UtilityLayerRenderer;
  135752. /**
  135753. * The root mesh of the gizmo
  135754. */
  135755. _rootMesh: Mesh;
  135756. private _attachedMesh;
  135757. private _attachedNode;
  135758. /**
  135759. * Ratio for the scale of the gizmo (Default: 1)
  135760. */
  135761. protected _scaleRatio: number;
  135762. /**
  135763. * boolean updated by pointermove when a gizmo mesh is hovered
  135764. */
  135765. protected _isHovered: boolean;
  135766. /**
  135767. * Ratio for the scale of the gizmo (Default: 1)
  135768. */
  135769. set scaleRatio(value: number);
  135770. get scaleRatio(): number;
  135771. /**
  135772. * True when the mouse pointer is hovered a gizmo mesh
  135773. */
  135774. get isHovered(): boolean;
  135775. /**
  135776. * If a custom mesh has been set (Default: false)
  135777. */
  135778. protected _customMeshSet: boolean;
  135779. /**
  135780. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  135781. * * When set, interactions will be enabled
  135782. */
  135783. get attachedMesh(): Nullable<AbstractMesh>;
  135784. set attachedMesh(value: Nullable<AbstractMesh>);
  135785. /**
  135786. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  135787. * * When set, interactions will be enabled
  135788. */
  135789. get attachedNode(): Nullable<Node>;
  135790. set attachedNode(value: Nullable<Node>);
  135791. /**
  135792. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  135793. * @param mesh The mesh to replace the default mesh of the gizmo
  135794. */
  135795. setCustomMesh(mesh: Mesh): void;
  135796. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  135797. /**
  135798. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  135799. */
  135800. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135801. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135802. /**
  135803. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  135804. */
  135805. updateGizmoPositionToMatchAttachedMesh: boolean;
  135806. /**
  135807. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  135808. */
  135809. updateScale: boolean;
  135810. protected _interactionsEnabled: boolean;
  135811. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135812. private _beforeRenderObserver;
  135813. private _tempQuaternion;
  135814. private _tempVector;
  135815. private _tempVector2;
  135816. private _tempMatrix1;
  135817. private _tempMatrix2;
  135818. private _rightHandtoLeftHandMatrix;
  135819. /**
  135820. * Creates a gizmo
  135821. * @param gizmoLayer The utility layer the gizmo will be added to
  135822. */
  135823. constructor(
  135824. /** The utility layer the gizmo will be added to */
  135825. gizmoLayer?: UtilityLayerRenderer);
  135826. /**
  135827. * Updates the gizmo to match the attached mesh's position/rotation
  135828. */
  135829. protected _update(): void;
  135830. /**
  135831. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  135832. * @param value Node, TransformNode or mesh
  135833. */
  135834. protected _matrixChanged(): void;
  135835. /**
  135836. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  135837. * @param gizmoLayer The utility layer the gizmo will be added to
  135838. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  135839. * @returns {Observer<PointerInfo>} pointerObserver
  135840. */
  135841. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  135842. /**
  135843. * Disposes of the gizmo
  135844. */
  135845. dispose(): void;
  135846. }
  135847. }
  135848. declare module BABYLON {
  135849. /**
  135850. * Single plane drag gizmo
  135851. */
  135852. export class PlaneDragGizmo extends Gizmo {
  135853. /**
  135854. * Drag behavior responsible for the gizmos dragging interactions
  135855. */
  135856. dragBehavior: PointerDragBehavior;
  135857. private _pointerObserver;
  135858. /**
  135859. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135860. */
  135861. snapDistance: number;
  135862. /**
  135863. * Event that fires each time the gizmo snaps to a new location.
  135864. * * snapDistance is the the change in distance
  135865. */
  135866. onSnapObservable: Observable<{
  135867. snapDistance: number;
  135868. }>;
  135869. private _gizmoMesh;
  135870. private _coloredMaterial;
  135871. private _hoverMaterial;
  135872. private _disableMaterial;
  135873. private _isEnabled;
  135874. private _parent;
  135875. private _dragging;
  135876. /** @hidden */
  135877. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135878. /**
  135879. * Creates a PlaneDragGizmo
  135880. * @param gizmoLayer The utility layer the gizmo will be added to
  135881. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135882. * @param color The color of the gizmo
  135883. */
  135884. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135885. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135886. /**
  135887. * If the gizmo is enabled
  135888. */
  135889. set isEnabled(value: boolean);
  135890. get isEnabled(): boolean;
  135891. /**
  135892. * Disposes of the gizmo
  135893. */
  135894. dispose(): void;
  135895. }
  135896. }
  135897. declare module BABYLON {
  135898. /**
  135899. * Single plane rotation gizmo
  135900. */
  135901. export class PlaneRotationGizmo extends Gizmo {
  135902. /**
  135903. * Drag behavior responsible for the gizmos dragging interactions
  135904. */
  135905. dragBehavior: PointerDragBehavior;
  135906. private _pointerObserver;
  135907. /**
  135908. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  135909. */
  135910. snapDistance: number;
  135911. /**
  135912. * Event that fires each time the gizmo snaps to a new location.
  135913. * * snapDistance is the the change in distance
  135914. */
  135915. onSnapObservable: Observable<{
  135916. snapDistance: number;
  135917. }>;
  135918. private _isEnabled;
  135919. private _parent;
  135920. private _coloredMaterial;
  135921. private _hoverMaterial;
  135922. private _disableMaterial;
  135923. private _gizmoMesh;
  135924. private _rotationCircle;
  135925. private _dragging;
  135926. private static _CircleConstants;
  135927. /**
  135928. * Creates a PlaneRotationGizmo
  135929. * @param gizmoLayer The utility layer the gizmo will be added to
  135930. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  135931. * @param color The color of the gizmo
  135932. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135933. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135934. * @param thickness display gizmo axis thickness
  135935. */
  135936. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  135937. /** Create Geometry for Gizmo */
  135938. private _createGizmoMesh;
  135939. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135940. private setupRotationCircle;
  135941. private updateRotationPath;
  135942. private updateRotationCircle;
  135943. /**
  135944. * If the gizmo is enabled
  135945. */
  135946. set isEnabled(value: boolean);
  135947. get isEnabled(): boolean;
  135948. /**
  135949. * Disposes of the gizmo
  135950. */
  135951. dispose(): void;
  135952. }
  135953. }
  135954. declare module BABYLON {
  135955. /**
  135956. * Gizmo that enables rotating a mesh along 3 axis
  135957. */
  135958. export class RotationGizmo extends Gizmo {
  135959. /**
  135960. * Internal gizmo used for interactions on the x axis
  135961. */
  135962. xGizmo: PlaneRotationGizmo;
  135963. /**
  135964. * Internal gizmo used for interactions on the y axis
  135965. */
  135966. yGizmo: PlaneRotationGizmo;
  135967. /**
  135968. * Internal gizmo used for interactions on the z axis
  135969. */
  135970. zGizmo: PlaneRotationGizmo;
  135971. /** Fires an event when any of it's sub gizmos are dragged */
  135972. onDragStartObservable: Observable<unknown>;
  135973. /** Fires an event when any of it's sub gizmos are released from dragging */
  135974. onDragEndObservable: Observable<unknown>;
  135975. private _meshAttached;
  135976. private _nodeAttached;
  135977. private _observables;
  135978. /** Node Caching for quick lookup */
  135979. private _gizmoAxisCache;
  135980. get attachedMesh(): Nullable<AbstractMesh>;
  135981. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135982. get attachedNode(): Nullable<Node>;
  135983. set attachedNode(node: Nullable<Node>);
  135984. protected _checkBillboardTransform(): void;
  135985. /**
  135986. * True when the mouse pointer is hovering a gizmo mesh
  135987. */
  135988. get isHovered(): boolean;
  135989. /**
  135990. * Creates a RotationGizmo
  135991. * @param gizmoLayer The utility layer the gizmo will be added to
  135992. * @param tessellation Amount of tessellation to be used when creating rotation circles
  135993. * @param useEulerRotation Use and update Euler angle instead of quaternion
  135994. * @param thickness display gizmo axis thickness
  135995. */
  135996. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  135997. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135998. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135999. /**
  136000. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136001. */
  136002. set snapDistance(value: number);
  136003. get snapDistance(): number;
  136004. /**
  136005. * Ratio for the scale of the gizmo (Default: 1)
  136006. */
  136007. set scaleRatio(value: number);
  136008. get scaleRatio(): number;
  136009. /**
  136010. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136011. * @param mesh Axis gizmo mesh
  136012. * @param cache Gizmo axis definition used for reactive gizmo UI
  136013. */
  136014. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136015. /**
  136016. * Disposes of the gizmo
  136017. */
  136018. dispose(): void;
  136019. /**
  136020. * CustomMeshes are not supported by this gizmo
  136021. * @param mesh The mesh to replace the default mesh of the gizmo
  136022. */
  136023. setCustomMesh(mesh: Mesh): void;
  136024. }
  136025. }
  136026. declare module BABYLON {
  136027. /**
  136028. * Class containing static functions to help procedurally build meshes
  136029. */
  136030. export class PolyhedronBuilder {
  136031. /**
  136032. * Creates a polyhedron mesh
  136033. * * 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
  136034. * * The parameter `size` (positive float, default 1) sets the polygon size
  136035. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136036. * * 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`
  136037. * * 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
  136038. * * 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)`)
  136039. * * 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
  136040. * * 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
  136041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136044. * @param name defines the name of the mesh
  136045. * @param options defines the options used to create the mesh
  136046. * @param scene defines the hosting scene
  136047. * @returns the polyhedron mesh
  136048. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136049. */
  136050. static CreatePolyhedron(name: string, options: {
  136051. type?: number;
  136052. size?: number;
  136053. sizeX?: number;
  136054. sizeY?: number;
  136055. sizeZ?: number;
  136056. custom?: any;
  136057. faceUV?: Vector4[];
  136058. faceColors?: Color4[];
  136059. flat?: boolean;
  136060. updatable?: boolean;
  136061. sideOrientation?: number;
  136062. frontUVs?: Vector4;
  136063. backUVs?: Vector4;
  136064. }, scene?: Nullable<Scene>): Mesh;
  136065. }
  136066. }
  136067. declare module BABYLON {
  136068. /**
  136069. * Class containing static functions to help procedurally build meshes
  136070. */
  136071. export class BoxBuilder {
  136072. /**
  136073. * Creates a box mesh
  136074. * * The parameter `size` sets the size (float) of each box side (default 1)
  136075. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  136076. * * 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)
  136077. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136081. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  136082. * @param name defines the name of the mesh
  136083. * @param options defines the options used to create the mesh
  136084. * @param scene defines the hosting scene
  136085. * @returns the box mesh
  136086. */
  136087. static CreateBox(name: string, options: {
  136088. size?: number;
  136089. width?: number;
  136090. height?: number;
  136091. depth?: number;
  136092. faceUV?: Vector4[];
  136093. faceColors?: Color4[];
  136094. sideOrientation?: number;
  136095. frontUVs?: Vector4;
  136096. backUVs?: Vector4;
  136097. wrap?: boolean;
  136098. topBaseAt?: number;
  136099. bottomBaseAt?: number;
  136100. updatable?: boolean;
  136101. }, scene?: Nullable<Scene>): Mesh;
  136102. }
  136103. }
  136104. declare module BABYLON {
  136105. /**
  136106. * Single axis scale gizmo
  136107. */
  136108. export class AxisScaleGizmo extends Gizmo {
  136109. /**
  136110. * Drag behavior responsible for the gizmos dragging interactions
  136111. */
  136112. dragBehavior: PointerDragBehavior;
  136113. private _pointerObserver;
  136114. /**
  136115. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136116. */
  136117. snapDistance: number;
  136118. /**
  136119. * Event that fires each time the gizmo snaps to a new location.
  136120. * * snapDistance is the the change in distance
  136121. */
  136122. onSnapObservable: Observable<{
  136123. snapDistance: number;
  136124. }>;
  136125. /**
  136126. * If the scaling operation should be done on all axis (default: false)
  136127. */
  136128. uniformScaling: boolean;
  136129. /**
  136130. * Custom sensitivity value for the drag strength
  136131. */
  136132. sensitivity: number;
  136133. private _isEnabled;
  136134. private _parent;
  136135. private _gizmoMesh;
  136136. private _coloredMaterial;
  136137. private _hoverMaterial;
  136138. private _disableMaterial;
  136139. private _dragging;
  136140. private _tmpVector;
  136141. private _tmpMatrix;
  136142. private _tmpMatrix2;
  136143. /**
  136144. * Creates an AxisScaleGizmo
  136145. * @param gizmoLayer The utility layer the gizmo will be added to
  136146. * @param dragAxis The axis which the gizmo will be able to scale on
  136147. * @param color The color of the gizmo
  136148. * @param thickness display gizmo axis thickness
  136149. */
  136150. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  136151. /** Create Geometry for Gizmo */
  136152. private _createGizmoMesh;
  136153. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136154. /**
  136155. * If the gizmo is enabled
  136156. */
  136157. set isEnabled(value: boolean);
  136158. get isEnabled(): boolean;
  136159. /**
  136160. * Disposes of the gizmo
  136161. */
  136162. dispose(): void;
  136163. /**
  136164. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  136165. * @param mesh The mesh to replace the default mesh of the gizmo
  136166. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  136167. */
  136168. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  136169. }
  136170. }
  136171. declare module BABYLON {
  136172. /**
  136173. * Gizmo that enables scaling a mesh along 3 axis
  136174. */
  136175. export class ScaleGizmo extends Gizmo {
  136176. /**
  136177. * Internal gizmo used for interactions on the x axis
  136178. */
  136179. xGizmo: AxisScaleGizmo;
  136180. /**
  136181. * Internal gizmo used for interactions on the y axis
  136182. */
  136183. yGizmo: AxisScaleGizmo;
  136184. /**
  136185. * Internal gizmo used for interactions on the z axis
  136186. */
  136187. zGizmo: AxisScaleGizmo;
  136188. /**
  136189. * Internal gizmo used to scale all axis equally
  136190. */
  136191. uniformScaleGizmo: AxisScaleGizmo;
  136192. private _meshAttached;
  136193. private _nodeAttached;
  136194. private _snapDistance;
  136195. private _uniformScalingMesh;
  136196. private _octahedron;
  136197. private _sensitivity;
  136198. private _coloredMaterial;
  136199. private _hoverMaterial;
  136200. private _disableMaterial;
  136201. private _observables;
  136202. /** Node Caching for quick lookup */
  136203. private _gizmoAxisCache;
  136204. /** Fires an event when any of it's sub gizmos are dragged */
  136205. onDragStartObservable: Observable<unknown>;
  136206. /** Fires an event when any of it's sub gizmos are released from dragging */
  136207. onDragEndObservable: Observable<unknown>;
  136208. get attachedMesh(): Nullable<AbstractMesh>;
  136209. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136210. get attachedNode(): Nullable<Node>;
  136211. set attachedNode(node: Nullable<Node>);
  136212. /**
  136213. * True when the mouse pointer is hovering a gizmo mesh
  136214. */
  136215. get isHovered(): boolean;
  136216. /**
  136217. * Creates a ScaleGizmo
  136218. * @param gizmoLayer The utility layer the gizmo will be added to
  136219. * @param thickness display gizmo axis thickness
  136220. */
  136221. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136222. /** Create Geometry for Gizmo */
  136223. private _createUniformScaleMesh;
  136224. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136225. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136226. /**
  136227. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136228. */
  136229. set snapDistance(value: number);
  136230. get snapDistance(): number;
  136231. /**
  136232. * Ratio for the scale of the gizmo (Default: 1)
  136233. */
  136234. set scaleRatio(value: number);
  136235. get scaleRatio(): number;
  136236. /**
  136237. * Sensitivity factor for dragging (Default: 1)
  136238. */
  136239. set sensitivity(value: number);
  136240. get sensitivity(): number;
  136241. /**
  136242. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136243. * @param mesh Axis gizmo mesh
  136244. * @param cache Gizmo axis definition used for reactive gizmo UI
  136245. */
  136246. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136247. /**
  136248. * Disposes of the gizmo
  136249. */
  136250. dispose(): void;
  136251. }
  136252. }
  136253. declare module BABYLON {
  136254. /**
  136255. * Bounding box gizmo
  136256. */
  136257. export class BoundingBoxGizmo extends Gizmo {
  136258. private _lineBoundingBox;
  136259. private _rotateSpheresParent;
  136260. private _scaleBoxesParent;
  136261. private _boundingDimensions;
  136262. private _renderObserver;
  136263. private _pointerObserver;
  136264. private _scaleDragSpeed;
  136265. private _tmpQuaternion;
  136266. private _tmpVector;
  136267. private _tmpRotationMatrix;
  136268. /**
  136269. * 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)
  136270. */
  136271. ignoreChildren: boolean;
  136272. /**
  136273. * 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)
  136274. */
  136275. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  136276. /**
  136277. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  136278. */
  136279. rotationSphereSize: number;
  136280. /**
  136281. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  136282. */
  136283. scaleBoxSize: number;
  136284. /**
  136285. * 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)
  136286. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  136287. */
  136288. fixedDragMeshScreenSize: boolean;
  136289. /**
  136290. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  136291. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  136292. */
  136293. fixedDragMeshBoundsSize: boolean;
  136294. /**
  136295. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  136296. */
  136297. fixedDragMeshScreenSizeDistanceFactor: number;
  136298. /**
  136299. * Fired when a rotation sphere or scale box is dragged
  136300. */
  136301. onDragStartObservable: Observable<{}>;
  136302. /**
  136303. * Fired when a scale box is dragged
  136304. */
  136305. onScaleBoxDragObservable: Observable<{}>;
  136306. /**
  136307. * Fired when a scale box drag is ended
  136308. */
  136309. onScaleBoxDragEndObservable: Observable<{}>;
  136310. /**
  136311. * Fired when a rotation sphere is dragged
  136312. */
  136313. onRotationSphereDragObservable: Observable<{}>;
  136314. /**
  136315. * Fired when a rotation sphere drag is ended
  136316. */
  136317. onRotationSphereDragEndObservable: Observable<{}>;
  136318. /**
  136319. * 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)
  136320. */
  136321. scalePivot: Nullable<Vector3>;
  136322. /**
  136323. * Mesh used as a pivot to rotate the attached node
  136324. */
  136325. private _anchorMesh;
  136326. private _existingMeshScale;
  136327. private _dragMesh;
  136328. private pointerDragBehavior;
  136329. private coloredMaterial;
  136330. private hoverColoredMaterial;
  136331. /**
  136332. * Sets the color of the bounding box gizmo
  136333. * @param color the color to set
  136334. */
  136335. setColor(color: Color3): void;
  136336. /**
  136337. * Creates an BoundingBoxGizmo
  136338. * @param gizmoLayer The utility layer the gizmo will be added to
  136339. * @param color The color of the gizmo
  136340. */
  136341. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  136342. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  136343. private _selectNode;
  136344. /**
  136345. * Updates the bounding box information for the Gizmo
  136346. */
  136347. updateBoundingBox(): void;
  136348. private _updateRotationSpheres;
  136349. private _updateScaleBoxes;
  136350. /**
  136351. * Enables rotation on the specified axis and disables rotation on the others
  136352. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  136353. */
  136354. setEnabledRotationAxis(axis: string): void;
  136355. /**
  136356. * Enables/disables scaling
  136357. * @param enable if scaling should be enabled
  136358. * @param homogeneousScaling defines if scaling should only be homogeneous
  136359. */
  136360. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  136361. private _updateDummy;
  136362. /**
  136363. * Enables a pointer drag behavior on the bounding box of the gizmo
  136364. */
  136365. enableDragBehavior(): void;
  136366. /**
  136367. * Disposes of the gizmo
  136368. */
  136369. dispose(): void;
  136370. /**
  136371. * 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)
  136372. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  136373. * @returns the bounding box mesh with the passed in mesh as a child
  136374. */
  136375. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  136376. /**
  136377. * CustomMeshes are not supported by this gizmo
  136378. * @param mesh The mesh to replace the default mesh of the gizmo
  136379. */
  136380. setCustomMesh(mesh: Mesh): void;
  136381. }
  136382. }
  136383. declare module BABYLON {
  136384. /**
  136385. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  136386. */
  136387. export class GizmoManager implements IDisposable {
  136388. private scene;
  136389. /**
  136390. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  136391. */
  136392. gizmos: {
  136393. positionGizmo: Nullable<PositionGizmo>;
  136394. rotationGizmo: Nullable<RotationGizmo>;
  136395. scaleGizmo: Nullable<ScaleGizmo>;
  136396. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  136397. };
  136398. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  136399. clearGizmoOnEmptyPointerEvent: boolean;
  136400. /** Fires an event when the manager is attached to a mesh */
  136401. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  136402. /** Fires an event when the manager is attached to a node */
  136403. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  136404. private _gizmosEnabled;
  136405. private _pointerObservers;
  136406. private _attachedMesh;
  136407. private _attachedNode;
  136408. private _boundingBoxColor;
  136409. private _defaultUtilityLayer;
  136410. private _defaultKeepDepthUtilityLayer;
  136411. private _thickness;
  136412. /** Node Caching for quick lookup */
  136413. private _gizmoAxisCache;
  136414. /**
  136415. * When bounding box gizmo is enabled, this can be used to track drag/end events
  136416. */
  136417. boundingBoxDragBehavior: SixDofDragBehavior;
  136418. /**
  136419. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  136420. */
  136421. attachableMeshes: Nullable<Array<AbstractMesh>>;
  136422. /**
  136423. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  136424. */
  136425. attachableNodes: Nullable<Array<Node>>;
  136426. /**
  136427. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  136428. */
  136429. usePointerToAttachGizmos: boolean;
  136430. /**
  136431. * Utility layer that the bounding box gizmo belongs to
  136432. */
  136433. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  136434. /**
  136435. * Utility layer that all gizmos besides bounding box belong to
  136436. */
  136437. get utilityLayer(): UtilityLayerRenderer;
  136438. /**
  136439. * True when the mouse pointer is hovering a gizmo mesh
  136440. */
  136441. get isHovered(): boolean;
  136442. /**
  136443. * Instatiates a gizmo manager
  136444. * @param scene the scene to overlay the gizmos on top of
  136445. * @param thickness display gizmo axis thickness
  136446. * @param utilityLayer the layer where gizmos are rendered
  136447. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  136448. */
  136449. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  136450. /**
  136451. * Subscribes to pointer down events, for attaching and detaching mesh
  136452. * @param scene The sceme layer the observer will be added to
  136453. */
  136454. private _attachToMeshPointerObserver;
  136455. /**
  136456. * Attaches a set of gizmos to the specified mesh
  136457. * @param mesh The mesh the gizmo's should be attached to
  136458. */
  136459. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  136460. /**
  136461. * Attaches a set of gizmos to the specified node
  136462. * @param node The node the gizmo's should be attached to
  136463. */
  136464. attachToNode(node: Nullable<Node>): void;
  136465. /**
  136466. * If the position gizmo is enabled
  136467. */
  136468. set positionGizmoEnabled(value: boolean);
  136469. get positionGizmoEnabled(): boolean;
  136470. /**
  136471. * If the rotation gizmo is enabled
  136472. */
  136473. set rotationGizmoEnabled(value: boolean);
  136474. get rotationGizmoEnabled(): boolean;
  136475. /**
  136476. * If the scale gizmo is enabled
  136477. */
  136478. set scaleGizmoEnabled(value: boolean);
  136479. get scaleGizmoEnabled(): boolean;
  136480. /**
  136481. * If the boundingBox gizmo is enabled
  136482. */
  136483. set boundingBoxGizmoEnabled(value: boolean);
  136484. get boundingBoxGizmoEnabled(): boolean;
  136485. /**
  136486. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136487. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  136488. */
  136489. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  136490. /**
  136491. * Disposes of the gizmo manager
  136492. */
  136493. dispose(): void;
  136494. }
  136495. }
  136496. declare module BABYLON {
  136497. /**
  136498. * Gizmo that enables dragging a mesh along 3 axis
  136499. */
  136500. export class PositionGizmo extends Gizmo {
  136501. /**
  136502. * Internal gizmo used for interactions on the x axis
  136503. */
  136504. xGizmo: AxisDragGizmo;
  136505. /**
  136506. * Internal gizmo used for interactions on the y axis
  136507. */
  136508. yGizmo: AxisDragGizmo;
  136509. /**
  136510. * Internal gizmo used for interactions on the z axis
  136511. */
  136512. zGizmo: AxisDragGizmo;
  136513. /**
  136514. * Internal gizmo used for interactions on the yz plane
  136515. */
  136516. xPlaneGizmo: PlaneDragGizmo;
  136517. /**
  136518. * Internal gizmo used for interactions on the xz plane
  136519. */
  136520. yPlaneGizmo: PlaneDragGizmo;
  136521. /**
  136522. * Internal gizmo used for interactions on the xy plane
  136523. */
  136524. zPlaneGizmo: PlaneDragGizmo;
  136525. /**
  136526. * private variables
  136527. */
  136528. private _meshAttached;
  136529. private _nodeAttached;
  136530. private _snapDistance;
  136531. private _observables;
  136532. /** Node Caching for quick lookup */
  136533. private _gizmoAxisCache;
  136534. /** Fires an event when any of it's sub gizmos are dragged */
  136535. onDragStartObservable: Observable<unknown>;
  136536. /** Fires an event when any of it's sub gizmos are released from dragging */
  136537. onDragEndObservable: Observable<unknown>;
  136538. /**
  136539. * If set to true, planar drag is enabled
  136540. */
  136541. private _planarGizmoEnabled;
  136542. get attachedMesh(): Nullable<AbstractMesh>;
  136543. set attachedMesh(mesh: Nullable<AbstractMesh>);
  136544. get attachedNode(): Nullable<Node>;
  136545. set attachedNode(node: Nullable<Node>);
  136546. /**
  136547. * True when the mouse pointer is hovering a gizmo mesh
  136548. */
  136549. get isHovered(): boolean;
  136550. /**
  136551. * Creates a PositionGizmo
  136552. * @param gizmoLayer The utility layer the gizmo will be added to
  136553. @param thickness display gizmo axis thickness
  136554. */
  136555. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  136556. /**
  136557. * If the planar drag gizmo is enabled
  136558. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  136559. */
  136560. set planarGizmoEnabled(value: boolean);
  136561. get planarGizmoEnabled(): boolean;
  136562. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  136563. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  136564. /**
  136565. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136566. */
  136567. set snapDistance(value: number);
  136568. get snapDistance(): number;
  136569. /**
  136570. * Ratio for the scale of the gizmo (Default: 1)
  136571. */
  136572. set scaleRatio(value: number);
  136573. get scaleRatio(): number;
  136574. /**
  136575. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  136576. * @param mesh Axis gizmo mesh
  136577. * @param cache Gizmo axis definition used for reactive gizmo UI
  136578. */
  136579. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  136580. /**
  136581. * Disposes of the gizmo
  136582. */
  136583. dispose(): void;
  136584. /**
  136585. * CustomMeshes are not supported by this gizmo
  136586. * @param mesh The mesh to replace the default mesh of the gizmo
  136587. */
  136588. setCustomMesh(mesh: Mesh): void;
  136589. }
  136590. }
  136591. declare module BABYLON {
  136592. /**
  136593. * Single axis drag gizmo
  136594. */
  136595. export class AxisDragGizmo extends Gizmo {
  136596. /**
  136597. * Drag behavior responsible for the gizmos dragging interactions
  136598. */
  136599. dragBehavior: PointerDragBehavior;
  136600. private _pointerObserver;
  136601. /**
  136602. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  136603. */
  136604. snapDistance: number;
  136605. /**
  136606. * Event that fires each time the gizmo snaps to a new location.
  136607. * * snapDistance is the the change in distance
  136608. */
  136609. onSnapObservable: Observable<{
  136610. snapDistance: number;
  136611. }>;
  136612. private _isEnabled;
  136613. private _parent;
  136614. private _gizmoMesh;
  136615. private _coloredMaterial;
  136616. private _hoverMaterial;
  136617. private _disableMaterial;
  136618. private _dragging;
  136619. /** @hidden */
  136620. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  136621. /** @hidden */
  136622. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  136623. /**
  136624. * Creates an AxisDragGizmo
  136625. * @param gizmoLayer The utility layer the gizmo will be added to
  136626. * @param dragAxis The axis which the gizmo will be able to drag on
  136627. * @param color The color of the gizmo
  136628. * @param thickness display gizmo axis thickness
  136629. */
  136630. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  136631. protected _attachedNodeChanged(value: Nullable<Node>): void;
  136632. /**
  136633. * If the gizmo is enabled
  136634. */
  136635. set isEnabled(value: boolean);
  136636. get isEnabled(): boolean;
  136637. /**
  136638. * Disposes of the gizmo
  136639. */
  136640. dispose(): void;
  136641. }
  136642. }
  136643. declare module BABYLON.Debug {
  136644. /**
  136645. * The Axes viewer will show 3 axes in a specific point in space
  136646. */
  136647. export class AxesViewer {
  136648. private _xAxis;
  136649. private _yAxis;
  136650. private _zAxis;
  136651. private _scaleLinesFactor;
  136652. private _instanced;
  136653. /**
  136654. * Gets the hosting scene
  136655. */
  136656. scene: Nullable<Scene>;
  136657. /**
  136658. * Gets or sets a number used to scale line length
  136659. */
  136660. scaleLines: number;
  136661. /** Gets the node hierarchy used to render x-axis */
  136662. get xAxis(): TransformNode;
  136663. /** Gets the node hierarchy used to render y-axis */
  136664. get yAxis(): TransformNode;
  136665. /** Gets the node hierarchy used to render z-axis */
  136666. get zAxis(): TransformNode;
  136667. /**
  136668. * Creates a new AxesViewer
  136669. * @param scene defines the hosting scene
  136670. * @param scaleLines defines a number used to scale line length (1 by default)
  136671. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  136672. * @param xAxis defines the node hierarchy used to render the x-axis
  136673. * @param yAxis defines the node hierarchy used to render the y-axis
  136674. * @param zAxis defines the node hierarchy used to render the z-axis
  136675. */
  136676. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  136677. /**
  136678. * Force the viewer to update
  136679. * @param position defines the position of the viewer
  136680. * @param xaxis defines the x axis of the viewer
  136681. * @param yaxis defines the y axis of the viewer
  136682. * @param zaxis defines the z axis of the viewer
  136683. */
  136684. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  136685. /**
  136686. * Creates an instance of this axes viewer.
  136687. * @returns a new axes viewer with instanced meshes
  136688. */
  136689. createInstance(): AxesViewer;
  136690. /** Releases resources */
  136691. dispose(): void;
  136692. private static _SetRenderingGroupId;
  136693. }
  136694. }
  136695. declare module BABYLON.Debug {
  136696. /**
  136697. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  136698. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  136699. */
  136700. export class BoneAxesViewer extends AxesViewer {
  136701. /**
  136702. * Gets or sets the target mesh where to display the axes viewer
  136703. */
  136704. mesh: Nullable<Mesh>;
  136705. /**
  136706. * Gets or sets the target bone where to display the axes viewer
  136707. */
  136708. bone: Nullable<Bone>;
  136709. /** Gets current position */
  136710. pos: Vector3;
  136711. /** Gets direction of X axis */
  136712. xaxis: Vector3;
  136713. /** Gets direction of Y axis */
  136714. yaxis: Vector3;
  136715. /** Gets direction of Z axis */
  136716. zaxis: Vector3;
  136717. /**
  136718. * Creates a new BoneAxesViewer
  136719. * @param scene defines the hosting scene
  136720. * @param bone defines the target bone
  136721. * @param mesh defines the target mesh
  136722. * @param scaleLines defines a scaling factor for line length (1 by default)
  136723. */
  136724. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  136725. /**
  136726. * Force the viewer to update
  136727. */
  136728. update(): void;
  136729. /** Releases resources */
  136730. dispose(): void;
  136731. }
  136732. }
  136733. declare module BABYLON {
  136734. /**
  136735. * Interface used to define scene explorer extensibility option
  136736. */
  136737. export interface IExplorerExtensibilityOption {
  136738. /**
  136739. * Define the option label
  136740. */
  136741. label: string;
  136742. /**
  136743. * Defines the action to execute on click
  136744. */
  136745. action: (entity: any) => void;
  136746. }
  136747. /**
  136748. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  136749. */
  136750. export interface IExplorerExtensibilityGroup {
  136751. /**
  136752. * Defines a predicate to test if a given type mut be extended
  136753. */
  136754. predicate: (entity: any) => boolean;
  136755. /**
  136756. * Gets the list of options added to a type
  136757. */
  136758. entries: IExplorerExtensibilityOption[];
  136759. }
  136760. /**
  136761. * Interface used to define the options to use to create the Inspector
  136762. */
  136763. export interface IInspectorOptions {
  136764. /**
  136765. * Display in overlay mode (default: false)
  136766. */
  136767. overlay?: boolean;
  136768. /**
  136769. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  136770. */
  136771. globalRoot?: HTMLElement;
  136772. /**
  136773. * Display the Scene explorer
  136774. */
  136775. showExplorer?: boolean;
  136776. /**
  136777. * Display the property inspector
  136778. */
  136779. showInspector?: boolean;
  136780. /**
  136781. * Display in embed mode (both panes on the right)
  136782. */
  136783. embedMode?: boolean;
  136784. /**
  136785. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  136786. */
  136787. handleResize?: boolean;
  136788. /**
  136789. * Allow the panes to popup (default: true)
  136790. */
  136791. enablePopup?: boolean;
  136792. /**
  136793. * Allow the panes to be closed by users (default: true)
  136794. */
  136795. enableClose?: boolean;
  136796. /**
  136797. * Optional list of extensibility entries
  136798. */
  136799. explorerExtensibility?: IExplorerExtensibilityGroup[];
  136800. /**
  136801. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  136802. */
  136803. inspectorURL?: string;
  136804. /**
  136805. * Optional initial tab (default to DebugLayerTab.Properties)
  136806. */
  136807. initialTab?: DebugLayerTab;
  136808. }
  136809. interface Scene {
  136810. /**
  136811. * @hidden
  136812. * Backing field
  136813. */
  136814. _debugLayer: DebugLayer;
  136815. /**
  136816. * Gets the debug layer (aka Inspector) associated with the scene
  136817. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136818. */
  136819. debugLayer: DebugLayer;
  136820. }
  136821. /**
  136822. * Enum of inspector action tab
  136823. */
  136824. export enum DebugLayerTab {
  136825. /**
  136826. * Properties tag (default)
  136827. */
  136828. Properties = 0,
  136829. /**
  136830. * Debug tab
  136831. */
  136832. Debug = 1,
  136833. /**
  136834. * Statistics tab
  136835. */
  136836. Statistics = 2,
  136837. /**
  136838. * Tools tab
  136839. */
  136840. Tools = 3,
  136841. /**
  136842. * Settings tab
  136843. */
  136844. Settings = 4
  136845. }
  136846. /**
  136847. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136848. * what is happening in your scene
  136849. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136850. */
  136851. export class DebugLayer {
  136852. /**
  136853. * Define the url to get the inspector script from.
  136854. * By default it uses the babylonjs CDN.
  136855. * @ignoreNaming
  136856. */
  136857. static InspectorURL: string;
  136858. private _scene;
  136859. private BJSINSPECTOR;
  136860. private _onPropertyChangedObservable?;
  136861. /**
  136862. * Observable triggered when a property is changed through the inspector.
  136863. */
  136864. get onPropertyChangedObservable(): any;
  136865. /**
  136866. * Instantiates a new debug layer.
  136867. * The debug layer (aka Inspector) is the go to tool in order to better understand
  136868. * what is happening in your scene
  136869. * @see https://doc.babylonjs.com/features/playground_debuglayer
  136870. * @param scene Defines the scene to inspect
  136871. */
  136872. constructor(scene: Scene);
  136873. /** Creates the inspector window. */
  136874. private _createInspector;
  136875. /**
  136876. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  136877. * @param entity defines the entity to select
  136878. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  136879. */
  136880. select(entity: any, lineContainerTitles?: string | string[]): void;
  136881. /** Get the inspector from bundle or global */
  136882. private _getGlobalInspector;
  136883. /**
  136884. * Get if the inspector is visible or not.
  136885. * @returns true if visible otherwise, false
  136886. */
  136887. isVisible(): boolean;
  136888. /**
  136889. * Hide the inspector and close its window.
  136890. */
  136891. hide(): void;
  136892. /**
  136893. * Update the scene in the inspector
  136894. */
  136895. setAsActiveScene(): void;
  136896. /**
  136897. * Launch the debugLayer.
  136898. * @param config Define the configuration of the inspector
  136899. * @return a promise fulfilled when the debug layer is visible
  136900. */
  136901. show(config?: IInspectorOptions): Promise<DebugLayer>;
  136902. }
  136903. }
  136904. declare module BABYLON.Debug {
  136905. /**
  136906. * Used to show the physics impostor around the specific mesh
  136907. */
  136908. export class PhysicsViewer {
  136909. /** @hidden */
  136910. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  136911. /** @hidden */
  136912. protected _meshes: Array<Nullable<AbstractMesh>>;
  136913. /** @hidden */
  136914. protected _scene: Nullable<Scene>;
  136915. /** @hidden */
  136916. protected _numMeshes: number;
  136917. /** @hidden */
  136918. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  136919. private _renderFunction;
  136920. private _utilityLayer;
  136921. private _debugBoxMesh;
  136922. private _debugSphereMesh;
  136923. private _debugCylinderMesh;
  136924. private _debugMaterial;
  136925. private _debugMeshMeshes;
  136926. /**
  136927. * Creates a new PhysicsViewer
  136928. * @param scene defines the hosting scene
  136929. */
  136930. constructor(scene: Scene);
  136931. /** @hidden */
  136932. protected _updateDebugMeshes(): void;
  136933. /**
  136934. * Renders a specified physic impostor
  136935. * @param impostor defines the impostor to render
  136936. * @param targetMesh defines the mesh represented by the impostor
  136937. * @returns the new debug mesh used to render the impostor
  136938. */
  136939. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  136940. /**
  136941. * Hides a specified physic impostor
  136942. * @param impostor defines the impostor to hide
  136943. */
  136944. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  136945. private _getDebugMaterial;
  136946. private _getDebugBoxMesh;
  136947. private _getDebugSphereMesh;
  136948. private _getDebugCylinderMesh;
  136949. private _getDebugMeshMesh;
  136950. private _getDebugMesh;
  136951. /** Releases all resources */
  136952. dispose(): void;
  136953. }
  136954. }
  136955. declare module BABYLON {
  136956. /**
  136957. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136958. * in order to better appreciate the issue one might have.
  136959. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136960. */
  136961. export class RayHelper {
  136962. /**
  136963. * Defines the ray we are currently tryin to visualize.
  136964. */
  136965. ray: Nullable<Ray>;
  136966. private _renderPoints;
  136967. private _renderLine;
  136968. private _renderFunction;
  136969. private _scene;
  136970. private _onAfterRenderObserver;
  136971. private _onAfterStepObserver;
  136972. private _attachedToMesh;
  136973. private _meshSpaceDirection;
  136974. private _meshSpaceOrigin;
  136975. /**
  136976. * Helper function to create a colored helper in a scene in one line.
  136977. * @param ray Defines the ray we are currently tryin to visualize
  136978. * @param scene Defines the scene the ray is used in
  136979. * @param color Defines the color we want to see the ray in
  136980. * @returns The newly created ray helper.
  136981. */
  136982. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  136983. /**
  136984. * Instantiate a new ray helper.
  136985. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  136986. * in order to better appreciate the issue one might have.
  136987. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  136988. * @param ray Defines the ray we are currently tryin to visualize
  136989. */
  136990. constructor(ray: Ray);
  136991. /**
  136992. * Shows the ray we are willing to debug.
  136993. * @param scene Defines the scene the ray needs to be rendered in
  136994. * @param color Defines the color the ray needs to be rendered in
  136995. */
  136996. show(scene: Scene, color?: Color3): void;
  136997. /**
  136998. * Hides the ray we are debugging.
  136999. */
  137000. hide(): void;
  137001. private _render;
  137002. /**
  137003. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  137004. * @param mesh Defines the mesh we want the helper attached to
  137005. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  137006. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  137007. * @param length Defines the length of the ray
  137008. */
  137009. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  137010. /**
  137011. * Detach the ray helper from the mesh it has previously been attached to.
  137012. */
  137013. detachFromMesh(): void;
  137014. private _updateToMesh;
  137015. /**
  137016. * Dispose the helper and release its associated resources.
  137017. */
  137018. dispose(): void;
  137019. }
  137020. }
  137021. declare module BABYLON {
  137022. /**
  137023. * Defines the options associated with the creation of a SkeletonViewer.
  137024. */
  137025. export interface ISkeletonViewerOptions {
  137026. /** Should the system pause animations before building the Viewer? */
  137027. pauseAnimations: boolean;
  137028. /** Should the system return the skeleton to rest before building? */
  137029. returnToRest: boolean;
  137030. /** public Display Mode of the Viewer */
  137031. displayMode: number;
  137032. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  137033. displayOptions: ISkeletonViewerDisplayOptions;
  137034. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  137035. computeBonesUsingShaders: boolean;
  137036. /** Flag ignore non weighted bones */
  137037. useAllBones: boolean;
  137038. }
  137039. /**
  137040. * Defines how to display the various bone meshes for the viewer.
  137041. */
  137042. export interface ISkeletonViewerDisplayOptions {
  137043. /** How far down to start tapering the bone spurs */
  137044. midStep?: number;
  137045. /** How big is the midStep? */
  137046. midStepFactor?: number;
  137047. /** Base for the Sphere Size */
  137048. sphereBaseSize?: number;
  137049. /** The ratio of the sphere to the longest bone in units */
  137050. sphereScaleUnit?: number;
  137051. /** Ratio for the Sphere Size */
  137052. sphereFactor?: number;
  137053. /** Whether a spur should attach its far end to the child bone position */
  137054. spurFollowsChild?: boolean;
  137055. /** Whether to show local axes or not */
  137056. showLocalAxes?: boolean;
  137057. /** Length of each local axis */
  137058. localAxesSize?: number;
  137059. }
  137060. /**
  137061. * Defines the constructor options for the BoneWeight Shader.
  137062. */
  137063. export interface IBoneWeightShaderOptions {
  137064. /** Skeleton to Map */
  137065. skeleton: Skeleton;
  137066. /** Colors for Uninfluenced bones */
  137067. colorBase?: Color3;
  137068. /** Colors for 0.0-0.25 Weight bones */
  137069. colorZero?: Color3;
  137070. /** Color for 0.25-0.5 Weight Influence */
  137071. colorQuarter?: Color3;
  137072. /** Color for 0.5-0.75 Weight Influence */
  137073. colorHalf?: Color3;
  137074. /** Color for 0.75-1 Weight Influence */
  137075. colorFull?: Color3;
  137076. /** Color for Zero Weight Influence */
  137077. targetBoneIndex?: number;
  137078. }
  137079. /**
  137080. * Simple structure of the gradient steps for the Color Map.
  137081. */
  137082. export interface ISkeletonMapShaderColorMapKnot {
  137083. /** Color of the Knot */
  137084. color: Color3;
  137085. /** Location of the Knot */
  137086. location: number;
  137087. }
  137088. /**
  137089. * Defines the constructor options for the SkeletonMap Shader.
  137090. */
  137091. export interface ISkeletonMapShaderOptions {
  137092. /** Skeleton to Map */
  137093. skeleton: Skeleton;
  137094. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  137095. colorMap?: ISkeletonMapShaderColorMapKnot[];
  137096. }
  137097. }
  137098. declare module BABYLON {
  137099. /**
  137100. * Class containing static functions to help procedurally build meshes
  137101. */
  137102. export class RibbonBuilder {
  137103. /**
  137104. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137105. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137106. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137107. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137108. * * 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
  137109. * * 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
  137110. * * 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
  137111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137113. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137114. * * 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
  137115. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  137116. * * 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
  137117. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  137118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137119. * @param name defines the name of the mesh
  137120. * @param options defines the options used to create the mesh
  137121. * @param scene defines the hosting scene
  137122. * @returns the ribbon mesh
  137123. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  137124. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137125. */
  137126. static CreateRibbon(name: string, options: {
  137127. pathArray: Vector3[][];
  137128. closeArray?: boolean;
  137129. closePath?: boolean;
  137130. offset?: number;
  137131. updatable?: boolean;
  137132. sideOrientation?: number;
  137133. frontUVs?: Vector4;
  137134. backUVs?: Vector4;
  137135. instance?: Mesh;
  137136. invertUV?: boolean;
  137137. uvs?: Vector2[];
  137138. colors?: Color4[];
  137139. }, scene?: Nullable<Scene>): Mesh;
  137140. }
  137141. }
  137142. declare module BABYLON {
  137143. /**
  137144. * Class containing static functions to help procedurally build meshes
  137145. */
  137146. export class ShapeBuilder {
  137147. /**
  137148. * 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.
  137149. * * 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.
  137150. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137151. * * 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.
  137152. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  137153. * * 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
  137154. * * 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
  137155. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  137156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137157. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137158. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  137159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  137160. * @param name defines the name of the mesh
  137161. * @param options defines the options used to create the mesh
  137162. * @param scene defines the hosting scene
  137163. * @returns the extruded shape mesh
  137164. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137165. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137166. */
  137167. static ExtrudeShape(name: string, options: {
  137168. shape: Vector3[];
  137169. path: Vector3[];
  137170. scale?: number;
  137171. rotation?: number;
  137172. cap?: number;
  137173. updatable?: boolean;
  137174. sideOrientation?: number;
  137175. frontUVs?: Vector4;
  137176. backUVs?: Vector4;
  137177. instance?: Mesh;
  137178. invertUV?: boolean;
  137179. }, scene?: Nullable<Scene>): Mesh;
  137180. /**
  137181. * Creates an custom extruded shape mesh.
  137182. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  137183. * * 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.
  137184. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  137185. * * 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
  137186. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  137187. * * 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
  137188. * * It must returns a float value that will be the scale value applied to the shape on each path point
  137189. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  137190. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  137191. * * 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
  137192. * * 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
  137193. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  137194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  137196. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  137197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137198. * @param name defines the name of the mesh
  137199. * @param options defines the options used to create the mesh
  137200. * @param scene defines the hosting scene
  137201. * @returns the custom extruded shape mesh
  137202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  137203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  137204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  137205. */
  137206. static ExtrudeShapeCustom(name: string, options: {
  137207. shape: Vector3[];
  137208. path: Vector3[];
  137209. scaleFunction?: any;
  137210. rotationFunction?: any;
  137211. ribbonCloseArray?: boolean;
  137212. ribbonClosePath?: boolean;
  137213. cap?: number;
  137214. updatable?: boolean;
  137215. sideOrientation?: number;
  137216. frontUVs?: Vector4;
  137217. backUVs?: Vector4;
  137218. instance?: Mesh;
  137219. invertUV?: boolean;
  137220. }, scene?: Nullable<Scene>): Mesh;
  137221. private static _ExtrudeShapeGeneric;
  137222. }
  137223. }
  137224. declare module BABYLON.Debug {
  137225. /**
  137226. * Class used to render a debug view of a given skeleton
  137227. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  137228. */
  137229. export class SkeletonViewer {
  137230. /** defines the skeleton to render */
  137231. skeleton: Skeleton;
  137232. /** defines the mesh attached to the skeleton */
  137233. mesh: AbstractMesh;
  137234. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137235. autoUpdateBonesMatrices: boolean;
  137236. /** defines the rendering group id to use with the viewer */
  137237. renderingGroupId: number;
  137238. /** is the options for the viewer */
  137239. options: Partial<ISkeletonViewerOptions>;
  137240. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  137241. static readonly DISPLAY_LINES: number;
  137242. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  137243. static readonly DISPLAY_SPHERES: number;
  137244. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  137245. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  137246. /** public static method to create a BoneWeight Shader
  137247. * @param options The constructor options
  137248. * @param scene The scene that the shader is scoped to
  137249. * @returns The created ShaderMaterial
  137250. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  137251. */
  137252. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  137253. /** public static method to create a BoneWeight Shader
  137254. * @param options The constructor options
  137255. * @param scene The scene that the shader is scoped to
  137256. * @returns The created ShaderMaterial
  137257. */
  137258. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  137259. /** private static method to create a BoneWeight Shader
  137260. * @param size The size of the buffer to create (usually the bone count)
  137261. * @param colorMap The gradient data to generate
  137262. * @param scene The scene that the shader is scoped to
  137263. * @returns an Array of floats from the color gradient values
  137264. */
  137265. private static _CreateBoneMapColorBuffer;
  137266. /** If SkeletonViewer scene scope. */
  137267. private _scene;
  137268. /** Gets or sets the color used to render the skeleton */
  137269. color: Color3;
  137270. /** Array of the points of the skeleton fo the line view. */
  137271. private _debugLines;
  137272. /** The SkeletonViewers Mesh. */
  137273. private _debugMesh;
  137274. /** The local axes Meshes. */
  137275. private _localAxes;
  137276. /** If SkeletonViewer is enabled. */
  137277. private _isEnabled;
  137278. /** If SkeletonViewer is ready. */
  137279. private _ready;
  137280. /** SkeletonViewer render observable. */
  137281. private _obs;
  137282. /** The Utility Layer to render the gizmos in. */
  137283. private _utilityLayer;
  137284. private _boneIndices;
  137285. /** Gets the Scene. */
  137286. get scene(): Scene;
  137287. /** Gets the utilityLayer. */
  137288. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  137289. /** Checks Ready Status. */
  137290. get isReady(): Boolean;
  137291. /** Sets Ready Status. */
  137292. set ready(value: boolean);
  137293. /** Gets the debugMesh */
  137294. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  137295. /** Sets the debugMesh */
  137296. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  137297. /** Gets the displayMode */
  137298. get displayMode(): number;
  137299. /** Sets the displayMode */
  137300. set displayMode(value: number);
  137301. /**
  137302. * Creates a new SkeletonViewer
  137303. * @param skeleton defines the skeleton to render
  137304. * @param mesh defines the mesh attached to the skeleton
  137305. * @param scene defines the hosting scene
  137306. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  137307. * @param renderingGroupId defines the rendering group id to use with the viewer
  137308. * @param options All of the extra constructor options for the SkeletonViewer
  137309. */
  137310. constructor(
  137311. /** defines the skeleton to render */
  137312. skeleton: Skeleton,
  137313. /** defines the mesh attached to the skeleton */
  137314. mesh: AbstractMesh,
  137315. /** The Scene scope*/
  137316. scene: Scene,
  137317. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  137318. autoUpdateBonesMatrices?: boolean,
  137319. /** defines the rendering group id to use with the viewer */
  137320. renderingGroupId?: number,
  137321. /** is the options for the viewer */
  137322. options?: Partial<ISkeletonViewerOptions>);
  137323. /** The Dynamic bindings for the update functions */
  137324. private _bindObs;
  137325. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  137326. update(): void;
  137327. /** Gets or sets a boolean indicating if the viewer is enabled */
  137328. set isEnabled(value: boolean);
  137329. get isEnabled(): boolean;
  137330. private _getBonePosition;
  137331. private _getLinesForBonesWithLength;
  137332. private _getLinesForBonesNoLength;
  137333. /** function to revert the mesh and scene back to the initial state. */
  137334. private _revert;
  137335. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  137336. private _getAbsoluteBindPoseToRef;
  137337. /** function to build and bind sphere joint points and spur bone representations. */
  137338. private _buildSpheresAndSpurs;
  137339. private _buildLocalAxes;
  137340. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  137341. private _displayLinesUpdate;
  137342. /** Changes the displayMode of the skeleton viewer
  137343. * @param mode The displayMode numerical value
  137344. */
  137345. changeDisplayMode(mode: number): void;
  137346. /** Sets a display option of the skeleton viewer
  137347. *
  137348. * | Option | Type | Default | Description |
  137349. * | ---------------- | ------- | ------- | ----------- |
  137350. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137351. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137352. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137353. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  137354. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  137355. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  137356. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  137357. *
  137358. * @param option String of the option name
  137359. * @param value The numerical option value
  137360. */
  137361. changeDisplayOptions(option: string, value: number): void;
  137362. /** Release associated resources */
  137363. dispose(): void;
  137364. }
  137365. }
  137366. declare module BABYLON {
  137367. /**
  137368. * Enum for Device Types
  137369. */
  137370. export enum DeviceType {
  137371. /** Generic */
  137372. Generic = 0,
  137373. /** Keyboard */
  137374. Keyboard = 1,
  137375. /** Mouse */
  137376. Mouse = 2,
  137377. /** Touch Pointers */
  137378. Touch = 3,
  137379. /** PS4 Dual Shock */
  137380. DualShock = 4,
  137381. /** Xbox */
  137382. Xbox = 5,
  137383. /** Switch Controller */
  137384. Switch = 6
  137385. }
  137386. /**
  137387. * Enum for All Pointers (Touch/Mouse)
  137388. */
  137389. export enum PointerInput {
  137390. /** Horizontal Axis */
  137391. Horizontal = 0,
  137392. /** Vertical Axis */
  137393. Vertical = 1,
  137394. /** Left Click or Touch */
  137395. LeftClick = 2,
  137396. /** Middle Click */
  137397. MiddleClick = 3,
  137398. /** Right Click */
  137399. RightClick = 4,
  137400. /** Browser Back */
  137401. BrowserBack = 5,
  137402. /** Browser Forward */
  137403. BrowserForward = 6
  137404. }
  137405. /**
  137406. * Enum for Dual Shock Gamepad
  137407. */
  137408. export enum DualShockInput {
  137409. /** Cross */
  137410. Cross = 0,
  137411. /** Circle */
  137412. Circle = 1,
  137413. /** Square */
  137414. Square = 2,
  137415. /** Triangle */
  137416. Triangle = 3,
  137417. /** L1 */
  137418. L1 = 4,
  137419. /** R1 */
  137420. R1 = 5,
  137421. /** L2 */
  137422. L2 = 6,
  137423. /** R2 */
  137424. R2 = 7,
  137425. /** Share */
  137426. Share = 8,
  137427. /** Options */
  137428. Options = 9,
  137429. /** L3 */
  137430. L3 = 10,
  137431. /** R3 */
  137432. R3 = 11,
  137433. /** DPadUp */
  137434. DPadUp = 12,
  137435. /** DPadDown */
  137436. DPadDown = 13,
  137437. /** DPadLeft */
  137438. DPadLeft = 14,
  137439. /** DRight */
  137440. DPadRight = 15,
  137441. /** Home */
  137442. Home = 16,
  137443. /** TouchPad */
  137444. TouchPad = 17,
  137445. /** LStickXAxis */
  137446. LStickXAxis = 18,
  137447. /** LStickYAxis */
  137448. LStickYAxis = 19,
  137449. /** RStickXAxis */
  137450. RStickXAxis = 20,
  137451. /** RStickYAxis */
  137452. RStickYAxis = 21
  137453. }
  137454. /**
  137455. * Enum for Xbox Gamepad
  137456. */
  137457. export enum XboxInput {
  137458. /** A */
  137459. A = 0,
  137460. /** B */
  137461. B = 1,
  137462. /** X */
  137463. X = 2,
  137464. /** Y */
  137465. Y = 3,
  137466. /** LB */
  137467. LB = 4,
  137468. /** RB */
  137469. RB = 5,
  137470. /** LT */
  137471. LT = 6,
  137472. /** RT */
  137473. RT = 7,
  137474. /** Back */
  137475. Back = 8,
  137476. /** Start */
  137477. Start = 9,
  137478. /** LS */
  137479. LS = 10,
  137480. /** RS */
  137481. RS = 11,
  137482. /** DPadUp */
  137483. DPadUp = 12,
  137484. /** DPadDown */
  137485. DPadDown = 13,
  137486. /** DPadLeft */
  137487. DPadLeft = 14,
  137488. /** DRight */
  137489. DPadRight = 15,
  137490. /** Home */
  137491. Home = 16,
  137492. /** LStickXAxis */
  137493. LStickXAxis = 17,
  137494. /** LStickYAxis */
  137495. LStickYAxis = 18,
  137496. /** RStickXAxis */
  137497. RStickXAxis = 19,
  137498. /** RStickYAxis */
  137499. RStickYAxis = 20
  137500. }
  137501. /**
  137502. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  137503. */
  137504. export enum SwitchInput {
  137505. /** B */
  137506. B = 0,
  137507. /** A */
  137508. A = 1,
  137509. /** Y */
  137510. Y = 2,
  137511. /** X */
  137512. X = 3,
  137513. /** L */
  137514. L = 4,
  137515. /** R */
  137516. R = 5,
  137517. /** ZL */
  137518. ZL = 6,
  137519. /** ZR */
  137520. ZR = 7,
  137521. /** Minus */
  137522. Minus = 8,
  137523. /** Plus */
  137524. Plus = 9,
  137525. /** LS */
  137526. LS = 10,
  137527. /** RS */
  137528. RS = 11,
  137529. /** DPadUp */
  137530. DPadUp = 12,
  137531. /** DPadDown */
  137532. DPadDown = 13,
  137533. /** DPadLeft */
  137534. DPadLeft = 14,
  137535. /** DRight */
  137536. DPadRight = 15,
  137537. /** Home */
  137538. Home = 16,
  137539. /** Capture */
  137540. Capture = 17,
  137541. /** LStickXAxis */
  137542. LStickXAxis = 18,
  137543. /** LStickYAxis */
  137544. LStickYAxis = 19,
  137545. /** RStickXAxis */
  137546. RStickXAxis = 20,
  137547. /** RStickYAxis */
  137548. RStickYAxis = 21
  137549. }
  137550. }
  137551. declare module BABYLON {
  137552. /**
  137553. * This class will take all inputs from Keyboard, Pointer, and
  137554. * any Gamepads and provide a polling system that all devices
  137555. * will use. This class assumes that there will only be one
  137556. * pointer device and one keyboard.
  137557. */
  137558. export class DeviceInputSystem implements IDisposable {
  137559. /**
  137560. * Returns onDeviceConnected callback property
  137561. * @returns Callback with function to execute when a device is connected
  137562. */
  137563. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  137564. /**
  137565. * Sets callback function when a device is connected and executes against all connected devices
  137566. * @param callback Function to execute when a device is connected
  137567. */
  137568. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  137569. /**
  137570. * Callback to be triggered when a device is disconnected
  137571. */
  137572. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  137573. /**
  137574. * Callback to be triggered when event driven input is updated
  137575. */
  137576. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  137577. private _inputs;
  137578. private _gamepads;
  137579. private _keyboardActive;
  137580. private _pointerActive;
  137581. private _elementToAttachTo;
  137582. private _keyboardDownEvent;
  137583. private _keyboardUpEvent;
  137584. private _pointerMoveEvent;
  137585. private _pointerDownEvent;
  137586. private _pointerUpEvent;
  137587. private _gamepadConnectedEvent;
  137588. private _gamepadDisconnectedEvent;
  137589. private _onDeviceConnected;
  137590. private static _MAX_KEYCODES;
  137591. private static _MAX_POINTER_INPUTS;
  137592. private constructor();
  137593. /**
  137594. * Creates a new DeviceInputSystem instance
  137595. * @param engine Engine to pull input element from
  137596. * @returns The new instance
  137597. */
  137598. static Create(engine: Engine): DeviceInputSystem;
  137599. /**
  137600. * Checks for current device input value, given an id and input index
  137601. * @param deviceName Id of connected device
  137602. * @param inputIndex Index of device input
  137603. * @returns Current value of input
  137604. */
  137605. /**
  137606. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  137607. * @param deviceType Enum specifiying device type
  137608. * @param deviceSlot "Slot" or index that device is referenced in
  137609. * @param inputIndex Id of input to be checked
  137610. * @returns Current value of input
  137611. */
  137612. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  137613. /**
  137614. * Dispose of all the eventlisteners
  137615. */
  137616. dispose(): void;
  137617. /**
  137618. * Checks for existing connections to devices and register them, if necessary
  137619. * Currently handles gamepads and mouse
  137620. */
  137621. private _checkForConnectedDevices;
  137622. /**
  137623. * Add a gamepad to the DeviceInputSystem
  137624. * @param gamepad A single DOM Gamepad object
  137625. */
  137626. private _addGamePad;
  137627. /**
  137628. * Add pointer device to DeviceInputSystem
  137629. * @param deviceType Type of Pointer to add
  137630. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  137631. * @param currentX Current X at point of adding
  137632. * @param currentY Current Y at point of adding
  137633. */
  137634. private _addPointerDevice;
  137635. /**
  137636. * Add device and inputs to device array
  137637. * @param deviceType Enum specifiying device type
  137638. * @param deviceSlot "Slot" or index that device is referenced in
  137639. * @param numberOfInputs Number of input entries to create for given device
  137640. */
  137641. private _registerDevice;
  137642. /**
  137643. * Given a specific device name, remove that device from the device map
  137644. * @param deviceType Enum specifiying device type
  137645. * @param deviceSlot "Slot" or index that device is referenced in
  137646. */
  137647. private _unregisterDevice;
  137648. /**
  137649. * Handle all actions that come from keyboard interaction
  137650. */
  137651. private _handleKeyActions;
  137652. /**
  137653. * Handle all actions that come from pointer interaction
  137654. */
  137655. private _handlePointerActions;
  137656. /**
  137657. * Handle all actions that come from gamepad interaction
  137658. */
  137659. private _handleGamepadActions;
  137660. /**
  137661. * Update all non-event based devices with each frame
  137662. * @param deviceType Enum specifiying device type
  137663. * @param deviceSlot "Slot" or index that device is referenced in
  137664. * @param inputIndex Id of input to be checked
  137665. */
  137666. private _updateDevice;
  137667. /**
  137668. * Gets DeviceType from the device name
  137669. * @param deviceName Name of Device from DeviceInputSystem
  137670. * @returns DeviceType enum value
  137671. */
  137672. private _getGamepadDeviceType;
  137673. }
  137674. }
  137675. declare module BABYLON {
  137676. /**
  137677. * Type to handle enforcement of inputs
  137678. */
  137679. 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;
  137680. }
  137681. declare module BABYLON {
  137682. /**
  137683. * Class that handles all input for a specific device
  137684. */
  137685. export class DeviceSource<T extends DeviceType> {
  137686. /** Type of device */
  137687. readonly deviceType: DeviceType;
  137688. /** "Slot" or index that device is referenced in */
  137689. readonly deviceSlot: number;
  137690. /**
  137691. * Observable to handle device input changes per device
  137692. */
  137693. readonly onInputChangedObservable: Observable<{
  137694. inputIndex: DeviceInput<T>;
  137695. previousState: Nullable<number>;
  137696. currentState: Nullable<number>;
  137697. }>;
  137698. private readonly _deviceInputSystem;
  137699. /**
  137700. * Default Constructor
  137701. * @param deviceInputSystem Reference to DeviceInputSystem
  137702. * @param deviceType Type of device
  137703. * @param deviceSlot "Slot" or index that device is referenced in
  137704. */
  137705. constructor(deviceInputSystem: DeviceInputSystem,
  137706. /** Type of device */
  137707. deviceType: DeviceType,
  137708. /** "Slot" or index that device is referenced in */
  137709. deviceSlot?: number);
  137710. /**
  137711. * Get input for specific input
  137712. * @param inputIndex index of specific input on device
  137713. * @returns Input value from DeviceInputSystem
  137714. */
  137715. getInput(inputIndex: DeviceInput<T>): number;
  137716. }
  137717. /**
  137718. * Class to keep track of devices
  137719. */
  137720. export class DeviceSourceManager implements IDisposable {
  137721. /**
  137722. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  137723. */
  137724. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  137725. /**
  137726. * Observable to be triggered when after a device is disconnected
  137727. */
  137728. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  137729. private readonly _devices;
  137730. private readonly _firstDevice;
  137731. private readonly _deviceInputSystem;
  137732. /**
  137733. * Default Constructor
  137734. * @param engine engine to pull input element from
  137735. */
  137736. constructor(engine: Engine);
  137737. /**
  137738. * Gets a DeviceSource, given a type and slot
  137739. * @param deviceType Enum specifying device type
  137740. * @param deviceSlot "Slot" or index that device is referenced in
  137741. * @returns DeviceSource object
  137742. */
  137743. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  137744. /**
  137745. * Gets an array of DeviceSource objects for a given device type
  137746. * @param deviceType Enum specifying device type
  137747. * @returns Array of DeviceSource objects
  137748. */
  137749. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  137750. /**
  137751. * Returns a read-only list of all available devices
  137752. * @returns Read-only array with active devices
  137753. */
  137754. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  137755. /**
  137756. * Dispose of DeviceInputSystem and other parts
  137757. */
  137758. dispose(): void;
  137759. /**
  137760. * Function to add device name to device list
  137761. * @param deviceType Enum specifying device type
  137762. * @param deviceSlot "Slot" or index that device is referenced in
  137763. */
  137764. private _addDevice;
  137765. /**
  137766. * Function to remove device name to device list
  137767. * @param deviceType Enum specifying device type
  137768. * @param deviceSlot "Slot" or index that device is referenced in
  137769. */
  137770. private _removeDevice;
  137771. /**
  137772. * Updates array storing first connected device of each type
  137773. * @param type Type of Device
  137774. */
  137775. private _updateFirstDevices;
  137776. }
  137777. }
  137778. declare module BABYLON {
  137779. /**
  137780. * Options to create the null engine
  137781. */
  137782. export class NullEngineOptions {
  137783. /**
  137784. * Render width (Default: 512)
  137785. */
  137786. renderWidth: number;
  137787. /**
  137788. * Render height (Default: 256)
  137789. */
  137790. renderHeight: number;
  137791. /**
  137792. * Texture size (Default: 512)
  137793. */
  137794. textureSize: number;
  137795. /**
  137796. * If delta time between frames should be constant
  137797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137798. */
  137799. deterministicLockstep: boolean;
  137800. /**
  137801. * Maximum about of steps between frames (Default: 4)
  137802. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137803. */
  137804. lockstepMaxSteps: number;
  137805. /**
  137806. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  137807. */
  137808. useHighPrecisionMatrix?: boolean;
  137809. }
  137810. /**
  137811. * The null engine class provides support for headless version of babylon.js.
  137812. * This can be used in server side scenario or for testing purposes
  137813. */
  137814. export class NullEngine extends Engine {
  137815. private _options;
  137816. /**
  137817. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  137818. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137819. * @returns true if engine is in deterministic lock step mode
  137820. */
  137821. isDeterministicLockStep(): boolean;
  137822. /**
  137823. * Gets the max steps when engine is running in deterministic lock step
  137824. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  137825. * @returns the max steps
  137826. */
  137827. getLockstepMaxSteps(): number;
  137828. /**
  137829. * Gets the current hardware scaling level.
  137830. * By default the hardware scaling level is computed from the window device ratio.
  137831. * 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.
  137832. * @returns a number indicating the current hardware scaling level
  137833. */
  137834. getHardwareScalingLevel(): number;
  137835. constructor(options?: NullEngineOptions);
  137836. /**
  137837. * Creates a vertex buffer
  137838. * @param vertices the data for the vertex buffer
  137839. * @returns the new WebGL static buffer
  137840. */
  137841. createVertexBuffer(vertices: FloatArray): DataBuffer;
  137842. /**
  137843. * Creates a new index buffer
  137844. * @param indices defines the content of the index buffer
  137845. * @param updatable defines if the index buffer must be updatable
  137846. * @returns a new webGL buffer
  137847. */
  137848. createIndexBuffer(indices: IndicesArray): DataBuffer;
  137849. /**
  137850. * Clear the current render buffer or the current render target (if any is set up)
  137851. * @param color defines the color to use
  137852. * @param backBuffer defines if the back buffer must be cleared
  137853. * @param depth defines if the depth buffer must be cleared
  137854. * @param stencil defines if the stencil buffer must be cleared
  137855. */
  137856. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137857. /**
  137858. * Gets the current render width
  137859. * @param useScreen defines if screen size must be used (or the current render target if any)
  137860. * @returns a number defining the current render width
  137861. */
  137862. getRenderWidth(useScreen?: boolean): number;
  137863. /**
  137864. * Gets the current render height
  137865. * @param useScreen defines if screen size must be used (or the current render target if any)
  137866. * @returns a number defining the current render height
  137867. */
  137868. getRenderHeight(useScreen?: boolean): number;
  137869. /**
  137870. * Set the WebGL's viewport
  137871. * @param viewport defines the viewport element to be used
  137872. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  137873. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  137874. */
  137875. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  137876. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  137877. /**
  137878. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  137879. * @param pipelineContext defines the pipeline context to use
  137880. * @param uniformsNames defines the list of uniform names
  137881. * @returns an array of webGL uniform locations
  137882. */
  137883. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  137884. /**
  137885. * Gets the lsit of active attributes for a given webGL program
  137886. * @param pipelineContext defines the pipeline context to use
  137887. * @param attributesNames defines the list of attribute names to get
  137888. * @returns an array of indices indicating the offset of each attribute
  137889. */
  137890. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137891. /**
  137892. * Binds an effect to the webGL context
  137893. * @param effect defines the effect to bind
  137894. */
  137895. bindSamplers(effect: Effect): void;
  137896. /**
  137897. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  137898. * @param effect defines the effect to activate
  137899. */
  137900. enableEffect(effect: Effect): void;
  137901. /**
  137902. * Set various states to the webGL context
  137903. * @param culling defines backface culling state
  137904. * @param zOffset defines the value to apply to zOffset (0 by default)
  137905. * @param force defines if states must be applied even if cache is up to date
  137906. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  137907. */
  137908. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137909. /**
  137910. * Set the value of an uniform to an array of int32
  137911. * @param uniform defines the webGL uniform location where to store the value
  137912. * @param array defines the array of int32 to store
  137913. * @returns true if value was set
  137914. */
  137915. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137916. /**
  137917. * Set the value of an uniform to an array of int32 (stored as vec2)
  137918. * @param uniform defines the webGL uniform location where to store the value
  137919. * @param array defines the array of int32 to store
  137920. * @returns true if value was set
  137921. */
  137922. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137923. /**
  137924. * Set the value of an uniform to an array of int32 (stored as vec3)
  137925. * @param uniform defines the webGL uniform location where to store the value
  137926. * @param array defines the array of int32 to store
  137927. * @returns true if value was set
  137928. */
  137929. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137930. /**
  137931. * Set the value of an uniform to an array of int32 (stored as vec4)
  137932. * @param uniform defines the webGL uniform location where to store the value
  137933. * @param array defines the array of int32 to store
  137934. * @returns true if value was set
  137935. */
  137936. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137937. /**
  137938. * Set the value of an uniform to an array of float32
  137939. * @param uniform defines the webGL uniform location where to store the value
  137940. * @param array defines the array of float32 to store
  137941. * @returns true if value was set
  137942. */
  137943. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137944. /**
  137945. * Set the value of an uniform to an array of float32 (stored as vec2)
  137946. * @param uniform defines the webGL uniform location where to store the value
  137947. * @param array defines the array of float32 to store
  137948. * @returns true if value was set
  137949. */
  137950. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137951. /**
  137952. * Set the value of an uniform to an array of float32 (stored as vec3)
  137953. * @param uniform defines the webGL uniform location where to store the value
  137954. * @param array defines the array of float32 to store
  137955. * @returns true if value was set
  137956. */
  137957. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137958. /**
  137959. * Set the value of an uniform to an array of float32 (stored as vec4)
  137960. * @param uniform defines the webGL uniform location where to store the value
  137961. * @param array defines the array of float32 to store
  137962. * @returns true if value was set
  137963. */
  137964. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137965. /**
  137966. * Set the value of an uniform to an array of number
  137967. * @param uniform defines the webGL uniform location where to store the value
  137968. * @param array defines the array of number to store
  137969. * @returns true if value was set
  137970. */
  137971. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137972. /**
  137973. * Set the value of an uniform to an array of number (stored as vec2)
  137974. * @param uniform defines the webGL uniform location where to store the value
  137975. * @param array defines the array of number to store
  137976. * @returns true if value was set
  137977. */
  137978. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137979. /**
  137980. * Set the value of an uniform to an array of number (stored as vec3)
  137981. * @param uniform defines the webGL uniform location where to store the value
  137982. * @param array defines the array of number to store
  137983. * @returns true if value was set
  137984. */
  137985. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137986. /**
  137987. * Set the value of an uniform to an array of number (stored as vec4)
  137988. * @param uniform defines the webGL uniform location where to store the value
  137989. * @param array defines the array of number to store
  137990. * @returns true if value was set
  137991. */
  137992. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137993. /**
  137994. * Set the value of an uniform to an array of float32 (stored as matrices)
  137995. * @param uniform defines the webGL uniform location where to store the value
  137996. * @param matrices defines the array of float32 to store
  137997. * @returns true if value was set
  137998. */
  137999. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138000. /**
  138001. * Set the value of an uniform to a matrix (3x3)
  138002. * @param uniform defines the webGL uniform location where to store the value
  138003. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  138004. * @returns true if value was set
  138005. */
  138006. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138007. /**
  138008. * Set the value of an uniform to a matrix (2x2)
  138009. * @param uniform defines the webGL uniform location where to store the value
  138010. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  138011. * @returns true if value was set
  138012. */
  138013. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138014. /**
  138015. * Set the value of an uniform to a number (float)
  138016. * @param uniform defines the webGL uniform location where to store the value
  138017. * @param value defines the float number to store
  138018. * @returns true if value was set
  138019. */
  138020. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138021. /**
  138022. * Set the value of an uniform to a vec2
  138023. * @param uniform defines the webGL uniform location where to store the value
  138024. * @param x defines the 1st component of the value
  138025. * @param y defines the 2nd component of the value
  138026. * @returns true if value was set
  138027. */
  138028. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138029. /**
  138030. * Set the value of an uniform to a vec3
  138031. * @param uniform defines the webGL uniform location where to store the value
  138032. * @param x defines the 1st component of the value
  138033. * @param y defines the 2nd component of the value
  138034. * @param z defines the 3rd component of the value
  138035. * @returns true if value was set
  138036. */
  138037. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138038. /**
  138039. * Set the value of an uniform to a boolean
  138040. * @param uniform defines the webGL uniform location where to store the value
  138041. * @param bool defines the boolean to store
  138042. * @returns true if value was set
  138043. */
  138044. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  138045. /**
  138046. * Set the value of an uniform to a vec4
  138047. * @param uniform defines the webGL uniform location where to store the value
  138048. * @param x defines the 1st component of the value
  138049. * @param y defines the 2nd component of the value
  138050. * @param z defines the 3rd component of the value
  138051. * @param w defines the 4th component of the value
  138052. * @returns true if value was set
  138053. */
  138054. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138055. /**
  138056. * Sets the current alpha mode
  138057. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  138058. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138059. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138060. */
  138061. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138062. /**
  138063. * Bind webGl buffers directly to the webGL context
  138064. * @param vertexBuffers defines the vertex buffer to bind
  138065. * @param indexBuffer defines the index buffer to bind
  138066. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  138067. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  138068. * @param effect defines the effect associated with the vertex buffer
  138069. */
  138070. bindBuffers(vertexBuffers: {
  138071. [key: string]: VertexBuffer;
  138072. }, indexBuffer: DataBuffer, effect: Effect): void;
  138073. /**
  138074. * Force the entire cache to be cleared
  138075. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  138076. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  138077. */
  138078. wipeCaches(bruteForce?: boolean): void;
  138079. /**
  138080. * Send a draw order
  138081. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  138082. * @param indexStart defines the starting index
  138083. * @param indexCount defines the number of index to draw
  138084. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138085. */
  138086. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  138087. /**
  138088. * Draw a list of indexed primitives
  138089. * @param fillMode defines the primitive to use
  138090. * @param indexStart defines the starting index
  138091. * @param indexCount defines the number of index to draw
  138092. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138093. */
  138094. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138095. /**
  138096. * Draw a list of unindexed primitives
  138097. * @param fillMode defines the primitive to use
  138098. * @param verticesStart defines the index of first vertex to draw
  138099. * @param verticesCount defines the count of vertices to draw
  138100. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138101. */
  138102. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138103. /** @hidden */
  138104. _createTexture(): WebGLTexture;
  138105. /** @hidden */
  138106. _releaseTexture(texture: InternalTexture): void;
  138107. /**
  138108. * Usually called from Texture.ts.
  138109. * Passed information to create a WebGLTexture
  138110. * @param urlArg defines a value which contains one of the following:
  138111. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138112. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138113. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138114. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138115. * @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)
  138116. * @param scene needed for loading to the correct scene
  138117. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138118. * @param onLoad optional callback to be called upon successful completion
  138119. * @param onError optional callback to be called upon failure
  138120. * @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
  138121. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138122. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138123. * @param forcedExtension defines the extension to use to pick the right loader
  138124. * @param mimeType defines an optional mime type
  138125. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138126. */
  138127. 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;
  138128. /**
  138129. * Creates a new render target texture
  138130. * @param size defines the size of the texture
  138131. * @param options defines the options used to create the texture
  138132. * @returns a new render target texture stored in an InternalTexture
  138133. */
  138134. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  138135. /**
  138136. * Update the sampling mode of a given texture
  138137. * @param samplingMode defines the required sampling mode
  138138. * @param texture defines the texture to update
  138139. */
  138140. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138141. /**
  138142. * Binds the frame buffer to the specified texture.
  138143. * @param texture The texture to render to or null for the default canvas
  138144. * @param faceIndex The face of the texture to render to in case of cube texture
  138145. * @param requiredWidth The width of the target to render to
  138146. * @param requiredHeight The height of the target to render to
  138147. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  138148. * @param lodLevel defines le lod level to bind to the frame buffer
  138149. */
  138150. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138151. /**
  138152. * Unbind the current render target texture from the webGL context
  138153. * @param texture defines the render target texture to unbind
  138154. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  138155. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  138156. */
  138157. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138158. /**
  138159. * Creates a dynamic vertex buffer
  138160. * @param vertices the data for the dynamic vertex buffer
  138161. * @returns the new WebGL dynamic buffer
  138162. */
  138163. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  138164. /**
  138165. * Update the content of a dynamic texture
  138166. * @param texture defines the texture to update
  138167. * @param canvas defines the canvas containing the source
  138168. * @param invertY defines if data must be stored with Y axis inverted
  138169. * @param premulAlpha defines if alpha is stored as premultiplied
  138170. * @param format defines the format of the data
  138171. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138172. */
  138173. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138174. /**
  138175. * Gets a boolean indicating if all created effects are ready
  138176. * @returns true if all effects are ready
  138177. */
  138178. areAllEffectsReady(): boolean;
  138179. /**
  138180. * @hidden
  138181. * Get the current error code of the webGL context
  138182. * @returns the error code
  138183. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  138184. */
  138185. getError(): number;
  138186. /** @hidden */
  138187. _getUnpackAlignement(): number;
  138188. /** @hidden */
  138189. _unpackFlipY(value: boolean): void;
  138190. /**
  138191. * Update a dynamic index buffer
  138192. * @param indexBuffer defines the target index buffer
  138193. * @param indices defines the data to update
  138194. * @param offset defines the offset in the target index buffer where update should start
  138195. */
  138196. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  138197. /**
  138198. * Updates a dynamic vertex buffer.
  138199. * @param vertexBuffer the vertex buffer to update
  138200. * @param vertices the data used to update the vertex buffer
  138201. * @param byteOffset the byte offset of the data (optional)
  138202. * @param byteLength the byte length of the data (optional)
  138203. */
  138204. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  138205. /** @hidden */
  138206. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  138207. /** @hidden */
  138208. _bindTexture(channel: number, texture: InternalTexture): void;
  138209. protected _deleteBuffer(buffer: WebGLBuffer): void;
  138210. /**
  138211. * 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
  138212. */
  138213. releaseEffects(): void;
  138214. displayLoadingUI(): void;
  138215. hideLoadingUI(): void;
  138216. /** @hidden */
  138217. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138218. /** @hidden */
  138219. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138220. /** @hidden */
  138221. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138222. /** @hidden */
  138223. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138224. }
  138225. }
  138226. declare module BABYLON {
  138227. /**
  138228. * @hidden
  138229. **/
  138230. export class _TimeToken {
  138231. _startTimeQuery: Nullable<WebGLQuery>;
  138232. _endTimeQuery: Nullable<WebGLQuery>;
  138233. _timeElapsedQuery: Nullable<WebGLQuery>;
  138234. _timeElapsedQueryEnded: boolean;
  138235. }
  138236. }
  138237. declare module BABYLON {
  138238. /** @hidden */
  138239. export class _OcclusionDataStorage {
  138240. /** @hidden */
  138241. occlusionInternalRetryCounter: number;
  138242. /** @hidden */
  138243. isOcclusionQueryInProgress: boolean;
  138244. /** @hidden */
  138245. isOccluded: boolean;
  138246. /** @hidden */
  138247. occlusionRetryCount: number;
  138248. /** @hidden */
  138249. occlusionType: number;
  138250. /** @hidden */
  138251. occlusionQueryAlgorithmType: number;
  138252. }
  138253. interface Engine {
  138254. /**
  138255. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  138256. * @return the new query
  138257. */
  138258. createQuery(): WebGLQuery;
  138259. /**
  138260. * Delete and release a webGL query
  138261. * @param query defines the query to delete
  138262. * @return the current engine
  138263. */
  138264. deleteQuery(query: WebGLQuery): Engine;
  138265. /**
  138266. * Check if a given query has resolved and got its value
  138267. * @param query defines the query to check
  138268. * @returns true if the query got its value
  138269. */
  138270. isQueryResultAvailable(query: WebGLQuery): boolean;
  138271. /**
  138272. * Gets the value of a given query
  138273. * @param query defines the query to check
  138274. * @returns the value of the query
  138275. */
  138276. getQueryResult(query: WebGLQuery): number;
  138277. /**
  138278. * Initiates an occlusion query
  138279. * @param algorithmType defines the algorithm to use
  138280. * @param query defines the query to use
  138281. * @returns the current engine
  138282. * @see https://doc.babylonjs.com/features/occlusionquery
  138283. */
  138284. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  138285. /**
  138286. * Ends an occlusion query
  138287. * @see https://doc.babylonjs.com/features/occlusionquery
  138288. * @param algorithmType defines the algorithm to use
  138289. * @returns the current engine
  138290. */
  138291. endOcclusionQuery(algorithmType: number): Engine;
  138292. /**
  138293. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  138294. * Please note that only one query can be issued at a time
  138295. * @returns a time token used to track the time span
  138296. */
  138297. startTimeQuery(): Nullable<_TimeToken>;
  138298. /**
  138299. * Ends a time query
  138300. * @param token defines the token used to measure the time span
  138301. * @returns the time spent (in ns)
  138302. */
  138303. endTimeQuery(token: _TimeToken): int;
  138304. /** @hidden */
  138305. _currentNonTimestampToken: Nullable<_TimeToken>;
  138306. /** @hidden */
  138307. _createTimeQuery(): WebGLQuery;
  138308. /** @hidden */
  138309. _deleteTimeQuery(query: WebGLQuery): void;
  138310. /** @hidden */
  138311. _getGlAlgorithmType(algorithmType: number): number;
  138312. /** @hidden */
  138313. _getTimeQueryResult(query: WebGLQuery): any;
  138314. /** @hidden */
  138315. _getTimeQueryAvailability(query: WebGLQuery): any;
  138316. }
  138317. interface AbstractMesh {
  138318. /**
  138319. * Backing filed
  138320. * @hidden
  138321. */
  138322. __occlusionDataStorage: _OcclusionDataStorage;
  138323. /**
  138324. * Access property
  138325. * @hidden
  138326. */
  138327. _occlusionDataStorage: _OcclusionDataStorage;
  138328. /**
  138329. * 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.
  138330. * The default value is -1 which means don't break the query and wait till the result
  138331. * @see https://doc.babylonjs.com/features/occlusionquery
  138332. */
  138333. occlusionRetryCount: number;
  138334. /**
  138335. * 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:
  138336. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  138337. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  138338. * * 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.
  138339. * @see https://doc.babylonjs.com/features/occlusionquery
  138340. */
  138341. occlusionType: number;
  138342. /**
  138343. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  138344. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  138345. * * 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.
  138346. * @see https://doc.babylonjs.com/features/occlusionquery
  138347. */
  138348. occlusionQueryAlgorithmType: number;
  138349. /**
  138350. * 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
  138351. * @see https://doc.babylonjs.com/features/occlusionquery
  138352. */
  138353. isOccluded: boolean;
  138354. /**
  138355. * Flag to check the progress status of the query
  138356. * @see https://doc.babylonjs.com/features/occlusionquery
  138357. */
  138358. isOcclusionQueryInProgress: boolean;
  138359. }
  138360. }
  138361. declare module BABYLON {
  138362. /** @hidden */
  138363. export var _forceTransformFeedbackToBundle: boolean;
  138364. interface Engine {
  138365. /**
  138366. * Creates a webGL transform feedback object
  138367. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  138368. * @returns the webGL transform feedback object
  138369. */
  138370. createTransformFeedback(): WebGLTransformFeedback;
  138371. /**
  138372. * Delete a webGL transform feedback object
  138373. * @param value defines the webGL transform feedback object to delete
  138374. */
  138375. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  138376. /**
  138377. * Bind a webGL transform feedback object to the webgl context
  138378. * @param value defines the webGL transform feedback object to bind
  138379. */
  138380. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  138381. /**
  138382. * Begins a transform feedback operation
  138383. * @param usePoints defines if points or triangles must be used
  138384. */
  138385. beginTransformFeedback(usePoints: boolean): void;
  138386. /**
  138387. * Ends a transform feedback operation
  138388. */
  138389. endTransformFeedback(): void;
  138390. /**
  138391. * Specify the varyings to use with transform feedback
  138392. * @param program defines the associated webGL program
  138393. * @param value defines the list of strings representing the varying names
  138394. */
  138395. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  138396. /**
  138397. * Bind a webGL buffer for a transform feedback operation
  138398. * @param value defines the webGL buffer to bind
  138399. */
  138400. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  138401. }
  138402. }
  138403. declare module BABYLON {
  138404. /**
  138405. * Class used to define an additional view for the engine
  138406. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138407. */
  138408. export class EngineView {
  138409. /** Defines the canvas where to render the view */
  138410. target: HTMLCanvasElement;
  138411. /** Defines an optional camera used to render the view (will use active camera else) */
  138412. camera?: Camera;
  138413. }
  138414. interface Engine {
  138415. /**
  138416. * Gets or sets the HTML element to use for attaching events
  138417. */
  138418. inputElement: Nullable<HTMLElement>;
  138419. /**
  138420. * Gets the current engine view
  138421. * @see https://doc.babylonjs.com/how_to/multi_canvases
  138422. */
  138423. activeView: Nullable<EngineView>;
  138424. /** Gets or sets the list of views */
  138425. views: EngineView[];
  138426. /**
  138427. * Register a new child canvas
  138428. * @param canvas defines the canvas to register
  138429. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  138430. * @returns the associated view
  138431. */
  138432. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  138433. /**
  138434. * Remove a registered child canvas
  138435. * @param canvas defines the canvas to remove
  138436. * @returns the current engine
  138437. */
  138438. unRegisterView(canvas: HTMLCanvasElement): Engine;
  138439. }
  138440. }
  138441. declare module BABYLON {
  138442. interface Engine {
  138443. /** @hidden */
  138444. _excludedCompressedTextures: string[];
  138445. /** @hidden */
  138446. _textureFormatInUse: string;
  138447. /**
  138448. * Gets the list of texture formats supported
  138449. */
  138450. readonly texturesSupported: Array<string>;
  138451. /**
  138452. * Gets the texture format in use
  138453. */
  138454. readonly textureFormatInUse: Nullable<string>;
  138455. /**
  138456. * Set the compressed texture extensions or file names to skip.
  138457. *
  138458. * @param skippedFiles defines the list of those texture files you want to skip
  138459. * Example: [".dds", ".env", "myfile.png"]
  138460. */
  138461. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  138462. /**
  138463. * Set the compressed texture format to use, based on the formats you have, and the formats
  138464. * supported by the hardware / browser.
  138465. *
  138466. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  138467. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  138468. * to API arguments needed to compressed textures. This puts the burden on the container
  138469. * generator to house the arcane code for determining these for current & future formats.
  138470. *
  138471. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138472. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138473. *
  138474. * Note: The result of this call is not taken into account when a texture is base64.
  138475. *
  138476. * @param formatsAvailable defines the list of those format families you have created
  138477. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  138478. *
  138479. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  138480. * @returns The extension selected.
  138481. */
  138482. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  138483. }
  138484. }
  138485. declare module BABYLON {
  138486. /** @hidden */
  138487. export var rgbdEncodePixelShader: {
  138488. name: string;
  138489. shader: string;
  138490. };
  138491. }
  138492. declare module BABYLON {
  138493. /**
  138494. * Raw texture data and descriptor sufficient for WebGL texture upload
  138495. */
  138496. export interface EnvironmentTextureInfo {
  138497. /**
  138498. * Version of the environment map
  138499. */
  138500. version: number;
  138501. /**
  138502. * Width of image
  138503. */
  138504. width: number;
  138505. /**
  138506. * Irradiance information stored in the file.
  138507. */
  138508. irradiance: any;
  138509. /**
  138510. * Specular information stored in the file.
  138511. */
  138512. specular: any;
  138513. }
  138514. /**
  138515. * Defines One Image in the file. It requires only the position in the file
  138516. * as well as the length.
  138517. */
  138518. interface BufferImageData {
  138519. /**
  138520. * Length of the image data.
  138521. */
  138522. length: number;
  138523. /**
  138524. * Position of the data from the null terminator delimiting the end of the JSON.
  138525. */
  138526. position: number;
  138527. }
  138528. /**
  138529. * Defines the specular data enclosed in the file.
  138530. * This corresponds to the version 1 of the data.
  138531. */
  138532. export interface EnvironmentTextureSpecularInfoV1 {
  138533. /**
  138534. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  138535. */
  138536. specularDataPosition?: number;
  138537. /**
  138538. * This contains all the images data needed to reconstruct the cubemap.
  138539. */
  138540. mipmaps: Array<BufferImageData>;
  138541. /**
  138542. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  138543. */
  138544. lodGenerationScale: number;
  138545. }
  138546. /**
  138547. * Sets of helpers addressing the serialization and deserialization of environment texture
  138548. * stored in a BabylonJS env file.
  138549. * Those files are usually stored as .env files.
  138550. */
  138551. export class EnvironmentTextureTools {
  138552. /**
  138553. * Magic number identifying the env file.
  138554. */
  138555. private static _MagicBytes;
  138556. /**
  138557. * Gets the environment info from an env file.
  138558. * @param data The array buffer containing the .env bytes.
  138559. * @returns the environment file info (the json header) if successfully parsed.
  138560. */
  138561. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  138562. /**
  138563. * Creates an environment texture from a loaded cube texture.
  138564. * @param texture defines the cube texture to convert in env file
  138565. * @return a promise containing the environment data if succesfull.
  138566. */
  138567. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  138568. /**
  138569. * Creates a JSON representation of the spherical data.
  138570. * @param texture defines the texture containing the polynomials
  138571. * @return the JSON representation of the spherical info
  138572. */
  138573. private static _CreateEnvTextureIrradiance;
  138574. /**
  138575. * Creates the ArrayBufferViews used for initializing environment texture image data.
  138576. * @param data the image data
  138577. * @param info parameters that determine what views will be created for accessing the underlying buffer
  138578. * @return the views described by info providing access to the underlying buffer
  138579. */
  138580. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  138581. /**
  138582. * Uploads the texture info contained in the env file to the GPU.
  138583. * @param texture defines the internal texture to upload to
  138584. * @param data defines the data to load
  138585. * @param info defines the texture info retrieved through the GetEnvInfo method
  138586. * @returns a promise
  138587. */
  138588. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  138589. private static _OnImageReadyAsync;
  138590. /**
  138591. * Uploads the levels of image data to the GPU.
  138592. * @param texture defines the internal texture to upload to
  138593. * @param imageData defines the array buffer views of image data [mipmap][face]
  138594. * @returns a promise
  138595. */
  138596. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  138597. /**
  138598. * Uploads spherical polynomials information to the texture.
  138599. * @param texture defines the texture we are trying to upload the information to
  138600. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  138601. */
  138602. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  138603. /** @hidden */
  138604. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  138605. }
  138606. }
  138607. declare module BABYLON {
  138608. /**
  138609. * Class used to inline functions in shader code
  138610. */
  138611. export class ShaderCodeInliner {
  138612. private static readonly _RegexpFindFunctionNameAndType;
  138613. private _sourceCode;
  138614. private _functionDescr;
  138615. private _numMaxIterations;
  138616. /** Gets or sets the token used to mark the functions to inline */
  138617. inlineToken: string;
  138618. /** Gets or sets the debug mode */
  138619. debug: boolean;
  138620. /** Gets the code after the inlining process */
  138621. get code(): string;
  138622. /**
  138623. * Initializes the inliner
  138624. * @param sourceCode shader code source to inline
  138625. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  138626. */
  138627. constructor(sourceCode: string, numMaxIterations?: number);
  138628. /**
  138629. * Start the processing of the shader code
  138630. */
  138631. processCode(): void;
  138632. private _collectFunctions;
  138633. private _processInlining;
  138634. private _extractBetweenMarkers;
  138635. private _skipWhitespaces;
  138636. private _removeComments;
  138637. private _replaceFunctionCallsByCode;
  138638. private _findBackward;
  138639. private _escapeRegExp;
  138640. private _replaceNames;
  138641. }
  138642. }
  138643. declare module BABYLON {
  138644. /**
  138645. * Container for accessors for natively-stored mesh data buffers.
  138646. */
  138647. class NativeDataBuffer extends DataBuffer {
  138648. /**
  138649. * Accessor value used to identify/retrieve a natively-stored index buffer.
  138650. */
  138651. nativeIndexBuffer?: any;
  138652. /**
  138653. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  138654. */
  138655. nativeVertexBuffer?: any;
  138656. }
  138657. /** @hidden */
  138658. class NativeTexture extends InternalTexture {
  138659. getInternalTexture(): InternalTexture;
  138660. getViewCount(): number;
  138661. }
  138662. /** @hidden */
  138663. export class NativeEngine extends Engine {
  138664. private readonly _native;
  138665. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  138666. private readonly INVALID_HANDLE;
  138667. private _boundBuffersVertexArray;
  138668. private _currentDepthTest;
  138669. getHardwareScalingLevel(): number;
  138670. constructor();
  138671. dispose(): void;
  138672. /**
  138673. * Can be used to override the current requestAnimationFrame requester.
  138674. * @hidden
  138675. */
  138676. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  138677. /**
  138678. * Override default engine behavior.
  138679. * @param color
  138680. * @param backBuffer
  138681. * @param depth
  138682. * @param stencil
  138683. */
  138684. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  138685. /**
  138686. * Gets host document
  138687. * @returns the host document object
  138688. */
  138689. getHostDocument(): Nullable<Document>;
  138690. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  138691. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  138692. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  138693. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  138694. [key: string]: VertexBuffer;
  138695. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138696. bindBuffers(vertexBuffers: {
  138697. [key: string]: VertexBuffer;
  138698. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  138699. recordVertexArrayObject(vertexBuffers: {
  138700. [key: string]: VertexBuffer;
  138701. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  138702. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138703. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  138704. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  138705. /**
  138706. * Draw a list of indexed primitives
  138707. * @param fillMode defines the primitive to use
  138708. * @param indexStart defines the starting index
  138709. * @param indexCount defines the number of index to draw
  138710. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138711. */
  138712. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  138713. /**
  138714. * Draw a list of unindexed primitives
  138715. * @param fillMode defines the primitive to use
  138716. * @param verticesStart defines the index of first vertex to draw
  138717. * @param verticesCount defines the count of vertices to draw
  138718. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  138719. */
  138720. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  138721. createPipelineContext(): IPipelineContext;
  138722. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  138723. /** @hidden */
  138724. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  138725. /** @hidden */
  138726. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  138727. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138728. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  138729. protected _setProgram(program: WebGLProgram): void;
  138730. _releaseEffect(effect: Effect): void;
  138731. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  138732. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  138733. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  138734. bindSamplers(effect: Effect): void;
  138735. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  138736. getRenderWidth(useScreen?: boolean): number;
  138737. getRenderHeight(useScreen?: boolean): number;
  138738. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  138739. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  138740. /**
  138741. * Set the z offset to apply to current rendering
  138742. * @param value defines the offset to apply
  138743. */
  138744. setZOffset(value: number): void;
  138745. /**
  138746. * Gets the current value of the zOffset
  138747. * @returns the current zOffset state
  138748. */
  138749. getZOffset(): number;
  138750. /**
  138751. * Enable or disable depth buffering
  138752. * @param enable defines the state to set
  138753. */
  138754. setDepthBuffer(enable: boolean): void;
  138755. /**
  138756. * Gets a boolean indicating if depth writing is enabled
  138757. * @returns the current depth writing state
  138758. */
  138759. getDepthWrite(): boolean;
  138760. setDepthFunctionToGreater(): void;
  138761. setDepthFunctionToGreaterOrEqual(): void;
  138762. setDepthFunctionToLess(): void;
  138763. setDepthFunctionToLessOrEqual(): void;
  138764. /**
  138765. * Enable or disable depth writing
  138766. * @param enable defines the state to set
  138767. */
  138768. setDepthWrite(enable: boolean): void;
  138769. /**
  138770. * Enable or disable color writing
  138771. * @param enable defines the state to set
  138772. */
  138773. setColorWrite(enable: boolean): void;
  138774. /**
  138775. * Gets a boolean indicating if color writing is enabled
  138776. * @returns the current color writing state
  138777. */
  138778. getColorWrite(): boolean;
  138779. /**
  138780. * Sets alpha constants used by some alpha blending modes
  138781. * @param r defines the red component
  138782. * @param g defines the green component
  138783. * @param b defines the blue component
  138784. * @param a defines the alpha component
  138785. */
  138786. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  138787. /**
  138788. * Sets the current alpha mode
  138789. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  138790. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  138791. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138792. */
  138793. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  138794. /**
  138795. * Gets the current alpha mode
  138796. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  138797. * @returns the current alpha mode
  138798. */
  138799. getAlphaMode(): number;
  138800. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  138801. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138802. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138803. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138804. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  138805. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138806. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138807. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138808. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  138809. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  138810. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  138811. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  138812. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  138813. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  138814. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138815. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  138816. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  138817. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  138818. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  138819. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  138820. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  138821. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  138822. wipeCaches(bruteForce?: boolean): void;
  138823. _createTexture(): WebGLTexture;
  138824. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  138825. /**
  138826. * Update the content of a dynamic texture
  138827. * @param texture defines the texture to update
  138828. * @param canvas defines the canvas containing the source
  138829. * @param invertY defines if data must be stored with Y axis inverted
  138830. * @param premulAlpha defines if alpha is stored as premultiplied
  138831. * @param format defines the format of the data
  138832. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  138833. */
  138834. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  138835. /**
  138836. * Usually called from Texture.ts.
  138837. * Passed information to create a WebGLTexture
  138838. * @param url defines a value which contains one of the following:
  138839. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  138840. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  138841. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  138842. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  138843. * @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)
  138844. * @param scene needed for loading to the correct scene
  138845. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  138846. * @param onLoad optional callback to be called upon successful completion
  138847. * @param onError optional callback to be called upon failure
  138848. * @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
  138849. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  138850. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  138851. * @param forcedExtension defines the extension to use to pick the right loader
  138852. * @param mimeType defines an optional mime type
  138853. * @param loaderOptions options to be passed to the loader
  138854. * @returns a InternalTexture for assignment back into BABYLON.Texture
  138855. */
  138856. 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, loaderOptions?: any): InternalTexture;
  138857. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  138858. _releaseFramebufferObjects(texture: InternalTexture): void;
  138859. /**
  138860. * Creates a cube texture
  138861. * @param rootUrl defines the url where the files to load is located
  138862. * @param scene defines the current scene
  138863. * @param files defines the list of files to load (1 per face)
  138864. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  138865. * @param onLoad defines an optional callback raised when the texture is loaded
  138866. * @param onError defines an optional callback raised if there is an issue to load the texture
  138867. * @param format defines the format of the data
  138868. * @param forcedExtension defines the extension to use to pick the right loader
  138869. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  138870. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  138871. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  138872. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  138873. * @returns the cube texture as an InternalTexture
  138874. */
  138875. 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;
  138876. createRenderTargetTexture(size: number | {
  138877. width: number;
  138878. height: number;
  138879. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  138880. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  138881. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  138882. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  138883. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  138884. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  138885. /**
  138886. * Updates a dynamic vertex buffer.
  138887. * @param vertexBuffer the vertex buffer to update
  138888. * @param data the data used to update the vertex buffer
  138889. * @param byteOffset the byte offset of the data (optional)
  138890. * @param byteLength the byte length of the data (optional)
  138891. */
  138892. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  138893. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  138894. private _updateAnisotropicLevel;
  138895. private _getAddressMode;
  138896. /** @hidden */
  138897. _bindTexture(channel: number, texture: InternalTexture): void;
  138898. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  138899. releaseEffects(): void;
  138900. /** @hidden */
  138901. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138902. /** @hidden */
  138903. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138904. /** @hidden */
  138905. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  138906. /** @hidden */
  138907. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  138908. private _getNativeSamplingMode;
  138909. private _getNativeTextureFormat;
  138910. private _getNativeAlphaMode;
  138911. private _getNativeAttribType;
  138912. }
  138913. }
  138914. declare module BABYLON {
  138915. /**
  138916. * Gather the list of clipboard event types as constants.
  138917. */
  138918. export class ClipboardEventTypes {
  138919. /**
  138920. * The clipboard event is fired when a copy command is active (pressed).
  138921. */
  138922. static readonly COPY: number;
  138923. /**
  138924. * The clipboard event is fired when a cut command is active (pressed).
  138925. */
  138926. static readonly CUT: number;
  138927. /**
  138928. * The clipboard event is fired when a paste command is active (pressed).
  138929. */
  138930. static readonly PASTE: number;
  138931. }
  138932. /**
  138933. * This class is used to store clipboard related info for the onClipboardObservable event.
  138934. */
  138935. export class ClipboardInfo {
  138936. /**
  138937. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138938. */
  138939. type: number;
  138940. /**
  138941. * Defines the related dom event
  138942. */
  138943. event: ClipboardEvent;
  138944. /**
  138945. *Creates an instance of ClipboardInfo.
  138946. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  138947. * @param event Defines the related dom event
  138948. */
  138949. constructor(
  138950. /**
  138951. * Defines the type of event (BABYLON.ClipboardEventTypes)
  138952. */
  138953. type: number,
  138954. /**
  138955. * Defines the related dom event
  138956. */
  138957. event: ClipboardEvent);
  138958. /**
  138959. * Get the clipboard event's type from the keycode.
  138960. * @param keyCode Defines the keyCode for the current keyboard event.
  138961. * @return {number}
  138962. */
  138963. static GetTypeFromCharacter(keyCode: number): number;
  138964. }
  138965. }
  138966. declare module BABYLON {
  138967. /**
  138968. * Google Daydream controller
  138969. */
  138970. export class DaydreamController extends WebVRController {
  138971. /**
  138972. * Base Url for the controller model.
  138973. */
  138974. static MODEL_BASE_URL: string;
  138975. /**
  138976. * File name for the controller model.
  138977. */
  138978. static MODEL_FILENAME: string;
  138979. /**
  138980. * Gamepad Id prefix used to identify Daydream Controller.
  138981. */
  138982. static readonly GAMEPAD_ID_PREFIX: string;
  138983. /**
  138984. * Creates a new DaydreamController from a gamepad
  138985. * @param vrGamepad the gamepad that the controller should be created from
  138986. */
  138987. constructor(vrGamepad: any);
  138988. /**
  138989. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  138990. * @param scene scene in which to add meshes
  138991. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  138992. */
  138993. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  138994. /**
  138995. * Called once for each button that changed state since the last frame
  138996. * @param buttonIdx Which button index changed
  138997. * @param state New state of the button
  138998. * @param changes Which properties on the state changed since last frame
  138999. */
  139000. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139001. }
  139002. }
  139003. declare module BABYLON {
  139004. /**
  139005. * Gear VR Controller
  139006. */
  139007. export class GearVRController extends WebVRController {
  139008. /**
  139009. * Base Url for the controller model.
  139010. */
  139011. static MODEL_BASE_URL: string;
  139012. /**
  139013. * File name for the controller model.
  139014. */
  139015. static MODEL_FILENAME: string;
  139016. /**
  139017. * Gamepad Id prefix used to identify this controller.
  139018. */
  139019. static readonly GAMEPAD_ID_PREFIX: string;
  139020. private readonly _buttonIndexToObservableNameMap;
  139021. /**
  139022. * Creates a new GearVRController from a gamepad
  139023. * @param vrGamepad the gamepad that the controller should be created from
  139024. */
  139025. constructor(vrGamepad: any);
  139026. /**
  139027. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139028. * @param scene scene in which to add meshes
  139029. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139030. */
  139031. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139032. /**
  139033. * Called once for each button that changed state since the last frame
  139034. * @param buttonIdx Which button index changed
  139035. * @param state New state of the button
  139036. * @param changes Which properties on the state changed since last frame
  139037. */
  139038. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139039. }
  139040. }
  139041. declare module BABYLON {
  139042. /**
  139043. * Generic Controller
  139044. */
  139045. export class GenericController extends WebVRController {
  139046. /**
  139047. * Base Url for the controller model.
  139048. */
  139049. static readonly MODEL_BASE_URL: string;
  139050. /**
  139051. * File name for the controller model.
  139052. */
  139053. static readonly MODEL_FILENAME: string;
  139054. /**
  139055. * Creates a new GenericController from a gamepad
  139056. * @param vrGamepad the gamepad that the controller should be created from
  139057. */
  139058. constructor(vrGamepad: any);
  139059. /**
  139060. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139061. * @param scene scene in which to add meshes
  139062. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139063. */
  139064. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139065. /**
  139066. * Called once for each button that changed state since the last frame
  139067. * @param buttonIdx Which button index changed
  139068. * @param state New state of the button
  139069. * @param changes Which properties on the state changed since last frame
  139070. */
  139071. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139072. }
  139073. }
  139074. declare module BABYLON {
  139075. /**
  139076. * Oculus Touch Controller
  139077. */
  139078. export class OculusTouchController extends WebVRController {
  139079. /**
  139080. * Base Url for the controller model.
  139081. */
  139082. static MODEL_BASE_URL: string;
  139083. /**
  139084. * File name for the left controller model.
  139085. */
  139086. static MODEL_LEFT_FILENAME: string;
  139087. /**
  139088. * File name for the right controller model.
  139089. */
  139090. static MODEL_RIGHT_FILENAME: string;
  139091. /**
  139092. * Base Url for the Quest controller model.
  139093. */
  139094. static QUEST_MODEL_BASE_URL: string;
  139095. /**
  139096. * @hidden
  139097. * If the controllers are running on a device that needs the updated Quest controller models
  139098. */
  139099. static _IsQuest: boolean;
  139100. /**
  139101. * Fired when the secondary trigger on this controller is modified
  139102. */
  139103. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  139104. /**
  139105. * Fired when the thumb rest on this controller is modified
  139106. */
  139107. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  139108. /**
  139109. * Creates a new OculusTouchController from a gamepad
  139110. * @param vrGamepad the gamepad that the controller should be created from
  139111. */
  139112. constructor(vrGamepad: any);
  139113. /**
  139114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139115. * @param scene scene in which to add meshes
  139116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139117. */
  139118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139119. /**
  139120. * Fired when the A button on this controller is modified
  139121. */
  139122. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139123. /**
  139124. * Fired when the B button on this controller is modified
  139125. */
  139126. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139127. /**
  139128. * Fired when the X button on this controller is modified
  139129. */
  139130. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139131. /**
  139132. * Fired when the Y button on this controller is modified
  139133. */
  139134. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139135. /**
  139136. * Called once for each button that changed state since the last frame
  139137. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  139138. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  139139. * 2) secondary trigger (same)
  139140. * 3) A (right) X (left), touch, pressed = value
  139141. * 4) B / Y
  139142. * 5) thumb rest
  139143. * @param buttonIdx Which button index changed
  139144. * @param state New state of the button
  139145. * @param changes Which properties on the state changed since last frame
  139146. */
  139147. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139148. }
  139149. }
  139150. declare module BABYLON {
  139151. /**
  139152. * Vive Controller
  139153. */
  139154. export class ViveController extends WebVRController {
  139155. /**
  139156. * Base Url for the controller model.
  139157. */
  139158. static MODEL_BASE_URL: string;
  139159. /**
  139160. * File name for the controller model.
  139161. */
  139162. static MODEL_FILENAME: string;
  139163. /**
  139164. * Creates a new ViveController from a gamepad
  139165. * @param vrGamepad the gamepad that the controller should be created from
  139166. */
  139167. constructor(vrGamepad: any);
  139168. /**
  139169. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139170. * @param scene scene in which to add meshes
  139171. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139172. */
  139173. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  139174. /**
  139175. * Fired when the left button on this controller is modified
  139176. */
  139177. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139178. /**
  139179. * Fired when the right button on this controller is modified
  139180. */
  139181. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139182. /**
  139183. * Fired when the menu button on this controller is modified
  139184. */
  139185. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139186. /**
  139187. * Called once for each button that changed state since the last frame
  139188. * Vive mapping:
  139189. * 0: touchpad
  139190. * 1: trigger
  139191. * 2: left AND right buttons
  139192. * 3: menu button
  139193. * @param buttonIdx Which button index changed
  139194. * @param state New state of the button
  139195. * @param changes Which properties on the state changed since last frame
  139196. */
  139197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139198. }
  139199. }
  139200. declare module BABYLON {
  139201. /**
  139202. * Defines the WindowsMotionController object that the state of the windows motion controller
  139203. */
  139204. export class WindowsMotionController extends WebVRController {
  139205. /**
  139206. * The base url used to load the left and right controller models
  139207. */
  139208. static MODEL_BASE_URL: string;
  139209. /**
  139210. * The name of the left controller model file
  139211. */
  139212. static MODEL_LEFT_FILENAME: string;
  139213. /**
  139214. * The name of the right controller model file
  139215. */
  139216. static MODEL_RIGHT_FILENAME: string;
  139217. /**
  139218. * The controller name prefix for this controller type
  139219. */
  139220. static readonly GAMEPAD_ID_PREFIX: string;
  139221. /**
  139222. * The controller id pattern for this controller type
  139223. */
  139224. private static readonly GAMEPAD_ID_PATTERN;
  139225. private _loadedMeshInfo;
  139226. protected readonly _mapping: {
  139227. buttons: string[];
  139228. buttonMeshNames: {
  139229. trigger: string;
  139230. menu: string;
  139231. grip: string;
  139232. thumbstick: string;
  139233. trackpad: string;
  139234. };
  139235. buttonObservableNames: {
  139236. trigger: string;
  139237. menu: string;
  139238. grip: string;
  139239. thumbstick: string;
  139240. trackpad: string;
  139241. };
  139242. axisMeshNames: string[];
  139243. pointingPoseMeshName: string;
  139244. };
  139245. /**
  139246. * Fired when the trackpad on this controller is clicked
  139247. */
  139248. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139249. /**
  139250. * Fired when the trackpad on this controller is modified
  139251. */
  139252. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139253. /**
  139254. * The current x and y values of this controller's trackpad
  139255. */
  139256. trackpad: StickValues;
  139257. /**
  139258. * Creates a new WindowsMotionController from a gamepad
  139259. * @param vrGamepad the gamepad that the controller should be created from
  139260. */
  139261. constructor(vrGamepad: any);
  139262. /**
  139263. * Fired when the trigger on this controller is modified
  139264. */
  139265. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139266. /**
  139267. * Fired when the menu button on this controller is modified
  139268. */
  139269. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139270. /**
  139271. * Fired when the grip button on this controller is modified
  139272. */
  139273. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139274. /**
  139275. * Fired when the thumbstick button on this controller is modified
  139276. */
  139277. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139278. /**
  139279. * Fired when the touchpad button on this controller is modified
  139280. */
  139281. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139282. /**
  139283. * Fired when the touchpad values on this controller are modified
  139284. */
  139285. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  139286. protected _updateTrackpad(): void;
  139287. /**
  139288. * Called once per frame by the engine.
  139289. */
  139290. update(): void;
  139291. /**
  139292. * Called once for each button that changed state since the last frame
  139293. * @param buttonIdx Which button index changed
  139294. * @param state New state of the button
  139295. * @param changes Which properties on the state changed since last frame
  139296. */
  139297. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  139298. /**
  139299. * Moves the buttons on the controller mesh based on their current state
  139300. * @param buttonName the name of the button to move
  139301. * @param buttonValue the value of the button which determines the buttons new position
  139302. */
  139303. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  139304. /**
  139305. * Moves the axis on the controller mesh based on its current state
  139306. * @param axis the index of the axis
  139307. * @param axisValue the value of the axis which determines the meshes new position
  139308. * @hidden
  139309. */
  139310. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  139311. /**
  139312. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  139313. * @param scene scene in which to add meshes
  139314. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  139315. */
  139316. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  139317. /**
  139318. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  139319. * can be transformed by button presses and axes values, based on this._mapping.
  139320. *
  139321. * @param scene scene in which the meshes exist
  139322. * @param meshes list of meshes that make up the controller model to process
  139323. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  139324. */
  139325. private processModel;
  139326. private createMeshInfo;
  139327. /**
  139328. * Gets the ray of the controller in the direction the controller is pointing
  139329. * @param length the length the resulting ray should be
  139330. * @returns a ray in the direction the controller is pointing
  139331. */
  139332. getForwardRay(length?: number): Ray;
  139333. /**
  139334. * Disposes of the controller
  139335. */
  139336. dispose(): void;
  139337. }
  139338. /**
  139339. * This class represents a new windows motion controller in XR.
  139340. */
  139341. export class XRWindowsMotionController extends WindowsMotionController {
  139342. /**
  139343. * Changing the original WIndowsMotionController mapping to fir the new mapping
  139344. */
  139345. protected readonly _mapping: {
  139346. buttons: string[];
  139347. buttonMeshNames: {
  139348. trigger: string;
  139349. menu: string;
  139350. grip: string;
  139351. thumbstick: string;
  139352. trackpad: string;
  139353. };
  139354. buttonObservableNames: {
  139355. trigger: string;
  139356. menu: string;
  139357. grip: string;
  139358. thumbstick: string;
  139359. trackpad: string;
  139360. };
  139361. axisMeshNames: string[];
  139362. pointingPoseMeshName: string;
  139363. };
  139364. /**
  139365. * Construct a new XR-Based windows motion controller
  139366. *
  139367. * @param gamepadInfo the gamepad object from the browser
  139368. */
  139369. constructor(gamepadInfo: any);
  139370. /**
  139371. * holds the thumbstick values (X,Y)
  139372. */
  139373. thumbstickValues: StickValues;
  139374. /**
  139375. * Fired when the thumbstick on this controller is clicked
  139376. */
  139377. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  139378. /**
  139379. * Fired when the thumbstick on this controller is modified
  139380. */
  139381. onThumbstickValuesChangedObservable: Observable<StickValues>;
  139382. /**
  139383. * Fired when the touchpad button on this controller is modified
  139384. */
  139385. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  139386. /**
  139387. * Fired when the touchpad values on this controller are modified
  139388. */
  139389. onTrackpadValuesChangedObservable: Observable<StickValues>;
  139390. /**
  139391. * Fired when the thumbstick button on this controller is modified
  139392. * here to prevent breaking changes
  139393. */
  139394. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  139395. /**
  139396. * updating the thumbstick(!) and not the trackpad.
  139397. * This is named this way due to the difference between WebVR and XR and to avoid
  139398. * changing the parent class.
  139399. */
  139400. protected _updateTrackpad(): void;
  139401. /**
  139402. * Disposes the class with joy
  139403. */
  139404. dispose(): void;
  139405. }
  139406. }
  139407. declare module BABYLON {
  139408. /**
  139409. * A directional light is defined by a direction (what a surprise!).
  139410. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  139411. * 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.
  139412. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139413. */
  139414. export class DirectionalLight extends ShadowLight {
  139415. private _shadowFrustumSize;
  139416. /**
  139417. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  139418. */
  139419. get shadowFrustumSize(): number;
  139420. /**
  139421. * Specifies a fix frustum size for the shadow generation.
  139422. */
  139423. set shadowFrustumSize(value: number);
  139424. private _shadowOrthoScale;
  139425. /**
  139426. * Gets the shadow projection scale against the optimal computed one.
  139427. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139428. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139429. */
  139430. get shadowOrthoScale(): number;
  139431. /**
  139432. * Sets the shadow projection scale against the optimal computed one.
  139433. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  139434. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  139435. */
  139436. set shadowOrthoScale(value: number);
  139437. /**
  139438. * Automatically compute the projection matrix to best fit (including all the casters)
  139439. * on each frame.
  139440. */
  139441. autoUpdateExtends: boolean;
  139442. /**
  139443. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  139444. * on each frame. autoUpdateExtends must be set to true for this to work
  139445. */
  139446. autoCalcShadowZBounds: boolean;
  139447. private _orthoLeft;
  139448. private _orthoRight;
  139449. private _orthoTop;
  139450. private _orthoBottom;
  139451. /**
  139452. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  139453. * The directional light is emitted from everywhere in the given direction.
  139454. * It can cast shadows.
  139455. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139456. * @param name The friendly name of the light
  139457. * @param direction The direction of the light
  139458. * @param scene The scene the light belongs to
  139459. */
  139460. constructor(name: string, direction: Vector3, scene: Scene);
  139461. /**
  139462. * Returns the string "DirectionalLight".
  139463. * @return The class name
  139464. */
  139465. getClassName(): string;
  139466. /**
  139467. * Returns the integer 1.
  139468. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139469. */
  139470. getTypeID(): number;
  139471. /**
  139472. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  139473. * Returns the DirectionalLight Shadow projection matrix.
  139474. */
  139475. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139476. /**
  139477. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  139478. * Returns the DirectionalLight Shadow projection matrix.
  139479. */
  139480. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  139481. /**
  139482. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  139483. * Returns the DirectionalLight Shadow projection matrix.
  139484. */
  139485. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139486. protected _buildUniformLayout(): void;
  139487. /**
  139488. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  139489. * @param effect The effect to update
  139490. * @param lightIndex The index of the light in the effect to update
  139491. * @returns The directional light
  139492. */
  139493. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  139494. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  139495. /**
  139496. * Gets the minZ used for shadow according to both the scene and the light.
  139497. *
  139498. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139499. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139500. * @param activeCamera The camera we are returning the min for
  139501. * @returns the depth min z
  139502. */
  139503. getDepthMinZ(activeCamera: Camera): number;
  139504. /**
  139505. * Gets the maxZ used for shadow according to both the scene and the light.
  139506. *
  139507. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  139508. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  139509. * @param activeCamera The camera we are returning the max for
  139510. * @returns the depth max z
  139511. */
  139512. getDepthMaxZ(activeCamera: Camera): number;
  139513. /**
  139514. * Prepares the list of defines specific to the light type.
  139515. * @param defines the list of defines
  139516. * @param lightIndex defines the index of the light for the effect
  139517. */
  139518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139519. }
  139520. }
  139521. declare module BABYLON {
  139522. /**
  139523. * Class containing static functions to help procedurally build meshes
  139524. */
  139525. export class HemisphereBuilder {
  139526. /**
  139527. * Creates a hemisphere mesh
  139528. * @param name defines the name of the mesh
  139529. * @param options defines the options used to create the mesh
  139530. * @param scene defines the hosting scene
  139531. * @returns the hemisphere mesh
  139532. */
  139533. static CreateHemisphere(name: string, options: {
  139534. segments?: number;
  139535. diameter?: number;
  139536. sideOrientation?: number;
  139537. }, scene: any): Mesh;
  139538. }
  139539. }
  139540. declare module BABYLON {
  139541. /**
  139542. * A spot light is defined by a position, a direction, an angle, and an exponent.
  139543. * These values define a cone of light starting from the position, emitting toward the direction.
  139544. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  139545. * and the exponent defines the speed of the decay of the light with distance (reach).
  139546. * Documentation: https://doc.babylonjs.com/babylon101/lights
  139547. */
  139548. export class SpotLight extends ShadowLight {
  139549. private _angle;
  139550. private _innerAngle;
  139551. private _cosHalfAngle;
  139552. private _lightAngleScale;
  139553. private _lightAngleOffset;
  139554. /**
  139555. * Gets the cone angle of the spot light in Radians.
  139556. */
  139557. get angle(): number;
  139558. /**
  139559. * Sets the cone angle of the spot light in Radians.
  139560. */
  139561. set angle(value: number);
  139562. /**
  139563. * Only used in gltf falloff mode, this defines the angle where
  139564. * the directional falloff will start before cutting at angle which could be seen
  139565. * as outer angle.
  139566. */
  139567. get innerAngle(): number;
  139568. /**
  139569. * Only used in gltf falloff mode, this defines the angle where
  139570. * the directional falloff will start before cutting at angle which could be seen
  139571. * as outer angle.
  139572. */
  139573. set innerAngle(value: number);
  139574. private _shadowAngleScale;
  139575. /**
  139576. * Allows scaling the angle of the light for shadow generation only.
  139577. */
  139578. get shadowAngleScale(): number;
  139579. /**
  139580. * Allows scaling the angle of the light for shadow generation only.
  139581. */
  139582. set shadowAngleScale(value: number);
  139583. /**
  139584. * The light decay speed with the distance from the emission spot.
  139585. */
  139586. exponent: number;
  139587. private _projectionTextureMatrix;
  139588. /**
  139589. * Allows reading the projecton texture
  139590. */
  139591. get projectionTextureMatrix(): Matrix;
  139592. protected _projectionTextureLightNear: number;
  139593. /**
  139594. * Gets the near clip of the Spotlight for texture projection.
  139595. */
  139596. get projectionTextureLightNear(): number;
  139597. /**
  139598. * Sets the near clip of the Spotlight for texture projection.
  139599. */
  139600. set projectionTextureLightNear(value: number);
  139601. protected _projectionTextureLightFar: number;
  139602. /**
  139603. * Gets the far clip of the Spotlight for texture projection.
  139604. */
  139605. get projectionTextureLightFar(): number;
  139606. /**
  139607. * Sets the far clip of the Spotlight for texture projection.
  139608. */
  139609. set projectionTextureLightFar(value: number);
  139610. protected _projectionTextureUpDirection: Vector3;
  139611. /**
  139612. * Gets the Up vector of the Spotlight for texture projection.
  139613. */
  139614. get projectionTextureUpDirection(): Vector3;
  139615. /**
  139616. * Sets the Up vector of the Spotlight for texture projection.
  139617. */
  139618. set projectionTextureUpDirection(value: Vector3);
  139619. private _projectionTexture;
  139620. /**
  139621. * Gets the projection texture of the light.
  139622. */
  139623. get projectionTexture(): Nullable<BaseTexture>;
  139624. /**
  139625. * Sets the projection texture of the light.
  139626. */
  139627. set projectionTexture(value: Nullable<BaseTexture>);
  139628. private static _IsProceduralTexture;
  139629. private static _IsTexture;
  139630. private _projectionTextureViewLightDirty;
  139631. private _projectionTextureProjectionLightDirty;
  139632. private _projectionTextureDirty;
  139633. private _projectionTextureViewTargetVector;
  139634. private _projectionTextureViewLightMatrix;
  139635. private _projectionTextureProjectionLightMatrix;
  139636. private _projectionTextureScalingMatrix;
  139637. /**
  139638. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  139639. * It can cast shadows.
  139640. * Documentation : https://doc.babylonjs.com/babylon101/lights
  139641. * @param name The light friendly name
  139642. * @param position The position of the spot light in the scene
  139643. * @param direction The direction of the light in the scene
  139644. * @param angle The cone angle of the light in Radians
  139645. * @param exponent The light decay speed with the distance from the emission spot
  139646. * @param scene The scene the lights belongs to
  139647. */
  139648. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  139649. /**
  139650. * Returns the string "SpotLight".
  139651. * @returns the class name
  139652. */
  139653. getClassName(): string;
  139654. /**
  139655. * Returns the integer 2.
  139656. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  139657. */
  139658. getTypeID(): number;
  139659. /**
  139660. * Overrides the direction setter to recompute the projection texture view light Matrix.
  139661. */
  139662. protected _setDirection(value: Vector3): void;
  139663. /**
  139664. * Overrides the position setter to recompute the projection texture view light Matrix.
  139665. */
  139666. protected _setPosition(value: Vector3): void;
  139667. /**
  139668. * 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.
  139669. * Returns the SpotLight.
  139670. */
  139671. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  139672. protected _computeProjectionTextureViewLightMatrix(): void;
  139673. protected _computeProjectionTextureProjectionLightMatrix(): void;
  139674. /**
  139675. * Main function for light texture projection matrix computing.
  139676. */
  139677. protected _computeProjectionTextureMatrix(): void;
  139678. protected _buildUniformLayout(): void;
  139679. private _computeAngleValues;
  139680. /**
  139681. * Sets the passed Effect "effect" with the Light textures.
  139682. * @param effect The effect to update
  139683. * @param lightIndex The index of the light in the effect to update
  139684. * @returns The light
  139685. */
  139686. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  139687. /**
  139688. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  139689. * @param effect The effect to update
  139690. * @param lightIndex The index of the light in the effect to update
  139691. * @returns The spot light
  139692. */
  139693. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  139694. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  139695. /**
  139696. * Disposes the light and the associated resources.
  139697. */
  139698. dispose(): void;
  139699. /**
  139700. * Prepares the list of defines specific to the light type.
  139701. * @param defines the list of defines
  139702. * @param lightIndex defines the index of the light for the effect
  139703. */
  139704. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  139705. }
  139706. }
  139707. declare module BABYLON {
  139708. /**
  139709. * Gizmo that enables viewing a light
  139710. */
  139711. export class LightGizmo extends Gizmo {
  139712. private _lightMesh;
  139713. private _material;
  139714. private _cachedPosition;
  139715. private _cachedForward;
  139716. private _attachedMeshParent;
  139717. private _pointerObserver;
  139718. /**
  139719. * Event that fires each time the gizmo is clicked
  139720. */
  139721. onClickedObservable: Observable<Light>;
  139722. /**
  139723. * Creates a LightGizmo
  139724. * @param gizmoLayer The utility layer the gizmo will be added to
  139725. */
  139726. constructor(gizmoLayer?: UtilityLayerRenderer);
  139727. private _light;
  139728. /**
  139729. * The light that the gizmo is attached to
  139730. */
  139731. set light(light: Nullable<Light>);
  139732. get light(): Nullable<Light>;
  139733. /**
  139734. * Gets the material used to render the light gizmo
  139735. */
  139736. get material(): StandardMaterial;
  139737. /**
  139738. * @hidden
  139739. * Updates the gizmo to match the attached mesh's position/rotation
  139740. */
  139741. protected _update(): void;
  139742. private static _Scale;
  139743. /**
  139744. * Creates the lines for a light mesh
  139745. */
  139746. private static _CreateLightLines;
  139747. /**
  139748. * Disposes of the light gizmo
  139749. */
  139750. dispose(): void;
  139751. private static _CreateHemisphericLightMesh;
  139752. private static _CreatePointLightMesh;
  139753. private static _CreateSpotLightMesh;
  139754. private static _CreateDirectionalLightMesh;
  139755. }
  139756. }
  139757. declare module BABYLON {
  139758. /**
  139759. * Gizmo that enables viewing a camera
  139760. */
  139761. export class CameraGizmo extends Gizmo {
  139762. private _cameraMesh;
  139763. private _cameraLinesMesh;
  139764. private _material;
  139765. private _pointerObserver;
  139766. /**
  139767. * Event that fires each time the gizmo is clicked
  139768. */
  139769. onClickedObservable: Observable<Camera>;
  139770. /**
  139771. * Creates a CameraGizmo
  139772. * @param gizmoLayer The utility layer the gizmo will be added to
  139773. */
  139774. constructor(gizmoLayer?: UtilityLayerRenderer);
  139775. private _camera;
  139776. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  139777. get displayFrustum(): boolean;
  139778. set displayFrustum(value: boolean);
  139779. /**
  139780. * The camera that the gizmo is attached to
  139781. */
  139782. set camera(camera: Nullable<Camera>);
  139783. get camera(): Nullable<Camera>;
  139784. /**
  139785. * Gets the material used to render the camera gizmo
  139786. */
  139787. get material(): StandardMaterial;
  139788. /**
  139789. * @hidden
  139790. * Updates the gizmo to match the attached mesh's position/rotation
  139791. */
  139792. protected _update(): void;
  139793. private static _Scale;
  139794. private _invProjection;
  139795. /**
  139796. * Disposes of the camera gizmo
  139797. */
  139798. dispose(): void;
  139799. private static _CreateCameraMesh;
  139800. private static _CreateCameraFrustum;
  139801. }
  139802. }
  139803. declare module BABYLON {
  139804. /** @hidden */
  139805. export var backgroundFragmentDeclaration: {
  139806. name: string;
  139807. shader: string;
  139808. };
  139809. }
  139810. declare module BABYLON {
  139811. /** @hidden */
  139812. export var backgroundUboDeclaration: {
  139813. name: string;
  139814. shader: string;
  139815. };
  139816. }
  139817. declare module BABYLON {
  139818. /** @hidden */
  139819. export var backgroundPixelShader: {
  139820. name: string;
  139821. shader: string;
  139822. };
  139823. }
  139824. declare module BABYLON {
  139825. /** @hidden */
  139826. export var backgroundVertexDeclaration: {
  139827. name: string;
  139828. shader: string;
  139829. };
  139830. }
  139831. declare module BABYLON {
  139832. /** @hidden */
  139833. export var backgroundVertexShader: {
  139834. name: string;
  139835. shader: string;
  139836. };
  139837. }
  139838. declare module BABYLON {
  139839. /**
  139840. * Background material used to create an efficient environement around your scene.
  139841. */
  139842. export class BackgroundMaterial extends PushMaterial {
  139843. /**
  139844. * Standard reflectance value at parallel view angle.
  139845. */
  139846. static StandardReflectance0: number;
  139847. /**
  139848. * Standard reflectance value at grazing angle.
  139849. */
  139850. static StandardReflectance90: number;
  139851. protected _primaryColor: Color3;
  139852. /**
  139853. * Key light Color (multiply against the environement texture)
  139854. */
  139855. primaryColor: Color3;
  139856. protected __perceptualColor: Nullable<Color3>;
  139857. /**
  139858. * Experimental Internal Use Only.
  139859. *
  139860. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  139861. * This acts as a helper to set the primary color to a more "human friendly" value.
  139862. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  139863. * output color as close as possible from the chosen value.
  139864. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  139865. * part of lighting setup.)
  139866. */
  139867. get _perceptualColor(): Nullable<Color3>;
  139868. set _perceptualColor(value: Nullable<Color3>);
  139869. protected _primaryColorShadowLevel: float;
  139870. /**
  139871. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  139872. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  139873. */
  139874. get primaryColorShadowLevel(): float;
  139875. set primaryColorShadowLevel(value: float);
  139876. protected _primaryColorHighlightLevel: float;
  139877. /**
  139878. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  139879. * The primary color is used at the level chosen to define what the white area would look.
  139880. */
  139881. get primaryColorHighlightLevel(): float;
  139882. set primaryColorHighlightLevel(value: float);
  139883. protected _reflectionTexture: Nullable<BaseTexture>;
  139884. /**
  139885. * Reflection Texture used in the material.
  139886. * Should be author in a specific way for the best result (refer to the documentation).
  139887. */
  139888. reflectionTexture: Nullable<BaseTexture>;
  139889. protected _reflectionBlur: float;
  139890. /**
  139891. * Reflection Texture level of blur.
  139892. *
  139893. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  139894. * texture twice.
  139895. */
  139896. reflectionBlur: float;
  139897. protected _diffuseTexture: Nullable<BaseTexture>;
  139898. /**
  139899. * Diffuse Texture used in the material.
  139900. * Should be author in a specific way for the best result (refer to the documentation).
  139901. */
  139902. diffuseTexture: Nullable<BaseTexture>;
  139903. protected _shadowLights: Nullable<IShadowLight[]>;
  139904. /**
  139905. * Specify the list of lights casting shadow on the material.
  139906. * All scene shadow lights will be included if null.
  139907. */
  139908. shadowLights: Nullable<IShadowLight[]>;
  139909. protected _shadowLevel: float;
  139910. /**
  139911. * Helps adjusting the shadow to a softer level if required.
  139912. * 0 means black shadows and 1 means no shadows.
  139913. */
  139914. shadowLevel: float;
  139915. protected _sceneCenter: Vector3;
  139916. /**
  139917. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  139918. * It is usually zero but might be interesting to modify according to your setup.
  139919. */
  139920. sceneCenter: Vector3;
  139921. protected _opacityFresnel: boolean;
  139922. /**
  139923. * This helps specifying that the material is falling off to the sky box at grazing angle.
  139924. * This helps ensuring a nice transition when the camera goes under the ground.
  139925. */
  139926. opacityFresnel: boolean;
  139927. protected _reflectionFresnel: boolean;
  139928. /**
  139929. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  139930. * This helps adding a mirror texture on the ground.
  139931. */
  139932. reflectionFresnel: boolean;
  139933. protected _reflectionFalloffDistance: number;
  139934. /**
  139935. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  139936. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  139937. */
  139938. reflectionFalloffDistance: number;
  139939. protected _reflectionAmount: number;
  139940. /**
  139941. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  139942. */
  139943. reflectionAmount: number;
  139944. protected _reflectionReflectance0: number;
  139945. /**
  139946. * This specifies the weight of the reflection at grazing angle.
  139947. */
  139948. reflectionReflectance0: number;
  139949. protected _reflectionReflectance90: number;
  139950. /**
  139951. * This specifies the weight of the reflection at a perpendicular point of view.
  139952. */
  139953. reflectionReflectance90: number;
  139954. /**
  139955. * Sets the reflection reflectance fresnel values according to the default standard
  139956. * empirically know to work well :-)
  139957. */
  139958. set reflectionStandardFresnelWeight(value: number);
  139959. protected _useRGBColor: boolean;
  139960. /**
  139961. * Helps to directly use the maps channels instead of their level.
  139962. */
  139963. useRGBColor: boolean;
  139964. protected _enableNoise: boolean;
  139965. /**
  139966. * This helps reducing the banding effect that could occur on the background.
  139967. */
  139968. enableNoise: boolean;
  139969. /**
  139970. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139971. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139972. * Recommended to be keep at 1.0 except for special cases.
  139973. */
  139974. get fovMultiplier(): number;
  139975. set fovMultiplier(value: number);
  139976. private _fovMultiplier;
  139977. /**
  139978. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139979. */
  139980. useEquirectangularFOV: boolean;
  139981. private _maxSimultaneousLights;
  139982. /**
  139983. * Number of Simultaneous lights allowed on the material.
  139984. */
  139985. maxSimultaneousLights: int;
  139986. private _shadowOnly;
  139987. /**
  139988. * Make the material only render shadows
  139989. */
  139990. shadowOnly: boolean;
  139991. /**
  139992. * Default configuration related to image processing available in the Background Material.
  139993. */
  139994. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139995. /**
  139996. * Keep track of the image processing observer to allow dispose and replace.
  139997. */
  139998. private _imageProcessingObserver;
  139999. /**
  140000. * Attaches a new image processing configuration to the PBR Material.
  140001. * @param configuration (if null the scene configuration will be use)
  140002. */
  140003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  140004. /**
  140005. * Gets the image processing configuration used either in this material.
  140006. */
  140007. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  140008. /**
  140009. * Sets the Default image processing configuration used either in the this material.
  140010. *
  140011. * If sets to null, the scene one is in use.
  140012. */
  140013. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  140014. /**
  140015. * Gets wether the color curves effect is enabled.
  140016. */
  140017. get cameraColorCurvesEnabled(): boolean;
  140018. /**
  140019. * Sets wether the color curves effect is enabled.
  140020. */
  140021. set cameraColorCurvesEnabled(value: boolean);
  140022. /**
  140023. * Gets wether the color grading effect is enabled.
  140024. */
  140025. get cameraColorGradingEnabled(): boolean;
  140026. /**
  140027. * Gets wether the color grading effect is enabled.
  140028. */
  140029. set cameraColorGradingEnabled(value: boolean);
  140030. /**
  140031. * Gets wether tonemapping is enabled or not.
  140032. */
  140033. get cameraToneMappingEnabled(): boolean;
  140034. /**
  140035. * Sets wether tonemapping is enabled or not
  140036. */
  140037. set cameraToneMappingEnabled(value: boolean);
  140038. /**
  140039. * The camera exposure used on this material.
  140040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  140041. * This corresponds to a photographic exposure.
  140042. */
  140043. get cameraExposure(): float;
  140044. /**
  140045. * The camera exposure used on this material.
  140046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  140047. * This corresponds to a photographic exposure.
  140048. */
  140049. set cameraExposure(value: float);
  140050. /**
  140051. * Gets The camera contrast used on this material.
  140052. */
  140053. get cameraContrast(): float;
  140054. /**
  140055. * Sets The camera contrast used on this material.
  140056. */
  140057. set cameraContrast(value: float);
  140058. /**
  140059. * Gets the Color Grading 2D Lookup Texture.
  140060. */
  140061. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  140062. /**
  140063. * Sets the Color Grading 2D Lookup Texture.
  140064. */
  140065. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  140066. /**
  140067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  140068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  140069. * 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;
  140070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  140071. */
  140072. get cameraColorCurves(): Nullable<ColorCurves>;
  140073. /**
  140074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  140075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  140076. * 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;
  140077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  140078. */
  140079. set cameraColorCurves(value: Nullable<ColorCurves>);
  140080. /**
  140081. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  140082. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  140083. */
  140084. switchToBGR: boolean;
  140085. private _renderTargets;
  140086. private _reflectionControls;
  140087. private _white;
  140088. private _primaryShadowColor;
  140089. private _primaryHighlightColor;
  140090. /**
  140091. * Instantiates a Background Material in the given scene
  140092. * @param name The friendly name of the material
  140093. * @param scene The scene to add the material to
  140094. */
  140095. constructor(name: string, scene: Scene);
  140096. /**
  140097. * Gets a boolean indicating that current material needs to register RTT
  140098. */
  140099. get hasRenderTargetTextures(): boolean;
  140100. /**
  140101. * The entire material has been created in order to prevent overdraw.
  140102. * @returns false
  140103. */
  140104. needAlphaTesting(): boolean;
  140105. /**
  140106. * The entire material has been created in order to prevent overdraw.
  140107. * @returns true if blending is enable
  140108. */
  140109. needAlphaBlending(): boolean;
  140110. /**
  140111. * Checks wether the material is ready to be rendered for a given mesh.
  140112. * @param mesh The mesh to render
  140113. * @param subMesh The submesh to check against
  140114. * @param useInstances Specify wether or not the material is used with instances
  140115. * @returns true if all the dependencies are ready (Textures, Effects...)
  140116. */
  140117. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  140118. /**
  140119. * Compute the primary color according to the chosen perceptual color.
  140120. */
  140121. private _computePrimaryColorFromPerceptualColor;
  140122. /**
  140123. * Compute the highlights and shadow colors according to their chosen levels.
  140124. */
  140125. private _computePrimaryColors;
  140126. /**
  140127. * Build the uniform buffer used in the material.
  140128. */
  140129. buildUniformLayout(): void;
  140130. /**
  140131. * Unbind the material.
  140132. */
  140133. unbind(): void;
  140134. /**
  140135. * Bind only the world matrix to the material.
  140136. * @param world The world matrix to bind.
  140137. */
  140138. bindOnlyWorldMatrix(world: Matrix): void;
  140139. /**
  140140. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  140141. * @param world The world matrix to bind.
  140142. * @param subMesh The submesh to bind for.
  140143. */
  140144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  140145. /**
  140146. * Checks to see if a texture is used in the material.
  140147. * @param texture - Base texture to use.
  140148. * @returns - Boolean specifying if a texture is used in the material.
  140149. */
  140150. hasTexture(texture: BaseTexture): boolean;
  140151. /**
  140152. * Dispose the material.
  140153. * @param forceDisposeEffect Force disposal of the associated effect.
  140154. * @param forceDisposeTextures Force disposal of the associated textures.
  140155. */
  140156. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  140157. /**
  140158. * Clones the material.
  140159. * @param name The cloned name.
  140160. * @returns The cloned material.
  140161. */
  140162. clone(name: string): BackgroundMaterial;
  140163. /**
  140164. * Serializes the current material to its JSON representation.
  140165. * @returns The JSON representation.
  140166. */
  140167. serialize(): any;
  140168. /**
  140169. * Gets the class name of the material
  140170. * @returns "BackgroundMaterial"
  140171. */
  140172. getClassName(): string;
  140173. /**
  140174. * Parse a JSON input to create back a background material.
  140175. * @param source The JSON data to parse
  140176. * @param scene The scene to create the parsed material in
  140177. * @param rootUrl The root url of the assets the material depends upon
  140178. * @returns the instantiated BackgroundMaterial.
  140179. */
  140180. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  140181. }
  140182. }
  140183. declare module BABYLON {
  140184. /**
  140185. * Represents the different options available during the creation of
  140186. * a Environment helper.
  140187. *
  140188. * This can control the default ground, skybox and image processing setup of your scene.
  140189. */
  140190. export interface IEnvironmentHelperOptions {
  140191. /**
  140192. * Specifies whether or not to create a ground.
  140193. * True by default.
  140194. */
  140195. createGround: boolean;
  140196. /**
  140197. * Specifies the ground size.
  140198. * 15 by default.
  140199. */
  140200. groundSize: number;
  140201. /**
  140202. * The texture used on the ground for the main color.
  140203. * Comes from the BabylonJS CDN by default.
  140204. *
  140205. * Remarks: Can be either a texture or a url.
  140206. */
  140207. groundTexture: string | BaseTexture;
  140208. /**
  140209. * The color mixed in the ground texture by default.
  140210. * BabylonJS clearColor by default.
  140211. */
  140212. groundColor: Color3;
  140213. /**
  140214. * Specifies the ground opacity.
  140215. * 1 by default.
  140216. */
  140217. groundOpacity: number;
  140218. /**
  140219. * Enables the ground to receive shadows.
  140220. * True by default.
  140221. */
  140222. enableGroundShadow: boolean;
  140223. /**
  140224. * Helps preventing the shadow to be fully black on the ground.
  140225. * 0.5 by default.
  140226. */
  140227. groundShadowLevel: number;
  140228. /**
  140229. * Creates a mirror texture attach to the ground.
  140230. * false by default.
  140231. */
  140232. enableGroundMirror: boolean;
  140233. /**
  140234. * Specifies the ground mirror size ratio.
  140235. * 0.3 by default as the default kernel is 64.
  140236. */
  140237. groundMirrorSizeRatio: number;
  140238. /**
  140239. * Specifies the ground mirror blur kernel size.
  140240. * 64 by default.
  140241. */
  140242. groundMirrorBlurKernel: number;
  140243. /**
  140244. * Specifies the ground mirror visibility amount.
  140245. * 1 by default
  140246. */
  140247. groundMirrorAmount: number;
  140248. /**
  140249. * Specifies the ground mirror reflectance weight.
  140250. * This uses the standard weight of the background material to setup the fresnel effect
  140251. * of the mirror.
  140252. * 1 by default.
  140253. */
  140254. groundMirrorFresnelWeight: number;
  140255. /**
  140256. * Specifies the ground mirror Falloff distance.
  140257. * This can helps reducing the size of the reflection.
  140258. * 0 by Default.
  140259. */
  140260. groundMirrorFallOffDistance: number;
  140261. /**
  140262. * Specifies the ground mirror texture type.
  140263. * Unsigned Int by Default.
  140264. */
  140265. groundMirrorTextureType: number;
  140266. /**
  140267. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  140268. * the shown objects.
  140269. */
  140270. groundYBias: number;
  140271. /**
  140272. * Specifies whether or not to create a skybox.
  140273. * True by default.
  140274. */
  140275. createSkybox: boolean;
  140276. /**
  140277. * Specifies the skybox size.
  140278. * 20 by default.
  140279. */
  140280. skyboxSize: number;
  140281. /**
  140282. * The texture used on the skybox for the main color.
  140283. * Comes from the BabylonJS CDN by default.
  140284. *
  140285. * Remarks: Can be either a texture or a url.
  140286. */
  140287. skyboxTexture: string | BaseTexture;
  140288. /**
  140289. * The color mixed in the skybox texture by default.
  140290. * BabylonJS clearColor by default.
  140291. */
  140292. skyboxColor: Color3;
  140293. /**
  140294. * The background rotation around the Y axis of the scene.
  140295. * This helps aligning the key lights of your scene with the background.
  140296. * 0 by default.
  140297. */
  140298. backgroundYRotation: number;
  140299. /**
  140300. * Compute automatically the size of the elements to best fit with the scene.
  140301. */
  140302. sizeAuto: boolean;
  140303. /**
  140304. * Default position of the rootMesh if autoSize is not true.
  140305. */
  140306. rootPosition: Vector3;
  140307. /**
  140308. * Sets up the image processing in the scene.
  140309. * true by default.
  140310. */
  140311. setupImageProcessing: boolean;
  140312. /**
  140313. * The texture used as your environment texture in the scene.
  140314. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  140315. *
  140316. * Remarks: Can be either a texture or a url.
  140317. */
  140318. environmentTexture: string | BaseTexture;
  140319. /**
  140320. * The value of the exposure to apply to the scene.
  140321. * 0.6 by default if setupImageProcessing is true.
  140322. */
  140323. cameraExposure: number;
  140324. /**
  140325. * The value of the contrast to apply to the scene.
  140326. * 1.6 by default if setupImageProcessing is true.
  140327. */
  140328. cameraContrast: number;
  140329. /**
  140330. * Specifies whether or not tonemapping should be enabled in the scene.
  140331. * true by default if setupImageProcessing is true.
  140332. */
  140333. toneMappingEnabled: boolean;
  140334. }
  140335. /**
  140336. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  140337. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  140338. * It also helps with the default setup of your imageProcessing configuration.
  140339. */
  140340. export class EnvironmentHelper {
  140341. /**
  140342. * Default ground texture URL.
  140343. */
  140344. private static _groundTextureCDNUrl;
  140345. /**
  140346. * Default skybox texture URL.
  140347. */
  140348. private static _skyboxTextureCDNUrl;
  140349. /**
  140350. * Default environment texture URL.
  140351. */
  140352. private static _environmentTextureCDNUrl;
  140353. /**
  140354. * Creates the default options for the helper.
  140355. */
  140356. private static _getDefaultOptions;
  140357. private _rootMesh;
  140358. /**
  140359. * Gets the root mesh created by the helper.
  140360. */
  140361. get rootMesh(): Mesh;
  140362. private _skybox;
  140363. /**
  140364. * Gets the skybox created by the helper.
  140365. */
  140366. get skybox(): Nullable<Mesh>;
  140367. private _skyboxTexture;
  140368. /**
  140369. * Gets the skybox texture created by the helper.
  140370. */
  140371. get skyboxTexture(): Nullable<BaseTexture>;
  140372. private _skyboxMaterial;
  140373. /**
  140374. * Gets the skybox material created by the helper.
  140375. */
  140376. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  140377. private _ground;
  140378. /**
  140379. * Gets the ground mesh created by the helper.
  140380. */
  140381. get ground(): Nullable<Mesh>;
  140382. private _groundTexture;
  140383. /**
  140384. * Gets the ground texture created by the helper.
  140385. */
  140386. get groundTexture(): Nullable<BaseTexture>;
  140387. private _groundMirror;
  140388. /**
  140389. * Gets the ground mirror created by the helper.
  140390. */
  140391. get groundMirror(): Nullable<MirrorTexture>;
  140392. /**
  140393. * Gets the ground mirror render list to helps pushing the meshes
  140394. * you wish in the ground reflection.
  140395. */
  140396. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  140397. private _groundMaterial;
  140398. /**
  140399. * Gets the ground material created by the helper.
  140400. */
  140401. get groundMaterial(): Nullable<BackgroundMaterial>;
  140402. /**
  140403. * Stores the creation options.
  140404. */
  140405. private readonly _scene;
  140406. private _options;
  140407. /**
  140408. * This observable will be notified with any error during the creation of the environment,
  140409. * mainly texture creation errors.
  140410. */
  140411. onErrorObservable: Observable<{
  140412. message?: string;
  140413. exception?: any;
  140414. }>;
  140415. /**
  140416. * constructor
  140417. * @param options Defines the options we want to customize the helper
  140418. * @param scene The scene to add the material to
  140419. */
  140420. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  140421. /**
  140422. * Updates the background according to the new options
  140423. * @param options
  140424. */
  140425. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  140426. /**
  140427. * Sets the primary color of all the available elements.
  140428. * @param color the main color to affect to the ground and the background
  140429. */
  140430. setMainColor(color: Color3): void;
  140431. /**
  140432. * Setup the image processing according to the specified options.
  140433. */
  140434. private _setupImageProcessing;
  140435. /**
  140436. * Setup the environment texture according to the specified options.
  140437. */
  140438. private _setupEnvironmentTexture;
  140439. /**
  140440. * Setup the background according to the specified options.
  140441. */
  140442. private _setupBackground;
  140443. /**
  140444. * Get the scene sizes according to the setup.
  140445. */
  140446. private _getSceneSize;
  140447. /**
  140448. * Setup the ground according to the specified options.
  140449. */
  140450. private _setupGround;
  140451. /**
  140452. * Setup the ground material according to the specified options.
  140453. */
  140454. private _setupGroundMaterial;
  140455. /**
  140456. * Setup the ground diffuse texture according to the specified options.
  140457. */
  140458. private _setupGroundDiffuseTexture;
  140459. /**
  140460. * Setup the ground mirror texture according to the specified options.
  140461. */
  140462. private _setupGroundMirrorTexture;
  140463. /**
  140464. * Setup the ground to receive the mirror texture.
  140465. */
  140466. private _setupMirrorInGroundMaterial;
  140467. /**
  140468. * Setup the skybox according to the specified options.
  140469. */
  140470. private _setupSkybox;
  140471. /**
  140472. * Setup the skybox material according to the specified options.
  140473. */
  140474. private _setupSkyboxMaterial;
  140475. /**
  140476. * Setup the skybox reflection texture according to the specified options.
  140477. */
  140478. private _setupSkyboxReflectionTexture;
  140479. private _errorHandler;
  140480. /**
  140481. * Dispose all the elements created by the Helper.
  140482. */
  140483. dispose(): void;
  140484. }
  140485. }
  140486. declare module BABYLON {
  140487. /**
  140488. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  140489. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  140490. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140491. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140492. */
  140493. export abstract class TextureDome<T extends Texture> extends TransformNode {
  140494. protected onError: Nullable<(message?: string, exception?: any) => void>;
  140495. /**
  140496. * Define the source as a Monoscopic panoramic 360/180.
  140497. */
  140498. static readonly MODE_MONOSCOPIC: number;
  140499. /**
  140500. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  140501. */
  140502. static readonly MODE_TOPBOTTOM: number;
  140503. /**
  140504. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  140505. */
  140506. static readonly MODE_SIDEBYSIDE: number;
  140507. private _halfDome;
  140508. private _crossEye;
  140509. protected _useDirectMapping: boolean;
  140510. /**
  140511. * The texture being displayed on the sphere
  140512. */
  140513. protected _texture: T;
  140514. /**
  140515. * Gets the texture being displayed on the sphere
  140516. */
  140517. get texture(): T;
  140518. /**
  140519. * Sets the texture being displayed on the sphere
  140520. */
  140521. set texture(newTexture: T);
  140522. /**
  140523. * The skybox material
  140524. */
  140525. protected _material: BackgroundMaterial;
  140526. /**
  140527. * The surface used for the dome
  140528. */
  140529. protected _mesh: Mesh;
  140530. /**
  140531. * Gets the mesh used for the dome.
  140532. */
  140533. get mesh(): Mesh;
  140534. /**
  140535. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  140536. */
  140537. private _halfDomeMask;
  140538. /**
  140539. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  140540. * Also see the options.resolution property.
  140541. */
  140542. get fovMultiplier(): number;
  140543. set fovMultiplier(value: number);
  140544. protected _textureMode: number;
  140545. /**
  140546. * Gets or set the current texture mode for the texture. It can be:
  140547. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140548. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140549. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140550. */
  140551. get textureMode(): number;
  140552. /**
  140553. * Sets the current texture mode for the texture. It can be:
  140554. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140555. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140556. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140557. */
  140558. set textureMode(value: number);
  140559. /**
  140560. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  140561. */
  140562. get halfDome(): boolean;
  140563. /**
  140564. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  140565. */
  140566. set halfDome(enabled: boolean);
  140567. /**
  140568. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  140569. */
  140570. set crossEye(enabled: boolean);
  140571. /**
  140572. * Is it a cross-eye texture?
  140573. */
  140574. get crossEye(): boolean;
  140575. /**
  140576. * The background material of this dome.
  140577. */
  140578. get material(): BackgroundMaterial;
  140579. /**
  140580. * Oberserver used in Stereoscopic VR Mode.
  140581. */
  140582. private _onBeforeCameraRenderObserver;
  140583. /**
  140584. * Observable raised when an error occured while loading the 360 image
  140585. */
  140586. onLoadErrorObservable: Observable<string>;
  140587. /**
  140588. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  140589. * @param name Element's name, child elements will append suffixes for their own names.
  140590. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  140591. * @param options An object containing optional or exposed sub element properties
  140592. */
  140593. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  140594. resolution?: number;
  140595. clickToPlay?: boolean;
  140596. autoPlay?: boolean;
  140597. loop?: boolean;
  140598. size?: number;
  140599. poster?: string;
  140600. faceForward?: boolean;
  140601. useDirectMapping?: boolean;
  140602. halfDomeMode?: boolean;
  140603. crossEyeMode?: boolean;
  140604. generateMipMaps?: boolean;
  140605. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  140606. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  140607. protected _changeTextureMode(value: number): void;
  140608. /**
  140609. * Releases resources associated with this node.
  140610. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  140611. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  140612. */
  140613. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  140614. }
  140615. }
  140616. declare module BABYLON {
  140617. /**
  140618. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  140619. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  140620. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  140621. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140622. */
  140623. export class PhotoDome extends TextureDome<Texture> {
  140624. /**
  140625. * Define the image as a Monoscopic panoramic 360 image.
  140626. */
  140627. static readonly MODE_MONOSCOPIC: number;
  140628. /**
  140629. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  140630. */
  140631. static readonly MODE_TOPBOTTOM: number;
  140632. /**
  140633. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  140634. */
  140635. static readonly MODE_SIDEBYSIDE: number;
  140636. /**
  140637. * Gets or sets the texture being displayed on the sphere
  140638. */
  140639. get photoTexture(): Texture;
  140640. /**
  140641. * sets the texture being displayed on the sphere
  140642. */
  140643. set photoTexture(value: Texture);
  140644. /**
  140645. * Gets the current video mode for the video. It can be:
  140646. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140647. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140648. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140649. */
  140650. get imageMode(): number;
  140651. /**
  140652. * Sets the current video mode for the video. It can be:
  140653. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  140654. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  140655. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  140656. */
  140657. set imageMode(value: number);
  140658. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  140659. }
  140660. }
  140661. declare module BABYLON {
  140662. /**
  140663. * Direct draw surface info
  140664. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  140665. */
  140666. export interface DDSInfo {
  140667. /**
  140668. * Width of the texture
  140669. */
  140670. width: number;
  140671. /**
  140672. * Width of the texture
  140673. */
  140674. height: number;
  140675. /**
  140676. * Number of Mipmaps for the texture
  140677. * @see https://en.wikipedia.org/wiki/Mipmap
  140678. */
  140679. mipmapCount: number;
  140680. /**
  140681. * If the textures format is a known fourCC format
  140682. * @see https://www.fourcc.org/
  140683. */
  140684. isFourCC: boolean;
  140685. /**
  140686. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  140687. */
  140688. isRGB: boolean;
  140689. /**
  140690. * If the texture is a lumincance format
  140691. */
  140692. isLuminance: boolean;
  140693. /**
  140694. * If this is a cube texture
  140695. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  140696. */
  140697. isCube: boolean;
  140698. /**
  140699. * If the texture is a compressed format eg. FOURCC_DXT1
  140700. */
  140701. isCompressed: boolean;
  140702. /**
  140703. * The dxgiFormat of the texture
  140704. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  140705. */
  140706. dxgiFormat: number;
  140707. /**
  140708. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  140709. */
  140710. textureType: number;
  140711. /**
  140712. * Sphericle polynomial created for the dds texture
  140713. */
  140714. sphericalPolynomial?: SphericalPolynomial;
  140715. }
  140716. /**
  140717. * Class used to provide DDS decompression tools
  140718. */
  140719. export class DDSTools {
  140720. /**
  140721. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  140722. */
  140723. static StoreLODInAlphaChannel: boolean;
  140724. /**
  140725. * Gets DDS information from an array buffer
  140726. * @param data defines the array buffer view to read data from
  140727. * @returns the DDS information
  140728. */
  140729. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  140730. private static _FloatView;
  140731. private static _Int32View;
  140732. private static _ToHalfFloat;
  140733. private static _FromHalfFloat;
  140734. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  140735. private static _GetHalfFloatRGBAArrayBuffer;
  140736. private static _GetFloatRGBAArrayBuffer;
  140737. private static _GetFloatAsUIntRGBAArrayBuffer;
  140738. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  140739. private static _GetRGBAArrayBuffer;
  140740. private static _ExtractLongWordOrder;
  140741. private static _GetRGBArrayBuffer;
  140742. private static _GetLuminanceArrayBuffer;
  140743. /**
  140744. * Uploads DDS Levels to a Babylon Texture
  140745. * @hidden
  140746. */
  140747. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  140748. }
  140749. interface ThinEngine {
  140750. /**
  140751. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  140752. * @param rootUrl defines the url where the file to load is located
  140753. * @param scene defines the current scene
  140754. * @param lodScale defines scale to apply to the mip map selection
  140755. * @param lodOffset defines offset to apply to the mip map selection
  140756. * @param onLoad defines an optional callback raised when the texture is loaded
  140757. * @param onError defines an optional callback raised if there is an issue to load the texture
  140758. * @param format defines the format of the data
  140759. * @param forcedExtension defines the extension to use to pick the right loader
  140760. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  140761. * @returns the cube texture as an InternalTexture
  140762. */
  140763. 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;
  140764. }
  140765. }
  140766. declare module BABYLON {
  140767. /**
  140768. * Implementation of the DDS Texture Loader.
  140769. * @hidden
  140770. */
  140771. export class _DDSTextureLoader implements IInternalTextureLoader {
  140772. /**
  140773. * Defines wether the loader supports cascade loading the different faces.
  140774. */
  140775. readonly supportCascades: boolean;
  140776. /**
  140777. * This returns if the loader support the current file information.
  140778. * @param extension defines the file extension of the file being loaded
  140779. * @returns true if the loader can load the specified file
  140780. */
  140781. canLoad(extension: string): boolean;
  140782. /**
  140783. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140784. * @param data contains the texture data
  140785. * @param texture defines the BabylonJS internal texture
  140786. * @param createPolynomials will be true if polynomials have been requested
  140787. * @param onLoad defines the callback to trigger once the texture is ready
  140788. * @param onError defines the callback to trigger in case of error
  140789. */
  140790. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140791. /**
  140792. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140793. * @param data contains the texture data
  140794. * @param texture defines the BabylonJS internal texture
  140795. * @param callback defines the method to call once ready to upload
  140796. */
  140797. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140798. }
  140799. }
  140800. declare module BABYLON {
  140801. /**
  140802. * Implementation of the ENV Texture Loader.
  140803. * @hidden
  140804. */
  140805. export class _ENVTextureLoader implements IInternalTextureLoader {
  140806. /**
  140807. * Defines wether the loader supports cascade loading the different faces.
  140808. */
  140809. readonly supportCascades: boolean;
  140810. /**
  140811. * This returns if the loader support the current file information.
  140812. * @param extension defines the file extension of the file being loaded
  140813. * @returns true if the loader can load the specified file
  140814. */
  140815. canLoad(extension: string): boolean;
  140816. /**
  140817. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140818. * @param data contains the texture data
  140819. * @param texture defines the BabylonJS internal texture
  140820. * @param createPolynomials will be true if polynomials have been requested
  140821. * @param onLoad defines the callback to trigger once the texture is ready
  140822. * @param onError defines the callback to trigger in case of error
  140823. */
  140824. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140825. /**
  140826. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140827. * @param data contains the texture data
  140828. * @param texture defines the BabylonJS internal texture
  140829. * @param callback defines the method to call once ready to upload
  140830. */
  140831. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  140832. }
  140833. }
  140834. declare module BABYLON {
  140835. /**
  140836. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  140837. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  140838. */
  140839. export class KhronosTextureContainer {
  140840. /** contents of the KTX container file */
  140841. data: ArrayBufferView;
  140842. private static HEADER_LEN;
  140843. private static COMPRESSED_2D;
  140844. private static COMPRESSED_3D;
  140845. private static TEX_2D;
  140846. private static TEX_3D;
  140847. /**
  140848. * Gets the openGL type
  140849. */
  140850. glType: number;
  140851. /**
  140852. * Gets the openGL type size
  140853. */
  140854. glTypeSize: number;
  140855. /**
  140856. * Gets the openGL format
  140857. */
  140858. glFormat: number;
  140859. /**
  140860. * Gets the openGL internal format
  140861. */
  140862. glInternalFormat: number;
  140863. /**
  140864. * Gets the base internal format
  140865. */
  140866. glBaseInternalFormat: number;
  140867. /**
  140868. * Gets image width in pixel
  140869. */
  140870. pixelWidth: number;
  140871. /**
  140872. * Gets image height in pixel
  140873. */
  140874. pixelHeight: number;
  140875. /**
  140876. * Gets image depth in pixels
  140877. */
  140878. pixelDepth: number;
  140879. /**
  140880. * Gets the number of array elements
  140881. */
  140882. numberOfArrayElements: number;
  140883. /**
  140884. * Gets the number of faces
  140885. */
  140886. numberOfFaces: number;
  140887. /**
  140888. * Gets the number of mipmap levels
  140889. */
  140890. numberOfMipmapLevels: number;
  140891. /**
  140892. * Gets the bytes of key value data
  140893. */
  140894. bytesOfKeyValueData: number;
  140895. /**
  140896. * Gets the load type
  140897. */
  140898. loadType: number;
  140899. /**
  140900. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  140901. */
  140902. isInvalid: boolean;
  140903. /**
  140904. * Creates a new KhronosTextureContainer
  140905. * @param data contents of the KTX container file
  140906. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  140907. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  140908. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  140909. */
  140910. constructor(
  140911. /** contents of the KTX container file */
  140912. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  140913. /**
  140914. * Uploads KTX content to a Babylon Texture.
  140915. * It is assumed that the texture has already been created & is currently bound
  140916. * @hidden
  140917. */
  140918. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  140919. private _upload2DCompressedLevels;
  140920. /**
  140921. * Checks if the given data starts with a KTX file identifier.
  140922. * @param data the data to check
  140923. * @returns true if the data is a KTX file or false otherwise
  140924. */
  140925. static IsValid(data: ArrayBufferView): boolean;
  140926. }
  140927. }
  140928. declare module BABYLON {
  140929. /**
  140930. * Helper class to push actions to a pool of workers.
  140931. */
  140932. export class WorkerPool implements IDisposable {
  140933. private _workerInfos;
  140934. private _pendingActions;
  140935. /**
  140936. * Constructor
  140937. * @param workers Array of workers to use for actions
  140938. */
  140939. constructor(workers: Array<Worker>);
  140940. /**
  140941. * Terminates all workers and clears any pending actions.
  140942. */
  140943. dispose(): void;
  140944. /**
  140945. * Pushes an action to the worker pool. If all the workers are active, the action will be
  140946. * pended until a worker has completed its action.
  140947. * @param action The action to perform. Call onComplete when the action is complete.
  140948. */
  140949. push(action: (worker: Worker, onComplete: () => void) => void): void;
  140950. private _execute;
  140951. }
  140952. }
  140953. declare module BABYLON {
  140954. /**
  140955. * Class for loading KTX2 files
  140956. */
  140957. export class KhronosTextureContainer2 {
  140958. private static _WorkerPoolPromise?;
  140959. private static _Initialized;
  140960. private static _Ktx2Decoder;
  140961. /**
  140962. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140963. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140964. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140965. * Urls you can change:
  140966. * URLConfig.jsDecoderModule
  140967. * URLConfig.wasmUASTCToASTC
  140968. * URLConfig.wasmUASTCToBC7
  140969. * URLConfig.wasmUASTCToRGBA_UNORM
  140970. * URLConfig.wasmUASTCToRGBA_SRGB
  140971. * URLConfig.jsMSCTranscoder
  140972. * URLConfig.wasmMSCTranscoder
  140973. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140974. */
  140975. static URLConfig: {
  140976. jsDecoderModule: string;
  140977. wasmUASTCToASTC: null;
  140978. wasmUASTCToBC7: null;
  140979. wasmUASTCToRGBA_UNORM: null;
  140980. wasmUASTCToRGBA_SRGB: null;
  140981. jsMSCTranscoder: null;
  140982. wasmMSCTranscoder: null;
  140983. };
  140984. /**
  140985. * Default number of workers used to handle data decoding
  140986. */
  140987. static DefaultNumWorkers: number;
  140988. private static GetDefaultNumWorkers;
  140989. private _engine;
  140990. private static _CreateWorkerPool;
  140991. /**
  140992. * Constructor
  140993. * @param engine The engine to use
  140994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140995. */
  140996. constructor(engine: ThinEngine, numWorkers?: number);
  140997. /** @hidden */
  140998. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140999. /**
  141000. * Stop all async operations and release resources.
  141001. */
  141002. dispose(): void;
  141003. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  141004. /**
  141005. * Checks if the given data starts with a KTX2 file identifier.
  141006. * @param data the data to check
  141007. * @returns true if the data is a KTX2 file or false otherwise
  141008. */
  141009. static IsValid(data: ArrayBufferView): boolean;
  141010. }
  141011. }
  141012. declare module BABYLON {
  141013. /**
  141014. * Implementation of the KTX Texture Loader.
  141015. * @hidden
  141016. */
  141017. export class _KTXTextureLoader implements IInternalTextureLoader {
  141018. /**
  141019. * Defines wether the loader supports cascade loading the different faces.
  141020. */
  141021. readonly supportCascades: boolean;
  141022. /**
  141023. * This returns if the loader support the current file information.
  141024. * @param extension defines the file extension of the file being loaded
  141025. * @param mimeType defines the optional mime type of the file being loaded
  141026. * @returns true if the loader can load the specified file
  141027. */
  141028. canLoad(extension: string, mimeType?: string): boolean;
  141029. /**
  141030. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  141031. * @param data contains the texture data
  141032. * @param texture defines the BabylonJS internal texture
  141033. * @param createPolynomials will be true if polynomials have been requested
  141034. * @param onLoad defines the callback to trigger once the texture is ready
  141035. * @param onError defines the callback to trigger in case of error
  141036. */
  141037. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  141038. /**
  141039. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  141040. * @param data contains the texture data
  141041. * @param texture defines the BabylonJS internal texture
  141042. * @param callback defines the method to call once ready to upload
  141043. */
  141044. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  141045. }
  141046. }
  141047. declare module BABYLON {
  141048. /** @hidden */
  141049. export var _forceSceneHelpersToBundle: boolean;
  141050. interface Scene {
  141051. /**
  141052. * Creates a default light for the scene.
  141053. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  141054. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  141055. */
  141056. createDefaultLight(replace?: boolean): void;
  141057. /**
  141058. * Creates a default camera for the scene.
  141059. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  141060. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  141061. * @param replace has default false, when true replaces the active camera in the scene
  141062. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  141063. */
  141064. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  141065. /**
  141066. * Creates a default camera and a default light.
  141067. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  141068. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  141069. * @param replace has the default false, when true replaces the active camera/light in the scene
  141070. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  141071. */
  141072. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  141073. /**
  141074. * Creates a new sky box
  141075. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  141076. * @param environmentTexture defines the texture to use as environment texture
  141077. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  141078. * @param scale defines the overall scale of the skybox
  141079. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  141080. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  141081. * @returns a new mesh holding the sky box
  141082. */
  141083. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  141084. /**
  141085. * Creates a new environment
  141086. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  141087. * @param options defines the options you can use to configure the environment
  141088. * @returns the new EnvironmentHelper
  141089. */
  141090. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  141091. /**
  141092. * Creates a new VREXperienceHelper
  141093. * @see https://doc.babylonjs.com/how_to/webvr_helper
  141094. * @param webVROptions defines the options used to create the new VREXperienceHelper
  141095. * @returns a new VREXperienceHelper
  141096. */
  141097. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  141098. /**
  141099. * Creates a new WebXRDefaultExperience
  141100. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  141101. * @param options experience options
  141102. * @returns a promise for a new WebXRDefaultExperience
  141103. */
  141104. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  141105. }
  141106. }
  141107. declare module BABYLON {
  141108. /**
  141109. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  141110. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  141111. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  141112. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  141113. */
  141114. export class VideoDome extends TextureDome<VideoTexture> {
  141115. /**
  141116. * Define the video source as a Monoscopic panoramic 360 video.
  141117. */
  141118. static readonly MODE_MONOSCOPIC: number;
  141119. /**
  141120. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  141121. */
  141122. static readonly MODE_TOPBOTTOM: number;
  141123. /**
  141124. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  141125. */
  141126. static readonly MODE_SIDEBYSIDE: number;
  141127. /**
  141128. * Get the video texture associated with this video dome
  141129. */
  141130. get videoTexture(): VideoTexture;
  141131. /**
  141132. * Get the video mode of this dome
  141133. */
  141134. get videoMode(): number;
  141135. /**
  141136. * Set the video mode of this dome.
  141137. * @see textureMode
  141138. */
  141139. set videoMode(value: number);
  141140. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  141141. }
  141142. }
  141143. declare module BABYLON {
  141144. /**
  141145. * This class can be used to get instrumentation data from a Babylon engine
  141146. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141147. */
  141148. export class EngineInstrumentation implements IDisposable {
  141149. /**
  141150. * Define the instrumented engine.
  141151. */
  141152. engine: Engine;
  141153. private _captureGPUFrameTime;
  141154. private _gpuFrameTimeToken;
  141155. private _gpuFrameTime;
  141156. private _captureShaderCompilationTime;
  141157. private _shaderCompilationTime;
  141158. private _onBeginFrameObserver;
  141159. private _onEndFrameObserver;
  141160. private _onBeforeShaderCompilationObserver;
  141161. private _onAfterShaderCompilationObserver;
  141162. /**
  141163. * Gets the perf counter used for GPU frame time
  141164. */
  141165. get gpuFrameTimeCounter(): PerfCounter;
  141166. /**
  141167. * Gets the GPU frame time capture status
  141168. */
  141169. get captureGPUFrameTime(): boolean;
  141170. /**
  141171. * Enable or disable the GPU frame time capture
  141172. */
  141173. set captureGPUFrameTime(value: boolean);
  141174. /**
  141175. * Gets the perf counter used for shader compilation time
  141176. */
  141177. get shaderCompilationTimeCounter(): PerfCounter;
  141178. /**
  141179. * Gets the shader compilation time capture status
  141180. */
  141181. get captureShaderCompilationTime(): boolean;
  141182. /**
  141183. * Enable or disable the shader compilation time capture
  141184. */
  141185. set captureShaderCompilationTime(value: boolean);
  141186. /**
  141187. * Instantiates a new engine instrumentation.
  141188. * This class can be used to get instrumentation data from a Babylon engine
  141189. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  141190. * @param engine Defines the engine to instrument
  141191. */
  141192. constructor(
  141193. /**
  141194. * Define the instrumented engine.
  141195. */
  141196. engine: Engine);
  141197. /**
  141198. * Dispose and release associated resources.
  141199. */
  141200. dispose(): void;
  141201. }
  141202. }
  141203. declare module BABYLON {
  141204. /**
  141205. * This class can be used to get instrumentation data from a Babylon engine
  141206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141207. */
  141208. export class SceneInstrumentation implements IDisposable {
  141209. /**
  141210. * Defines the scene to instrument
  141211. */
  141212. scene: Scene;
  141213. private _captureActiveMeshesEvaluationTime;
  141214. private _activeMeshesEvaluationTime;
  141215. private _captureRenderTargetsRenderTime;
  141216. private _renderTargetsRenderTime;
  141217. private _captureFrameTime;
  141218. private _frameTime;
  141219. private _captureRenderTime;
  141220. private _renderTime;
  141221. private _captureInterFrameTime;
  141222. private _interFrameTime;
  141223. private _captureParticlesRenderTime;
  141224. private _particlesRenderTime;
  141225. private _captureSpritesRenderTime;
  141226. private _spritesRenderTime;
  141227. private _capturePhysicsTime;
  141228. private _physicsTime;
  141229. private _captureAnimationsTime;
  141230. private _animationsTime;
  141231. private _captureCameraRenderTime;
  141232. private _cameraRenderTime;
  141233. private _onBeforeActiveMeshesEvaluationObserver;
  141234. private _onAfterActiveMeshesEvaluationObserver;
  141235. private _onBeforeRenderTargetsRenderObserver;
  141236. private _onAfterRenderTargetsRenderObserver;
  141237. private _onAfterRenderObserver;
  141238. private _onBeforeDrawPhaseObserver;
  141239. private _onAfterDrawPhaseObserver;
  141240. private _onBeforeAnimationsObserver;
  141241. private _onBeforeParticlesRenderingObserver;
  141242. private _onAfterParticlesRenderingObserver;
  141243. private _onBeforeSpritesRenderingObserver;
  141244. private _onAfterSpritesRenderingObserver;
  141245. private _onBeforePhysicsObserver;
  141246. private _onAfterPhysicsObserver;
  141247. private _onAfterAnimationsObserver;
  141248. private _onBeforeCameraRenderObserver;
  141249. private _onAfterCameraRenderObserver;
  141250. /**
  141251. * Gets the perf counter used for active meshes evaluation time
  141252. */
  141253. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  141254. /**
  141255. * Gets the active meshes evaluation time capture status
  141256. */
  141257. get captureActiveMeshesEvaluationTime(): boolean;
  141258. /**
  141259. * Enable or disable the active meshes evaluation time capture
  141260. */
  141261. set captureActiveMeshesEvaluationTime(value: boolean);
  141262. /**
  141263. * Gets the perf counter used for render targets render time
  141264. */
  141265. get renderTargetsRenderTimeCounter(): PerfCounter;
  141266. /**
  141267. * Gets the render targets render time capture status
  141268. */
  141269. get captureRenderTargetsRenderTime(): boolean;
  141270. /**
  141271. * Enable or disable the render targets render time capture
  141272. */
  141273. set captureRenderTargetsRenderTime(value: boolean);
  141274. /**
  141275. * Gets the perf counter used for particles render time
  141276. */
  141277. get particlesRenderTimeCounter(): PerfCounter;
  141278. /**
  141279. * Gets the particles render time capture status
  141280. */
  141281. get captureParticlesRenderTime(): boolean;
  141282. /**
  141283. * Enable or disable the particles render time capture
  141284. */
  141285. set captureParticlesRenderTime(value: boolean);
  141286. /**
  141287. * Gets the perf counter used for sprites render time
  141288. */
  141289. get spritesRenderTimeCounter(): PerfCounter;
  141290. /**
  141291. * Gets the sprites render time capture status
  141292. */
  141293. get captureSpritesRenderTime(): boolean;
  141294. /**
  141295. * Enable or disable the sprites render time capture
  141296. */
  141297. set captureSpritesRenderTime(value: boolean);
  141298. /**
  141299. * Gets the perf counter used for physics time
  141300. */
  141301. get physicsTimeCounter(): PerfCounter;
  141302. /**
  141303. * Gets the physics time capture status
  141304. */
  141305. get capturePhysicsTime(): boolean;
  141306. /**
  141307. * Enable or disable the physics time capture
  141308. */
  141309. set capturePhysicsTime(value: boolean);
  141310. /**
  141311. * Gets the perf counter used for animations time
  141312. */
  141313. get animationsTimeCounter(): PerfCounter;
  141314. /**
  141315. * Gets the animations time capture status
  141316. */
  141317. get captureAnimationsTime(): boolean;
  141318. /**
  141319. * Enable or disable the animations time capture
  141320. */
  141321. set captureAnimationsTime(value: boolean);
  141322. /**
  141323. * Gets the perf counter used for frame time capture
  141324. */
  141325. get frameTimeCounter(): PerfCounter;
  141326. /**
  141327. * Gets the frame time capture status
  141328. */
  141329. get captureFrameTime(): boolean;
  141330. /**
  141331. * Enable or disable the frame time capture
  141332. */
  141333. set captureFrameTime(value: boolean);
  141334. /**
  141335. * Gets the perf counter used for inter-frames time capture
  141336. */
  141337. get interFrameTimeCounter(): PerfCounter;
  141338. /**
  141339. * Gets the inter-frames time capture status
  141340. */
  141341. get captureInterFrameTime(): boolean;
  141342. /**
  141343. * Enable or disable the inter-frames time capture
  141344. */
  141345. set captureInterFrameTime(value: boolean);
  141346. /**
  141347. * Gets the perf counter used for render time capture
  141348. */
  141349. get renderTimeCounter(): PerfCounter;
  141350. /**
  141351. * Gets the render time capture status
  141352. */
  141353. get captureRenderTime(): boolean;
  141354. /**
  141355. * Enable or disable the render time capture
  141356. */
  141357. set captureRenderTime(value: boolean);
  141358. /**
  141359. * Gets the perf counter used for camera render time capture
  141360. */
  141361. get cameraRenderTimeCounter(): PerfCounter;
  141362. /**
  141363. * Gets the camera render time capture status
  141364. */
  141365. get captureCameraRenderTime(): boolean;
  141366. /**
  141367. * Enable or disable the camera render time capture
  141368. */
  141369. set captureCameraRenderTime(value: boolean);
  141370. /**
  141371. * Gets the perf counter used for draw calls
  141372. */
  141373. get drawCallsCounter(): PerfCounter;
  141374. /**
  141375. * Instantiates a new scene instrumentation.
  141376. * This class can be used to get instrumentation data from a Babylon engine
  141377. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  141378. * @param scene Defines the scene to instrument
  141379. */
  141380. constructor(
  141381. /**
  141382. * Defines the scene to instrument
  141383. */
  141384. scene: Scene);
  141385. /**
  141386. * Dispose and release associated resources.
  141387. */
  141388. dispose(): void;
  141389. }
  141390. }
  141391. declare module BABYLON {
  141392. /** @hidden */
  141393. export var glowMapGenerationPixelShader: {
  141394. name: string;
  141395. shader: string;
  141396. };
  141397. }
  141398. declare module BABYLON {
  141399. /** @hidden */
  141400. export var glowMapGenerationVertexShader: {
  141401. name: string;
  141402. shader: string;
  141403. };
  141404. }
  141405. declare module BABYLON {
  141406. /**
  141407. * Effect layer options. This helps customizing the behaviour
  141408. * of the effect layer.
  141409. */
  141410. export interface IEffectLayerOptions {
  141411. /**
  141412. * Multiplication factor apply to the canvas size to compute the render target size
  141413. * used to generated the objects (the smaller the faster).
  141414. */
  141415. mainTextureRatio: number;
  141416. /**
  141417. * Enforces a fixed size texture to ensure effect stability across devices.
  141418. */
  141419. mainTextureFixedSize?: number;
  141420. /**
  141421. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  141422. */
  141423. alphaBlendingMode: number;
  141424. /**
  141425. * The camera attached to the layer.
  141426. */
  141427. camera: Nullable<Camera>;
  141428. /**
  141429. * The rendering group to draw the layer in.
  141430. */
  141431. renderingGroupId: number;
  141432. }
  141433. /**
  141434. * The effect layer Helps adding post process effect blended with the main pass.
  141435. *
  141436. * This can be for instance use to generate glow or higlight effects on the scene.
  141437. *
  141438. * The effect layer class can not be used directly and is intented to inherited from to be
  141439. * customized per effects.
  141440. */
  141441. export abstract class EffectLayer {
  141442. private _vertexBuffers;
  141443. private _indexBuffer;
  141444. private _cachedDefines;
  141445. private _effectLayerMapGenerationEffect;
  141446. private _effectLayerOptions;
  141447. private _mergeEffect;
  141448. protected _scene: Scene;
  141449. protected _engine: Engine;
  141450. protected _maxSize: number;
  141451. protected _mainTextureDesiredSize: ISize;
  141452. protected _mainTexture: RenderTargetTexture;
  141453. protected _shouldRender: boolean;
  141454. protected _postProcesses: PostProcess[];
  141455. protected _textures: BaseTexture[];
  141456. protected _emissiveTextureAndColor: {
  141457. texture: Nullable<BaseTexture>;
  141458. color: Color4;
  141459. };
  141460. /**
  141461. * The name of the layer
  141462. */
  141463. name: string;
  141464. /**
  141465. * The clear color of the texture used to generate the glow map.
  141466. */
  141467. neutralColor: Color4;
  141468. /**
  141469. * Specifies whether the highlight layer is enabled or not.
  141470. */
  141471. isEnabled: boolean;
  141472. /**
  141473. * Gets the camera attached to the layer.
  141474. */
  141475. get camera(): Nullable<Camera>;
  141476. /**
  141477. * Gets the rendering group id the layer should render in.
  141478. */
  141479. get renderingGroupId(): number;
  141480. set renderingGroupId(renderingGroupId: number);
  141481. /**
  141482. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  141483. */
  141484. disableBoundingBoxesFromEffectLayer: boolean;
  141485. /**
  141486. * An event triggered when the effect layer has been disposed.
  141487. */
  141488. onDisposeObservable: Observable<EffectLayer>;
  141489. /**
  141490. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  141491. */
  141492. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  141493. /**
  141494. * An event triggered when the generated texture is being merged in the scene.
  141495. */
  141496. onBeforeComposeObservable: Observable<EffectLayer>;
  141497. /**
  141498. * An event triggered when the mesh is rendered into the effect render target.
  141499. */
  141500. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  141501. /**
  141502. * An event triggered after the mesh has been rendered into the effect render target.
  141503. */
  141504. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  141505. /**
  141506. * An event triggered when the generated texture has been merged in the scene.
  141507. */
  141508. onAfterComposeObservable: Observable<EffectLayer>;
  141509. /**
  141510. * An event triggered when the efffect layer changes its size.
  141511. */
  141512. onSizeChangedObservable: Observable<EffectLayer>;
  141513. /** @hidden */
  141514. static _SceneComponentInitialization: (scene: Scene) => void;
  141515. /**
  141516. * Instantiates a new effect Layer and references it in the scene.
  141517. * @param name The name of the layer
  141518. * @param scene The scene to use the layer in
  141519. */
  141520. constructor(
  141521. /** The Friendly of the effect in the scene */
  141522. name: string, scene: Scene);
  141523. /**
  141524. * Get the effect name of the layer.
  141525. * @return The effect name
  141526. */
  141527. abstract getEffectName(): string;
  141528. /**
  141529. * Checks for the readiness of the element composing the layer.
  141530. * @param subMesh the mesh to check for
  141531. * @param useInstances specify whether or not to use instances to render the mesh
  141532. * @return true if ready otherwise, false
  141533. */
  141534. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141535. /**
  141536. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141537. * @returns true if the effect requires stencil during the main canvas render pass.
  141538. */
  141539. abstract needStencil(): boolean;
  141540. /**
  141541. * Create the merge effect. This is the shader use to blit the information back
  141542. * to the main canvas at the end of the scene rendering.
  141543. * @returns The effect containing the shader used to merge the effect on the main canvas
  141544. */
  141545. protected abstract _createMergeEffect(): Effect;
  141546. /**
  141547. * Creates the render target textures and post processes used in the effect layer.
  141548. */
  141549. protected abstract _createTextureAndPostProcesses(): void;
  141550. /**
  141551. * Implementation specific of rendering the generating effect on the main canvas.
  141552. * @param effect The effect used to render through
  141553. */
  141554. protected abstract _internalRender(effect: Effect): void;
  141555. /**
  141556. * Sets the required values for both the emissive texture and and the main color.
  141557. */
  141558. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141559. /**
  141560. * Free any resources and references associated to a mesh.
  141561. * Internal use
  141562. * @param mesh The mesh to free.
  141563. */
  141564. abstract _disposeMesh(mesh: Mesh): void;
  141565. /**
  141566. * Serializes this layer (Glow or Highlight for example)
  141567. * @returns a serialized layer object
  141568. */
  141569. abstract serialize?(): any;
  141570. /**
  141571. * Initializes the effect layer with the required options.
  141572. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  141573. */
  141574. protected _init(options: Partial<IEffectLayerOptions>): void;
  141575. /**
  141576. * Generates the index buffer of the full screen quad blending to the main canvas.
  141577. */
  141578. private _generateIndexBuffer;
  141579. /**
  141580. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  141581. */
  141582. private _generateVertexBuffer;
  141583. /**
  141584. * Sets the main texture desired size which is the closest power of two
  141585. * of the engine canvas size.
  141586. */
  141587. private _setMainTextureSize;
  141588. /**
  141589. * Creates the main texture for the effect layer.
  141590. */
  141591. protected _createMainTexture(): void;
  141592. /**
  141593. * Adds specific effects defines.
  141594. * @param defines The defines to add specifics to.
  141595. */
  141596. protected _addCustomEffectDefines(defines: string[]): void;
  141597. /**
  141598. * Checks for the readiness of the element composing the layer.
  141599. * @param subMesh the mesh to check for
  141600. * @param useInstances specify whether or not to use instances to render the mesh
  141601. * @param emissiveTexture the associated emissive texture used to generate the glow
  141602. * @return true if ready otherwise, false
  141603. */
  141604. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  141605. /**
  141606. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  141607. */
  141608. render(): void;
  141609. /**
  141610. * Determine if a given mesh will be used in the current effect.
  141611. * @param mesh mesh to test
  141612. * @returns true if the mesh will be used
  141613. */
  141614. hasMesh(mesh: AbstractMesh): boolean;
  141615. /**
  141616. * Returns true if the layer contains information to display, otherwise false.
  141617. * @returns true if the glow layer should be rendered
  141618. */
  141619. shouldRender(): boolean;
  141620. /**
  141621. * Returns true if the mesh should render, otherwise false.
  141622. * @param mesh The mesh to render
  141623. * @returns true if it should render otherwise false
  141624. */
  141625. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  141626. /**
  141627. * Returns true if the mesh can be rendered, otherwise false.
  141628. * @param mesh The mesh to render
  141629. * @param material The material used on the mesh
  141630. * @returns true if it can be rendered otherwise false
  141631. */
  141632. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141633. /**
  141634. * Returns true if the mesh should render, otherwise false.
  141635. * @param mesh The mesh to render
  141636. * @returns true if it should render otherwise false
  141637. */
  141638. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  141639. /**
  141640. * Renders the submesh passed in parameter to the generation map.
  141641. */
  141642. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  141643. /**
  141644. * Defines whether the current material of the mesh should be use to render the effect.
  141645. * @param mesh defines the current mesh to render
  141646. */
  141647. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141648. /**
  141649. * Rebuild the required buffers.
  141650. * @hidden Internal use only.
  141651. */
  141652. _rebuild(): void;
  141653. /**
  141654. * Dispose only the render target textures and post process.
  141655. */
  141656. private _disposeTextureAndPostProcesses;
  141657. /**
  141658. * Dispose the highlight layer and free resources.
  141659. */
  141660. dispose(): void;
  141661. /**
  141662. * Gets the class name of the effect layer
  141663. * @returns the string with the class name of the effect layer
  141664. */
  141665. getClassName(): string;
  141666. /**
  141667. * Creates an effect layer from parsed effect layer data
  141668. * @param parsedEffectLayer defines effect layer data
  141669. * @param scene defines the current scene
  141670. * @param rootUrl defines the root URL containing the effect layer information
  141671. * @returns a parsed effect Layer
  141672. */
  141673. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  141674. }
  141675. }
  141676. declare module BABYLON {
  141677. interface AbstractScene {
  141678. /**
  141679. * The list of effect layers (highlights/glow) added to the scene
  141680. * @see https://doc.babylonjs.com/how_to/highlight_layer
  141681. * @see https://doc.babylonjs.com/how_to/glow_layer
  141682. */
  141683. effectLayers: Array<EffectLayer>;
  141684. /**
  141685. * Removes the given effect layer from this scene.
  141686. * @param toRemove defines the effect layer to remove
  141687. * @returns the index of the removed effect layer
  141688. */
  141689. removeEffectLayer(toRemove: EffectLayer): number;
  141690. /**
  141691. * Adds the given effect layer to this scene
  141692. * @param newEffectLayer defines the effect layer to add
  141693. */
  141694. addEffectLayer(newEffectLayer: EffectLayer): void;
  141695. }
  141696. /**
  141697. * Defines the layer scene component responsible to manage any effect layers
  141698. * in a given scene.
  141699. */
  141700. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  141701. /**
  141702. * The component name helpfull to identify the component in the list of scene components.
  141703. */
  141704. readonly name: string;
  141705. /**
  141706. * The scene the component belongs to.
  141707. */
  141708. scene: Scene;
  141709. private _engine;
  141710. private _renderEffects;
  141711. private _needStencil;
  141712. private _previousStencilState;
  141713. /**
  141714. * Creates a new instance of the component for the given scene
  141715. * @param scene Defines the scene to register the component in
  141716. */
  141717. constructor(scene: Scene);
  141718. /**
  141719. * Registers the component in a given scene
  141720. */
  141721. register(): void;
  141722. /**
  141723. * Rebuilds the elements related to this component in case of
  141724. * context lost for instance.
  141725. */
  141726. rebuild(): void;
  141727. /**
  141728. * Serializes the component data to the specified json object
  141729. * @param serializationObject The object to serialize to
  141730. */
  141731. serialize(serializationObject: any): void;
  141732. /**
  141733. * Adds all the elements from the container to the scene
  141734. * @param container the container holding the elements
  141735. */
  141736. addFromContainer(container: AbstractScene): void;
  141737. /**
  141738. * Removes all the elements in the container from the scene
  141739. * @param container contains the elements to remove
  141740. * @param dispose if the removed element should be disposed (default: false)
  141741. */
  141742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141743. /**
  141744. * Disposes the component and the associated ressources.
  141745. */
  141746. dispose(): void;
  141747. private _isReadyForMesh;
  141748. private _renderMainTexture;
  141749. private _setStencil;
  141750. private _setStencilBack;
  141751. private _draw;
  141752. private _drawCamera;
  141753. private _drawRenderingGroup;
  141754. }
  141755. }
  141756. declare module BABYLON {
  141757. /** @hidden */
  141758. export var glowMapMergePixelShader: {
  141759. name: string;
  141760. shader: string;
  141761. };
  141762. }
  141763. declare module BABYLON {
  141764. /** @hidden */
  141765. export var glowMapMergeVertexShader: {
  141766. name: string;
  141767. shader: string;
  141768. };
  141769. }
  141770. declare module BABYLON {
  141771. interface AbstractScene {
  141772. /**
  141773. * Return a the first highlight layer of the scene with a given name.
  141774. * @param name The name of the highlight layer to look for.
  141775. * @return The highlight layer if found otherwise null.
  141776. */
  141777. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  141778. }
  141779. /**
  141780. * Glow layer options. This helps customizing the behaviour
  141781. * of the glow layer.
  141782. */
  141783. export interface IGlowLayerOptions {
  141784. /**
  141785. * Multiplication factor apply to the canvas size to compute the render target size
  141786. * used to generated the glowing objects (the smaller the faster).
  141787. */
  141788. mainTextureRatio: number;
  141789. /**
  141790. * Enforces a fixed size texture to ensure resize independant blur.
  141791. */
  141792. mainTextureFixedSize?: number;
  141793. /**
  141794. * How big is the kernel of the blur texture.
  141795. */
  141796. blurKernelSize: number;
  141797. /**
  141798. * The camera attached to the layer.
  141799. */
  141800. camera: Nullable<Camera>;
  141801. /**
  141802. * Enable MSAA by chosing the number of samples.
  141803. */
  141804. mainTextureSamples?: number;
  141805. /**
  141806. * The rendering group to draw the layer in.
  141807. */
  141808. renderingGroupId: number;
  141809. }
  141810. /**
  141811. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  141812. *
  141813. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  141814. *
  141815. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  141816. */
  141817. export class GlowLayer extends EffectLayer {
  141818. /**
  141819. * Effect Name of the layer.
  141820. */
  141821. static readonly EffectName: string;
  141822. /**
  141823. * The default blur kernel size used for the glow.
  141824. */
  141825. static DefaultBlurKernelSize: number;
  141826. /**
  141827. * The default texture size ratio used for the glow.
  141828. */
  141829. static DefaultTextureRatio: number;
  141830. /**
  141831. * Sets the kernel size of the blur.
  141832. */
  141833. set blurKernelSize(value: number);
  141834. /**
  141835. * Gets the kernel size of the blur.
  141836. */
  141837. get blurKernelSize(): number;
  141838. /**
  141839. * Sets the glow intensity.
  141840. */
  141841. set intensity(value: number);
  141842. /**
  141843. * Gets the glow intensity.
  141844. */
  141845. get intensity(): number;
  141846. private _options;
  141847. private _intensity;
  141848. private _horizontalBlurPostprocess1;
  141849. private _verticalBlurPostprocess1;
  141850. private _horizontalBlurPostprocess2;
  141851. private _verticalBlurPostprocess2;
  141852. private _blurTexture1;
  141853. private _blurTexture2;
  141854. private _postProcesses1;
  141855. private _postProcesses2;
  141856. private _includedOnlyMeshes;
  141857. private _excludedMeshes;
  141858. private _meshesUsingTheirOwnMaterials;
  141859. /**
  141860. * Callback used to let the user override the color selection on a per mesh basis
  141861. */
  141862. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  141863. /**
  141864. * Callback used to let the user override the texture selection on a per mesh basis
  141865. */
  141866. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  141867. /**
  141868. * Instantiates a new glow Layer and references it to the scene.
  141869. * @param name The name of the layer
  141870. * @param scene The scene to use the layer in
  141871. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  141872. */
  141873. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  141874. /**
  141875. * Get the effect name of the layer.
  141876. * @return The effect name
  141877. */
  141878. getEffectName(): string;
  141879. /**
  141880. * Create the merge effect. This is the shader use to blit the information back
  141881. * to the main canvas at the end of the scene rendering.
  141882. */
  141883. protected _createMergeEffect(): Effect;
  141884. /**
  141885. * Creates the render target textures and post processes used in the glow layer.
  141886. */
  141887. protected _createTextureAndPostProcesses(): void;
  141888. /**
  141889. * Checks for the readiness of the element composing the layer.
  141890. * @param subMesh the mesh to check for
  141891. * @param useInstances specify wether or not to use instances to render the mesh
  141892. * @param emissiveTexture the associated emissive texture used to generate the glow
  141893. * @return true if ready otherwise, false
  141894. */
  141895. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141896. /**
  141897. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  141898. */
  141899. needStencil(): boolean;
  141900. /**
  141901. * Returns true if the mesh can be rendered, otherwise false.
  141902. * @param mesh The mesh to render
  141903. * @param material The material used on the mesh
  141904. * @returns true if it can be rendered otherwise false
  141905. */
  141906. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141907. /**
  141908. * Implementation specific of rendering the generating effect on the main canvas.
  141909. * @param effect The effect used to render through
  141910. */
  141911. protected _internalRender(effect: Effect): void;
  141912. /**
  141913. * Sets the required values for both the emissive texture and and the main color.
  141914. */
  141915. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141916. /**
  141917. * Returns true if the mesh should render, otherwise false.
  141918. * @param mesh The mesh to render
  141919. * @returns true if it should render otherwise false
  141920. */
  141921. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141922. /**
  141923. * Adds specific effects defines.
  141924. * @param defines The defines to add specifics to.
  141925. */
  141926. protected _addCustomEffectDefines(defines: string[]): void;
  141927. /**
  141928. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  141929. * @param mesh The mesh to exclude from the glow layer
  141930. */
  141931. addExcludedMesh(mesh: Mesh): void;
  141932. /**
  141933. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  141934. * @param mesh The mesh to remove
  141935. */
  141936. removeExcludedMesh(mesh: Mesh): void;
  141937. /**
  141938. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  141939. * @param mesh The mesh to include in the glow layer
  141940. */
  141941. addIncludedOnlyMesh(mesh: Mesh): void;
  141942. /**
  141943. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  141944. * @param mesh The mesh to remove
  141945. */
  141946. removeIncludedOnlyMesh(mesh: Mesh): void;
  141947. /**
  141948. * Determine if a given mesh will be used in the glow layer
  141949. * @param mesh The mesh to test
  141950. * @returns true if the mesh will be highlighted by the current glow layer
  141951. */
  141952. hasMesh(mesh: AbstractMesh): boolean;
  141953. /**
  141954. * Defines whether the current material of the mesh should be use to render the effect.
  141955. * @param mesh defines the current mesh to render
  141956. */
  141957. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  141958. /**
  141959. * Add a mesh to be rendered through its own material and not with emissive only.
  141960. * @param mesh The mesh for which we need to use its material
  141961. */
  141962. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141963. /**
  141964. * Remove a mesh from being rendered through its own material and not with emissive only.
  141965. * @param mesh The mesh for which we need to not use its material
  141966. */
  141967. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141968. /**
  141969. * Free any resources and references associated to a mesh.
  141970. * Internal use
  141971. * @param mesh The mesh to free.
  141972. * @hidden
  141973. */
  141974. _disposeMesh(mesh: Mesh): void;
  141975. /**
  141976. * Gets the class name of the effect layer
  141977. * @returns the string with the class name of the effect layer
  141978. */
  141979. getClassName(): string;
  141980. /**
  141981. * Serializes this glow layer
  141982. * @returns a serialized glow layer object
  141983. */
  141984. serialize(): any;
  141985. /**
  141986. * Creates a Glow Layer from parsed glow layer data
  141987. * @param parsedGlowLayer defines glow layer data
  141988. * @param scene defines the current scene
  141989. * @param rootUrl defines the root URL containing the glow layer information
  141990. * @returns a parsed Glow Layer
  141991. */
  141992. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141993. }
  141994. }
  141995. declare module BABYLON {
  141996. /** @hidden */
  141997. export var glowBlurPostProcessPixelShader: {
  141998. name: string;
  141999. shader: string;
  142000. };
  142001. }
  142002. declare module BABYLON {
  142003. interface AbstractScene {
  142004. /**
  142005. * Return a the first highlight layer of the scene with a given name.
  142006. * @param name The name of the highlight layer to look for.
  142007. * @return The highlight layer if found otherwise null.
  142008. */
  142009. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  142010. }
  142011. /**
  142012. * Highlight layer options. This helps customizing the behaviour
  142013. * of the highlight layer.
  142014. */
  142015. export interface IHighlightLayerOptions {
  142016. /**
  142017. * Multiplication factor apply to the canvas size to compute the render target size
  142018. * used to generated the glowing objects (the smaller the faster).
  142019. */
  142020. mainTextureRatio: number;
  142021. /**
  142022. * Enforces a fixed size texture to ensure resize independant blur.
  142023. */
  142024. mainTextureFixedSize?: number;
  142025. /**
  142026. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  142027. * of the picture to blur (the smaller the faster).
  142028. */
  142029. blurTextureSizeRatio: number;
  142030. /**
  142031. * How big in texel of the blur texture is the vertical blur.
  142032. */
  142033. blurVerticalSize: number;
  142034. /**
  142035. * How big in texel of the blur texture is the horizontal blur.
  142036. */
  142037. blurHorizontalSize: number;
  142038. /**
  142039. * Alpha blending mode used to apply the blur. Default is combine.
  142040. */
  142041. alphaBlendingMode: number;
  142042. /**
  142043. * The camera attached to the layer.
  142044. */
  142045. camera: Nullable<Camera>;
  142046. /**
  142047. * Should we display highlight as a solid stroke?
  142048. */
  142049. isStroke?: boolean;
  142050. /**
  142051. * The rendering group to draw the layer in.
  142052. */
  142053. renderingGroupId: number;
  142054. }
  142055. /**
  142056. * The highlight layer Helps adding a glow effect around a mesh.
  142057. *
  142058. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  142059. * glowy meshes to your scene.
  142060. *
  142061. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  142062. */
  142063. export class HighlightLayer extends EffectLayer {
  142064. name: string;
  142065. /**
  142066. * Effect Name of the highlight layer.
  142067. */
  142068. static readonly EffectName: string;
  142069. /**
  142070. * The neutral color used during the preparation of the glow effect.
  142071. * This is black by default as the blend operation is a blend operation.
  142072. */
  142073. static NeutralColor: Color4;
  142074. /**
  142075. * Stencil value used for glowing meshes.
  142076. */
  142077. static GlowingMeshStencilReference: number;
  142078. /**
  142079. * Stencil value used for the other meshes in the scene.
  142080. */
  142081. static NormalMeshStencilReference: number;
  142082. /**
  142083. * Specifies whether or not the inner glow is ACTIVE in the layer.
  142084. */
  142085. innerGlow: boolean;
  142086. /**
  142087. * Specifies whether or not the outer glow is ACTIVE in the layer.
  142088. */
  142089. outerGlow: boolean;
  142090. /**
  142091. * Specifies the horizontal size of the blur.
  142092. */
  142093. set blurHorizontalSize(value: number);
  142094. /**
  142095. * Specifies the vertical size of the blur.
  142096. */
  142097. set blurVerticalSize(value: number);
  142098. /**
  142099. * Gets the horizontal size of the blur.
  142100. */
  142101. get blurHorizontalSize(): number;
  142102. /**
  142103. * Gets the vertical size of the blur.
  142104. */
  142105. get blurVerticalSize(): number;
  142106. /**
  142107. * An event triggered when the highlight layer is being blurred.
  142108. */
  142109. onBeforeBlurObservable: Observable<HighlightLayer>;
  142110. /**
  142111. * An event triggered when the highlight layer has been blurred.
  142112. */
  142113. onAfterBlurObservable: Observable<HighlightLayer>;
  142114. private _instanceGlowingMeshStencilReference;
  142115. private _options;
  142116. private _downSamplePostprocess;
  142117. private _horizontalBlurPostprocess;
  142118. private _verticalBlurPostprocess;
  142119. private _blurTexture;
  142120. private _meshes;
  142121. private _excludedMeshes;
  142122. /**
  142123. * Instantiates a new highlight Layer and references it to the scene..
  142124. * @param name The name of the layer
  142125. * @param scene The scene to use the layer in
  142126. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  142127. */
  142128. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  142129. /**
  142130. * Get the effect name of the layer.
  142131. * @return The effect name
  142132. */
  142133. getEffectName(): string;
  142134. /**
  142135. * Create the merge effect. This is the shader use to blit the information back
  142136. * to the main canvas at the end of the scene rendering.
  142137. */
  142138. protected _createMergeEffect(): Effect;
  142139. /**
  142140. * Creates the render target textures and post processes used in the highlight layer.
  142141. */
  142142. protected _createTextureAndPostProcesses(): void;
  142143. /**
  142144. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  142145. */
  142146. needStencil(): boolean;
  142147. /**
  142148. * Checks for the readiness of the element composing the layer.
  142149. * @param subMesh the mesh to check for
  142150. * @param useInstances specify wether or not to use instances to render the mesh
  142151. * @param emissiveTexture the associated emissive texture used to generate the glow
  142152. * @return true if ready otherwise, false
  142153. */
  142154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142155. /**
  142156. * Implementation specific of rendering the generating effect on the main canvas.
  142157. * @param effect The effect used to render through
  142158. */
  142159. protected _internalRender(effect: Effect): void;
  142160. /**
  142161. * Returns true if the layer contains information to display, otherwise false.
  142162. */
  142163. shouldRender(): boolean;
  142164. /**
  142165. * Returns true if the mesh should render, otherwise false.
  142166. * @param mesh The mesh to render
  142167. * @returns true if it should render otherwise false
  142168. */
  142169. protected _shouldRenderMesh(mesh: Mesh): boolean;
  142170. /**
  142171. * Returns true if the mesh can be rendered, otherwise false.
  142172. * @param mesh The mesh to render
  142173. * @param material The material used on the mesh
  142174. * @returns true if it can be rendered otherwise false
  142175. */
  142176. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  142177. /**
  142178. * Adds specific effects defines.
  142179. * @param defines The defines to add specifics to.
  142180. */
  142181. protected _addCustomEffectDefines(defines: string[]): void;
  142182. /**
  142183. * Sets the required values for both the emissive texture and and the main color.
  142184. */
  142185. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  142186. /**
  142187. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  142188. * @param mesh The mesh to exclude from the highlight layer
  142189. */
  142190. addExcludedMesh(mesh: Mesh): void;
  142191. /**
  142192. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  142193. * @param mesh The mesh to highlight
  142194. */
  142195. removeExcludedMesh(mesh: Mesh): void;
  142196. /**
  142197. * Determine if a given mesh will be highlighted by the current HighlightLayer
  142198. * @param mesh mesh to test
  142199. * @returns true if the mesh will be highlighted by the current HighlightLayer
  142200. */
  142201. hasMesh(mesh: AbstractMesh): boolean;
  142202. /**
  142203. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  142204. * @param mesh The mesh to highlight
  142205. * @param color The color of the highlight
  142206. * @param glowEmissiveOnly Extract the glow from the emissive texture
  142207. */
  142208. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  142209. /**
  142210. * Remove a mesh from the highlight layer in order to make it stop glowing.
  142211. * @param mesh The mesh to highlight
  142212. */
  142213. removeMesh(mesh: Mesh): void;
  142214. /**
  142215. * Remove all the meshes currently referenced in the highlight layer
  142216. */
  142217. removeAllMeshes(): void;
  142218. /**
  142219. * Force the stencil to the normal expected value for none glowing parts
  142220. */
  142221. private _defaultStencilReference;
  142222. /**
  142223. * Free any resources and references associated to a mesh.
  142224. * Internal use
  142225. * @param mesh The mesh to free.
  142226. * @hidden
  142227. */
  142228. _disposeMesh(mesh: Mesh): void;
  142229. /**
  142230. * Dispose the highlight layer and free resources.
  142231. */
  142232. dispose(): void;
  142233. /**
  142234. * Gets the class name of the effect layer
  142235. * @returns the string with the class name of the effect layer
  142236. */
  142237. getClassName(): string;
  142238. /**
  142239. * Serializes this Highlight layer
  142240. * @returns a serialized Highlight layer object
  142241. */
  142242. serialize(): any;
  142243. /**
  142244. * Creates a Highlight layer from parsed Highlight layer data
  142245. * @param parsedHightlightLayer defines the Highlight layer data
  142246. * @param scene defines the current scene
  142247. * @param rootUrl defines the root URL containing the Highlight layer information
  142248. * @returns a parsed Highlight layer
  142249. */
  142250. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  142251. }
  142252. }
  142253. declare module BABYLON {
  142254. interface AbstractScene {
  142255. /**
  142256. * The list of layers (background and foreground) of the scene
  142257. */
  142258. layers: Array<Layer>;
  142259. }
  142260. /**
  142261. * Defines the layer scene component responsible to manage any layers
  142262. * in a given scene.
  142263. */
  142264. export class LayerSceneComponent implements ISceneComponent {
  142265. /**
  142266. * The component name helpfull to identify the component in the list of scene components.
  142267. */
  142268. readonly name: string;
  142269. /**
  142270. * The scene the component belongs to.
  142271. */
  142272. scene: Scene;
  142273. private _engine;
  142274. /**
  142275. * Creates a new instance of the component for the given scene
  142276. * @param scene Defines the scene to register the component in
  142277. */
  142278. constructor(scene: Scene);
  142279. /**
  142280. * Registers the component in a given scene
  142281. */
  142282. register(): void;
  142283. /**
  142284. * Rebuilds the elements related to this component in case of
  142285. * context lost for instance.
  142286. */
  142287. rebuild(): void;
  142288. /**
  142289. * Disposes the component and the associated ressources.
  142290. */
  142291. dispose(): void;
  142292. private _draw;
  142293. private _drawCameraPredicate;
  142294. private _drawCameraBackground;
  142295. private _drawCameraForeground;
  142296. private _drawRenderTargetPredicate;
  142297. private _drawRenderTargetBackground;
  142298. private _drawRenderTargetForeground;
  142299. /**
  142300. * Adds all the elements from the container to the scene
  142301. * @param container the container holding the elements
  142302. */
  142303. addFromContainer(container: AbstractScene): void;
  142304. /**
  142305. * Removes all the elements in the container from the scene
  142306. * @param container contains the elements to remove
  142307. * @param dispose if the removed element should be disposed (default: false)
  142308. */
  142309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142310. }
  142311. }
  142312. declare module BABYLON {
  142313. /** @hidden */
  142314. export var layerPixelShader: {
  142315. name: string;
  142316. shader: string;
  142317. };
  142318. }
  142319. declare module BABYLON {
  142320. /** @hidden */
  142321. export var layerVertexShader: {
  142322. name: string;
  142323. shader: string;
  142324. };
  142325. }
  142326. declare module BABYLON {
  142327. /**
  142328. * This represents a full screen 2d layer.
  142329. * This can be useful to display a picture in the background of your scene for instance.
  142330. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142331. */
  142332. export class Layer {
  142333. /**
  142334. * Define the name of the layer.
  142335. */
  142336. name: string;
  142337. /**
  142338. * Define the texture the layer should display.
  142339. */
  142340. texture: Nullable<Texture>;
  142341. /**
  142342. * Is the layer in background or foreground.
  142343. */
  142344. isBackground: boolean;
  142345. /**
  142346. * Define the color of the layer (instead of texture).
  142347. */
  142348. color: Color4;
  142349. /**
  142350. * Define the scale of the layer in order to zoom in out of the texture.
  142351. */
  142352. scale: Vector2;
  142353. /**
  142354. * Define an offset for the layer in order to shift the texture.
  142355. */
  142356. offset: Vector2;
  142357. /**
  142358. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  142359. */
  142360. alphaBlendingMode: number;
  142361. /**
  142362. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  142363. * Alpha test will not mix with the background color in case of transparency.
  142364. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  142365. */
  142366. alphaTest: boolean;
  142367. /**
  142368. * Define a mask to restrict the layer to only some of the scene cameras.
  142369. */
  142370. layerMask: number;
  142371. /**
  142372. * Define the list of render target the layer is visible into.
  142373. */
  142374. renderTargetTextures: RenderTargetTexture[];
  142375. /**
  142376. * Define if the layer is only used in renderTarget or if it also
  142377. * renders in the main frame buffer of the canvas.
  142378. */
  142379. renderOnlyInRenderTargetTextures: boolean;
  142380. private _scene;
  142381. private _vertexBuffers;
  142382. private _indexBuffer;
  142383. private _effect;
  142384. private _previousDefines;
  142385. /**
  142386. * An event triggered when the layer is disposed.
  142387. */
  142388. onDisposeObservable: Observable<Layer>;
  142389. private _onDisposeObserver;
  142390. /**
  142391. * Back compatibility with callback before the onDisposeObservable existed.
  142392. * The set callback will be triggered when the layer has been disposed.
  142393. */
  142394. set onDispose(callback: () => void);
  142395. /**
  142396. * An event triggered before rendering the scene
  142397. */
  142398. onBeforeRenderObservable: Observable<Layer>;
  142399. private _onBeforeRenderObserver;
  142400. /**
  142401. * Back compatibility with callback before the onBeforeRenderObservable existed.
  142402. * The set callback will be triggered just before rendering the layer.
  142403. */
  142404. set onBeforeRender(callback: () => void);
  142405. /**
  142406. * An event triggered after rendering the scene
  142407. */
  142408. onAfterRenderObservable: Observable<Layer>;
  142409. private _onAfterRenderObserver;
  142410. /**
  142411. * Back compatibility with callback before the onAfterRenderObservable existed.
  142412. * The set callback will be triggered just after rendering the layer.
  142413. */
  142414. set onAfterRender(callback: () => void);
  142415. /**
  142416. * Instantiates a new layer.
  142417. * This represents a full screen 2d layer.
  142418. * This can be useful to display a picture in the background of your scene for instance.
  142419. * @see https://www.babylonjs-playground.com/#08A2BS#1
  142420. * @param name Define the name of the layer in the scene
  142421. * @param imgUrl Define the url of the texture to display in the layer
  142422. * @param scene Define the scene the layer belongs to
  142423. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  142424. * @param color Defines a color for the layer
  142425. */
  142426. constructor(
  142427. /**
  142428. * Define the name of the layer.
  142429. */
  142430. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  142431. private _createIndexBuffer;
  142432. /** @hidden */
  142433. _rebuild(): void;
  142434. /**
  142435. * Renders the layer in the scene.
  142436. */
  142437. render(): void;
  142438. /**
  142439. * Disposes and releases the associated ressources.
  142440. */
  142441. dispose(): void;
  142442. }
  142443. }
  142444. declare module BABYLON {
  142445. /** @hidden */
  142446. export var lensFlarePixelShader: {
  142447. name: string;
  142448. shader: string;
  142449. };
  142450. }
  142451. declare module BABYLON {
  142452. /** @hidden */
  142453. export var lensFlareVertexShader: {
  142454. name: string;
  142455. shader: string;
  142456. };
  142457. }
  142458. declare module BABYLON {
  142459. /**
  142460. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142461. * It is usually composed of several `lensFlare`.
  142462. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142463. */
  142464. export class LensFlareSystem {
  142465. /**
  142466. * Define the name of the lens flare system
  142467. */
  142468. name: string;
  142469. /**
  142470. * List of lens flares used in this system.
  142471. */
  142472. lensFlares: LensFlare[];
  142473. /**
  142474. * Define a limit from the border the lens flare can be visible.
  142475. */
  142476. borderLimit: number;
  142477. /**
  142478. * Define a viewport border we do not want to see the lens flare in.
  142479. */
  142480. viewportBorder: number;
  142481. /**
  142482. * Define a predicate which could limit the list of meshes able to occlude the effect.
  142483. */
  142484. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  142485. /**
  142486. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  142487. */
  142488. layerMask: number;
  142489. /**
  142490. * Define the id of the lens flare system in the scene.
  142491. * (equal to name by default)
  142492. */
  142493. id: string;
  142494. private _scene;
  142495. private _emitter;
  142496. private _vertexBuffers;
  142497. private _indexBuffer;
  142498. private _effect;
  142499. private _positionX;
  142500. private _positionY;
  142501. private _isEnabled;
  142502. /** @hidden */
  142503. static _SceneComponentInitialization: (scene: Scene) => void;
  142504. /**
  142505. * Instantiates a lens flare system.
  142506. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  142507. * It is usually composed of several `lensFlare`.
  142508. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142509. * @param name Define the name of the lens flare system in the scene
  142510. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  142511. * @param scene Define the scene the lens flare system belongs to
  142512. */
  142513. constructor(
  142514. /**
  142515. * Define the name of the lens flare system
  142516. */
  142517. name: string, emitter: any, scene: Scene);
  142518. /**
  142519. * Define if the lens flare system is enabled.
  142520. */
  142521. get isEnabled(): boolean;
  142522. set isEnabled(value: boolean);
  142523. /**
  142524. * Get the scene the effects belongs to.
  142525. * @returns the scene holding the lens flare system
  142526. */
  142527. getScene(): Scene;
  142528. /**
  142529. * Get the emitter of the lens flare system.
  142530. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142531. * @returns the emitter of the lens flare system
  142532. */
  142533. getEmitter(): any;
  142534. /**
  142535. * Set the emitter of the lens flare system.
  142536. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  142537. * @param newEmitter Define the new emitter of the system
  142538. */
  142539. setEmitter(newEmitter: any): void;
  142540. /**
  142541. * Get the lens flare system emitter position.
  142542. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  142543. * @returns the position
  142544. */
  142545. getEmitterPosition(): Vector3;
  142546. /**
  142547. * @hidden
  142548. */
  142549. computeEffectivePosition(globalViewport: Viewport): boolean;
  142550. /** @hidden */
  142551. _isVisible(): boolean;
  142552. /**
  142553. * @hidden
  142554. */
  142555. render(): boolean;
  142556. /**
  142557. * Dispose and release the lens flare with its associated resources.
  142558. */
  142559. dispose(): void;
  142560. /**
  142561. * Parse a lens flare system from a JSON repressentation
  142562. * @param parsedLensFlareSystem Define the JSON to parse
  142563. * @param scene Define the scene the parsed system should be instantiated in
  142564. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  142565. * @returns the parsed system
  142566. */
  142567. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  142568. /**
  142569. * Serialize the current Lens Flare System into a JSON representation.
  142570. * @returns the serialized JSON
  142571. */
  142572. serialize(): any;
  142573. }
  142574. }
  142575. declare module BABYLON {
  142576. /**
  142577. * This represents one of the lens effect in a `lensFlareSystem`.
  142578. * It controls one of the indiviual texture used in the effect.
  142579. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142580. */
  142581. export class LensFlare {
  142582. /**
  142583. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142584. */
  142585. size: number;
  142586. /**
  142587. * 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.
  142588. */
  142589. position: number;
  142590. /**
  142591. * Define the lens color.
  142592. */
  142593. color: Color3;
  142594. /**
  142595. * Define the lens texture.
  142596. */
  142597. texture: Nullable<Texture>;
  142598. /**
  142599. * Define the alpha mode to render this particular lens.
  142600. */
  142601. alphaMode: number;
  142602. private _system;
  142603. /**
  142604. * Creates a new Lens Flare.
  142605. * This represents one of the lens effect in a `lensFlareSystem`.
  142606. * It controls one of the indiviual texture used in the effect.
  142607. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142608. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  142609. * @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.
  142610. * @param color Define the lens color
  142611. * @param imgUrl Define the lens texture url
  142612. * @param system Define the `lensFlareSystem` this flare is part of
  142613. * @returns The newly created Lens Flare
  142614. */
  142615. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  142616. /**
  142617. * Instantiates a new Lens Flare.
  142618. * This represents one of the lens effect in a `lensFlareSystem`.
  142619. * It controls one of the indiviual texture used in the effect.
  142620. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142621. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  142622. * @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.
  142623. * @param color Define the lens color
  142624. * @param imgUrl Define the lens texture url
  142625. * @param system Define the `lensFlareSystem` this flare is part of
  142626. */
  142627. constructor(
  142628. /**
  142629. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  142630. */
  142631. size: number,
  142632. /**
  142633. * 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.
  142634. */
  142635. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  142636. /**
  142637. * Dispose and release the lens flare with its associated resources.
  142638. */
  142639. dispose(): void;
  142640. }
  142641. }
  142642. declare module BABYLON {
  142643. interface AbstractScene {
  142644. /**
  142645. * The list of lens flare system added to the scene
  142646. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  142647. */
  142648. lensFlareSystems: Array<LensFlareSystem>;
  142649. /**
  142650. * Removes the given lens flare system from this scene.
  142651. * @param toRemove The lens flare system to remove
  142652. * @returns The index of the removed lens flare system
  142653. */
  142654. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  142655. /**
  142656. * Adds the given lens flare system to this scene
  142657. * @param newLensFlareSystem The lens flare system to add
  142658. */
  142659. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  142660. /**
  142661. * Gets a lens flare system using its name
  142662. * @param name defines the name to look for
  142663. * @returns the lens flare system or null if not found
  142664. */
  142665. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  142666. /**
  142667. * Gets a lens flare system using its id
  142668. * @param id defines the id to look for
  142669. * @returns the lens flare system or null if not found
  142670. */
  142671. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  142672. }
  142673. /**
  142674. * Defines the lens flare scene component responsible to manage any lens flares
  142675. * in a given scene.
  142676. */
  142677. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  142678. /**
  142679. * The component name helpfull to identify the component in the list of scene components.
  142680. */
  142681. readonly name: string;
  142682. /**
  142683. * The scene the component belongs to.
  142684. */
  142685. scene: Scene;
  142686. /**
  142687. * Creates a new instance of the component for the given scene
  142688. * @param scene Defines the scene to register the component in
  142689. */
  142690. constructor(scene: Scene);
  142691. /**
  142692. * Registers the component in a given scene
  142693. */
  142694. register(): void;
  142695. /**
  142696. * Rebuilds the elements related to this component in case of
  142697. * context lost for instance.
  142698. */
  142699. rebuild(): void;
  142700. /**
  142701. * Adds all the elements from the container to the scene
  142702. * @param container the container holding the elements
  142703. */
  142704. addFromContainer(container: AbstractScene): void;
  142705. /**
  142706. * Removes all the elements in the container from the scene
  142707. * @param container contains the elements to remove
  142708. * @param dispose if the removed element should be disposed (default: false)
  142709. */
  142710. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142711. /**
  142712. * Serializes the component data to the specified json object
  142713. * @param serializationObject The object to serialize to
  142714. */
  142715. serialize(serializationObject: any): void;
  142716. /**
  142717. * Disposes the component and the associated ressources.
  142718. */
  142719. dispose(): void;
  142720. private _draw;
  142721. }
  142722. }
  142723. declare module BABYLON {
  142724. /** @hidden */
  142725. export var depthPixelShader: {
  142726. name: string;
  142727. shader: string;
  142728. };
  142729. }
  142730. declare module BABYLON {
  142731. /** @hidden */
  142732. export var depthVertexShader: {
  142733. name: string;
  142734. shader: string;
  142735. };
  142736. }
  142737. declare module BABYLON {
  142738. /**
  142739. * This represents a depth renderer in Babylon.
  142740. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  142741. */
  142742. export class DepthRenderer {
  142743. private _scene;
  142744. private _depthMap;
  142745. private _effect;
  142746. private readonly _storeNonLinearDepth;
  142747. private readonly _clearColor;
  142748. /** Get if the depth renderer is using packed depth or not */
  142749. readonly isPacked: boolean;
  142750. private _cachedDefines;
  142751. private _camera;
  142752. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  142753. enabled: boolean;
  142754. /**
  142755. * Specifiess that the depth renderer will only be used within
  142756. * the camera it is created for.
  142757. * This can help forcing its rendering during the camera processing.
  142758. */
  142759. useOnlyInActiveCamera: boolean;
  142760. /** @hidden */
  142761. static _SceneComponentInitialization: (scene: Scene) => void;
  142762. /**
  142763. * Instantiates a depth renderer
  142764. * @param scene The scene the renderer belongs to
  142765. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  142766. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  142767. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  142768. */
  142769. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  142770. /**
  142771. * Creates the depth rendering effect and checks if the effect is ready.
  142772. * @param subMesh The submesh to be used to render the depth map of
  142773. * @param useInstances If multiple world instances should be used
  142774. * @returns if the depth renderer is ready to render the depth map
  142775. */
  142776. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  142777. /**
  142778. * Gets the texture which the depth map will be written to.
  142779. * @returns The depth map texture
  142780. */
  142781. getDepthMap(): RenderTargetTexture;
  142782. /**
  142783. * Disposes of the depth renderer.
  142784. */
  142785. dispose(): void;
  142786. }
  142787. }
  142788. declare module BABYLON {
  142789. /** @hidden */
  142790. export var minmaxReduxPixelShader: {
  142791. name: string;
  142792. shader: string;
  142793. };
  142794. }
  142795. declare module BABYLON {
  142796. /**
  142797. * This class computes a min/max reduction from a texture: it means it computes the minimum
  142798. * and maximum values from all values of the texture.
  142799. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  142800. * The source values are read from the red channel of the texture.
  142801. */
  142802. export class MinMaxReducer {
  142803. /**
  142804. * Observable triggered when the computation has been performed
  142805. */
  142806. onAfterReductionPerformed: Observable<{
  142807. min: number;
  142808. max: number;
  142809. }>;
  142810. protected _camera: Camera;
  142811. protected _sourceTexture: Nullable<RenderTargetTexture>;
  142812. protected _reductionSteps: Nullable<Array<PostProcess>>;
  142813. protected _postProcessManager: PostProcessManager;
  142814. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  142815. protected _forceFullscreenViewport: boolean;
  142816. /**
  142817. * Creates a min/max reducer
  142818. * @param camera The camera to use for the post processes
  142819. */
  142820. constructor(camera: Camera);
  142821. /**
  142822. * Gets the texture used to read the values from.
  142823. */
  142824. get sourceTexture(): Nullable<RenderTargetTexture>;
  142825. /**
  142826. * Sets the source texture to read the values from.
  142827. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  142828. * because in such textures '1' value must not be taken into account to compute the maximum
  142829. * as this value is used to clear the texture.
  142830. * Note that the computation is not activated by calling this function, you must call activate() for that!
  142831. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  142832. * @param depthRedux Indicates if the texture is a depth texture or not
  142833. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  142834. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142835. */
  142836. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142837. /**
  142838. * Defines the refresh rate of the computation.
  142839. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142840. */
  142841. get refreshRate(): number;
  142842. set refreshRate(value: number);
  142843. protected _activated: boolean;
  142844. /**
  142845. * Gets the activation status of the reducer
  142846. */
  142847. get activated(): boolean;
  142848. /**
  142849. * Activates the reduction computation.
  142850. * When activated, the observers registered in onAfterReductionPerformed are
  142851. * called after the compuation is performed
  142852. */
  142853. activate(): void;
  142854. /**
  142855. * Deactivates the reduction computation.
  142856. */
  142857. deactivate(): void;
  142858. /**
  142859. * Disposes the min/max reducer
  142860. * @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.
  142861. */
  142862. dispose(disposeAll?: boolean): void;
  142863. }
  142864. }
  142865. declare module BABYLON {
  142866. /**
  142867. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  142868. */
  142869. export class DepthReducer extends MinMaxReducer {
  142870. private _depthRenderer;
  142871. private _depthRendererId;
  142872. /**
  142873. * Gets the depth renderer used for the computation.
  142874. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  142875. */
  142876. get depthRenderer(): Nullable<DepthRenderer>;
  142877. /**
  142878. * Creates a depth reducer
  142879. * @param camera The camera used to render the depth texture
  142880. */
  142881. constructor(camera: Camera);
  142882. /**
  142883. * Sets the depth renderer to use to generate the depth map
  142884. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  142885. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  142886. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  142887. */
  142888. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  142889. /** @hidden */
  142890. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  142891. /**
  142892. * Activates the reduction computation.
  142893. * When activated, the observers registered in onAfterReductionPerformed are
  142894. * called after the compuation is performed
  142895. */
  142896. activate(): void;
  142897. /**
  142898. * Deactivates the reduction computation.
  142899. */
  142900. deactivate(): void;
  142901. /**
  142902. * Disposes the depth reducer
  142903. * @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.
  142904. */
  142905. dispose(disposeAll?: boolean): void;
  142906. }
  142907. }
  142908. declare module BABYLON {
  142909. /**
  142910. * A CSM implementation allowing casting shadows on large scenes.
  142911. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142912. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  142913. */
  142914. export class CascadedShadowGenerator extends ShadowGenerator {
  142915. private static readonly frustumCornersNDCSpace;
  142916. /**
  142917. * Name of the CSM class
  142918. */
  142919. static CLASSNAME: string;
  142920. /**
  142921. * Defines the default number of cascades used by the CSM.
  142922. */
  142923. static readonly DEFAULT_CASCADES_COUNT: number;
  142924. /**
  142925. * Defines the minimum number of cascades used by the CSM.
  142926. */
  142927. static readonly MIN_CASCADES_COUNT: number;
  142928. /**
  142929. * Defines the maximum number of cascades used by the CSM.
  142930. */
  142931. static readonly MAX_CASCADES_COUNT: number;
  142932. protected _validateFilter(filter: number): number;
  142933. /**
  142934. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  142935. */
  142936. penumbraDarkness: number;
  142937. private _numCascades;
  142938. /**
  142939. * Gets or set the number of cascades used by the CSM.
  142940. */
  142941. get numCascades(): number;
  142942. set numCascades(value: number);
  142943. /**
  142944. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  142945. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  142946. */
  142947. stabilizeCascades: boolean;
  142948. private _freezeShadowCastersBoundingInfo;
  142949. private _freezeShadowCastersBoundingInfoObservable;
  142950. /**
  142951. * Enables or disables the shadow casters bounding info computation.
  142952. * If your shadow casters don't move, you can disable this feature.
  142953. * If it is enabled, the bounding box computation is done every frame.
  142954. */
  142955. get freezeShadowCastersBoundingInfo(): boolean;
  142956. set freezeShadowCastersBoundingInfo(freeze: boolean);
  142957. private _scbiMin;
  142958. private _scbiMax;
  142959. protected _computeShadowCastersBoundingInfo(): void;
  142960. protected _shadowCastersBoundingInfo: BoundingInfo;
  142961. /**
  142962. * Gets or sets the shadow casters bounding info.
  142963. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142964. * so that the system won't overwrite the bounds you provide
  142965. */
  142966. get shadowCastersBoundingInfo(): BoundingInfo;
  142967. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142968. protected _breaksAreDirty: boolean;
  142969. protected _minDistance: number;
  142970. protected _maxDistance: number;
  142971. /**
  142972. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142973. *
  142974. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142975. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142976. * @param min minimal distance for the breaks (default to 0.)
  142977. * @param max maximal distance for the breaks (default to 1.)
  142978. */
  142979. setMinMaxDistance(min: number, max: number): void;
  142980. /** Gets the minimal distance used in the cascade break computation */
  142981. get minDistance(): number;
  142982. /** Gets the maximal distance used in the cascade break computation */
  142983. get maxDistance(): number;
  142984. /**
  142985. * Gets the class name of that object
  142986. * @returns "CascadedShadowGenerator"
  142987. */
  142988. getClassName(): string;
  142989. private _cascadeMinExtents;
  142990. private _cascadeMaxExtents;
  142991. /**
  142992. * Gets a cascade minimum extents
  142993. * @param cascadeIndex index of the cascade
  142994. * @returns the minimum cascade extents
  142995. */
  142996. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142997. /**
  142998. * Gets a cascade maximum extents
  142999. * @param cascadeIndex index of the cascade
  143000. * @returns the maximum cascade extents
  143001. */
  143002. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  143003. private _cascades;
  143004. private _currentLayer;
  143005. private _viewSpaceFrustumsZ;
  143006. private _viewMatrices;
  143007. private _projectionMatrices;
  143008. private _transformMatrices;
  143009. private _transformMatricesAsArray;
  143010. private _frustumLengths;
  143011. private _lightSizeUVCorrection;
  143012. private _depthCorrection;
  143013. private _frustumCornersWorldSpace;
  143014. private _frustumCenter;
  143015. private _shadowCameraPos;
  143016. private _shadowMaxZ;
  143017. /**
  143018. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  143019. * It defaults to camera.maxZ
  143020. */
  143021. get shadowMaxZ(): number;
  143022. /**
  143023. * Sets the shadow max z distance.
  143024. */
  143025. set shadowMaxZ(value: number);
  143026. protected _debug: boolean;
  143027. /**
  143028. * Gets or sets the debug flag.
  143029. * When enabled, the cascades are materialized by different colors on the screen.
  143030. */
  143031. get debug(): boolean;
  143032. set debug(dbg: boolean);
  143033. private _depthClamp;
  143034. /**
  143035. * Gets or sets the depth clamping value.
  143036. *
  143037. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  143038. * to account for the shadow casters far away.
  143039. *
  143040. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  143041. */
  143042. get depthClamp(): boolean;
  143043. set depthClamp(value: boolean);
  143044. private _cascadeBlendPercentage;
  143045. /**
  143046. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  143047. * It defaults to 0.1 (10% blending).
  143048. */
  143049. get cascadeBlendPercentage(): number;
  143050. set cascadeBlendPercentage(value: number);
  143051. private _lambda;
  143052. /**
  143053. * Gets or set the lambda parameter.
  143054. * This parameter is used to split the camera frustum and create the cascades.
  143055. * 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.
  143056. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  143057. */
  143058. get lambda(): number;
  143059. set lambda(value: number);
  143060. /**
  143061. * Gets the view matrix corresponding to a given cascade
  143062. * @param cascadeNum cascade to retrieve the view matrix from
  143063. * @returns the cascade view matrix
  143064. */
  143065. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  143066. /**
  143067. * Gets the projection matrix corresponding to a given cascade
  143068. * @param cascadeNum cascade to retrieve the projection matrix from
  143069. * @returns the cascade projection matrix
  143070. */
  143071. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  143072. /**
  143073. * Gets the transformation matrix corresponding to a given cascade
  143074. * @param cascadeNum cascade to retrieve the transformation matrix from
  143075. * @returns the cascade transformation matrix
  143076. */
  143077. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  143078. private _depthRenderer;
  143079. /**
  143080. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  143081. *
  143082. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  143083. *
  143084. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  143085. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  143086. * @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
  143087. */
  143088. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  143089. private _depthReducer;
  143090. private _autoCalcDepthBounds;
  143091. /**
  143092. * Gets or sets the autoCalcDepthBounds property.
  143093. *
  143094. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  143095. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  143096. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  143097. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  143098. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  143099. */
  143100. get autoCalcDepthBounds(): boolean;
  143101. set autoCalcDepthBounds(value: boolean);
  143102. /**
  143103. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  143104. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  143105. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  143106. * for setting the refresh rate on the renderer yourself!
  143107. */
  143108. get autoCalcDepthBoundsRefreshRate(): number;
  143109. set autoCalcDepthBoundsRefreshRate(value: number);
  143110. /**
  143111. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  143112. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  143113. * you change the camera near/far planes!
  143114. */
  143115. splitFrustum(): void;
  143116. private _splitFrustum;
  143117. private _computeMatrices;
  143118. private _computeFrustumInWorldSpace;
  143119. private _computeCascadeFrustum;
  143120. /**
  143121. * Support test.
  143122. */
  143123. static get IsSupported(): boolean;
  143124. /** @hidden */
  143125. static _SceneComponentInitialization: (scene: Scene) => void;
  143126. /**
  143127. * Creates a Cascaded Shadow Generator object.
  143128. * A ShadowGenerator is the required tool to use the shadows.
  143129. * Each directional light casting shadows needs to use its own ShadowGenerator.
  143130. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  143131. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  143132. * @param light The directional light object generating the shadows.
  143133. * @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.
  143134. */
  143135. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  143136. protected _initializeGenerator(): void;
  143137. protected _createTargetRenderTexture(): void;
  143138. protected _initializeShadowMap(): void;
  143139. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  143140. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  143141. /**
  143142. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  143143. * @param defines Defines of the material we want to update
  143144. * @param lightIndex Index of the light in the enabled light list of the material
  143145. */
  143146. prepareDefines(defines: any, lightIndex: number): void;
  143147. /**
  143148. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  143149. * defined in the generator but impacting the effect).
  143150. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  143151. * @param effect The effect we are binfing the information for
  143152. */
  143153. bindShadowLight(lightIndex: string, effect: Effect): void;
  143154. /**
  143155. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  143156. * (eq to view projection * shadow projection matrices)
  143157. * @returns The transform matrix used to create the shadow map
  143158. */
  143159. getTransformMatrix(): Matrix;
  143160. /**
  143161. * Disposes the ShadowGenerator.
  143162. * Returns nothing.
  143163. */
  143164. dispose(): void;
  143165. /**
  143166. * Serializes the shadow generator setup to a json object.
  143167. * @returns The serialized JSON object
  143168. */
  143169. serialize(): any;
  143170. /**
  143171. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  143172. * @param parsedShadowGenerator The JSON object to parse
  143173. * @param scene The scene to create the shadow map for
  143174. * @returns The parsed shadow generator
  143175. */
  143176. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  143177. }
  143178. }
  143179. declare module BABYLON {
  143180. /**
  143181. * Defines the shadow generator component responsible to manage any shadow generators
  143182. * in a given scene.
  143183. */
  143184. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  143185. /**
  143186. * The component name helpfull to identify the component in the list of scene components.
  143187. */
  143188. readonly name: string;
  143189. /**
  143190. * The scene the component belongs to.
  143191. */
  143192. scene: Scene;
  143193. /**
  143194. * Creates a new instance of the component for the given scene
  143195. * @param scene Defines the scene to register the component in
  143196. */
  143197. constructor(scene: Scene);
  143198. /**
  143199. * Registers the component in a given scene
  143200. */
  143201. register(): void;
  143202. /**
  143203. * Rebuilds the elements related to this component in case of
  143204. * context lost for instance.
  143205. */
  143206. rebuild(): void;
  143207. /**
  143208. * Serializes the component data to the specified json object
  143209. * @param serializationObject The object to serialize to
  143210. */
  143211. serialize(serializationObject: any): void;
  143212. /**
  143213. * Adds all the elements from the container to the scene
  143214. * @param container the container holding the elements
  143215. */
  143216. addFromContainer(container: AbstractScene): void;
  143217. /**
  143218. * Removes all the elements in the container from the scene
  143219. * @param container contains the elements to remove
  143220. * @param dispose if the removed element should be disposed (default: false)
  143221. */
  143222. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  143223. /**
  143224. * Rebuilds the elements related to this component in case of
  143225. * context lost for instance.
  143226. */
  143227. dispose(): void;
  143228. private _gatherRenderTargets;
  143229. }
  143230. }
  143231. declare module BABYLON {
  143232. /**
  143233. * A point light is a light defined by an unique point in world space.
  143234. * The light is emitted in every direction from this point.
  143235. * A good example of a point light is a standard light bulb.
  143236. * Documentation: https://doc.babylonjs.com/babylon101/lights
  143237. */
  143238. export class PointLight extends ShadowLight {
  143239. private _shadowAngle;
  143240. /**
  143241. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143242. * This specifies what angle the shadow will use to be created.
  143243. *
  143244. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143245. */
  143246. get shadowAngle(): number;
  143247. /**
  143248. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143249. * This specifies what angle the shadow will use to be created.
  143250. *
  143251. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  143252. */
  143253. set shadowAngle(value: number);
  143254. /**
  143255. * Gets the direction if it has been set.
  143256. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143257. */
  143258. get direction(): Vector3;
  143259. /**
  143260. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  143261. */
  143262. set direction(value: Vector3);
  143263. /**
  143264. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  143265. * A PointLight emits the light in every direction.
  143266. * It can cast shadows.
  143267. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  143268. * ```javascript
  143269. * var pointLight = new PointLight("pl", camera.position, scene);
  143270. * ```
  143271. * Documentation : https://doc.babylonjs.com/babylon101/lights
  143272. * @param name The light friendly name
  143273. * @param position The position of the point light in the scene
  143274. * @param scene The scene the lights belongs to
  143275. */
  143276. constructor(name: string, position: Vector3, scene: Scene);
  143277. /**
  143278. * Returns the string "PointLight"
  143279. * @returns the class name
  143280. */
  143281. getClassName(): string;
  143282. /**
  143283. * Returns the integer 0.
  143284. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  143285. */
  143286. getTypeID(): number;
  143287. /**
  143288. * Specifies wether or not the shadowmap should be a cube texture.
  143289. * @returns true if the shadowmap needs to be a cube texture.
  143290. */
  143291. needCube(): boolean;
  143292. /**
  143293. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  143294. * @param faceIndex The index of the face we are computed the direction to generate shadow
  143295. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  143296. */
  143297. getShadowDirection(faceIndex?: number): Vector3;
  143298. /**
  143299. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  143300. * - fov = PI / 2
  143301. * - aspect ratio : 1.0
  143302. * - z-near and far equal to the active camera minZ and maxZ.
  143303. * Returns the PointLight.
  143304. */
  143305. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  143306. protected _buildUniformLayout(): void;
  143307. /**
  143308. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  143309. * @param effect The effect to update
  143310. * @param lightIndex The index of the light in the effect to update
  143311. * @returns The point light
  143312. */
  143313. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  143314. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  143315. /**
  143316. * Prepares the list of defines specific to the light type.
  143317. * @param defines the list of defines
  143318. * @param lightIndex defines the index of the light for the effect
  143319. */
  143320. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  143321. }
  143322. }
  143323. declare module BABYLON {
  143324. /**
  143325. * Header information of HDR texture files.
  143326. */
  143327. export interface HDRInfo {
  143328. /**
  143329. * The height of the texture in pixels.
  143330. */
  143331. height: number;
  143332. /**
  143333. * The width of the texture in pixels.
  143334. */
  143335. width: number;
  143336. /**
  143337. * The index of the beginning of the data in the binary file.
  143338. */
  143339. dataPosition: number;
  143340. }
  143341. /**
  143342. * This groups tools to convert HDR texture to native colors array.
  143343. */
  143344. export class HDRTools {
  143345. private static Ldexp;
  143346. private static Rgbe2float;
  143347. private static readStringLine;
  143348. /**
  143349. * Reads header information from an RGBE texture stored in a native array.
  143350. * More information on this format are available here:
  143351. * https://en.wikipedia.org/wiki/RGBE_image_format
  143352. *
  143353. * @param uint8array The binary file stored in native array.
  143354. * @return The header information.
  143355. */
  143356. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  143357. /**
  143358. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  143359. * This RGBE texture needs to store the information as a panorama.
  143360. *
  143361. * More information on this format are available here:
  143362. * https://en.wikipedia.org/wiki/RGBE_image_format
  143363. *
  143364. * @param buffer The binary file stored in an array buffer.
  143365. * @param size The expected size of the extracted cubemap.
  143366. * @return The Cube Map information.
  143367. */
  143368. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  143369. /**
  143370. * Returns the pixels data extracted from an RGBE texture.
  143371. * This pixels will be stored left to right up to down in the R G B order in one array.
  143372. *
  143373. * More information on this format are available here:
  143374. * https://en.wikipedia.org/wiki/RGBE_image_format
  143375. *
  143376. * @param uint8array The binary file stored in an array buffer.
  143377. * @param hdrInfo The header information of the file.
  143378. * @return The pixels data in RGB right to left up to down order.
  143379. */
  143380. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  143381. private static RGBE_ReadPixels_RLE;
  143382. private static RGBE_ReadPixels_NOT_RLE;
  143383. }
  143384. }
  143385. declare module BABYLON {
  143386. /**
  143387. * Effect Render Options
  143388. */
  143389. export interface IEffectRendererOptions {
  143390. /**
  143391. * Defines the vertices positions.
  143392. */
  143393. positions?: number[];
  143394. /**
  143395. * Defines the indices.
  143396. */
  143397. indices?: number[];
  143398. }
  143399. /**
  143400. * Helper class to render one or more effects.
  143401. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  143402. */
  143403. export class EffectRenderer {
  143404. private engine;
  143405. private static _DefaultOptions;
  143406. private _vertexBuffers;
  143407. private _indexBuffer;
  143408. private _fullscreenViewport;
  143409. /**
  143410. * Creates an effect renderer
  143411. * @param engine the engine to use for rendering
  143412. * @param options defines the options of the effect renderer
  143413. */
  143414. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  143415. /**
  143416. * Sets the current viewport in normalized coordinates 0-1
  143417. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  143418. */
  143419. setViewport(viewport?: Viewport): void;
  143420. /**
  143421. * Binds the embedded attributes buffer to the effect.
  143422. * @param effect Defines the effect to bind the attributes for
  143423. */
  143424. bindBuffers(effect: Effect): void;
  143425. /**
  143426. * Sets the current effect wrapper to use during draw.
  143427. * The effect needs to be ready before calling this api.
  143428. * This also sets the default full screen position attribute.
  143429. * @param effectWrapper Defines the effect to draw with
  143430. */
  143431. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  143432. /**
  143433. * Restores engine states
  143434. */
  143435. restoreStates(): void;
  143436. /**
  143437. * Draws a full screen quad.
  143438. */
  143439. draw(): void;
  143440. private isRenderTargetTexture;
  143441. /**
  143442. * renders one or more effects to a specified texture
  143443. * @param effectWrapper the effect to renderer
  143444. * @param outputTexture texture to draw to, if null it will render to the screen.
  143445. */
  143446. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  143447. /**
  143448. * Disposes of the effect renderer
  143449. */
  143450. dispose(): void;
  143451. }
  143452. /**
  143453. * Options to create an EffectWrapper
  143454. */
  143455. interface EffectWrapperCreationOptions {
  143456. /**
  143457. * Engine to use to create the effect
  143458. */
  143459. engine: ThinEngine;
  143460. /**
  143461. * Fragment shader for the effect
  143462. */
  143463. fragmentShader: string;
  143464. /**
  143465. * Use the shader store instead of direct source code
  143466. */
  143467. useShaderStore?: boolean;
  143468. /**
  143469. * Vertex shader for the effect
  143470. */
  143471. vertexShader?: string;
  143472. /**
  143473. * Attributes to use in the shader
  143474. */
  143475. attributeNames?: Array<string>;
  143476. /**
  143477. * Uniforms to use in the shader
  143478. */
  143479. uniformNames?: Array<string>;
  143480. /**
  143481. * Texture sampler names to use in the shader
  143482. */
  143483. samplerNames?: Array<string>;
  143484. /**
  143485. * Defines to use in the shader
  143486. */
  143487. defines?: Array<string>;
  143488. /**
  143489. * Callback when effect is compiled
  143490. */
  143491. onCompiled?: Nullable<(effect: Effect) => void>;
  143492. /**
  143493. * The friendly name of the effect displayed in Spector.
  143494. */
  143495. name?: string;
  143496. }
  143497. /**
  143498. * Wraps an effect to be used for rendering
  143499. */
  143500. export class EffectWrapper {
  143501. /**
  143502. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  143503. */
  143504. onApplyObservable: Observable<{}>;
  143505. /**
  143506. * The underlying effect
  143507. */
  143508. effect: Effect;
  143509. /**
  143510. * Creates an effect to be renderer
  143511. * @param creationOptions options to create the effect
  143512. */
  143513. constructor(creationOptions: EffectWrapperCreationOptions);
  143514. /**
  143515. * Disposes of the effect wrapper
  143516. */
  143517. dispose(): void;
  143518. }
  143519. }
  143520. declare module BABYLON {
  143521. /** @hidden */
  143522. export var hdrFilteringVertexShader: {
  143523. name: string;
  143524. shader: string;
  143525. };
  143526. }
  143527. declare module BABYLON {
  143528. /** @hidden */
  143529. export var hdrFilteringPixelShader: {
  143530. name: string;
  143531. shader: string;
  143532. };
  143533. }
  143534. declare module BABYLON {
  143535. /**
  143536. * Options for texture filtering
  143537. */
  143538. interface IHDRFilteringOptions {
  143539. /**
  143540. * Scales pixel intensity for the input HDR map.
  143541. */
  143542. hdrScale?: number;
  143543. /**
  143544. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  143545. */
  143546. quality?: number;
  143547. }
  143548. /**
  143549. * Filters HDR maps to get correct renderings of PBR reflections
  143550. */
  143551. export class HDRFiltering {
  143552. private _engine;
  143553. private _effectRenderer;
  143554. private _effectWrapper;
  143555. private _lodGenerationOffset;
  143556. private _lodGenerationScale;
  143557. /**
  143558. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  143559. * you care about baking speed.
  143560. */
  143561. quality: number;
  143562. /**
  143563. * Scales pixel intensity for the input HDR map.
  143564. */
  143565. hdrScale: number;
  143566. /**
  143567. * Instantiates HDR filter for reflection maps
  143568. *
  143569. * @param engine Thin engine
  143570. * @param options Options
  143571. */
  143572. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  143573. private _createRenderTarget;
  143574. private _prefilterInternal;
  143575. private _createEffect;
  143576. /**
  143577. * Get a value indicating if the filter is ready to be used
  143578. * @param texture Texture to filter
  143579. * @returns true if the filter is ready
  143580. */
  143581. isReady(texture: BaseTexture): boolean;
  143582. /**
  143583. * Prefilters a cube texture to have mipmap levels representing roughness values.
  143584. * Prefiltering will be invoked at the end of next rendering pass.
  143585. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  143586. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  143587. * @param texture Texture to filter
  143588. * @param onFinished Callback when filtering is done
  143589. * @return Promise called when prefiltering is done
  143590. */
  143591. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  143592. }
  143593. }
  143594. declare module BABYLON {
  143595. /**
  143596. * This represents a texture coming from an HDR input.
  143597. *
  143598. * The only supported format is currently panorama picture stored in RGBE format.
  143599. * Example of such files can be found on HDRLib: http://hdrlib.com/
  143600. */
  143601. export class HDRCubeTexture extends BaseTexture {
  143602. private static _facesMapping;
  143603. private _generateHarmonics;
  143604. private _noMipmap;
  143605. private _prefilterOnLoad;
  143606. private _textureMatrix;
  143607. private _size;
  143608. private _onLoad;
  143609. private _onError;
  143610. /**
  143611. * The texture URL.
  143612. */
  143613. url: string;
  143614. protected _isBlocking: boolean;
  143615. /**
  143616. * Sets wether or not the texture is blocking during loading.
  143617. */
  143618. set isBlocking(value: boolean);
  143619. /**
  143620. * Gets wether or not the texture is blocking during loading.
  143621. */
  143622. get isBlocking(): boolean;
  143623. protected _rotationY: number;
  143624. /**
  143625. * Sets texture matrix rotation angle around Y axis in radians.
  143626. */
  143627. set rotationY(value: number);
  143628. /**
  143629. * Gets texture matrix rotation angle around Y axis radians.
  143630. */
  143631. get rotationY(): number;
  143632. /**
  143633. * Gets or sets the center of the bounding box associated with the cube texture
  143634. * It must define where the camera used to render the texture was set
  143635. */
  143636. boundingBoxPosition: Vector3;
  143637. private _boundingBoxSize;
  143638. /**
  143639. * Gets or sets the size of the bounding box associated with the cube texture
  143640. * When defined, the cubemap will switch to local mode
  143641. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  143642. * @example https://www.babylonjs-playground.com/#RNASML
  143643. */
  143644. set boundingBoxSize(value: Vector3);
  143645. get boundingBoxSize(): Vector3;
  143646. /**
  143647. * Instantiates an HDRTexture from the following parameters.
  143648. *
  143649. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  143650. * @param sceneOrEngine The scene or engine the texture will be used in
  143651. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143652. * @param noMipmap Forces to not generate the mipmap if true
  143653. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  143654. * @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)
  143655. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  143656. */
  143657. 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>);
  143658. /**
  143659. * Get the current class name of the texture useful for serialization or dynamic coding.
  143660. * @returns "HDRCubeTexture"
  143661. */
  143662. getClassName(): string;
  143663. /**
  143664. * Occurs when the file is raw .hdr file.
  143665. */
  143666. private loadTexture;
  143667. clone(): HDRCubeTexture;
  143668. delayLoad(): void;
  143669. /**
  143670. * Get the texture reflection matrix used to rotate/transform the reflection.
  143671. * @returns the reflection matrix
  143672. */
  143673. getReflectionTextureMatrix(): Matrix;
  143674. /**
  143675. * Set the texture reflection matrix used to rotate/transform the reflection.
  143676. * @param value Define the reflection matrix to set
  143677. */
  143678. setReflectionTextureMatrix(value: Matrix): void;
  143679. /**
  143680. * Parses a JSON representation of an HDR Texture in order to create the texture
  143681. * @param parsedTexture Define the JSON representation
  143682. * @param scene Define the scene the texture should be created in
  143683. * @param rootUrl Define the root url in case we need to load relative dependencies
  143684. * @returns the newly created texture after parsing
  143685. */
  143686. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  143687. serialize(): any;
  143688. }
  143689. }
  143690. declare module BABYLON {
  143691. /**
  143692. * Class used to control physics engine
  143693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143694. */
  143695. export class PhysicsEngine implements IPhysicsEngine {
  143696. private _physicsPlugin;
  143697. /**
  143698. * Global value used to control the smallest number supported by the simulation
  143699. */
  143700. static Epsilon: number;
  143701. private _impostors;
  143702. private _joints;
  143703. private _subTimeStep;
  143704. /**
  143705. * Gets the gravity vector used by the simulation
  143706. */
  143707. gravity: Vector3;
  143708. /**
  143709. * Factory used to create the default physics plugin.
  143710. * @returns The default physics plugin
  143711. */
  143712. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  143713. /**
  143714. * Creates a new Physics Engine
  143715. * @param gravity defines the gravity vector used by the simulation
  143716. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  143717. */
  143718. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  143719. /**
  143720. * Sets the gravity vector used by the simulation
  143721. * @param gravity defines the gravity vector to use
  143722. */
  143723. setGravity(gravity: Vector3): void;
  143724. /**
  143725. * Set the time step of the physics engine.
  143726. * Default is 1/60.
  143727. * To slow it down, enter 1/600 for example.
  143728. * To speed it up, 1/30
  143729. * @param newTimeStep defines the new timestep to apply to this world.
  143730. */
  143731. setTimeStep(newTimeStep?: number): void;
  143732. /**
  143733. * Get the time step of the physics engine.
  143734. * @returns the current time step
  143735. */
  143736. getTimeStep(): number;
  143737. /**
  143738. * Set the sub time step of the physics engine.
  143739. * Default is 0 meaning there is no sub steps
  143740. * To increase physics resolution precision, set a small value (like 1 ms)
  143741. * @param subTimeStep defines the new sub timestep used for physics resolution.
  143742. */
  143743. setSubTimeStep(subTimeStep?: number): void;
  143744. /**
  143745. * Get the sub time step of the physics engine.
  143746. * @returns the current sub time step
  143747. */
  143748. getSubTimeStep(): number;
  143749. /**
  143750. * Release all resources
  143751. */
  143752. dispose(): void;
  143753. /**
  143754. * Gets the name of the current physics plugin
  143755. * @returns the name of the plugin
  143756. */
  143757. getPhysicsPluginName(): string;
  143758. /**
  143759. * Adding a new impostor for the impostor tracking.
  143760. * This will be done by the impostor itself.
  143761. * @param impostor the impostor to add
  143762. */
  143763. addImpostor(impostor: PhysicsImpostor): void;
  143764. /**
  143765. * Remove an impostor from the engine.
  143766. * This impostor and its mesh will not longer be updated by the physics engine.
  143767. * @param impostor the impostor to remove
  143768. */
  143769. removeImpostor(impostor: PhysicsImpostor): void;
  143770. /**
  143771. * Add a joint to the physics engine
  143772. * @param mainImpostor defines the main impostor to which the joint is added.
  143773. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  143774. * @param joint defines the joint that will connect both impostors.
  143775. */
  143776. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143777. /**
  143778. * Removes a joint from the simulation
  143779. * @param mainImpostor defines the impostor used with the joint
  143780. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  143781. * @param joint defines the joint to remove
  143782. */
  143783. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  143784. /**
  143785. * Called by the scene. No need to call it.
  143786. * @param delta defines the timespam between frames
  143787. */
  143788. _step(delta: number): void;
  143789. /**
  143790. * Gets the current plugin used to run the simulation
  143791. * @returns current plugin
  143792. */
  143793. getPhysicsPlugin(): IPhysicsEnginePlugin;
  143794. /**
  143795. * Gets the list of physic impostors
  143796. * @returns an array of PhysicsImpostor
  143797. */
  143798. getImpostors(): Array<PhysicsImpostor>;
  143799. /**
  143800. * Gets the impostor for a physics enabled object
  143801. * @param object defines the object impersonated by the impostor
  143802. * @returns the PhysicsImpostor or null if not found
  143803. */
  143804. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  143805. /**
  143806. * Gets the impostor for a physics body object
  143807. * @param body defines physics body used by the impostor
  143808. * @returns the PhysicsImpostor or null if not found
  143809. */
  143810. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  143811. /**
  143812. * Does a raycast in the physics world
  143813. * @param from when should the ray start?
  143814. * @param to when should the ray end?
  143815. * @returns PhysicsRaycastResult
  143816. */
  143817. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143818. }
  143819. }
  143820. declare module BABYLON {
  143821. /** @hidden */
  143822. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  143823. private _useDeltaForWorldStep;
  143824. world: any;
  143825. name: string;
  143826. private _physicsMaterials;
  143827. private _fixedTimeStep;
  143828. private _cannonRaycastResult;
  143829. private _raycastResult;
  143830. private _physicsBodysToRemoveAfterStep;
  143831. private _firstFrame;
  143832. BJSCANNON: any;
  143833. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  143834. setGravity(gravity: Vector3): void;
  143835. setTimeStep(timeStep: number): void;
  143836. getTimeStep(): number;
  143837. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143838. private _removeMarkedPhysicsBodiesFromWorld;
  143839. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143840. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143841. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143842. private _processChildMeshes;
  143843. removePhysicsBody(impostor: PhysicsImpostor): void;
  143844. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143845. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143846. private _addMaterial;
  143847. private _checkWithEpsilon;
  143848. private _createShape;
  143849. private _createHeightmap;
  143850. private _minus90X;
  143851. private _plus90X;
  143852. private _tmpPosition;
  143853. private _tmpDeltaPosition;
  143854. private _tmpUnityRotation;
  143855. private _updatePhysicsBodyTransformation;
  143856. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143857. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143858. isSupported(): boolean;
  143859. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143860. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143861. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143862. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143863. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143864. getBodyMass(impostor: PhysicsImpostor): number;
  143865. getBodyFriction(impostor: PhysicsImpostor): number;
  143866. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143867. getBodyRestitution(impostor: PhysicsImpostor): number;
  143868. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143869. sleepBody(impostor: PhysicsImpostor): void;
  143870. wakeUpBody(impostor: PhysicsImpostor): void;
  143871. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  143872. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143873. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143874. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143875. getRadius(impostor: PhysicsImpostor): number;
  143876. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143877. dispose(): void;
  143878. private _extendNamespace;
  143879. /**
  143880. * Does a raycast in the physics world
  143881. * @param from when should the ray start?
  143882. * @param to when should the ray end?
  143883. * @returns PhysicsRaycastResult
  143884. */
  143885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143886. }
  143887. }
  143888. declare module BABYLON {
  143889. /** @hidden */
  143890. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  143891. private _useDeltaForWorldStep;
  143892. world: any;
  143893. name: string;
  143894. BJSOIMO: any;
  143895. private _raycastResult;
  143896. private _fixedTimeStep;
  143897. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  143898. setGravity(gravity: Vector3): void;
  143899. setTimeStep(timeStep: number): void;
  143900. getTimeStep(): number;
  143901. private _tmpImpostorsArray;
  143902. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143904. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143905. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143906. private _tmpPositionVector;
  143907. removePhysicsBody(impostor: PhysicsImpostor): void;
  143908. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143909. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143910. isSupported(): boolean;
  143911. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143912. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143913. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143914. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143915. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143916. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143917. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143918. getBodyMass(impostor: PhysicsImpostor): number;
  143919. getBodyFriction(impostor: PhysicsImpostor): number;
  143920. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143921. getBodyRestitution(impostor: PhysicsImpostor): number;
  143922. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143923. sleepBody(impostor: PhysicsImpostor): void;
  143924. wakeUpBody(impostor: PhysicsImpostor): void;
  143925. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143926. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  143927. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  143928. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143929. getRadius(impostor: PhysicsImpostor): number;
  143930. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143931. dispose(): void;
  143932. /**
  143933. * Does a raycast in the physics world
  143934. * @param from when should the ray start?
  143935. * @param to when should the ray end?
  143936. * @returns PhysicsRaycastResult
  143937. */
  143938. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143939. }
  143940. }
  143941. declare module BABYLON {
  143942. /**
  143943. * AmmoJS Physics plugin
  143944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  143945. * @see https://github.com/kripken/ammo.js/
  143946. */
  143947. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  143948. private _useDeltaForWorldStep;
  143949. /**
  143950. * Reference to the Ammo library
  143951. */
  143952. bjsAMMO: any;
  143953. /**
  143954. * Created ammoJS world which physics bodies are added to
  143955. */
  143956. world: any;
  143957. /**
  143958. * Name of the plugin
  143959. */
  143960. name: string;
  143961. private _timeStep;
  143962. private _fixedTimeStep;
  143963. private _maxSteps;
  143964. private _tmpQuaternion;
  143965. private _tmpAmmoTransform;
  143966. private _tmpAmmoQuaternion;
  143967. private _tmpAmmoConcreteContactResultCallback;
  143968. private _collisionConfiguration;
  143969. private _dispatcher;
  143970. private _overlappingPairCache;
  143971. private _solver;
  143972. private _softBodySolver;
  143973. private _tmpAmmoVectorA;
  143974. private _tmpAmmoVectorB;
  143975. private _tmpAmmoVectorC;
  143976. private _tmpAmmoVectorD;
  143977. private _tmpContactCallbackResult;
  143978. private _tmpAmmoVectorRCA;
  143979. private _tmpAmmoVectorRCB;
  143980. private _raycastResult;
  143981. private _tmpContactPoint;
  143982. private static readonly DISABLE_COLLISION_FLAG;
  143983. private static readonly KINEMATIC_FLAG;
  143984. private static readonly DISABLE_DEACTIVATION_FLAG;
  143985. /**
  143986. * Initializes the ammoJS plugin
  143987. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143988. * @param ammoInjection can be used to inject your own ammo reference
  143989. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143990. */
  143991. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143992. /**
  143993. * Sets the gravity of the physics world (m/(s^2))
  143994. * @param gravity Gravity to set
  143995. */
  143996. setGravity(gravity: Vector3): void;
  143997. /**
  143998. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143999. * @param timeStep timestep to use in seconds
  144000. */
  144001. setTimeStep(timeStep: number): void;
  144002. /**
  144003. * 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)
  144004. * @param fixedTimeStep fixedTimeStep to use in seconds
  144005. */
  144006. setFixedTimeStep(fixedTimeStep: number): void;
  144007. /**
  144008. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  144009. * @param maxSteps the maximum number of steps by the physics engine per frame
  144010. */
  144011. setMaxSteps(maxSteps: number): void;
  144012. /**
  144013. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  144014. * @returns the current timestep in seconds
  144015. */
  144016. getTimeStep(): number;
  144017. /**
  144018. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  144019. */
  144020. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  144021. private _isImpostorInContact;
  144022. private _isImpostorPairInContact;
  144023. private _stepSimulation;
  144024. /**
  144025. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  144026. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  144027. * After the step the babylon meshes are set to the position of the physics imposters
  144028. * @param delta amount of time to step forward
  144029. * @param impostors array of imposters to update before/after the step
  144030. */
  144031. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  144032. /**
  144033. * Update babylon mesh to match physics world object
  144034. * @param impostor imposter to match
  144035. */
  144036. private _afterSoftStep;
  144037. /**
  144038. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  144039. * @param impostor imposter to match
  144040. */
  144041. private _ropeStep;
  144042. /**
  144043. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  144044. * @param impostor imposter to match
  144045. */
  144046. private _softbodyOrClothStep;
  144047. private _tmpMatrix;
  144048. /**
  144049. * Applies an impulse on the imposter
  144050. * @param impostor imposter to apply impulse to
  144051. * @param force amount of force to be applied to the imposter
  144052. * @param contactPoint the location to apply the impulse on the imposter
  144053. */
  144054. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  144055. /**
  144056. * Applies a force on the imposter
  144057. * @param impostor imposter to apply force
  144058. * @param force amount of force to be applied to the imposter
  144059. * @param contactPoint the location to apply the force on the imposter
  144060. */
  144061. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  144062. /**
  144063. * Creates a physics body using the plugin
  144064. * @param impostor the imposter to create the physics body on
  144065. */
  144066. generatePhysicsBody(impostor: PhysicsImpostor): void;
  144067. /**
  144068. * Removes the physics body from the imposter and disposes of the body's memory
  144069. * @param impostor imposter to remove the physics body from
  144070. */
  144071. removePhysicsBody(impostor: PhysicsImpostor): void;
  144072. /**
  144073. * Generates a joint
  144074. * @param impostorJoint the imposter joint to create the joint with
  144075. */
  144076. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  144077. /**
  144078. * Removes a joint
  144079. * @param impostorJoint the imposter joint to remove the joint from
  144080. */
  144081. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  144082. private _addMeshVerts;
  144083. /**
  144084. * Initialise the soft body vertices to match its object's (mesh) vertices
  144085. * Softbody vertices (nodes) are in world space and to match this
  144086. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  144087. * @param impostor to create the softbody for
  144088. */
  144089. private _softVertexData;
  144090. /**
  144091. * Create an impostor's soft body
  144092. * @param impostor to create the softbody for
  144093. */
  144094. private _createSoftbody;
  144095. /**
  144096. * Create cloth for an impostor
  144097. * @param impostor to create the softbody for
  144098. */
  144099. private _createCloth;
  144100. /**
  144101. * Create rope for an impostor
  144102. * @param impostor to create the softbody for
  144103. */
  144104. private _createRope;
  144105. /**
  144106. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  144107. * @param impostor to create the custom physics shape for
  144108. */
  144109. private _createCustom;
  144110. private _addHullVerts;
  144111. private _createShape;
  144112. /**
  144113. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  144114. * @param impostor imposter containing the physics body and babylon object
  144115. */
  144116. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  144117. /**
  144118. * Sets the babylon object's position/rotation from the physics body's position/rotation
  144119. * @param impostor imposter containing the physics body and babylon object
  144120. * @param newPosition new position
  144121. * @param newRotation new rotation
  144122. */
  144123. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  144124. /**
  144125. * If this plugin is supported
  144126. * @returns true if its supported
  144127. */
  144128. isSupported(): boolean;
  144129. /**
  144130. * Sets the linear velocity of the physics body
  144131. * @param impostor imposter to set the velocity on
  144132. * @param velocity velocity to set
  144133. */
  144134. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144135. /**
  144136. * Sets the angular velocity of the physics body
  144137. * @param impostor imposter to set the velocity on
  144138. * @param velocity velocity to set
  144139. */
  144140. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  144141. /**
  144142. * gets the linear velocity
  144143. * @param impostor imposter to get linear velocity from
  144144. * @returns linear velocity
  144145. */
  144146. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144147. /**
  144148. * gets the angular velocity
  144149. * @param impostor imposter to get angular velocity from
  144150. * @returns angular velocity
  144151. */
  144152. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  144153. /**
  144154. * Sets the mass of physics body
  144155. * @param impostor imposter to set the mass on
  144156. * @param mass mass to set
  144157. */
  144158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  144159. /**
  144160. * Gets the mass of the physics body
  144161. * @param impostor imposter to get the mass from
  144162. * @returns mass
  144163. */
  144164. getBodyMass(impostor: PhysicsImpostor): number;
  144165. /**
  144166. * Gets friction of the impostor
  144167. * @param impostor impostor to get friction from
  144168. * @returns friction value
  144169. */
  144170. getBodyFriction(impostor: PhysicsImpostor): number;
  144171. /**
  144172. * Sets friction of the impostor
  144173. * @param impostor impostor to set friction on
  144174. * @param friction friction value
  144175. */
  144176. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  144177. /**
  144178. * Gets restitution of the impostor
  144179. * @param impostor impostor to get restitution from
  144180. * @returns restitution value
  144181. */
  144182. getBodyRestitution(impostor: PhysicsImpostor): number;
  144183. /**
  144184. * Sets resitution of the impostor
  144185. * @param impostor impostor to set resitution on
  144186. * @param restitution resitution value
  144187. */
  144188. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  144189. /**
  144190. * Gets pressure inside the impostor
  144191. * @param impostor impostor to get pressure from
  144192. * @returns pressure value
  144193. */
  144194. getBodyPressure(impostor: PhysicsImpostor): number;
  144195. /**
  144196. * Sets pressure inside a soft body impostor
  144197. * Cloth and rope must remain 0 pressure
  144198. * @param impostor impostor to set pressure on
  144199. * @param pressure pressure value
  144200. */
  144201. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  144202. /**
  144203. * Gets stiffness of the impostor
  144204. * @param impostor impostor to get stiffness from
  144205. * @returns pressure value
  144206. */
  144207. getBodyStiffness(impostor: PhysicsImpostor): number;
  144208. /**
  144209. * Sets stiffness of the impostor
  144210. * @param impostor impostor to set stiffness on
  144211. * @param stiffness stiffness value from 0 to 1
  144212. */
  144213. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  144214. /**
  144215. * Gets velocityIterations of the impostor
  144216. * @param impostor impostor to get velocity iterations from
  144217. * @returns velocityIterations value
  144218. */
  144219. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  144220. /**
  144221. * Sets velocityIterations of the impostor
  144222. * @param impostor impostor to set velocity iterations on
  144223. * @param velocityIterations velocityIterations value
  144224. */
  144225. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  144226. /**
  144227. * Gets positionIterations of the impostor
  144228. * @param impostor impostor to get position iterations from
  144229. * @returns positionIterations value
  144230. */
  144231. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  144232. /**
  144233. * Sets positionIterations of the impostor
  144234. * @param impostor impostor to set position on
  144235. * @param positionIterations positionIterations value
  144236. */
  144237. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  144238. /**
  144239. * Append an anchor to a cloth object
  144240. * @param impostor is the cloth impostor to add anchor to
  144241. * @param otherImpostor is the rigid impostor to anchor to
  144242. * @param width ratio across width from 0 to 1
  144243. * @param height ratio up height from 0 to 1
  144244. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  144245. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144246. */
  144247. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144248. /**
  144249. * Append an hook to a rope object
  144250. * @param impostor is the rope impostor to add hook to
  144251. * @param otherImpostor is the rigid impostor to hook to
  144252. * @param length ratio along the rope from 0 to 1
  144253. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  144254. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  144255. */
  144256. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  144257. /**
  144258. * Sleeps the physics body and stops it from being active
  144259. * @param impostor impostor to sleep
  144260. */
  144261. sleepBody(impostor: PhysicsImpostor): void;
  144262. /**
  144263. * Activates the physics body
  144264. * @param impostor impostor to activate
  144265. */
  144266. wakeUpBody(impostor: PhysicsImpostor): void;
  144267. /**
  144268. * Updates the distance parameters of the joint
  144269. * @param joint joint to update
  144270. * @param maxDistance maximum distance of the joint
  144271. * @param minDistance minimum distance of the joint
  144272. */
  144273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  144274. /**
  144275. * Sets a motor on the joint
  144276. * @param joint joint to set motor on
  144277. * @param speed speed of the motor
  144278. * @param maxForce maximum force of the motor
  144279. * @param motorIndex index of the motor
  144280. */
  144281. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  144282. /**
  144283. * Sets the motors limit
  144284. * @param joint joint to set limit on
  144285. * @param upperLimit upper limit
  144286. * @param lowerLimit lower limit
  144287. */
  144288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  144289. /**
  144290. * Syncs the position and rotation of a mesh with the impostor
  144291. * @param mesh mesh to sync
  144292. * @param impostor impostor to update the mesh with
  144293. */
  144294. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  144295. /**
  144296. * Gets the radius of the impostor
  144297. * @param impostor impostor to get radius from
  144298. * @returns the radius
  144299. */
  144300. getRadius(impostor: PhysicsImpostor): number;
  144301. /**
  144302. * Gets the box size of the impostor
  144303. * @param impostor impostor to get box size from
  144304. * @param result the resulting box size
  144305. */
  144306. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  144307. /**
  144308. * Disposes of the impostor
  144309. */
  144310. dispose(): void;
  144311. /**
  144312. * Does a raycast in the physics world
  144313. * @param from when should the ray start?
  144314. * @param to when should the ray end?
  144315. * @returns PhysicsRaycastResult
  144316. */
  144317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  144318. }
  144319. }
  144320. declare module BABYLON {
  144321. interface AbstractScene {
  144322. /**
  144323. * The list of reflection probes added to the scene
  144324. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144325. */
  144326. reflectionProbes: Array<ReflectionProbe>;
  144327. /**
  144328. * Removes the given reflection probe from this scene.
  144329. * @param toRemove The reflection probe to remove
  144330. * @returns The index of the removed reflection probe
  144331. */
  144332. removeReflectionProbe(toRemove: ReflectionProbe): number;
  144333. /**
  144334. * Adds the given reflection probe to this scene.
  144335. * @param newReflectionProbe The reflection probe to add
  144336. */
  144337. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  144338. }
  144339. /**
  144340. * Class used to generate realtime reflection / refraction cube textures
  144341. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  144342. */
  144343. export class ReflectionProbe {
  144344. /** defines the name of the probe */
  144345. name: string;
  144346. private _scene;
  144347. private _renderTargetTexture;
  144348. private _projectionMatrix;
  144349. private _viewMatrix;
  144350. private _target;
  144351. private _add;
  144352. private _attachedMesh;
  144353. private _invertYAxis;
  144354. /** Gets or sets probe position (center of the cube map) */
  144355. position: Vector3;
  144356. /**
  144357. * Creates a new reflection probe
  144358. * @param name defines the name of the probe
  144359. * @param size defines the texture resolution (for each face)
  144360. * @param scene defines the hosting scene
  144361. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  144362. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  144363. */
  144364. constructor(
  144365. /** defines the name of the probe */
  144366. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  144367. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  144368. get samples(): number;
  144369. set samples(value: number);
  144370. /** Gets or sets the refresh rate to use (on every frame by default) */
  144371. get refreshRate(): number;
  144372. set refreshRate(value: number);
  144373. /**
  144374. * Gets the hosting scene
  144375. * @returns a Scene
  144376. */
  144377. getScene(): Scene;
  144378. /** Gets the internal CubeTexture used to render to */
  144379. get cubeTexture(): RenderTargetTexture;
  144380. /** Gets the list of meshes to render */
  144381. get renderList(): Nullable<AbstractMesh[]>;
  144382. /**
  144383. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  144384. * @param mesh defines the mesh to attach to
  144385. */
  144386. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  144387. /**
  144388. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  144389. * @param renderingGroupId The rendering group id corresponding to its index
  144390. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  144391. */
  144392. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  144393. /**
  144394. * Clean all associated resources
  144395. */
  144396. dispose(): void;
  144397. /**
  144398. * Converts the reflection probe information to a readable string for debug purpose.
  144399. * @param fullDetails Supports for multiple levels of logging within scene loading
  144400. * @returns the human readable reflection probe info
  144401. */
  144402. toString(fullDetails?: boolean): string;
  144403. /**
  144404. * Get the class name of the relfection probe.
  144405. * @returns "ReflectionProbe"
  144406. */
  144407. getClassName(): string;
  144408. /**
  144409. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  144410. * @returns The JSON representation of the texture
  144411. */
  144412. serialize(): any;
  144413. /**
  144414. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  144415. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  144416. * @param scene Define the scene the parsed reflection probe should be instantiated in
  144417. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  144418. * @returns The parsed reflection probe if successful
  144419. */
  144420. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  144421. }
  144422. }
  144423. declare module BABYLON {
  144424. /** @hidden */
  144425. export var _BabylonLoaderRegistered: boolean;
  144426. /**
  144427. * Helps setting up some configuration for the babylon file loader.
  144428. */
  144429. export class BabylonFileLoaderConfiguration {
  144430. /**
  144431. * The loader does not allow injecting custom physix engine into the plugins.
  144432. * Unfortunately in ES6, we need to manually inject them into the plugin.
  144433. * So you could set this variable to your engine import to make it work.
  144434. */
  144435. static LoaderInjectedPhysicsEngine: any;
  144436. }
  144437. }
  144438. declare module BABYLON {
  144439. /**
  144440. * The Physically based simple base material of BJS.
  144441. *
  144442. * This enables better naming and convention enforcements on top of the pbrMaterial.
  144443. * It is used as the base class for both the specGloss and metalRough conventions.
  144444. */
  144445. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  144446. /**
  144447. * Number of Simultaneous lights allowed on the material.
  144448. */
  144449. maxSimultaneousLights: number;
  144450. /**
  144451. * If sets to true, disables all the lights affecting the material.
  144452. */
  144453. disableLighting: boolean;
  144454. /**
  144455. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  144456. */
  144457. environmentTexture: BaseTexture;
  144458. /**
  144459. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  144460. */
  144461. invertNormalMapX: boolean;
  144462. /**
  144463. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  144464. */
  144465. invertNormalMapY: boolean;
  144466. /**
  144467. * Normal map used in the model.
  144468. */
  144469. normalTexture: BaseTexture;
  144470. /**
  144471. * Emissivie color used to self-illuminate the model.
  144472. */
  144473. emissiveColor: Color3;
  144474. /**
  144475. * Emissivie texture used to self-illuminate the model.
  144476. */
  144477. emissiveTexture: BaseTexture;
  144478. /**
  144479. * Occlusion Channel Strenght.
  144480. */
  144481. occlusionStrength: number;
  144482. /**
  144483. * Occlusion Texture of the material (adding extra occlusion effects).
  144484. */
  144485. occlusionTexture: BaseTexture;
  144486. /**
  144487. * Defines the alpha limits in alpha test mode.
  144488. */
  144489. alphaCutOff: number;
  144490. /**
  144491. * Gets the current double sided mode.
  144492. */
  144493. get doubleSided(): boolean;
  144494. /**
  144495. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  144496. */
  144497. set doubleSided(value: boolean);
  144498. /**
  144499. * Stores the pre-calculated light information of a mesh in a texture.
  144500. */
  144501. lightmapTexture: BaseTexture;
  144502. /**
  144503. * If true, the light map contains occlusion information instead of lighting info.
  144504. */
  144505. useLightmapAsShadowmap: boolean;
  144506. /**
  144507. * Instantiates a new PBRMaterial instance.
  144508. *
  144509. * @param name The material name
  144510. * @param scene The scene the material will be use in.
  144511. */
  144512. constructor(name: string, scene: Scene);
  144513. getClassName(): string;
  144514. }
  144515. }
  144516. declare module BABYLON {
  144517. /**
  144518. * The PBR material of BJS following the metal roughness convention.
  144519. *
  144520. * This fits to the PBR convention in the GLTF definition:
  144521. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  144522. */
  144523. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  144524. /**
  144525. * The base color has two different interpretations depending on the value of metalness.
  144526. * When the material is a metal, the base color is the specific measured reflectance value
  144527. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  144528. * of the material.
  144529. */
  144530. baseColor: Color3;
  144531. /**
  144532. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  144533. * well as opacity information in the alpha channel.
  144534. */
  144535. baseTexture: BaseTexture;
  144536. /**
  144537. * Specifies the metallic scalar value of the material.
  144538. * Can also be used to scale the metalness values of the metallic texture.
  144539. */
  144540. metallic: number;
  144541. /**
  144542. * Specifies the roughness scalar value of the material.
  144543. * Can also be used to scale the roughness values of the metallic texture.
  144544. */
  144545. roughness: number;
  144546. /**
  144547. * Texture containing both the metallic value in the B channel and the
  144548. * roughness value in the G channel to keep better precision.
  144549. */
  144550. metallicRoughnessTexture: BaseTexture;
  144551. /**
  144552. * Instantiates a new PBRMetalRoughnessMaterial instance.
  144553. *
  144554. * @param name The material name
  144555. * @param scene The scene the material will be use in.
  144556. */
  144557. constructor(name: string, scene: Scene);
  144558. /**
  144559. * Return the currrent class name of the material.
  144560. */
  144561. getClassName(): string;
  144562. /**
  144563. * Makes a duplicate of the current material.
  144564. * @param name - name to use for the new material.
  144565. */
  144566. clone(name: string): PBRMetallicRoughnessMaterial;
  144567. /**
  144568. * Serialize the material to a parsable JSON object.
  144569. */
  144570. serialize(): any;
  144571. /**
  144572. * Parses a JSON object correponding to the serialize function.
  144573. */
  144574. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  144575. }
  144576. }
  144577. declare module BABYLON {
  144578. /**
  144579. * The PBR material of BJS following the specular glossiness convention.
  144580. *
  144581. * This fits to the PBR convention in the GLTF definition:
  144582. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  144583. */
  144584. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  144585. /**
  144586. * Specifies the diffuse color of the material.
  144587. */
  144588. diffuseColor: Color3;
  144589. /**
  144590. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  144591. * channel.
  144592. */
  144593. diffuseTexture: BaseTexture;
  144594. /**
  144595. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  144596. */
  144597. specularColor: Color3;
  144598. /**
  144599. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  144600. */
  144601. glossiness: number;
  144602. /**
  144603. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  144604. */
  144605. specularGlossinessTexture: BaseTexture;
  144606. /**
  144607. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  144608. *
  144609. * @param name The material name
  144610. * @param scene The scene the material will be use in.
  144611. */
  144612. constructor(name: string, scene: Scene);
  144613. /**
  144614. * Return the currrent class name of the material.
  144615. */
  144616. getClassName(): string;
  144617. /**
  144618. * Makes a duplicate of the current material.
  144619. * @param name - name to use for the new material.
  144620. */
  144621. clone(name: string): PBRSpecularGlossinessMaterial;
  144622. /**
  144623. * Serialize the material to a parsable JSON object.
  144624. */
  144625. serialize(): any;
  144626. /**
  144627. * Parses a JSON object correponding to the serialize function.
  144628. */
  144629. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  144630. }
  144631. }
  144632. declare module BABYLON {
  144633. /**
  144634. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  144635. * It can help converting any input color in a desired output one. This can then be used to create effects
  144636. * from sepia, black and white to sixties or futuristic rendering...
  144637. *
  144638. * The only supported format is currently 3dl.
  144639. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  144640. */
  144641. export class ColorGradingTexture extends BaseTexture {
  144642. /**
  144643. * The texture URL.
  144644. */
  144645. url: string;
  144646. /**
  144647. * Empty line regex stored for GC.
  144648. */
  144649. private static _noneEmptyLineRegex;
  144650. private _textureMatrix;
  144651. private _onLoad;
  144652. /**
  144653. * Instantiates a ColorGradingTexture from the following parameters.
  144654. *
  144655. * @param url The location of the color gradind data (currently only supporting 3dl)
  144656. * @param sceneOrEngine The scene or engine the texture will be used in
  144657. * @param onLoad defines a callback triggered when the texture has been loaded
  144658. */
  144659. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  144660. /**
  144661. * Fires the onload event from the constructor if requested.
  144662. */
  144663. private _triggerOnLoad;
  144664. /**
  144665. * Returns the texture matrix used in most of the material.
  144666. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  144667. */
  144668. getTextureMatrix(): Matrix;
  144669. /**
  144670. * Occurs when the file being loaded is a .3dl LUT file.
  144671. */
  144672. private load3dlTexture;
  144673. /**
  144674. * Starts the loading process of the texture.
  144675. */
  144676. private loadTexture;
  144677. /**
  144678. * Clones the color gradind texture.
  144679. */
  144680. clone(): ColorGradingTexture;
  144681. /**
  144682. * Called during delayed load for textures.
  144683. */
  144684. delayLoad(): void;
  144685. /**
  144686. * Parses a color grading texture serialized by Babylon.
  144687. * @param parsedTexture The texture information being parsedTexture
  144688. * @param scene The scene to load the texture in
  144689. * @param rootUrl The root url of the data assets to load
  144690. * @return A color gradind texture
  144691. */
  144692. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  144693. /**
  144694. * Serializes the LUT texture to json format.
  144695. */
  144696. serialize(): any;
  144697. }
  144698. }
  144699. declare module BABYLON {
  144700. /**
  144701. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  144702. */
  144703. export class EquiRectangularCubeTexture extends BaseTexture {
  144704. /** The six faces of the cube. */
  144705. private static _FacesMapping;
  144706. private _noMipmap;
  144707. private _onLoad;
  144708. private _onError;
  144709. /** The size of the cubemap. */
  144710. private _size;
  144711. /** The buffer of the image. */
  144712. private _buffer;
  144713. /** The width of the input image. */
  144714. private _width;
  144715. /** The height of the input image. */
  144716. private _height;
  144717. /** The URL to the image. */
  144718. url: string;
  144719. /**
  144720. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  144721. * @param url The location of the image
  144722. * @param scene The scene the texture will be used in
  144723. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  144724. * @param noMipmap Forces to not generate the mipmap if true
  144725. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  144726. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  144727. * @param onLoad — defines a callback called when texture is loaded
  144728. * @param onError — defines a callback called if there is an error
  144729. */
  144730. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  144731. /**
  144732. * Load the image data, by putting the image on a canvas and extracting its buffer.
  144733. */
  144734. private loadImage;
  144735. /**
  144736. * Convert the image buffer into a cubemap and create a CubeTexture.
  144737. */
  144738. private loadTexture;
  144739. /**
  144740. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  144741. * @param buffer The ArrayBuffer that should be converted.
  144742. * @returns The buffer as Float32Array.
  144743. */
  144744. private getFloat32ArrayFromArrayBuffer;
  144745. /**
  144746. * Get the current class name of the texture useful for serialization or dynamic coding.
  144747. * @returns "EquiRectangularCubeTexture"
  144748. */
  144749. getClassName(): string;
  144750. /**
  144751. * Create a clone of the current EquiRectangularCubeTexture and return it.
  144752. * @returns A clone of the current EquiRectangularCubeTexture.
  144753. */
  144754. clone(): EquiRectangularCubeTexture;
  144755. }
  144756. }
  144757. declare module BABYLON {
  144758. /**
  144759. * Defines the options related to the creation of an HtmlElementTexture
  144760. */
  144761. export interface IHtmlElementTextureOptions {
  144762. /**
  144763. * Defines wether mip maps should be created or not.
  144764. */
  144765. generateMipMaps?: boolean;
  144766. /**
  144767. * Defines the sampling mode of the texture.
  144768. */
  144769. samplingMode?: number;
  144770. /**
  144771. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  144772. */
  144773. engine: Nullable<ThinEngine>;
  144774. /**
  144775. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  144776. */
  144777. scene: Nullable<Scene>;
  144778. }
  144779. /**
  144780. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  144781. * To be as efficient as possible depending on your constraints nothing aside the first upload
  144782. * is automatically managed.
  144783. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  144784. * in your application.
  144785. *
  144786. * As the update is not automatic, you need to call them manually.
  144787. */
  144788. export class HtmlElementTexture extends BaseTexture {
  144789. /**
  144790. * The texture URL.
  144791. */
  144792. element: HTMLVideoElement | HTMLCanvasElement;
  144793. private static readonly DefaultOptions;
  144794. private _textureMatrix;
  144795. private _isVideo;
  144796. private _generateMipMaps;
  144797. private _samplingMode;
  144798. /**
  144799. * Instantiates a HtmlElementTexture from the following parameters.
  144800. *
  144801. * @param name Defines the name of the texture
  144802. * @param element Defines the video or canvas the texture is filled with
  144803. * @param options Defines the other none mandatory texture creation options
  144804. */
  144805. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  144806. private _createInternalTexture;
  144807. /**
  144808. * Returns the texture matrix used in most of the material.
  144809. */
  144810. getTextureMatrix(): Matrix;
  144811. /**
  144812. * Updates the content of the texture.
  144813. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  144814. */
  144815. update(invertY?: Nullable<boolean>): void;
  144816. }
  144817. }
  144818. declare module BABYLON {
  144819. /**
  144820. * Based on jsTGALoader - Javascript loader for TGA file
  144821. * By Vincent Thibault
  144822. * @see http://blog.robrowser.com/javascript-tga-loader.html
  144823. */
  144824. export class TGATools {
  144825. private static _TYPE_INDEXED;
  144826. private static _TYPE_RGB;
  144827. private static _TYPE_GREY;
  144828. private static _TYPE_RLE_INDEXED;
  144829. private static _TYPE_RLE_RGB;
  144830. private static _TYPE_RLE_GREY;
  144831. private static _ORIGIN_MASK;
  144832. private static _ORIGIN_SHIFT;
  144833. private static _ORIGIN_BL;
  144834. private static _ORIGIN_BR;
  144835. private static _ORIGIN_UL;
  144836. private static _ORIGIN_UR;
  144837. /**
  144838. * Gets the header of a TGA file
  144839. * @param data defines the TGA data
  144840. * @returns the header
  144841. */
  144842. static GetTGAHeader(data: Uint8Array): any;
  144843. /**
  144844. * Uploads TGA content to a Babylon Texture
  144845. * @hidden
  144846. */
  144847. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  144848. /** @hidden */
  144849. 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;
  144850. /** @hidden */
  144851. 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;
  144852. /** @hidden */
  144853. 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;
  144854. /** @hidden */
  144855. 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;
  144856. /** @hidden */
  144857. 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;
  144858. /** @hidden */
  144859. 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;
  144860. }
  144861. }
  144862. declare module BABYLON {
  144863. /**
  144864. * Implementation of the TGA Texture Loader.
  144865. * @hidden
  144866. */
  144867. export class _TGATextureLoader implements IInternalTextureLoader {
  144868. /**
  144869. * Defines wether the loader supports cascade loading the different faces.
  144870. */
  144871. readonly supportCascades: boolean;
  144872. /**
  144873. * This returns if the loader support the current file information.
  144874. * @param extension defines the file extension of the file being loaded
  144875. * @returns true if the loader can load the specified file
  144876. */
  144877. canLoad(extension: string): boolean;
  144878. /**
  144879. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144880. * @param data contains the texture data
  144881. * @param texture defines the BabylonJS internal texture
  144882. * @param createPolynomials will be true if polynomials have been requested
  144883. * @param onLoad defines the callback to trigger once the texture is ready
  144884. * @param onError defines the callback to trigger in case of error
  144885. */
  144886. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144887. /**
  144888. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144889. * @param data contains the texture data
  144890. * @param texture defines the BabylonJS internal texture
  144891. * @param callback defines the method to call once ready to upload
  144892. */
  144893. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144894. }
  144895. }
  144896. declare module BABYLON {
  144897. /**
  144898. * Info about the .basis files
  144899. */
  144900. class BasisFileInfo {
  144901. /**
  144902. * If the file has alpha
  144903. */
  144904. hasAlpha: boolean;
  144905. /**
  144906. * Info about each image of the basis file
  144907. */
  144908. images: Array<{
  144909. levels: Array<{
  144910. width: number;
  144911. height: number;
  144912. transcodedPixels: ArrayBufferView;
  144913. }>;
  144914. }>;
  144915. }
  144916. /**
  144917. * Result of transcoding a basis file
  144918. */
  144919. class TranscodeResult {
  144920. /**
  144921. * Info about the .basis file
  144922. */
  144923. fileInfo: BasisFileInfo;
  144924. /**
  144925. * Format to use when loading the file
  144926. */
  144927. format: number;
  144928. }
  144929. /**
  144930. * Configuration options for the Basis transcoder
  144931. */
  144932. export class BasisTranscodeConfiguration {
  144933. /**
  144934. * Supported compression formats used to determine the supported output format of the transcoder
  144935. */
  144936. supportedCompressionFormats?: {
  144937. /**
  144938. * etc1 compression format
  144939. */
  144940. etc1?: boolean;
  144941. /**
  144942. * s3tc compression format
  144943. */
  144944. s3tc?: boolean;
  144945. /**
  144946. * pvrtc compression format
  144947. */
  144948. pvrtc?: boolean;
  144949. /**
  144950. * etc2 compression format
  144951. */
  144952. etc2?: boolean;
  144953. };
  144954. /**
  144955. * If mipmap levels should be loaded for transcoded images (Default: true)
  144956. */
  144957. loadMipmapLevels?: boolean;
  144958. /**
  144959. * Index of a single image to load (Default: all images)
  144960. */
  144961. loadSingleImage?: number;
  144962. }
  144963. /**
  144964. * Used to load .Basis files
  144965. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144966. */
  144967. export class BasisTools {
  144968. private static _IgnoreSupportedFormats;
  144969. /**
  144970. * URL to use when loading the basis transcoder
  144971. */
  144972. static JSModuleURL: string;
  144973. /**
  144974. * URL to use when loading the wasm module for the transcoder
  144975. */
  144976. static WasmModuleURL: string;
  144977. /**
  144978. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144979. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144980. * @returns internal format corresponding to the Basis format
  144981. */
  144982. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144983. private static _WorkerPromise;
  144984. private static _Worker;
  144985. private static _actionId;
  144986. private static _CreateWorkerAsync;
  144987. /**
  144988. * Transcodes a loaded image file to compressed pixel data
  144989. * @param data image data to transcode
  144990. * @param config configuration options for the transcoding
  144991. * @returns a promise resulting in the transcoded image
  144992. */
  144993. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144994. /**
  144995. * Loads a texture from the transcode result
  144996. * @param texture texture load to
  144997. * @param transcodeResult the result of transcoding the basis file to load from
  144998. */
  144999. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  145000. }
  145001. }
  145002. declare module BABYLON {
  145003. /**
  145004. * Loader for .basis file format
  145005. */
  145006. export class _BasisTextureLoader implements IInternalTextureLoader {
  145007. /**
  145008. * Defines whether the loader supports cascade loading the different faces.
  145009. */
  145010. readonly supportCascades: boolean;
  145011. /**
  145012. * This returns if the loader support the current file information.
  145013. * @param extension defines the file extension of the file being loaded
  145014. * @returns true if the loader can load the specified file
  145015. */
  145016. canLoad(extension: string): boolean;
  145017. /**
  145018. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  145019. * @param data contains the texture data
  145020. * @param texture defines the BabylonJS internal texture
  145021. * @param createPolynomials will be true if polynomials have been requested
  145022. * @param onLoad defines the callback to trigger once the texture is ready
  145023. * @param onError defines the callback to trigger in case of error
  145024. */
  145025. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  145026. /**
  145027. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  145028. * @param data contains the texture data
  145029. * @param texture defines the BabylonJS internal texture
  145030. * @param callback defines the method to call once ready to upload
  145031. */
  145032. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  145033. }
  145034. }
  145035. declare module BABYLON {
  145036. /**
  145037. * Defines the basic options interface of a TexturePacker Frame
  145038. */
  145039. export interface ITexturePackerFrame {
  145040. /**
  145041. * The frame ID
  145042. */
  145043. id: number;
  145044. /**
  145045. * The frames Scale
  145046. */
  145047. scale: Vector2;
  145048. /**
  145049. * The Frames offset
  145050. */
  145051. offset: Vector2;
  145052. }
  145053. /**
  145054. * This is a support class for frame Data on texture packer sets.
  145055. */
  145056. export class TexturePackerFrame implements ITexturePackerFrame {
  145057. /**
  145058. * The frame ID
  145059. */
  145060. id: number;
  145061. /**
  145062. * The frames Scale
  145063. */
  145064. scale: Vector2;
  145065. /**
  145066. * The Frames offset
  145067. */
  145068. offset: Vector2;
  145069. /**
  145070. * Initializes a texture package frame.
  145071. * @param id The numerical frame identifier
  145072. * @param scale Scalar Vector2 for UV frame
  145073. * @param offset Vector2 for the frame position in UV units.
  145074. * @returns TexturePackerFrame
  145075. */
  145076. constructor(id: number, scale: Vector2, offset: Vector2);
  145077. }
  145078. }
  145079. declare module BABYLON {
  145080. /**
  145081. * Defines the basic options interface of a TexturePacker
  145082. */
  145083. export interface ITexturePackerOptions {
  145084. /**
  145085. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  145086. */
  145087. map?: string[];
  145088. /**
  145089. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  145090. */
  145091. uvsIn?: string;
  145092. /**
  145093. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  145094. */
  145095. uvsOut?: string;
  145096. /**
  145097. * number representing the layout style. Defaults to LAYOUT_STRIP
  145098. */
  145099. layout?: number;
  145100. /**
  145101. * number of columns if using custom column count layout(2). This defaults to 4.
  145102. */
  145103. colnum?: number;
  145104. /**
  145105. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  145106. */
  145107. updateInputMeshes?: boolean;
  145108. /**
  145109. * boolean flag to dispose all the source textures. Defaults to true.
  145110. */
  145111. disposeSources?: boolean;
  145112. /**
  145113. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  145114. */
  145115. fillBlanks?: boolean;
  145116. /**
  145117. * string value representing the context fill style color. Defaults to 'black'.
  145118. */
  145119. customFillColor?: string;
  145120. /**
  145121. * Width and Height Value of each Frame in the TexturePacker Sets
  145122. */
  145123. frameSize?: number;
  145124. /**
  145125. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  145126. */
  145127. paddingRatio?: number;
  145128. /**
  145129. * Number that declares the fill method for the padding gutter.
  145130. */
  145131. paddingMode?: number;
  145132. /**
  145133. * If in SUBUV_COLOR padding mode what color to use.
  145134. */
  145135. paddingColor?: Color3 | Color4;
  145136. }
  145137. /**
  145138. * Defines the basic interface of a TexturePacker JSON File
  145139. */
  145140. export interface ITexturePackerJSON {
  145141. /**
  145142. * The frame ID
  145143. */
  145144. name: string;
  145145. /**
  145146. * The base64 channel data
  145147. */
  145148. sets: any;
  145149. /**
  145150. * The options of the Packer
  145151. */
  145152. options: ITexturePackerOptions;
  145153. /**
  145154. * The frame data of the Packer
  145155. */
  145156. frames: Array<number>;
  145157. }
  145158. /**
  145159. * This is a support class that generates a series of packed texture sets.
  145160. * @see https://doc.babylonjs.com/babylon101/materials
  145161. */
  145162. export class TexturePacker {
  145163. /** Packer Layout Constant 0 */
  145164. static readonly LAYOUT_STRIP: number;
  145165. /** Packer Layout Constant 1 */
  145166. static readonly LAYOUT_POWER2: number;
  145167. /** Packer Layout Constant 2 */
  145168. static readonly LAYOUT_COLNUM: number;
  145169. /** Packer Layout Constant 0 */
  145170. static readonly SUBUV_WRAP: number;
  145171. /** Packer Layout Constant 1 */
  145172. static readonly SUBUV_EXTEND: number;
  145173. /** Packer Layout Constant 2 */
  145174. static readonly SUBUV_COLOR: number;
  145175. /** The Name of the Texture Package */
  145176. name: string;
  145177. /** The scene scope of the TexturePacker */
  145178. scene: Scene;
  145179. /** The Meshes to target */
  145180. meshes: AbstractMesh[];
  145181. /** Arguments passed with the Constructor */
  145182. options: ITexturePackerOptions;
  145183. /** The promise that is started upon initialization */
  145184. promise: Nullable<Promise<TexturePacker | string>>;
  145185. /** The Container object for the channel sets that are generated */
  145186. sets: object;
  145187. /** The Container array for the frames that are generated */
  145188. frames: TexturePackerFrame[];
  145189. /** The expected number of textures the system is parsing. */
  145190. private _expecting;
  145191. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  145192. private _paddingValue;
  145193. /**
  145194. * Initializes a texture package series from an array of meshes or a single mesh.
  145195. * @param name The name of the package
  145196. * @param meshes The target meshes to compose the package from
  145197. * @param options The arguments that texture packer should follow while building.
  145198. * @param scene The scene which the textures are scoped to.
  145199. * @returns TexturePacker
  145200. */
  145201. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  145202. /**
  145203. * Starts the package process
  145204. * @param resolve The promises resolution function
  145205. * @returns TexturePacker
  145206. */
  145207. private _createFrames;
  145208. /**
  145209. * Calculates the Size of the Channel Sets
  145210. * @returns Vector2
  145211. */
  145212. private _calculateSize;
  145213. /**
  145214. * Calculates the UV data for the frames.
  145215. * @param baseSize the base frameSize
  145216. * @param padding the base frame padding
  145217. * @param dtSize size of the Dynamic Texture for that channel
  145218. * @param dtUnits is 1/dtSize
  145219. * @param update flag to update the input meshes
  145220. */
  145221. private _calculateMeshUVFrames;
  145222. /**
  145223. * Calculates the frames Offset.
  145224. * @param index of the frame
  145225. * @returns Vector2
  145226. */
  145227. private _getFrameOffset;
  145228. /**
  145229. * Updates a Mesh to the frame data
  145230. * @param mesh that is the target
  145231. * @param frameID or the frame index
  145232. */
  145233. private _updateMeshUV;
  145234. /**
  145235. * Updates a Meshes materials to use the texture packer channels
  145236. * @param m is the mesh to target
  145237. * @param force all channels on the packer to be set.
  145238. */
  145239. private _updateTextureReferences;
  145240. /**
  145241. * Public method to set a Mesh to a frame
  145242. * @param m that is the target
  145243. * @param frameID or the frame index
  145244. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  145245. */
  145246. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  145247. /**
  145248. * Starts the async promise to compile the texture packer.
  145249. * @returns Promise<void>
  145250. */
  145251. processAsync(): Promise<void>;
  145252. /**
  145253. * Disposes all textures associated with this packer
  145254. */
  145255. dispose(): void;
  145256. /**
  145257. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  145258. * @param imageType is the image type to use.
  145259. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  145260. */
  145261. download(imageType?: string, quality?: number): void;
  145262. /**
  145263. * Public method to load a texturePacker JSON file.
  145264. * @param data of the JSON file in string format.
  145265. */
  145266. updateFromJSON(data: string): void;
  145267. }
  145268. }
  145269. declare module BABYLON {
  145270. /**
  145271. * 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.
  145272. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145273. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145274. */
  145275. export class CustomProceduralTexture extends ProceduralTexture {
  145276. private _animate;
  145277. private _time;
  145278. private _config;
  145279. private _texturePath;
  145280. /**
  145281. * Instantiates a new Custom Procedural Texture.
  145282. * 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.
  145283. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  145284. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  145285. * @param name Define the name of the texture
  145286. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  145287. * @param size Define the size of the texture to create
  145288. * @param scene Define the scene the texture belongs to
  145289. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  145290. * @param generateMipMaps Define if the texture should creates mip maps or not
  145291. */
  145292. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145293. private _loadJson;
  145294. /**
  145295. * Is the texture ready to be used ? (rendered at least once)
  145296. * @returns true if ready, otherwise, false.
  145297. */
  145298. isReady(): boolean;
  145299. /**
  145300. * Render the texture to its associated render target.
  145301. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  145302. */
  145303. render(useCameraPostProcess?: boolean): void;
  145304. /**
  145305. * Update the list of dependant textures samplers in the shader.
  145306. */
  145307. updateTextures(): void;
  145308. /**
  145309. * Update the uniform values of the procedural texture in the shader.
  145310. */
  145311. updateShaderUniforms(): void;
  145312. /**
  145313. * Define if the texture animates or not.
  145314. */
  145315. get animate(): boolean;
  145316. set animate(value: boolean);
  145317. }
  145318. }
  145319. declare module BABYLON {
  145320. /** @hidden */
  145321. export var noisePixelShader: {
  145322. name: string;
  145323. shader: string;
  145324. };
  145325. }
  145326. declare module BABYLON {
  145327. /**
  145328. * Class used to generate noise procedural textures
  145329. */
  145330. export class NoiseProceduralTexture extends ProceduralTexture {
  145331. /** Gets or sets the start time (default is 0) */
  145332. time: number;
  145333. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  145334. brightness: number;
  145335. /** Defines the number of octaves to process */
  145336. octaves: number;
  145337. /** Defines the level of persistence (0.8 by default) */
  145338. persistence: number;
  145339. /** Gets or sets animation speed factor (default is 1) */
  145340. animationSpeedFactor: number;
  145341. /**
  145342. * Creates a new NoiseProceduralTexture
  145343. * @param name defines the name fo the texture
  145344. * @param size defines the size of the texture (default is 256)
  145345. * @param scene defines the hosting scene
  145346. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  145347. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  145348. */
  145349. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  145350. private _updateShaderUniforms;
  145351. protected _getDefines(): string;
  145352. /** Generate the current state of the procedural texture */
  145353. render(useCameraPostProcess?: boolean): void;
  145354. /**
  145355. * Serializes this noise procedural texture
  145356. * @returns a serialized noise procedural texture object
  145357. */
  145358. serialize(): any;
  145359. /**
  145360. * Clone the texture.
  145361. * @returns the cloned texture
  145362. */
  145363. clone(): NoiseProceduralTexture;
  145364. /**
  145365. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  145366. * @param parsedTexture defines parsed texture data
  145367. * @param scene defines the current scene
  145368. * @param rootUrl defines the root URL containing noise procedural texture information
  145369. * @returns a parsed NoiseProceduralTexture
  145370. */
  145371. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  145372. }
  145373. }
  145374. declare module BABYLON {
  145375. /**
  145376. * Raw cube texture where the raw buffers are passed in
  145377. */
  145378. export class RawCubeTexture extends CubeTexture {
  145379. /**
  145380. * Creates a cube texture where the raw buffers are passed in.
  145381. * @param scene defines the scene the texture is attached to
  145382. * @param data defines the array of data to use to create each face
  145383. * @param size defines the size of the textures
  145384. * @param format defines the format of the data
  145385. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  145386. * @param generateMipMaps defines if the engine should generate the mip levels
  145387. * @param invertY defines if data must be stored with Y axis inverted
  145388. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  145389. * @param compression defines the compression used (null by default)
  145390. */
  145391. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  145392. /**
  145393. * Updates the raw cube texture.
  145394. * @param data defines the data to store
  145395. * @param format defines the data format
  145396. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  145397. * @param invertY defines if data must be stored with Y axis inverted
  145398. * @param compression defines the compression used (null by default)
  145399. * @param level defines which level of the texture to update
  145400. */
  145401. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  145402. /**
  145403. * Updates a raw cube texture with RGBD encoded data.
  145404. * @param data defines the array of data [mipmap][face] to use to create each face
  145405. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  145406. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  145407. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  145408. * @returns a promsie that resolves when the operation is complete
  145409. */
  145410. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  145411. /**
  145412. * Clones the raw cube texture.
  145413. * @return a new cube texture
  145414. */
  145415. clone(): CubeTexture;
  145416. /** @hidden */
  145417. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  145418. }
  145419. }
  145420. declare module BABYLON {
  145421. /**
  145422. * Class used to store 2D array textures containing user data
  145423. */
  145424. export class RawTexture2DArray extends Texture {
  145425. /** Gets or sets the texture format to use */
  145426. format: number;
  145427. /**
  145428. * Create a new RawTexture2DArray
  145429. * @param data defines the data of the texture
  145430. * @param width defines the width of the texture
  145431. * @param height defines the height of the texture
  145432. * @param depth defines the number of layers of the texture
  145433. * @param format defines the texture format to use
  145434. * @param scene defines the hosting scene
  145435. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145436. * @param invertY defines if texture must be stored with Y axis inverted
  145437. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145438. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145439. */
  145440. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145441. /** Gets or sets the texture format to use */
  145442. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145443. /**
  145444. * Update the texture with new data
  145445. * @param data defines the data to store in the texture
  145446. */
  145447. update(data: ArrayBufferView): void;
  145448. }
  145449. }
  145450. declare module BABYLON {
  145451. /**
  145452. * Class used to store 3D textures containing user data
  145453. */
  145454. export class RawTexture3D extends Texture {
  145455. /** Gets or sets the texture format to use */
  145456. format: number;
  145457. /**
  145458. * Create a new RawTexture3D
  145459. * @param data defines the data of the texture
  145460. * @param width defines the width of the texture
  145461. * @param height defines the height of the texture
  145462. * @param depth defines the depth of the texture
  145463. * @param format defines the texture format to use
  145464. * @param scene defines the hosting scene
  145465. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  145466. * @param invertY defines if texture must be stored with Y axis inverted
  145467. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  145468. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  145469. */
  145470. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  145471. /** Gets or sets the texture format to use */
  145472. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  145473. /**
  145474. * Update the texture with new data
  145475. * @param data defines the data to store in the texture
  145476. */
  145477. update(data: ArrayBufferView): void;
  145478. }
  145479. }
  145480. declare module BABYLON {
  145481. /**
  145482. * Creates a refraction texture used by refraction channel of the standard material.
  145483. * It is like a mirror but to see through a material.
  145484. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145485. */
  145486. export class RefractionTexture extends RenderTargetTexture {
  145487. /**
  145488. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  145489. * 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.
  145490. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145491. */
  145492. refractionPlane: Plane;
  145493. /**
  145494. * Define how deep under the surface we should see.
  145495. */
  145496. depth: number;
  145497. /**
  145498. * Creates a refraction texture used by refraction channel of the standard material.
  145499. * It is like a mirror but to see through a material.
  145500. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  145501. * @param name Define the texture name
  145502. * @param size Define the size of the underlying texture
  145503. * @param scene Define the scene the refraction belongs to
  145504. * @param generateMipMaps Define if we need to generate mips level for the refraction
  145505. */
  145506. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  145507. /**
  145508. * Clone the refraction texture.
  145509. * @returns the cloned texture
  145510. */
  145511. clone(): RefractionTexture;
  145512. /**
  145513. * Serialize the texture to a JSON representation you could use in Parse later on
  145514. * @returns the serialized JSON representation
  145515. */
  145516. serialize(): any;
  145517. }
  145518. }
  145519. declare module BABYLON {
  145520. /**
  145521. * Block used to add support for vertex skinning (bones)
  145522. */
  145523. export class BonesBlock extends NodeMaterialBlock {
  145524. /**
  145525. * Creates a new BonesBlock
  145526. * @param name defines the block name
  145527. */
  145528. constructor(name: string);
  145529. /**
  145530. * Initialize the block and prepare the context for build
  145531. * @param state defines the state that will be used for the build
  145532. */
  145533. initialize(state: NodeMaterialBuildState): void;
  145534. /**
  145535. * Gets the current class name
  145536. * @returns the class name
  145537. */
  145538. getClassName(): string;
  145539. /**
  145540. * Gets the matrix indices input component
  145541. */
  145542. get matricesIndices(): NodeMaterialConnectionPoint;
  145543. /**
  145544. * Gets the matrix weights input component
  145545. */
  145546. get matricesWeights(): NodeMaterialConnectionPoint;
  145547. /**
  145548. * Gets the extra matrix indices input component
  145549. */
  145550. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  145551. /**
  145552. * Gets the extra matrix weights input component
  145553. */
  145554. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  145555. /**
  145556. * Gets the world input component
  145557. */
  145558. get world(): NodeMaterialConnectionPoint;
  145559. /**
  145560. * Gets the output component
  145561. */
  145562. get output(): NodeMaterialConnectionPoint;
  145563. autoConfigure(material: NodeMaterial): void;
  145564. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  145565. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145567. protected _buildBlock(state: NodeMaterialBuildState): this;
  145568. }
  145569. }
  145570. declare module BABYLON {
  145571. /**
  145572. * Block used to add support for instances
  145573. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  145574. */
  145575. export class InstancesBlock extends NodeMaterialBlock {
  145576. /**
  145577. * Creates a new InstancesBlock
  145578. * @param name defines the block name
  145579. */
  145580. constructor(name: string);
  145581. /**
  145582. * Gets the current class name
  145583. * @returns the class name
  145584. */
  145585. getClassName(): string;
  145586. /**
  145587. * Gets the first world row input component
  145588. */
  145589. get world0(): NodeMaterialConnectionPoint;
  145590. /**
  145591. * Gets the second world row input component
  145592. */
  145593. get world1(): NodeMaterialConnectionPoint;
  145594. /**
  145595. * Gets the third world row input component
  145596. */
  145597. get world2(): NodeMaterialConnectionPoint;
  145598. /**
  145599. * Gets the forth world row input component
  145600. */
  145601. get world3(): NodeMaterialConnectionPoint;
  145602. /**
  145603. * Gets the world input component
  145604. */
  145605. get world(): NodeMaterialConnectionPoint;
  145606. /**
  145607. * Gets the output component
  145608. */
  145609. get output(): NodeMaterialConnectionPoint;
  145610. /**
  145611. * Gets the isntanceID component
  145612. */
  145613. get instanceID(): NodeMaterialConnectionPoint;
  145614. autoConfigure(material: NodeMaterial): void;
  145615. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  145616. protected _buildBlock(state: NodeMaterialBuildState): this;
  145617. }
  145618. }
  145619. declare module BABYLON {
  145620. /**
  145621. * Block used to add morph targets support to vertex shader
  145622. */
  145623. export class MorphTargetsBlock extends NodeMaterialBlock {
  145624. private _repeatableContentAnchor;
  145625. /**
  145626. * Create a new MorphTargetsBlock
  145627. * @param name defines the block name
  145628. */
  145629. constructor(name: string);
  145630. /**
  145631. * Gets the current class name
  145632. * @returns the class name
  145633. */
  145634. getClassName(): string;
  145635. /**
  145636. * Gets the position input component
  145637. */
  145638. get position(): NodeMaterialConnectionPoint;
  145639. /**
  145640. * Gets the normal input component
  145641. */
  145642. get normal(): NodeMaterialConnectionPoint;
  145643. /**
  145644. * Gets the tangent input component
  145645. */
  145646. get tangent(): NodeMaterialConnectionPoint;
  145647. /**
  145648. * Gets the tangent input component
  145649. */
  145650. get uv(): NodeMaterialConnectionPoint;
  145651. /**
  145652. * Gets the position output component
  145653. */
  145654. get positionOutput(): NodeMaterialConnectionPoint;
  145655. /**
  145656. * Gets the normal output component
  145657. */
  145658. get normalOutput(): NodeMaterialConnectionPoint;
  145659. /**
  145660. * Gets the tangent output component
  145661. */
  145662. get tangentOutput(): NodeMaterialConnectionPoint;
  145663. /**
  145664. * Gets the tangent output component
  145665. */
  145666. get uvOutput(): NodeMaterialConnectionPoint;
  145667. initialize(state: NodeMaterialBuildState): void;
  145668. autoConfigure(material: NodeMaterial): void;
  145669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145670. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145671. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  145672. protected _buildBlock(state: NodeMaterialBuildState): this;
  145673. }
  145674. }
  145675. declare module BABYLON {
  145676. /**
  145677. * Block used to get data information from a light
  145678. */
  145679. export class LightInformationBlock extends NodeMaterialBlock {
  145680. private _lightDataUniformName;
  145681. private _lightColorUniformName;
  145682. private _lightTypeDefineName;
  145683. /**
  145684. * Gets or sets the light associated with this block
  145685. */
  145686. light: Nullable<Light>;
  145687. /**
  145688. * Creates a new LightInformationBlock
  145689. * @param name defines the block name
  145690. */
  145691. constructor(name: string);
  145692. /**
  145693. * Gets the current class name
  145694. * @returns the class name
  145695. */
  145696. getClassName(): string;
  145697. /**
  145698. * Gets the world position input component
  145699. */
  145700. get worldPosition(): NodeMaterialConnectionPoint;
  145701. /**
  145702. * Gets the direction output component
  145703. */
  145704. get direction(): NodeMaterialConnectionPoint;
  145705. /**
  145706. * Gets the direction output component
  145707. */
  145708. get color(): NodeMaterialConnectionPoint;
  145709. /**
  145710. * Gets the direction output component
  145711. */
  145712. get intensity(): NodeMaterialConnectionPoint;
  145713. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145715. protected _buildBlock(state: NodeMaterialBuildState): this;
  145716. serialize(): any;
  145717. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145718. }
  145719. }
  145720. declare module BABYLON {
  145721. /**
  145722. * Block used to add image processing support to fragment shader
  145723. */
  145724. export class ImageProcessingBlock extends NodeMaterialBlock {
  145725. /**
  145726. * Create a new ImageProcessingBlock
  145727. * @param name defines the block name
  145728. */
  145729. constructor(name: string);
  145730. /**
  145731. * Gets the current class name
  145732. * @returns the class name
  145733. */
  145734. getClassName(): string;
  145735. /**
  145736. * Gets the color input component
  145737. */
  145738. get color(): NodeMaterialConnectionPoint;
  145739. /**
  145740. * Gets the output component
  145741. */
  145742. get output(): NodeMaterialConnectionPoint;
  145743. /**
  145744. * Initialize the block and prepare the context for build
  145745. * @param state defines the state that will be used for the build
  145746. */
  145747. initialize(state: NodeMaterialBuildState): void;
  145748. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  145749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145751. protected _buildBlock(state: NodeMaterialBuildState): this;
  145752. }
  145753. }
  145754. declare module BABYLON {
  145755. /**
  145756. * Block used to pertub normals based on a normal map
  145757. */
  145758. export class PerturbNormalBlock extends NodeMaterialBlock {
  145759. private _tangentSpaceParameterName;
  145760. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  145761. invertX: boolean;
  145762. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  145763. invertY: boolean;
  145764. /**
  145765. * Create a new PerturbNormalBlock
  145766. * @param name defines the block name
  145767. */
  145768. constructor(name: string);
  145769. /**
  145770. * Gets the current class name
  145771. * @returns the class name
  145772. */
  145773. getClassName(): string;
  145774. /**
  145775. * Gets the world position input component
  145776. */
  145777. get worldPosition(): NodeMaterialConnectionPoint;
  145778. /**
  145779. * Gets the world normal input component
  145780. */
  145781. get worldNormal(): NodeMaterialConnectionPoint;
  145782. /**
  145783. * Gets the world tangent input component
  145784. */
  145785. get worldTangent(): NodeMaterialConnectionPoint;
  145786. /**
  145787. * Gets the uv input component
  145788. */
  145789. get uv(): NodeMaterialConnectionPoint;
  145790. /**
  145791. * Gets the normal map color input component
  145792. */
  145793. get normalMapColor(): NodeMaterialConnectionPoint;
  145794. /**
  145795. * Gets the strength input component
  145796. */
  145797. get strength(): NodeMaterialConnectionPoint;
  145798. /**
  145799. * Gets the output component
  145800. */
  145801. get output(): NodeMaterialConnectionPoint;
  145802. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145803. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145804. autoConfigure(material: NodeMaterial): void;
  145805. protected _buildBlock(state: NodeMaterialBuildState): this;
  145806. protected _dumpPropertiesCode(): string;
  145807. serialize(): any;
  145808. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145809. }
  145810. }
  145811. declare module BABYLON {
  145812. /**
  145813. * Block used to discard a pixel if a value is smaller than a cutoff
  145814. */
  145815. export class DiscardBlock extends NodeMaterialBlock {
  145816. /**
  145817. * Create a new DiscardBlock
  145818. * @param name defines the block name
  145819. */
  145820. constructor(name: string);
  145821. /**
  145822. * Gets the current class name
  145823. * @returns the class name
  145824. */
  145825. getClassName(): string;
  145826. /**
  145827. * Gets the color input component
  145828. */
  145829. get value(): NodeMaterialConnectionPoint;
  145830. /**
  145831. * Gets the cutoff input component
  145832. */
  145833. get cutoff(): NodeMaterialConnectionPoint;
  145834. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145835. }
  145836. }
  145837. declare module BABYLON {
  145838. /**
  145839. * Block used to test if the fragment shader is front facing
  145840. */
  145841. export class FrontFacingBlock extends NodeMaterialBlock {
  145842. /**
  145843. * Creates a new FrontFacingBlock
  145844. * @param name defines the block name
  145845. */
  145846. constructor(name: string);
  145847. /**
  145848. * Gets the current class name
  145849. * @returns the class name
  145850. */
  145851. getClassName(): string;
  145852. /**
  145853. * Gets the output component
  145854. */
  145855. get output(): NodeMaterialConnectionPoint;
  145856. protected _buildBlock(state: NodeMaterialBuildState): this;
  145857. }
  145858. }
  145859. declare module BABYLON {
  145860. /**
  145861. * Block used to get the derivative value on x and y of a given input
  145862. */
  145863. export class DerivativeBlock extends NodeMaterialBlock {
  145864. /**
  145865. * Create a new DerivativeBlock
  145866. * @param name defines the block name
  145867. */
  145868. constructor(name: string);
  145869. /**
  145870. * Gets the current class name
  145871. * @returns the class name
  145872. */
  145873. getClassName(): string;
  145874. /**
  145875. * Gets the input component
  145876. */
  145877. get input(): NodeMaterialConnectionPoint;
  145878. /**
  145879. * Gets the derivative output on x
  145880. */
  145881. get dx(): NodeMaterialConnectionPoint;
  145882. /**
  145883. * Gets the derivative output on y
  145884. */
  145885. get dy(): NodeMaterialConnectionPoint;
  145886. protected _buildBlock(state: NodeMaterialBuildState): this;
  145887. }
  145888. }
  145889. declare module BABYLON {
  145890. /**
  145891. * Block used to make gl_FragCoord available
  145892. */
  145893. export class FragCoordBlock extends NodeMaterialBlock {
  145894. /**
  145895. * Creates a new FragCoordBlock
  145896. * @param name defines the block name
  145897. */
  145898. constructor(name: string);
  145899. /**
  145900. * Gets the current class name
  145901. * @returns the class name
  145902. */
  145903. getClassName(): string;
  145904. /**
  145905. * Gets the xy component
  145906. */
  145907. get xy(): NodeMaterialConnectionPoint;
  145908. /**
  145909. * Gets the xyz component
  145910. */
  145911. get xyz(): NodeMaterialConnectionPoint;
  145912. /**
  145913. * Gets the xyzw component
  145914. */
  145915. get xyzw(): NodeMaterialConnectionPoint;
  145916. /**
  145917. * Gets the x component
  145918. */
  145919. get x(): NodeMaterialConnectionPoint;
  145920. /**
  145921. * Gets the y component
  145922. */
  145923. get y(): NodeMaterialConnectionPoint;
  145924. /**
  145925. * Gets the z component
  145926. */
  145927. get z(): NodeMaterialConnectionPoint;
  145928. /**
  145929. * Gets the w component
  145930. */
  145931. get output(): NodeMaterialConnectionPoint;
  145932. protected writeOutputs(state: NodeMaterialBuildState): string;
  145933. protected _buildBlock(state: NodeMaterialBuildState): this;
  145934. }
  145935. }
  145936. declare module BABYLON {
  145937. /**
  145938. * Block used to get the screen sizes
  145939. */
  145940. export class ScreenSizeBlock extends NodeMaterialBlock {
  145941. private _varName;
  145942. private _scene;
  145943. /**
  145944. * Creates a new ScreenSizeBlock
  145945. * @param name defines the block name
  145946. */
  145947. constructor(name: string);
  145948. /**
  145949. * Gets the current class name
  145950. * @returns the class name
  145951. */
  145952. getClassName(): string;
  145953. /**
  145954. * Gets the xy component
  145955. */
  145956. get xy(): NodeMaterialConnectionPoint;
  145957. /**
  145958. * Gets the x component
  145959. */
  145960. get x(): NodeMaterialConnectionPoint;
  145961. /**
  145962. * Gets the y component
  145963. */
  145964. get y(): NodeMaterialConnectionPoint;
  145965. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145966. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145967. protected _buildBlock(state: NodeMaterialBuildState): this;
  145968. }
  145969. }
  145970. declare module BABYLON {
  145971. /**
  145972. * Block used to add support for scene fog
  145973. */
  145974. export class FogBlock extends NodeMaterialBlock {
  145975. private _fogDistanceName;
  145976. private _fogParameters;
  145977. /**
  145978. * Create a new FogBlock
  145979. * @param name defines the block name
  145980. */
  145981. constructor(name: string);
  145982. /**
  145983. * Gets the current class name
  145984. * @returns the class name
  145985. */
  145986. getClassName(): string;
  145987. /**
  145988. * Gets the world position input component
  145989. */
  145990. get worldPosition(): NodeMaterialConnectionPoint;
  145991. /**
  145992. * Gets the view input component
  145993. */
  145994. get view(): NodeMaterialConnectionPoint;
  145995. /**
  145996. * Gets the color input component
  145997. */
  145998. get input(): NodeMaterialConnectionPoint;
  145999. /**
  146000. * Gets the fog color input component
  146001. */
  146002. get fogColor(): NodeMaterialConnectionPoint;
  146003. /**
  146004. * Gets the output component
  146005. */
  146006. get output(): NodeMaterialConnectionPoint;
  146007. autoConfigure(material: NodeMaterial): void;
  146008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146009. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146010. protected _buildBlock(state: NodeMaterialBuildState): this;
  146011. }
  146012. }
  146013. declare module BABYLON {
  146014. /**
  146015. * Block used to add light in the fragment shader
  146016. */
  146017. export class LightBlock extends NodeMaterialBlock {
  146018. private _lightId;
  146019. /**
  146020. * Gets or sets the light associated with this block
  146021. */
  146022. light: Nullable<Light>;
  146023. /**
  146024. * Create a new LightBlock
  146025. * @param name defines the block name
  146026. */
  146027. constructor(name: string);
  146028. /**
  146029. * Gets the current class name
  146030. * @returns the class name
  146031. */
  146032. getClassName(): string;
  146033. /**
  146034. * Gets the world position input component
  146035. */
  146036. get worldPosition(): NodeMaterialConnectionPoint;
  146037. /**
  146038. * Gets the world normal input component
  146039. */
  146040. get worldNormal(): NodeMaterialConnectionPoint;
  146041. /**
  146042. * Gets the camera (or eye) position component
  146043. */
  146044. get cameraPosition(): NodeMaterialConnectionPoint;
  146045. /**
  146046. * Gets the glossiness component
  146047. */
  146048. get glossiness(): NodeMaterialConnectionPoint;
  146049. /**
  146050. * Gets the glossinness power component
  146051. */
  146052. get glossPower(): NodeMaterialConnectionPoint;
  146053. /**
  146054. * Gets the diffuse color component
  146055. */
  146056. get diffuseColor(): NodeMaterialConnectionPoint;
  146057. /**
  146058. * Gets the specular color component
  146059. */
  146060. get specularColor(): NodeMaterialConnectionPoint;
  146061. /**
  146062. * Gets the view matrix component
  146063. */
  146064. get view(): NodeMaterialConnectionPoint;
  146065. /**
  146066. * Gets the diffuse output component
  146067. */
  146068. get diffuseOutput(): NodeMaterialConnectionPoint;
  146069. /**
  146070. * Gets the specular output component
  146071. */
  146072. get specularOutput(): NodeMaterialConnectionPoint;
  146073. /**
  146074. * Gets the shadow output component
  146075. */
  146076. get shadow(): NodeMaterialConnectionPoint;
  146077. autoConfigure(material: NodeMaterial): void;
  146078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146079. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  146080. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  146081. private _injectVertexCode;
  146082. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146083. serialize(): any;
  146084. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146085. }
  146086. }
  146087. declare module BABYLON {
  146088. /**
  146089. * Block used to read a reflection texture from a sampler
  146090. */
  146091. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  146092. /**
  146093. * Create a new ReflectionTextureBlock
  146094. * @param name defines the block name
  146095. */
  146096. constructor(name: string);
  146097. /**
  146098. * Gets the current class name
  146099. * @returns the class name
  146100. */
  146101. getClassName(): string;
  146102. /**
  146103. * Gets the world position input component
  146104. */
  146105. get position(): NodeMaterialConnectionPoint;
  146106. /**
  146107. * Gets the world position input component
  146108. */
  146109. get worldPosition(): NodeMaterialConnectionPoint;
  146110. /**
  146111. * Gets the world normal input component
  146112. */
  146113. get worldNormal(): NodeMaterialConnectionPoint;
  146114. /**
  146115. * Gets the world input component
  146116. */
  146117. get world(): NodeMaterialConnectionPoint;
  146118. /**
  146119. * Gets the camera (or eye) position component
  146120. */
  146121. get cameraPosition(): NodeMaterialConnectionPoint;
  146122. /**
  146123. * Gets the view input component
  146124. */
  146125. get view(): NodeMaterialConnectionPoint;
  146126. /**
  146127. * Gets the rgb output component
  146128. */
  146129. get rgb(): NodeMaterialConnectionPoint;
  146130. /**
  146131. * Gets the rgba output component
  146132. */
  146133. get rgba(): NodeMaterialConnectionPoint;
  146134. /**
  146135. * Gets the r output component
  146136. */
  146137. get r(): NodeMaterialConnectionPoint;
  146138. /**
  146139. * Gets the g output component
  146140. */
  146141. get g(): NodeMaterialConnectionPoint;
  146142. /**
  146143. * Gets the b output component
  146144. */
  146145. get b(): NodeMaterialConnectionPoint;
  146146. /**
  146147. * Gets the a output component
  146148. */
  146149. get a(): NodeMaterialConnectionPoint;
  146150. autoConfigure(material: NodeMaterial): void;
  146151. protected _buildBlock(state: NodeMaterialBuildState): this;
  146152. }
  146153. }
  146154. declare module BABYLON {
  146155. /**
  146156. * Block used to add 2 vectors
  146157. */
  146158. export class AddBlock extends NodeMaterialBlock {
  146159. /**
  146160. * Creates a new AddBlock
  146161. * @param name defines the block name
  146162. */
  146163. constructor(name: string);
  146164. /**
  146165. * Gets the current class name
  146166. * @returns the class name
  146167. */
  146168. getClassName(): string;
  146169. /**
  146170. * Gets the left operand input component
  146171. */
  146172. get left(): NodeMaterialConnectionPoint;
  146173. /**
  146174. * Gets the right operand input component
  146175. */
  146176. get right(): NodeMaterialConnectionPoint;
  146177. /**
  146178. * Gets the output component
  146179. */
  146180. get output(): NodeMaterialConnectionPoint;
  146181. protected _buildBlock(state: NodeMaterialBuildState): this;
  146182. }
  146183. }
  146184. declare module BABYLON {
  146185. /**
  146186. * Block used to scale a vector by a float
  146187. */
  146188. export class ScaleBlock extends NodeMaterialBlock {
  146189. /**
  146190. * Creates a new ScaleBlock
  146191. * @param name defines the block name
  146192. */
  146193. constructor(name: string);
  146194. /**
  146195. * Gets the current class name
  146196. * @returns the class name
  146197. */
  146198. getClassName(): string;
  146199. /**
  146200. * Gets the input component
  146201. */
  146202. get input(): NodeMaterialConnectionPoint;
  146203. /**
  146204. * Gets the factor input component
  146205. */
  146206. get factor(): NodeMaterialConnectionPoint;
  146207. /**
  146208. * Gets the output component
  146209. */
  146210. get output(): NodeMaterialConnectionPoint;
  146211. protected _buildBlock(state: NodeMaterialBuildState): this;
  146212. }
  146213. }
  146214. declare module BABYLON {
  146215. /**
  146216. * Block used to clamp a float
  146217. */
  146218. export class ClampBlock extends NodeMaterialBlock {
  146219. /** Gets or sets the minimum range */
  146220. minimum: number;
  146221. /** Gets or sets the maximum range */
  146222. maximum: number;
  146223. /**
  146224. * Creates a new ClampBlock
  146225. * @param name defines the block name
  146226. */
  146227. constructor(name: string);
  146228. /**
  146229. * Gets the current class name
  146230. * @returns the class name
  146231. */
  146232. getClassName(): string;
  146233. /**
  146234. * Gets the value input component
  146235. */
  146236. get value(): NodeMaterialConnectionPoint;
  146237. /**
  146238. * Gets the output component
  146239. */
  146240. get output(): NodeMaterialConnectionPoint;
  146241. protected _buildBlock(state: NodeMaterialBuildState): this;
  146242. protected _dumpPropertiesCode(): string;
  146243. serialize(): any;
  146244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146245. }
  146246. }
  146247. declare module BABYLON {
  146248. /**
  146249. * Block used to apply a cross product between 2 vectors
  146250. */
  146251. export class CrossBlock extends NodeMaterialBlock {
  146252. /**
  146253. * Creates a new CrossBlock
  146254. * @param name defines the block name
  146255. */
  146256. constructor(name: string);
  146257. /**
  146258. * Gets the current class name
  146259. * @returns the class name
  146260. */
  146261. getClassName(): string;
  146262. /**
  146263. * Gets the left operand input component
  146264. */
  146265. get left(): NodeMaterialConnectionPoint;
  146266. /**
  146267. * Gets the right operand input component
  146268. */
  146269. get right(): NodeMaterialConnectionPoint;
  146270. /**
  146271. * Gets the output component
  146272. */
  146273. get output(): NodeMaterialConnectionPoint;
  146274. protected _buildBlock(state: NodeMaterialBuildState): this;
  146275. }
  146276. }
  146277. declare module BABYLON {
  146278. /**
  146279. * Block used to apply a dot product between 2 vectors
  146280. */
  146281. export class DotBlock extends NodeMaterialBlock {
  146282. /**
  146283. * Creates a new DotBlock
  146284. * @param name defines the block name
  146285. */
  146286. constructor(name: string);
  146287. /**
  146288. * Gets the current class name
  146289. * @returns the class name
  146290. */
  146291. getClassName(): string;
  146292. /**
  146293. * Gets the left operand input component
  146294. */
  146295. get left(): NodeMaterialConnectionPoint;
  146296. /**
  146297. * Gets the right operand input component
  146298. */
  146299. get right(): NodeMaterialConnectionPoint;
  146300. /**
  146301. * Gets the output component
  146302. */
  146303. get output(): NodeMaterialConnectionPoint;
  146304. protected _buildBlock(state: NodeMaterialBuildState): this;
  146305. }
  146306. }
  146307. declare module BABYLON {
  146308. /**
  146309. * Block used to normalize a vector
  146310. */
  146311. export class NormalizeBlock extends NodeMaterialBlock {
  146312. /**
  146313. * Creates a new NormalizeBlock
  146314. * @param name defines the block name
  146315. */
  146316. constructor(name: string);
  146317. /**
  146318. * Gets the current class name
  146319. * @returns the class name
  146320. */
  146321. getClassName(): string;
  146322. /**
  146323. * Gets the input component
  146324. */
  146325. get input(): NodeMaterialConnectionPoint;
  146326. /**
  146327. * Gets the output component
  146328. */
  146329. get output(): NodeMaterialConnectionPoint;
  146330. protected _buildBlock(state: NodeMaterialBuildState): this;
  146331. }
  146332. }
  146333. declare module BABYLON {
  146334. /**
  146335. * Block used to create a Color3/4 out of individual inputs (one for each component)
  146336. */
  146337. export class ColorMergerBlock extends NodeMaterialBlock {
  146338. /**
  146339. * Create a new ColorMergerBlock
  146340. * @param name defines the block name
  146341. */
  146342. constructor(name: string);
  146343. /**
  146344. * Gets the current class name
  146345. * @returns the class name
  146346. */
  146347. getClassName(): string;
  146348. /**
  146349. * Gets the rgb component (input)
  146350. */
  146351. get rgbIn(): NodeMaterialConnectionPoint;
  146352. /**
  146353. * Gets the r component (input)
  146354. */
  146355. get r(): NodeMaterialConnectionPoint;
  146356. /**
  146357. * Gets the g component (input)
  146358. */
  146359. get g(): NodeMaterialConnectionPoint;
  146360. /**
  146361. * Gets the b component (input)
  146362. */
  146363. get b(): NodeMaterialConnectionPoint;
  146364. /**
  146365. * Gets the a component (input)
  146366. */
  146367. get a(): NodeMaterialConnectionPoint;
  146368. /**
  146369. * Gets the rgba component (output)
  146370. */
  146371. get rgba(): NodeMaterialConnectionPoint;
  146372. /**
  146373. * Gets the rgb component (output)
  146374. */
  146375. get rgbOut(): NodeMaterialConnectionPoint;
  146376. /**
  146377. * Gets the rgb component (output)
  146378. * @deprecated Please use rgbOut instead.
  146379. */
  146380. get rgb(): NodeMaterialConnectionPoint;
  146381. protected _buildBlock(state: NodeMaterialBuildState): this;
  146382. }
  146383. }
  146384. declare module BABYLON {
  146385. /**
  146386. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  146387. */
  146388. export class VectorSplitterBlock extends NodeMaterialBlock {
  146389. /**
  146390. * Create a new VectorSplitterBlock
  146391. * @param name defines the block name
  146392. */
  146393. constructor(name: string);
  146394. /**
  146395. * Gets the current class name
  146396. * @returns the class name
  146397. */
  146398. getClassName(): string;
  146399. /**
  146400. * Gets the xyzw component (input)
  146401. */
  146402. get xyzw(): NodeMaterialConnectionPoint;
  146403. /**
  146404. * Gets the xyz component (input)
  146405. */
  146406. get xyzIn(): NodeMaterialConnectionPoint;
  146407. /**
  146408. * Gets the xy component (input)
  146409. */
  146410. get xyIn(): NodeMaterialConnectionPoint;
  146411. /**
  146412. * Gets the xyz component (output)
  146413. */
  146414. get xyzOut(): NodeMaterialConnectionPoint;
  146415. /**
  146416. * Gets the xy component (output)
  146417. */
  146418. get xyOut(): NodeMaterialConnectionPoint;
  146419. /**
  146420. * Gets the x component (output)
  146421. */
  146422. get x(): NodeMaterialConnectionPoint;
  146423. /**
  146424. * Gets the y component (output)
  146425. */
  146426. get y(): NodeMaterialConnectionPoint;
  146427. /**
  146428. * Gets the z component (output)
  146429. */
  146430. get z(): NodeMaterialConnectionPoint;
  146431. /**
  146432. * Gets the w component (output)
  146433. */
  146434. get w(): NodeMaterialConnectionPoint;
  146435. protected _inputRename(name: string): string;
  146436. protected _outputRename(name: string): string;
  146437. protected _buildBlock(state: NodeMaterialBuildState): this;
  146438. }
  146439. }
  146440. declare module BABYLON {
  146441. /**
  146442. * Block used to lerp between 2 values
  146443. */
  146444. export class LerpBlock extends NodeMaterialBlock {
  146445. /**
  146446. * Creates a new LerpBlock
  146447. * @param name defines the block name
  146448. */
  146449. constructor(name: string);
  146450. /**
  146451. * Gets the current class name
  146452. * @returns the class name
  146453. */
  146454. getClassName(): string;
  146455. /**
  146456. * Gets the left operand input component
  146457. */
  146458. get left(): NodeMaterialConnectionPoint;
  146459. /**
  146460. * Gets the right operand input component
  146461. */
  146462. get right(): NodeMaterialConnectionPoint;
  146463. /**
  146464. * Gets the gradient operand input component
  146465. */
  146466. get gradient(): NodeMaterialConnectionPoint;
  146467. /**
  146468. * Gets the output component
  146469. */
  146470. get output(): NodeMaterialConnectionPoint;
  146471. protected _buildBlock(state: NodeMaterialBuildState): this;
  146472. }
  146473. }
  146474. declare module BABYLON {
  146475. /**
  146476. * Block used to divide 2 vectors
  146477. */
  146478. export class DivideBlock extends NodeMaterialBlock {
  146479. /**
  146480. * Creates a new DivideBlock
  146481. * @param name defines the block name
  146482. */
  146483. constructor(name: string);
  146484. /**
  146485. * Gets the current class name
  146486. * @returns the class name
  146487. */
  146488. getClassName(): string;
  146489. /**
  146490. * Gets the left operand input component
  146491. */
  146492. get left(): NodeMaterialConnectionPoint;
  146493. /**
  146494. * Gets the right operand input component
  146495. */
  146496. get right(): NodeMaterialConnectionPoint;
  146497. /**
  146498. * Gets the output component
  146499. */
  146500. get output(): NodeMaterialConnectionPoint;
  146501. protected _buildBlock(state: NodeMaterialBuildState): this;
  146502. }
  146503. }
  146504. declare module BABYLON {
  146505. /**
  146506. * Block used to subtract 2 vectors
  146507. */
  146508. export class SubtractBlock extends NodeMaterialBlock {
  146509. /**
  146510. * Creates a new SubtractBlock
  146511. * @param name defines the block name
  146512. */
  146513. constructor(name: string);
  146514. /**
  146515. * Gets the current class name
  146516. * @returns the class name
  146517. */
  146518. getClassName(): string;
  146519. /**
  146520. * Gets the left operand input component
  146521. */
  146522. get left(): NodeMaterialConnectionPoint;
  146523. /**
  146524. * Gets the right operand input component
  146525. */
  146526. get right(): NodeMaterialConnectionPoint;
  146527. /**
  146528. * Gets the output component
  146529. */
  146530. get output(): NodeMaterialConnectionPoint;
  146531. protected _buildBlock(state: NodeMaterialBuildState): this;
  146532. }
  146533. }
  146534. declare module BABYLON {
  146535. /**
  146536. * Block used to step a value
  146537. */
  146538. export class StepBlock extends NodeMaterialBlock {
  146539. /**
  146540. * Creates a new StepBlock
  146541. * @param name defines the block name
  146542. */
  146543. constructor(name: string);
  146544. /**
  146545. * Gets the current class name
  146546. * @returns the class name
  146547. */
  146548. getClassName(): string;
  146549. /**
  146550. * Gets the value operand input component
  146551. */
  146552. get value(): NodeMaterialConnectionPoint;
  146553. /**
  146554. * Gets the edge operand input component
  146555. */
  146556. get edge(): NodeMaterialConnectionPoint;
  146557. /**
  146558. * Gets the output component
  146559. */
  146560. get output(): NodeMaterialConnectionPoint;
  146561. protected _buildBlock(state: NodeMaterialBuildState): this;
  146562. }
  146563. }
  146564. declare module BABYLON {
  146565. /**
  146566. * Block used to get the opposite (1 - x) of a value
  146567. */
  146568. export class OneMinusBlock extends NodeMaterialBlock {
  146569. /**
  146570. * Creates a new OneMinusBlock
  146571. * @param name defines the block name
  146572. */
  146573. constructor(name: string);
  146574. /**
  146575. * Gets the current class name
  146576. * @returns the class name
  146577. */
  146578. getClassName(): string;
  146579. /**
  146580. * Gets the input component
  146581. */
  146582. get input(): NodeMaterialConnectionPoint;
  146583. /**
  146584. * Gets the output component
  146585. */
  146586. get output(): NodeMaterialConnectionPoint;
  146587. protected _buildBlock(state: NodeMaterialBuildState): this;
  146588. }
  146589. }
  146590. declare module BABYLON {
  146591. /**
  146592. * Block used to get the view direction
  146593. */
  146594. export class ViewDirectionBlock extends NodeMaterialBlock {
  146595. /**
  146596. * Creates a new ViewDirectionBlock
  146597. * @param name defines the block name
  146598. */
  146599. constructor(name: string);
  146600. /**
  146601. * Gets the current class name
  146602. * @returns the class name
  146603. */
  146604. getClassName(): string;
  146605. /**
  146606. * Gets the world position component
  146607. */
  146608. get worldPosition(): NodeMaterialConnectionPoint;
  146609. /**
  146610. * Gets the camera position component
  146611. */
  146612. get cameraPosition(): NodeMaterialConnectionPoint;
  146613. /**
  146614. * Gets the output component
  146615. */
  146616. get output(): NodeMaterialConnectionPoint;
  146617. autoConfigure(material: NodeMaterial): void;
  146618. protected _buildBlock(state: NodeMaterialBuildState): this;
  146619. }
  146620. }
  146621. declare module BABYLON {
  146622. /**
  146623. * Block used to compute fresnel value
  146624. */
  146625. export class FresnelBlock extends NodeMaterialBlock {
  146626. /**
  146627. * Create a new FresnelBlock
  146628. * @param name defines the block name
  146629. */
  146630. constructor(name: string);
  146631. /**
  146632. * Gets the current class name
  146633. * @returns the class name
  146634. */
  146635. getClassName(): string;
  146636. /**
  146637. * Gets the world normal input component
  146638. */
  146639. get worldNormal(): NodeMaterialConnectionPoint;
  146640. /**
  146641. * Gets the view direction input component
  146642. */
  146643. get viewDirection(): NodeMaterialConnectionPoint;
  146644. /**
  146645. * Gets the bias input component
  146646. */
  146647. get bias(): NodeMaterialConnectionPoint;
  146648. /**
  146649. * Gets the camera (or eye) position component
  146650. */
  146651. get power(): NodeMaterialConnectionPoint;
  146652. /**
  146653. * Gets the fresnel output component
  146654. */
  146655. get fresnel(): NodeMaterialConnectionPoint;
  146656. autoConfigure(material: NodeMaterial): void;
  146657. protected _buildBlock(state: NodeMaterialBuildState): this;
  146658. }
  146659. }
  146660. declare module BABYLON {
  146661. /**
  146662. * Block used to get the max of 2 values
  146663. */
  146664. export class MaxBlock extends NodeMaterialBlock {
  146665. /**
  146666. * Creates a new MaxBlock
  146667. * @param name defines the block name
  146668. */
  146669. constructor(name: string);
  146670. /**
  146671. * Gets the current class name
  146672. * @returns the class name
  146673. */
  146674. getClassName(): string;
  146675. /**
  146676. * Gets the left operand input component
  146677. */
  146678. get left(): NodeMaterialConnectionPoint;
  146679. /**
  146680. * Gets the right operand input component
  146681. */
  146682. get right(): NodeMaterialConnectionPoint;
  146683. /**
  146684. * Gets the output component
  146685. */
  146686. get output(): NodeMaterialConnectionPoint;
  146687. protected _buildBlock(state: NodeMaterialBuildState): this;
  146688. }
  146689. }
  146690. declare module BABYLON {
  146691. /**
  146692. * Block used to get the min of 2 values
  146693. */
  146694. export class MinBlock extends NodeMaterialBlock {
  146695. /**
  146696. * Creates a new MinBlock
  146697. * @param name defines the block name
  146698. */
  146699. constructor(name: string);
  146700. /**
  146701. * Gets the current class name
  146702. * @returns the class name
  146703. */
  146704. getClassName(): string;
  146705. /**
  146706. * Gets the left operand input component
  146707. */
  146708. get left(): NodeMaterialConnectionPoint;
  146709. /**
  146710. * Gets the right operand input component
  146711. */
  146712. get right(): NodeMaterialConnectionPoint;
  146713. /**
  146714. * Gets the output component
  146715. */
  146716. get output(): NodeMaterialConnectionPoint;
  146717. protected _buildBlock(state: NodeMaterialBuildState): this;
  146718. }
  146719. }
  146720. declare module BABYLON {
  146721. /**
  146722. * Block used to get the distance between 2 values
  146723. */
  146724. export class DistanceBlock extends NodeMaterialBlock {
  146725. /**
  146726. * Creates a new DistanceBlock
  146727. * @param name defines the block name
  146728. */
  146729. constructor(name: string);
  146730. /**
  146731. * Gets the current class name
  146732. * @returns the class name
  146733. */
  146734. getClassName(): string;
  146735. /**
  146736. * Gets the left operand input component
  146737. */
  146738. get left(): NodeMaterialConnectionPoint;
  146739. /**
  146740. * Gets the right operand input component
  146741. */
  146742. get right(): NodeMaterialConnectionPoint;
  146743. /**
  146744. * Gets the output component
  146745. */
  146746. get output(): NodeMaterialConnectionPoint;
  146747. protected _buildBlock(state: NodeMaterialBuildState): this;
  146748. }
  146749. }
  146750. declare module BABYLON {
  146751. /**
  146752. * Block used to get the length of a vector
  146753. */
  146754. export class LengthBlock extends NodeMaterialBlock {
  146755. /**
  146756. * Creates a new LengthBlock
  146757. * @param name defines the block name
  146758. */
  146759. constructor(name: string);
  146760. /**
  146761. * Gets the current class name
  146762. * @returns the class name
  146763. */
  146764. getClassName(): string;
  146765. /**
  146766. * Gets the value input component
  146767. */
  146768. get value(): NodeMaterialConnectionPoint;
  146769. /**
  146770. * Gets the output component
  146771. */
  146772. get output(): NodeMaterialConnectionPoint;
  146773. protected _buildBlock(state: NodeMaterialBuildState): this;
  146774. }
  146775. }
  146776. declare module BABYLON {
  146777. /**
  146778. * Block used to get negative version of a value (i.e. x * -1)
  146779. */
  146780. export class NegateBlock extends NodeMaterialBlock {
  146781. /**
  146782. * Creates a new NegateBlock
  146783. * @param name defines the block name
  146784. */
  146785. constructor(name: string);
  146786. /**
  146787. * Gets the current class name
  146788. * @returns the class name
  146789. */
  146790. getClassName(): string;
  146791. /**
  146792. * Gets the value input component
  146793. */
  146794. get value(): NodeMaterialConnectionPoint;
  146795. /**
  146796. * Gets the output component
  146797. */
  146798. get output(): NodeMaterialConnectionPoint;
  146799. protected _buildBlock(state: NodeMaterialBuildState): this;
  146800. }
  146801. }
  146802. declare module BABYLON {
  146803. /**
  146804. * Block used to get the value of the first parameter raised to the power of the second
  146805. */
  146806. export class PowBlock extends NodeMaterialBlock {
  146807. /**
  146808. * Creates a new PowBlock
  146809. * @param name defines the block name
  146810. */
  146811. constructor(name: string);
  146812. /**
  146813. * Gets the current class name
  146814. * @returns the class name
  146815. */
  146816. getClassName(): string;
  146817. /**
  146818. * Gets the value operand input component
  146819. */
  146820. get value(): NodeMaterialConnectionPoint;
  146821. /**
  146822. * Gets the power operand input component
  146823. */
  146824. get power(): NodeMaterialConnectionPoint;
  146825. /**
  146826. * Gets the output component
  146827. */
  146828. get output(): NodeMaterialConnectionPoint;
  146829. protected _buildBlock(state: NodeMaterialBuildState): this;
  146830. }
  146831. }
  146832. declare module BABYLON {
  146833. /**
  146834. * Block used to get a random number
  146835. */
  146836. export class RandomNumberBlock extends NodeMaterialBlock {
  146837. /**
  146838. * Creates a new RandomNumberBlock
  146839. * @param name defines the block name
  146840. */
  146841. constructor(name: string);
  146842. /**
  146843. * Gets the current class name
  146844. * @returns the class name
  146845. */
  146846. getClassName(): string;
  146847. /**
  146848. * Gets the seed input component
  146849. */
  146850. get seed(): NodeMaterialConnectionPoint;
  146851. /**
  146852. * Gets the output component
  146853. */
  146854. get output(): NodeMaterialConnectionPoint;
  146855. protected _buildBlock(state: NodeMaterialBuildState): this;
  146856. }
  146857. }
  146858. declare module BABYLON {
  146859. /**
  146860. * Block used to compute arc tangent of 2 values
  146861. */
  146862. export class ArcTan2Block extends NodeMaterialBlock {
  146863. /**
  146864. * Creates a new ArcTan2Block
  146865. * @param name defines the block name
  146866. */
  146867. constructor(name: string);
  146868. /**
  146869. * Gets the current class name
  146870. * @returns the class name
  146871. */
  146872. getClassName(): string;
  146873. /**
  146874. * Gets the x operand input component
  146875. */
  146876. get x(): NodeMaterialConnectionPoint;
  146877. /**
  146878. * Gets the y operand input component
  146879. */
  146880. get y(): NodeMaterialConnectionPoint;
  146881. /**
  146882. * Gets the output component
  146883. */
  146884. get output(): NodeMaterialConnectionPoint;
  146885. protected _buildBlock(state: NodeMaterialBuildState): this;
  146886. }
  146887. }
  146888. declare module BABYLON {
  146889. /**
  146890. * Block used to smooth step a value
  146891. */
  146892. export class SmoothStepBlock extends NodeMaterialBlock {
  146893. /**
  146894. * Creates a new SmoothStepBlock
  146895. * @param name defines the block name
  146896. */
  146897. constructor(name: string);
  146898. /**
  146899. * Gets the current class name
  146900. * @returns the class name
  146901. */
  146902. getClassName(): string;
  146903. /**
  146904. * Gets the value operand input component
  146905. */
  146906. get value(): NodeMaterialConnectionPoint;
  146907. /**
  146908. * Gets the first edge operand input component
  146909. */
  146910. get edge0(): NodeMaterialConnectionPoint;
  146911. /**
  146912. * Gets the second edge operand input component
  146913. */
  146914. get edge1(): NodeMaterialConnectionPoint;
  146915. /**
  146916. * Gets the output component
  146917. */
  146918. get output(): NodeMaterialConnectionPoint;
  146919. protected _buildBlock(state: NodeMaterialBuildState): this;
  146920. }
  146921. }
  146922. declare module BABYLON {
  146923. /**
  146924. * Block used to get the reciprocal (1 / x) of a value
  146925. */
  146926. export class ReciprocalBlock extends NodeMaterialBlock {
  146927. /**
  146928. * Creates a new ReciprocalBlock
  146929. * @param name defines the block name
  146930. */
  146931. constructor(name: string);
  146932. /**
  146933. * Gets the current class name
  146934. * @returns the class name
  146935. */
  146936. getClassName(): string;
  146937. /**
  146938. * Gets the input component
  146939. */
  146940. get input(): NodeMaterialConnectionPoint;
  146941. /**
  146942. * Gets the output component
  146943. */
  146944. get output(): NodeMaterialConnectionPoint;
  146945. protected _buildBlock(state: NodeMaterialBuildState): this;
  146946. }
  146947. }
  146948. declare module BABYLON {
  146949. /**
  146950. * Block used to replace a color by another one
  146951. */
  146952. export class ReplaceColorBlock extends NodeMaterialBlock {
  146953. /**
  146954. * Creates a new ReplaceColorBlock
  146955. * @param name defines the block name
  146956. */
  146957. constructor(name: string);
  146958. /**
  146959. * Gets the current class name
  146960. * @returns the class name
  146961. */
  146962. getClassName(): string;
  146963. /**
  146964. * Gets the value input component
  146965. */
  146966. get value(): NodeMaterialConnectionPoint;
  146967. /**
  146968. * Gets the reference input component
  146969. */
  146970. get reference(): NodeMaterialConnectionPoint;
  146971. /**
  146972. * Gets the distance input component
  146973. */
  146974. get distance(): NodeMaterialConnectionPoint;
  146975. /**
  146976. * Gets the replacement input component
  146977. */
  146978. get replacement(): NodeMaterialConnectionPoint;
  146979. /**
  146980. * Gets the output component
  146981. */
  146982. get output(): NodeMaterialConnectionPoint;
  146983. protected _buildBlock(state: NodeMaterialBuildState): this;
  146984. }
  146985. }
  146986. declare module BABYLON {
  146987. /**
  146988. * Block used to posterize a value
  146989. * @see https://en.wikipedia.org/wiki/Posterization
  146990. */
  146991. export class PosterizeBlock extends NodeMaterialBlock {
  146992. /**
  146993. * Creates a new PosterizeBlock
  146994. * @param name defines the block name
  146995. */
  146996. constructor(name: string);
  146997. /**
  146998. * Gets the current class name
  146999. * @returns the class name
  147000. */
  147001. getClassName(): string;
  147002. /**
  147003. * Gets the value input component
  147004. */
  147005. get value(): NodeMaterialConnectionPoint;
  147006. /**
  147007. * Gets the steps input component
  147008. */
  147009. get steps(): NodeMaterialConnectionPoint;
  147010. /**
  147011. * Gets the output component
  147012. */
  147013. get output(): NodeMaterialConnectionPoint;
  147014. protected _buildBlock(state: NodeMaterialBuildState): this;
  147015. }
  147016. }
  147017. declare module BABYLON {
  147018. /**
  147019. * Operations supported by the Wave block
  147020. */
  147021. export enum WaveBlockKind {
  147022. /** SawTooth */
  147023. SawTooth = 0,
  147024. /** Square */
  147025. Square = 1,
  147026. /** Triangle */
  147027. Triangle = 2
  147028. }
  147029. /**
  147030. * Block used to apply wave operation to floats
  147031. */
  147032. export class WaveBlock extends NodeMaterialBlock {
  147033. /**
  147034. * Gets or sets the kibnd of wave to be applied by the block
  147035. */
  147036. kind: WaveBlockKind;
  147037. /**
  147038. * Creates a new WaveBlock
  147039. * @param name defines the block name
  147040. */
  147041. constructor(name: string);
  147042. /**
  147043. * Gets the current class name
  147044. * @returns the class name
  147045. */
  147046. getClassName(): string;
  147047. /**
  147048. * Gets the input component
  147049. */
  147050. get input(): NodeMaterialConnectionPoint;
  147051. /**
  147052. * Gets the output component
  147053. */
  147054. get output(): NodeMaterialConnectionPoint;
  147055. protected _buildBlock(state: NodeMaterialBuildState): this;
  147056. serialize(): any;
  147057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147058. }
  147059. }
  147060. declare module BABYLON {
  147061. /**
  147062. * Class used to store a color step for the GradientBlock
  147063. */
  147064. export class GradientBlockColorStep {
  147065. private _step;
  147066. /**
  147067. * Gets value indicating which step this color is associated with (between 0 and 1)
  147068. */
  147069. get step(): number;
  147070. /**
  147071. * Sets a value indicating which step this color is associated with (between 0 and 1)
  147072. */
  147073. set step(val: number);
  147074. private _color;
  147075. /**
  147076. * Gets the color associated with this step
  147077. */
  147078. get color(): Color3;
  147079. /**
  147080. * Sets the color associated with this step
  147081. */
  147082. set color(val: Color3);
  147083. /**
  147084. * Creates a new GradientBlockColorStep
  147085. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  147086. * @param color defines the color associated with this step
  147087. */
  147088. constructor(step: number, color: Color3);
  147089. }
  147090. /**
  147091. * Block used to return a color from a gradient based on an input value between 0 and 1
  147092. */
  147093. export class GradientBlock extends NodeMaterialBlock {
  147094. /**
  147095. * Gets or sets the list of color steps
  147096. */
  147097. colorSteps: GradientBlockColorStep[];
  147098. /** Gets an observable raised when the value is changed */
  147099. onValueChangedObservable: Observable<GradientBlock>;
  147100. /** calls observable when the value is changed*/
  147101. colorStepsUpdated(): void;
  147102. /**
  147103. * Creates a new GradientBlock
  147104. * @param name defines the block name
  147105. */
  147106. constructor(name: string);
  147107. /**
  147108. * Gets the current class name
  147109. * @returns the class name
  147110. */
  147111. getClassName(): string;
  147112. /**
  147113. * Gets the gradient input component
  147114. */
  147115. get gradient(): NodeMaterialConnectionPoint;
  147116. /**
  147117. * Gets the output component
  147118. */
  147119. get output(): NodeMaterialConnectionPoint;
  147120. private _writeColorConstant;
  147121. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147122. serialize(): any;
  147123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147124. protected _dumpPropertiesCode(): string;
  147125. }
  147126. }
  147127. declare module BABYLON {
  147128. /**
  147129. * Block used to normalize lerp between 2 values
  147130. */
  147131. export class NLerpBlock extends NodeMaterialBlock {
  147132. /**
  147133. * Creates a new NLerpBlock
  147134. * @param name defines the block name
  147135. */
  147136. constructor(name: string);
  147137. /**
  147138. * Gets the current class name
  147139. * @returns the class name
  147140. */
  147141. getClassName(): string;
  147142. /**
  147143. * Gets the left operand input component
  147144. */
  147145. get left(): NodeMaterialConnectionPoint;
  147146. /**
  147147. * Gets the right operand input component
  147148. */
  147149. get right(): NodeMaterialConnectionPoint;
  147150. /**
  147151. * Gets the gradient operand input component
  147152. */
  147153. get gradient(): NodeMaterialConnectionPoint;
  147154. /**
  147155. * Gets the output component
  147156. */
  147157. get output(): NodeMaterialConnectionPoint;
  147158. protected _buildBlock(state: NodeMaterialBuildState): this;
  147159. }
  147160. }
  147161. declare module BABYLON {
  147162. /**
  147163. * block used to Generate a Worley Noise 3D Noise Pattern
  147164. */
  147165. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  147166. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  147167. manhattanDistance: boolean;
  147168. /**
  147169. * Creates a new WorleyNoise3DBlock
  147170. * @param name defines the block name
  147171. */
  147172. constructor(name: string);
  147173. /**
  147174. * Gets the current class name
  147175. * @returns the class name
  147176. */
  147177. getClassName(): string;
  147178. /**
  147179. * Gets the seed input component
  147180. */
  147181. get seed(): NodeMaterialConnectionPoint;
  147182. /**
  147183. * Gets the jitter input component
  147184. */
  147185. get jitter(): NodeMaterialConnectionPoint;
  147186. /**
  147187. * Gets the output component
  147188. */
  147189. get output(): NodeMaterialConnectionPoint;
  147190. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147191. /**
  147192. * Exposes the properties to the UI?
  147193. */
  147194. protected _dumpPropertiesCode(): string;
  147195. /**
  147196. * Exposes the properties to the Seralize?
  147197. */
  147198. serialize(): any;
  147199. /**
  147200. * Exposes the properties to the deseralize?
  147201. */
  147202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147203. }
  147204. }
  147205. declare module BABYLON {
  147206. /**
  147207. * block used to Generate a Simplex Perlin 3d Noise Pattern
  147208. */
  147209. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  147210. /**
  147211. * Creates a new SimplexPerlin3DBlock
  147212. * @param name defines the block name
  147213. */
  147214. constructor(name: string);
  147215. /**
  147216. * Gets the current class name
  147217. * @returns the class name
  147218. */
  147219. getClassName(): string;
  147220. /**
  147221. * Gets the seed operand input component
  147222. */
  147223. get seed(): NodeMaterialConnectionPoint;
  147224. /**
  147225. * Gets the output component
  147226. */
  147227. get output(): NodeMaterialConnectionPoint;
  147228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  147229. }
  147230. }
  147231. declare module BABYLON {
  147232. /**
  147233. * Block used to blend normals
  147234. */
  147235. export class NormalBlendBlock extends NodeMaterialBlock {
  147236. /**
  147237. * Creates a new NormalBlendBlock
  147238. * @param name defines the block name
  147239. */
  147240. constructor(name: string);
  147241. /**
  147242. * Gets the current class name
  147243. * @returns the class name
  147244. */
  147245. getClassName(): string;
  147246. /**
  147247. * Gets the first input component
  147248. */
  147249. get normalMap0(): NodeMaterialConnectionPoint;
  147250. /**
  147251. * Gets the second input component
  147252. */
  147253. get normalMap1(): NodeMaterialConnectionPoint;
  147254. /**
  147255. * Gets the output component
  147256. */
  147257. get output(): NodeMaterialConnectionPoint;
  147258. protected _buildBlock(state: NodeMaterialBuildState): this;
  147259. }
  147260. }
  147261. declare module BABYLON {
  147262. /**
  147263. * Block used to rotate a 2d vector by a given angle
  147264. */
  147265. export class Rotate2dBlock extends NodeMaterialBlock {
  147266. /**
  147267. * Creates a new Rotate2dBlock
  147268. * @param name defines the block name
  147269. */
  147270. constructor(name: string);
  147271. /**
  147272. * Gets the current class name
  147273. * @returns the class name
  147274. */
  147275. getClassName(): string;
  147276. /**
  147277. * Gets the input vector
  147278. */
  147279. get input(): NodeMaterialConnectionPoint;
  147280. /**
  147281. * Gets the input angle
  147282. */
  147283. get angle(): NodeMaterialConnectionPoint;
  147284. /**
  147285. * Gets the output component
  147286. */
  147287. get output(): NodeMaterialConnectionPoint;
  147288. autoConfigure(material: NodeMaterial): void;
  147289. protected _buildBlock(state: NodeMaterialBuildState): this;
  147290. }
  147291. }
  147292. declare module BABYLON {
  147293. /**
  147294. * Block used to get the reflected vector from a direction and a normal
  147295. */
  147296. export class ReflectBlock extends NodeMaterialBlock {
  147297. /**
  147298. * Creates a new ReflectBlock
  147299. * @param name defines the block name
  147300. */
  147301. constructor(name: string);
  147302. /**
  147303. * Gets the current class name
  147304. * @returns the class name
  147305. */
  147306. getClassName(): string;
  147307. /**
  147308. * Gets the incident component
  147309. */
  147310. get incident(): NodeMaterialConnectionPoint;
  147311. /**
  147312. * Gets the normal component
  147313. */
  147314. get normal(): NodeMaterialConnectionPoint;
  147315. /**
  147316. * Gets the output component
  147317. */
  147318. get output(): NodeMaterialConnectionPoint;
  147319. protected _buildBlock(state: NodeMaterialBuildState): this;
  147320. }
  147321. }
  147322. declare module BABYLON {
  147323. /**
  147324. * Block used to get the refracted vector from a direction and a normal
  147325. */
  147326. export class RefractBlock extends NodeMaterialBlock {
  147327. /**
  147328. * Creates a new RefractBlock
  147329. * @param name defines the block name
  147330. */
  147331. constructor(name: string);
  147332. /**
  147333. * Gets the current class name
  147334. * @returns the class name
  147335. */
  147336. getClassName(): string;
  147337. /**
  147338. * Gets the incident component
  147339. */
  147340. get incident(): NodeMaterialConnectionPoint;
  147341. /**
  147342. * Gets the normal component
  147343. */
  147344. get normal(): NodeMaterialConnectionPoint;
  147345. /**
  147346. * Gets the index of refraction component
  147347. */
  147348. get ior(): NodeMaterialConnectionPoint;
  147349. /**
  147350. * Gets the output component
  147351. */
  147352. get output(): NodeMaterialConnectionPoint;
  147353. protected _buildBlock(state: NodeMaterialBuildState): this;
  147354. }
  147355. }
  147356. declare module BABYLON {
  147357. /**
  147358. * Block used to desaturate a color
  147359. */
  147360. export class DesaturateBlock extends NodeMaterialBlock {
  147361. /**
  147362. * Creates a new DesaturateBlock
  147363. * @param name defines the block name
  147364. */
  147365. constructor(name: string);
  147366. /**
  147367. * Gets the current class name
  147368. * @returns the class name
  147369. */
  147370. getClassName(): string;
  147371. /**
  147372. * Gets the color operand input component
  147373. */
  147374. get color(): NodeMaterialConnectionPoint;
  147375. /**
  147376. * Gets the level operand input component
  147377. */
  147378. get level(): NodeMaterialConnectionPoint;
  147379. /**
  147380. * Gets the output component
  147381. */
  147382. get output(): NodeMaterialConnectionPoint;
  147383. protected _buildBlock(state: NodeMaterialBuildState): this;
  147384. }
  147385. }
  147386. declare module BABYLON {
  147387. /**
  147388. * Block used to implement the reflection module of the PBR material
  147389. */
  147390. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  147391. /** @hidden */
  147392. _defineLODReflectionAlpha: string;
  147393. /** @hidden */
  147394. _defineLinearSpecularReflection: string;
  147395. private _vEnvironmentIrradianceName;
  147396. /** @hidden */
  147397. _vReflectionMicrosurfaceInfosName: string;
  147398. /** @hidden */
  147399. _vReflectionInfosName: string;
  147400. /** @hidden */
  147401. _vReflectionFilteringInfoName: string;
  147402. private _scene;
  147403. /**
  147404. * The properties below are set by the main PBR block prior to calling methods of this class.
  147405. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147406. * It's less burden on the user side in the editor part.
  147407. */
  147408. /** @hidden */
  147409. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147410. /** @hidden */
  147411. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147412. /** @hidden */
  147413. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  147414. /** @hidden */
  147415. viewConnectionPoint: NodeMaterialConnectionPoint;
  147416. /**
  147417. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  147418. * diffuse part of the IBL.
  147419. */
  147420. useSphericalHarmonics: boolean;
  147421. /**
  147422. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  147423. */
  147424. forceIrradianceInFragment: boolean;
  147425. /**
  147426. * Create a new ReflectionBlock
  147427. * @param name defines the block name
  147428. */
  147429. constructor(name: string);
  147430. /**
  147431. * Gets the current class name
  147432. * @returns the class name
  147433. */
  147434. getClassName(): string;
  147435. /**
  147436. * Gets the position input component
  147437. */
  147438. get position(): NodeMaterialConnectionPoint;
  147439. /**
  147440. * Gets the world position input component
  147441. */
  147442. get worldPosition(): NodeMaterialConnectionPoint;
  147443. /**
  147444. * Gets the world normal input component
  147445. */
  147446. get worldNormal(): NodeMaterialConnectionPoint;
  147447. /**
  147448. * Gets the world input component
  147449. */
  147450. get world(): NodeMaterialConnectionPoint;
  147451. /**
  147452. * Gets the camera (or eye) position component
  147453. */
  147454. get cameraPosition(): NodeMaterialConnectionPoint;
  147455. /**
  147456. * Gets the view input component
  147457. */
  147458. get view(): NodeMaterialConnectionPoint;
  147459. /**
  147460. * Gets the color input component
  147461. */
  147462. get color(): NodeMaterialConnectionPoint;
  147463. /**
  147464. * Gets the reflection object output component
  147465. */
  147466. get reflection(): NodeMaterialConnectionPoint;
  147467. /**
  147468. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  147469. */
  147470. get hasTexture(): boolean;
  147471. /**
  147472. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  147473. */
  147474. get reflectionColor(): string;
  147475. protected _getTexture(): Nullable<BaseTexture>;
  147476. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147477. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147478. /**
  147479. * Gets the code to inject in the vertex shader
  147480. * @param state current state of the node material building
  147481. * @returns the shader code
  147482. */
  147483. handleVertexSide(state: NodeMaterialBuildState): string;
  147484. /**
  147485. * Gets the main code of the block (fragment side)
  147486. * @param state current state of the node material building
  147487. * @param normalVarName name of the existing variable corresponding to the normal
  147488. * @returns the shader code
  147489. */
  147490. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  147491. protected _buildBlock(state: NodeMaterialBuildState): this;
  147492. protected _dumpPropertiesCode(): string;
  147493. serialize(): any;
  147494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147495. }
  147496. }
  147497. declare module BABYLON {
  147498. /**
  147499. * Block used to implement the sheen module of the PBR material
  147500. */
  147501. export class SheenBlock extends NodeMaterialBlock {
  147502. /**
  147503. * Create a new SheenBlock
  147504. * @param name defines the block name
  147505. */
  147506. constructor(name: string);
  147507. /**
  147508. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  147509. * It allows the strength of the sheen effect to not depend on the base color of the material,
  147510. * making it easier to setup and tweak the effect
  147511. */
  147512. albedoScaling: boolean;
  147513. /**
  147514. * Defines if the sheen is linked to the sheen color.
  147515. */
  147516. linkSheenWithAlbedo: boolean;
  147517. /**
  147518. * Initialize the block and prepare the context for build
  147519. * @param state defines the state that will be used for the build
  147520. */
  147521. initialize(state: NodeMaterialBuildState): void;
  147522. /**
  147523. * Gets the current class name
  147524. * @returns the class name
  147525. */
  147526. getClassName(): string;
  147527. /**
  147528. * Gets the intensity input component
  147529. */
  147530. get intensity(): NodeMaterialConnectionPoint;
  147531. /**
  147532. * Gets the color input component
  147533. */
  147534. get color(): NodeMaterialConnectionPoint;
  147535. /**
  147536. * Gets the roughness input component
  147537. */
  147538. get roughness(): NodeMaterialConnectionPoint;
  147539. /**
  147540. * Gets the sheen object output component
  147541. */
  147542. get sheen(): NodeMaterialConnectionPoint;
  147543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147544. /**
  147545. * Gets the main code of the block (fragment side)
  147546. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147547. * @returns the shader code
  147548. */
  147549. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  147550. protected _buildBlock(state: NodeMaterialBuildState): this;
  147551. protected _dumpPropertiesCode(): string;
  147552. serialize(): any;
  147553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147554. }
  147555. }
  147556. declare module BABYLON {
  147557. /**
  147558. * Block used to implement the anisotropy module of the PBR material
  147559. */
  147560. export class AnisotropyBlock extends NodeMaterialBlock {
  147561. /**
  147562. * The two properties below are set by the main PBR block prior to calling methods of this class.
  147563. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  147564. * It's less burden on the user side in the editor part.
  147565. */
  147566. /** @hidden */
  147567. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  147568. /** @hidden */
  147569. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  147570. /**
  147571. * Create a new AnisotropyBlock
  147572. * @param name defines the block name
  147573. */
  147574. constructor(name: string);
  147575. /**
  147576. * Initialize the block and prepare the context for build
  147577. * @param state defines the state that will be used for the build
  147578. */
  147579. initialize(state: NodeMaterialBuildState): void;
  147580. /**
  147581. * Gets the current class name
  147582. * @returns the class name
  147583. */
  147584. getClassName(): string;
  147585. /**
  147586. * Gets the intensity input component
  147587. */
  147588. get intensity(): NodeMaterialConnectionPoint;
  147589. /**
  147590. * Gets the direction input component
  147591. */
  147592. get direction(): NodeMaterialConnectionPoint;
  147593. /**
  147594. * Gets the uv input component
  147595. */
  147596. get uv(): NodeMaterialConnectionPoint;
  147597. /**
  147598. * Gets the worldTangent input component
  147599. */
  147600. get worldTangent(): NodeMaterialConnectionPoint;
  147601. /**
  147602. * Gets the anisotropy object output component
  147603. */
  147604. get anisotropy(): NodeMaterialConnectionPoint;
  147605. private _generateTBNSpace;
  147606. /**
  147607. * Gets the main code of the block (fragment side)
  147608. * @param state current state of the node material building
  147609. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147610. * @returns the shader code
  147611. */
  147612. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  147613. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147614. protected _buildBlock(state: NodeMaterialBuildState): this;
  147615. }
  147616. }
  147617. declare module BABYLON {
  147618. /**
  147619. * Block used to implement the clear coat module of the PBR material
  147620. */
  147621. export class ClearCoatBlock extends NodeMaterialBlock {
  147622. private _scene;
  147623. /**
  147624. * Create a new ClearCoatBlock
  147625. * @param name defines the block name
  147626. */
  147627. constructor(name: string);
  147628. /**
  147629. * Defines if the F0 value should be remapped to account for the interface change in the material.
  147630. */
  147631. remapF0OnInterfaceChange: boolean;
  147632. /**
  147633. * Initialize the block and prepare the context for build
  147634. * @param state defines the state that will be used for the build
  147635. */
  147636. initialize(state: NodeMaterialBuildState): void;
  147637. /**
  147638. * Gets the current class name
  147639. * @returns the class name
  147640. */
  147641. getClassName(): string;
  147642. /**
  147643. * Gets the intensity input component
  147644. */
  147645. get intensity(): NodeMaterialConnectionPoint;
  147646. /**
  147647. * Gets the roughness input component
  147648. */
  147649. get roughness(): NodeMaterialConnectionPoint;
  147650. /**
  147651. * Gets the ior input component
  147652. */
  147653. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147654. /**
  147655. * Gets the bump texture input component
  147656. */
  147657. get normalMapColor(): NodeMaterialConnectionPoint;
  147658. /**
  147659. * Gets the uv input component
  147660. */
  147661. get uv(): NodeMaterialConnectionPoint;
  147662. /**
  147663. * Gets the tint color input component
  147664. */
  147665. get tintColor(): NodeMaterialConnectionPoint;
  147666. /**
  147667. * Gets the tint "at distance" input component
  147668. */
  147669. get tintAtDistance(): NodeMaterialConnectionPoint;
  147670. /**
  147671. * Gets the tint thickness input component
  147672. */
  147673. get tintThickness(): NodeMaterialConnectionPoint;
  147674. /**
  147675. * Gets the world tangent input component
  147676. */
  147677. get worldTangent(): NodeMaterialConnectionPoint;
  147678. /**
  147679. * Gets the clear coat object output component
  147680. */
  147681. get clearcoat(): NodeMaterialConnectionPoint;
  147682. autoConfigure(material: NodeMaterial): void;
  147683. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147684. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  147685. private _generateTBNSpace;
  147686. /**
  147687. * Gets the main code of the block (fragment side)
  147688. * @param state current state of the node material building
  147689. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  147690. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147691. * @param worldPosVarName name of the variable holding the world position
  147692. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  147693. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  147694. * @param worldNormalVarName name of the variable holding the world normal
  147695. * @returns the shader code
  147696. */
  147697. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  147698. protected _buildBlock(state: NodeMaterialBuildState): this;
  147699. protected _dumpPropertiesCode(): string;
  147700. serialize(): any;
  147701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147702. }
  147703. }
  147704. declare module BABYLON {
  147705. /**
  147706. * Block used to implement the sub surface module of the PBR material
  147707. */
  147708. export class SubSurfaceBlock extends NodeMaterialBlock {
  147709. /**
  147710. * Create a new SubSurfaceBlock
  147711. * @param name defines the block name
  147712. */
  147713. constructor(name: string);
  147714. /**
  147715. * Initialize the block and prepare the context for build
  147716. * @param state defines the state that will be used for the build
  147717. */
  147718. initialize(state: NodeMaterialBuildState): void;
  147719. /**
  147720. * Gets the current class name
  147721. * @returns the class name
  147722. */
  147723. getClassName(): string;
  147724. /**
  147725. * Gets the thickness component
  147726. */
  147727. get thickness(): NodeMaterialConnectionPoint;
  147728. /**
  147729. * Gets the tint color input component
  147730. */
  147731. get tintColor(): NodeMaterialConnectionPoint;
  147732. /**
  147733. * Gets the translucency intensity input component
  147734. */
  147735. get translucencyIntensity(): NodeMaterialConnectionPoint;
  147736. /**
  147737. * Gets the translucency diffusion distance input component
  147738. */
  147739. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  147740. /**
  147741. * Gets the refraction object parameters
  147742. */
  147743. get refraction(): NodeMaterialConnectionPoint;
  147744. /**
  147745. * Gets the sub surface object output component
  147746. */
  147747. get subsurface(): NodeMaterialConnectionPoint;
  147748. autoConfigure(material: NodeMaterial): void;
  147749. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147750. /**
  147751. * Gets the main code of the block (fragment side)
  147752. * @param state current state of the node material building
  147753. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  147754. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  147755. * @param worldPosVarName name of the variable holding the world position
  147756. * @returns the shader code
  147757. */
  147758. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  147759. protected _buildBlock(state: NodeMaterialBuildState): this;
  147760. }
  147761. }
  147762. declare module BABYLON {
  147763. /**
  147764. * Block used to implement the PBR metallic/roughness model
  147765. */
  147766. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  147767. /**
  147768. * Gets or sets the light associated with this block
  147769. */
  147770. light: Nullable<Light>;
  147771. private _lightId;
  147772. private _scene;
  147773. private _environmentBRDFTexture;
  147774. private _environmentBrdfSamplerName;
  147775. private _vNormalWName;
  147776. private _invertNormalName;
  147777. private _metallicReflectanceColor;
  147778. private _metallicF0Factor;
  147779. private _vMetallicReflectanceFactorsName;
  147780. /**
  147781. * Create a new ReflectionBlock
  147782. * @param name defines the block name
  147783. */
  147784. constructor(name: string);
  147785. /**
  147786. * Intensity of the direct lights e.g. the four lights available in your scene.
  147787. * This impacts both the direct diffuse and specular highlights.
  147788. */
  147789. directIntensity: number;
  147790. /**
  147791. * Intensity of the environment e.g. how much the environment will light the object
  147792. * either through harmonics for rough material or through the refelction for shiny ones.
  147793. */
  147794. environmentIntensity: number;
  147795. /**
  147796. * This is a special control allowing the reduction of the specular highlights coming from the
  147797. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  147798. */
  147799. specularIntensity: number;
  147800. /**
  147801. * Defines the falloff type used in this material.
  147802. * It by default is Physical.
  147803. */
  147804. lightFalloff: number;
  147805. /**
  147806. * Specifies that alpha test should be used
  147807. */
  147808. useAlphaTest: boolean;
  147809. /**
  147810. * Defines the alpha limits in alpha test mode.
  147811. */
  147812. alphaTestCutoff: number;
  147813. /**
  147814. * Specifies that alpha blending should be used
  147815. */
  147816. useAlphaBlending: boolean;
  147817. /**
  147818. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147819. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147820. */
  147821. useRadianceOverAlpha: boolean;
  147822. /**
  147823. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147824. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147825. */
  147826. useSpecularOverAlpha: boolean;
  147827. /**
  147828. * Enables specular anti aliasing in the PBR shader.
  147829. * It will both interacts on the Geometry for analytical and IBL lighting.
  147830. * It also prefilter the roughness map based on the bump values.
  147831. */
  147832. enableSpecularAntiAliasing: boolean;
  147833. /**
  147834. * Enables realtime filtering on the texture.
  147835. */
  147836. realTimeFiltering: boolean;
  147837. /**
  147838. * Quality switch for realtime filtering
  147839. */
  147840. realTimeFilteringQuality: number;
  147841. /**
  147842. * Defines if the material uses energy conservation.
  147843. */
  147844. useEnergyConservation: boolean;
  147845. /**
  147846. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147847. * too much the area relying on ambient texture to define their ambient occlusion.
  147848. */
  147849. useRadianceOcclusion: boolean;
  147850. /**
  147851. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147852. * makes the reflect vector face the model (under horizon).
  147853. */
  147854. useHorizonOcclusion: boolean;
  147855. /**
  147856. * If set to true, no lighting calculations will be applied.
  147857. */
  147858. unlit: boolean;
  147859. /**
  147860. * Force normal to face away from face.
  147861. */
  147862. forceNormalForward: boolean;
  147863. /**
  147864. * Defines the material debug mode.
  147865. * It helps seeing only some components of the material while troubleshooting.
  147866. */
  147867. debugMode: number;
  147868. /**
  147869. * Specify from where on screen the debug mode should start.
  147870. * The value goes from -1 (full screen) to 1 (not visible)
  147871. * It helps with side by side comparison against the final render
  147872. * This defaults to 0
  147873. */
  147874. debugLimit: number;
  147875. /**
  147876. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147877. * You can use the factor to better multiply the final value.
  147878. */
  147879. debugFactor: number;
  147880. /**
  147881. * Initialize the block and prepare the context for build
  147882. * @param state defines the state that will be used for the build
  147883. */
  147884. initialize(state: NodeMaterialBuildState): void;
  147885. /**
  147886. * Gets the current class name
  147887. * @returns the class name
  147888. */
  147889. getClassName(): string;
  147890. /**
  147891. * Gets the world position input component
  147892. */
  147893. get worldPosition(): NodeMaterialConnectionPoint;
  147894. /**
  147895. * Gets the world normal input component
  147896. */
  147897. get worldNormal(): NodeMaterialConnectionPoint;
  147898. /**
  147899. * Gets the view matrix parameter
  147900. */
  147901. get view(): NodeMaterialConnectionPoint;
  147902. /**
  147903. * Gets the camera position input component
  147904. */
  147905. get cameraPosition(): NodeMaterialConnectionPoint;
  147906. /**
  147907. * Gets the perturbed normal input component
  147908. */
  147909. get perturbedNormal(): NodeMaterialConnectionPoint;
  147910. /**
  147911. * Gets the base color input component
  147912. */
  147913. get baseColor(): NodeMaterialConnectionPoint;
  147914. /**
  147915. * Gets the metallic input component
  147916. */
  147917. get metallic(): NodeMaterialConnectionPoint;
  147918. /**
  147919. * Gets the roughness input component
  147920. */
  147921. get roughness(): NodeMaterialConnectionPoint;
  147922. /**
  147923. * Gets the ambient occlusion input component
  147924. */
  147925. get ambientOcc(): NodeMaterialConnectionPoint;
  147926. /**
  147927. * Gets the opacity input component
  147928. */
  147929. get opacity(): NodeMaterialConnectionPoint;
  147930. /**
  147931. * Gets the index of refraction input component
  147932. */
  147933. get indexOfRefraction(): NodeMaterialConnectionPoint;
  147934. /**
  147935. * Gets the ambient color input component
  147936. */
  147937. get ambientColor(): NodeMaterialConnectionPoint;
  147938. /**
  147939. * Gets the reflection object parameters
  147940. */
  147941. get reflection(): NodeMaterialConnectionPoint;
  147942. /**
  147943. * Gets the clear coat object parameters
  147944. */
  147945. get clearcoat(): NodeMaterialConnectionPoint;
  147946. /**
  147947. * Gets the sheen object parameters
  147948. */
  147949. get sheen(): NodeMaterialConnectionPoint;
  147950. /**
  147951. * Gets the sub surface object parameters
  147952. */
  147953. get subsurface(): NodeMaterialConnectionPoint;
  147954. /**
  147955. * Gets the anisotropy object parameters
  147956. */
  147957. get anisotropy(): NodeMaterialConnectionPoint;
  147958. /**
  147959. * Gets the ambient output component
  147960. */
  147961. get ambientClr(): NodeMaterialConnectionPoint;
  147962. /**
  147963. * Gets the diffuse output component
  147964. */
  147965. get diffuseDir(): NodeMaterialConnectionPoint;
  147966. /**
  147967. * Gets the specular output component
  147968. */
  147969. get specularDir(): NodeMaterialConnectionPoint;
  147970. /**
  147971. * Gets the clear coat output component
  147972. */
  147973. get clearcoatDir(): NodeMaterialConnectionPoint;
  147974. /**
  147975. * Gets the sheen output component
  147976. */
  147977. get sheenDir(): NodeMaterialConnectionPoint;
  147978. /**
  147979. * Gets the indirect diffuse output component
  147980. */
  147981. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147982. /**
  147983. * Gets the indirect specular output component
  147984. */
  147985. get specularIndirect(): NodeMaterialConnectionPoint;
  147986. /**
  147987. * Gets the indirect clear coat output component
  147988. */
  147989. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147990. /**
  147991. * Gets the indirect sheen output component
  147992. */
  147993. get sheenIndirect(): NodeMaterialConnectionPoint;
  147994. /**
  147995. * Gets the refraction output component
  147996. */
  147997. get refraction(): NodeMaterialConnectionPoint;
  147998. /**
  147999. * Gets the global lighting output component
  148000. */
  148001. get lighting(): NodeMaterialConnectionPoint;
  148002. /**
  148003. * Gets the shadow output component
  148004. */
  148005. get shadow(): NodeMaterialConnectionPoint;
  148006. /**
  148007. * Gets the alpha output component
  148008. */
  148009. get alpha(): NodeMaterialConnectionPoint;
  148010. autoConfigure(material: NodeMaterial): void;
  148011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  148012. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  148013. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  148014. private _injectVertexCode;
  148015. private _getAlbedoOpacityCode;
  148016. private _getAmbientOcclusionCode;
  148017. private _getReflectivityCode;
  148018. protected _buildBlock(state: NodeMaterialBuildState): this;
  148019. protected _dumpPropertiesCode(): string;
  148020. serialize(): any;
  148021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  148022. }
  148023. }
  148024. declare module BABYLON {
  148025. /**
  148026. * Block used to compute value of one parameter modulo another
  148027. */
  148028. export class ModBlock extends NodeMaterialBlock {
  148029. /**
  148030. * Creates a new ModBlock
  148031. * @param name defines the block name
  148032. */
  148033. constructor(name: string);
  148034. /**
  148035. * Gets the current class name
  148036. * @returns the class name
  148037. */
  148038. getClassName(): string;
  148039. /**
  148040. * Gets the left operand input component
  148041. */
  148042. get left(): NodeMaterialConnectionPoint;
  148043. /**
  148044. * Gets the right operand input component
  148045. */
  148046. get right(): NodeMaterialConnectionPoint;
  148047. /**
  148048. * Gets the output component
  148049. */
  148050. get output(): NodeMaterialConnectionPoint;
  148051. protected _buildBlock(state: NodeMaterialBuildState): this;
  148052. }
  148053. }
  148054. declare module BABYLON {
  148055. /**
  148056. * Configuration for Draco compression
  148057. */
  148058. export interface IDracoCompressionConfiguration {
  148059. /**
  148060. * Configuration for the decoder.
  148061. */
  148062. decoder: {
  148063. /**
  148064. * The url to the WebAssembly module.
  148065. */
  148066. wasmUrl?: string;
  148067. /**
  148068. * The url to the WebAssembly binary.
  148069. */
  148070. wasmBinaryUrl?: string;
  148071. /**
  148072. * The url to the fallback JavaScript module.
  148073. */
  148074. fallbackUrl?: string;
  148075. };
  148076. }
  148077. /**
  148078. * Draco compression (https://google.github.io/draco/)
  148079. *
  148080. * This class wraps the Draco module.
  148081. *
  148082. * **Encoder**
  148083. *
  148084. * The encoder is not currently implemented.
  148085. *
  148086. * **Decoder**
  148087. *
  148088. * 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.
  148089. *
  148090. * To update the configuration, use the following code:
  148091. * ```javascript
  148092. * DracoCompression.Configuration = {
  148093. * decoder: {
  148094. * wasmUrl: "<url to the WebAssembly library>",
  148095. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  148096. * fallbackUrl: "<url to the fallback JavaScript library>",
  148097. * }
  148098. * };
  148099. * ```
  148100. *
  148101. * 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.
  148102. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  148103. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  148104. *
  148105. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  148106. * ```javascript
  148107. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  148108. * ```
  148109. *
  148110. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  148111. */
  148112. export class DracoCompression implements IDisposable {
  148113. private _workerPoolPromise?;
  148114. private _decoderModulePromise?;
  148115. /**
  148116. * The configuration. Defaults to the following urls:
  148117. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  148118. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  148119. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  148120. */
  148121. static Configuration: IDracoCompressionConfiguration;
  148122. /**
  148123. * Returns true if the decoder configuration is available.
  148124. */
  148125. static get DecoderAvailable(): boolean;
  148126. /**
  148127. * Default number of workers to create when creating the draco compression object.
  148128. */
  148129. static DefaultNumWorkers: number;
  148130. private static GetDefaultNumWorkers;
  148131. private static _Default;
  148132. /**
  148133. * Default instance for the draco compression object.
  148134. */
  148135. static get Default(): DracoCompression;
  148136. /**
  148137. * Constructor
  148138. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  148139. */
  148140. constructor(numWorkers?: number);
  148141. /**
  148142. * Stop all async operations and release resources.
  148143. */
  148144. dispose(): void;
  148145. /**
  148146. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  148147. * @returns a promise that resolves when ready
  148148. */
  148149. whenReadyAsync(): Promise<void>;
  148150. /**
  148151. * Decode Draco compressed mesh data to vertex data.
  148152. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  148153. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  148154. * @returns A promise that resolves with the decoded vertex data
  148155. */
  148156. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  148157. [kind: string]: number;
  148158. }): Promise<VertexData>;
  148159. }
  148160. }
  148161. declare module BABYLON {
  148162. /**
  148163. * Class for building Constructive Solid Geometry
  148164. */
  148165. export class CSG {
  148166. private polygons;
  148167. /**
  148168. * The world matrix
  148169. */
  148170. matrix: Matrix;
  148171. /**
  148172. * Stores the position
  148173. */
  148174. position: Vector3;
  148175. /**
  148176. * Stores the rotation
  148177. */
  148178. rotation: Vector3;
  148179. /**
  148180. * Stores the rotation quaternion
  148181. */
  148182. rotationQuaternion: Nullable<Quaternion>;
  148183. /**
  148184. * Stores the scaling vector
  148185. */
  148186. scaling: Vector3;
  148187. /**
  148188. * Convert the Mesh to CSG
  148189. * @param mesh The Mesh to convert to CSG
  148190. * @returns A new CSG from the Mesh
  148191. */
  148192. static FromMesh(mesh: Mesh): CSG;
  148193. /**
  148194. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  148195. * @param polygons Polygons used to construct a CSG solid
  148196. */
  148197. private static FromPolygons;
  148198. /**
  148199. * Clones, or makes a deep copy, of the CSG
  148200. * @returns A new CSG
  148201. */
  148202. clone(): CSG;
  148203. /**
  148204. * Unions this CSG with another CSG
  148205. * @param csg The CSG to union against this CSG
  148206. * @returns The unioned CSG
  148207. */
  148208. union(csg: CSG): CSG;
  148209. /**
  148210. * Unions this CSG with another CSG in place
  148211. * @param csg The CSG to union against this CSG
  148212. */
  148213. unionInPlace(csg: CSG): void;
  148214. /**
  148215. * Subtracts this CSG with another CSG
  148216. * @param csg The CSG to subtract against this CSG
  148217. * @returns A new CSG
  148218. */
  148219. subtract(csg: CSG): CSG;
  148220. /**
  148221. * Subtracts this CSG with another CSG in place
  148222. * @param csg The CSG to subtact against this CSG
  148223. */
  148224. subtractInPlace(csg: CSG): void;
  148225. /**
  148226. * Intersect this CSG with another CSG
  148227. * @param csg The CSG to intersect against this CSG
  148228. * @returns A new CSG
  148229. */
  148230. intersect(csg: CSG): CSG;
  148231. /**
  148232. * Intersects this CSG with another CSG in place
  148233. * @param csg The CSG to intersect against this CSG
  148234. */
  148235. intersectInPlace(csg: CSG): void;
  148236. /**
  148237. * Return a new CSG solid with solid and empty space switched. This solid is
  148238. * not modified.
  148239. * @returns A new CSG solid with solid and empty space switched
  148240. */
  148241. inverse(): CSG;
  148242. /**
  148243. * Inverses the CSG in place
  148244. */
  148245. inverseInPlace(): void;
  148246. /**
  148247. * This is used to keep meshes transformations so they can be restored
  148248. * when we build back a Babylon Mesh
  148249. * NB : All CSG operations are performed in world coordinates
  148250. * @param csg The CSG to copy the transform attributes from
  148251. * @returns This CSG
  148252. */
  148253. copyTransformAttributes(csg: CSG): CSG;
  148254. /**
  148255. * Build Raw mesh from CSG
  148256. * Coordinates here are in world space
  148257. * @param name The name of the mesh geometry
  148258. * @param scene The Scene
  148259. * @param keepSubMeshes Specifies if the submeshes should be kept
  148260. * @returns A new Mesh
  148261. */
  148262. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148263. /**
  148264. * Build Mesh from CSG taking material and transforms into account
  148265. * @param name The name of the Mesh
  148266. * @param material The material of the Mesh
  148267. * @param scene The Scene
  148268. * @param keepSubMeshes Specifies if submeshes should be kept
  148269. * @returns The new Mesh
  148270. */
  148271. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  148272. }
  148273. }
  148274. declare module BABYLON {
  148275. /**
  148276. * Class used to create a trail following a mesh
  148277. */
  148278. export class TrailMesh extends Mesh {
  148279. private _generator;
  148280. private _autoStart;
  148281. private _running;
  148282. private _diameter;
  148283. private _length;
  148284. private _sectionPolygonPointsCount;
  148285. private _sectionVectors;
  148286. private _sectionNormalVectors;
  148287. private _beforeRenderObserver;
  148288. /**
  148289. * @constructor
  148290. * @param name The value used by scene.getMeshByName() to do a lookup.
  148291. * @param generator The mesh or transform node to generate a trail.
  148292. * @param scene The scene to add this mesh to.
  148293. * @param diameter Diameter of trailing mesh. Default is 1.
  148294. * @param length Length of trailing mesh. Default is 60.
  148295. * @param autoStart Automatically start trailing mesh. Default true.
  148296. */
  148297. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  148298. /**
  148299. * "TrailMesh"
  148300. * @returns "TrailMesh"
  148301. */
  148302. getClassName(): string;
  148303. private _createMesh;
  148304. /**
  148305. * Start trailing mesh.
  148306. */
  148307. start(): void;
  148308. /**
  148309. * Stop trailing mesh.
  148310. */
  148311. stop(): void;
  148312. /**
  148313. * Update trailing mesh geometry.
  148314. */
  148315. update(): void;
  148316. /**
  148317. * Returns a new TrailMesh object.
  148318. * @param name is a string, the name given to the new mesh
  148319. * @param newGenerator use new generator object for cloned trail mesh
  148320. * @returns a new mesh
  148321. */
  148322. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  148323. /**
  148324. * Serializes this trail mesh
  148325. * @param serializationObject object to write serialization to
  148326. */
  148327. serialize(serializationObject: any): void;
  148328. /**
  148329. * Parses a serialized trail mesh
  148330. * @param parsedMesh the serialized mesh
  148331. * @param scene the scene to create the trail mesh in
  148332. * @returns the created trail mesh
  148333. */
  148334. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  148335. }
  148336. }
  148337. declare module BABYLON {
  148338. /**
  148339. * Class containing static functions to help procedurally build meshes
  148340. */
  148341. export class TiledBoxBuilder {
  148342. /**
  148343. * Creates a box mesh
  148344. * 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)
  148345. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148349. * @param name defines the name of the mesh
  148350. * @param options defines the options used to create the mesh
  148351. * @param scene defines the hosting scene
  148352. * @returns the box mesh
  148353. */
  148354. static CreateTiledBox(name: string, options: {
  148355. pattern?: number;
  148356. width?: number;
  148357. height?: number;
  148358. depth?: number;
  148359. tileSize?: number;
  148360. tileWidth?: number;
  148361. tileHeight?: number;
  148362. alignHorizontal?: number;
  148363. alignVertical?: number;
  148364. faceUV?: Vector4[];
  148365. faceColors?: Color4[];
  148366. sideOrientation?: number;
  148367. updatable?: boolean;
  148368. }, scene?: Nullable<Scene>): Mesh;
  148369. }
  148370. }
  148371. declare module BABYLON {
  148372. /**
  148373. * Class containing static functions to help procedurally build meshes
  148374. */
  148375. export class TorusKnotBuilder {
  148376. /**
  148377. * Creates a torus knot mesh
  148378. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148379. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148380. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148381. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148385. * @param name defines the name of the mesh
  148386. * @param options defines the options used to create the mesh
  148387. * @param scene defines the hosting scene
  148388. * @returns the torus knot mesh
  148389. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148390. */
  148391. static CreateTorusKnot(name: string, options: {
  148392. radius?: number;
  148393. tube?: number;
  148394. radialSegments?: number;
  148395. tubularSegments?: number;
  148396. p?: number;
  148397. q?: number;
  148398. updatable?: boolean;
  148399. sideOrientation?: number;
  148400. frontUVs?: Vector4;
  148401. backUVs?: Vector4;
  148402. }, scene: any): Mesh;
  148403. }
  148404. }
  148405. declare module BABYLON {
  148406. /**
  148407. * Polygon
  148408. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  148409. */
  148410. export class Polygon {
  148411. /**
  148412. * Creates a rectangle
  148413. * @param xmin bottom X coord
  148414. * @param ymin bottom Y coord
  148415. * @param xmax top X coord
  148416. * @param ymax top Y coord
  148417. * @returns points that make the resulting rectation
  148418. */
  148419. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  148420. /**
  148421. * Creates a circle
  148422. * @param radius radius of circle
  148423. * @param cx scale in x
  148424. * @param cy scale in y
  148425. * @param numberOfSides number of sides that make up the circle
  148426. * @returns points that make the resulting circle
  148427. */
  148428. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  148429. /**
  148430. * Creates a polygon from input string
  148431. * @param input Input polygon data
  148432. * @returns the parsed points
  148433. */
  148434. static Parse(input: string): Vector2[];
  148435. /**
  148436. * Starts building a polygon from x and y coordinates
  148437. * @param x x coordinate
  148438. * @param y y coordinate
  148439. * @returns the started path2
  148440. */
  148441. static StartingAt(x: number, y: number): Path2;
  148442. }
  148443. /**
  148444. * Builds a polygon
  148445. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  148446. */
  148447. export class PolygonMeshBuilder {
  148448. private _points;
  148449. private _outlinepoints;
  148450. private _holes;
  148451. private _name;
  148452. private _scene;
  148453. private _epoints;
  148454. private _eholes;
  148455. private _addToepoint;
  148456. /**
  148457. * Babylon reference to the earcut plugin.
  148458. */
  148459. bjsEarcut: any;
  148460. /**
  148461. * Creates a PolygonMeshBuilder
  148462. * @param name name of the builder
  148463. * @param contours Path of the polygon
  148464. * @param scene scene to add to when creating the mesh
  148465. * @param earcutInjection can be used to inject your own earcut reference
  148466. */
  148467. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  148468. /**
  148469. * Adds a whole within the polygon
  148470. * @param hole Array of points defining the hole
  148471. * @returns this
  148472. */
  148473. addHole(hole: Vector2[]): PolygonMeshBuilder;
  148474. /**
  148475. * Creates the polygon
  148476. * @param updatable If the mesh should be updatable
  148477. * @param depth The depth of the mesh created
  148478. * @returns the created mesh
  148479. */
  148480. build(updatable?: boolean, depth?: number): Mesh;
  148481. /**
  148482. * Creates the polygon
  148483. * @param depth The depth of the mesh created
  148484. * @returns the created VertexData
  148485. */
  148486. buildVertexData(depth?: number): VertexData;
  148487. /**
  148488. * Adds a side to the polygon
  148489. * @param positions points that make the polygon
  148490. * @param normals normals of the polygon
  148491. * @param uvs uvs of the polygon
  148492. * @param indices indices of the polygon
  148493. * @param bounds bounds of the polygon
  148494. * @param points points of the polygon
  148495. * @param depth depth of the polygon
  148496. * @param flip flip of the polygon
  148497. */
  148498. private addSide;
  148499. }
  148500. }
  148501. declare module BABYLON {
  148502. /**
  148503. * Class containing static functions to help procedurally build meshes
  148504. */
  148505. export class PolygonBuilder {
  148506. /**
  148507. * Creates a polygon mesh
  148508. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148509. * * 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
  148510. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  148513. * * Remember you can only change the shape positions, not their number when updating a polygon
  148514. * @param name defines the name of the mesh
  148515. * @param options defines the options used to create the mesh
  148516. * @param scene defines the hosting scene
  148517. * @param earcutInjection can be used to inject your own earcut reference
  148518. * @returns the polygon mesh
  148519. */
  148520. static CreatePolygon(name: string, options: {
  148521. shape: Vector3[];
  148522. holes?: Vector3[][];
  148523. depth?: number;
  148524. faceUV?: Vector4[];
  148525. faceColors?: Color4[];
  148526. updatable?: boolean;
  148527. sideOrientation?: number;
  148528. frontUVs?: Vector4;
  148529. backUVs?: Vector4;
  148530. wrap?: boolean;
  148531. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148532. /**
  148533. * Creates an extruded polygon mesh, with depth in the Y direction.
  148534. * * 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)
  148535. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148536. * @param name defines the name of the mesh
  148537. * @param options defines the options used to create the mesh
  148538. * @param scene defines the hosting scene
  148539. * @param earcutInjection can be used to inject your own earcut reference
  148540. * @returns the polygon mesh
  148541. */
  148542. static ExtrudePolygon(name: string, options: {
  148543. shape: Vector3[];
  148544. holes?: Vector3[][];
  148545. depth?: number;
  148546. faceUV?: Vector4[];
  148547. faceColors?: Color4[];
  148548. updatable?: boolean;
  148549. sideOrientation?: number;
  148550. frontUVs?: Vector4;
  148551. backUVs?: Vector4;
  148552. wrap?: boolean;
  148553. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148554. }
  148555. }
  148556. declare module BABYLON {
  148557. /**
  148558. * Class containing static functions to help procedurally build meshes
  148559. */
  148560. export class LatheBuilder {
  148561. /**
  148562. * Creates lathe mesh.
  148563. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148564. * * 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
  148565. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148566. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148567. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148568. * * 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
  148569. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148570. * * 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
  148571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148573. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148575. * @param name defines the name of the mesh
  148576. * @param options defines the options used to create the mesh
  148577. * @param scene defines the hosting scene
  148578. * @returns the lathe mesh
  148579. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148580. */
  148581. static CreateLathe(name: string, options: {
  148582. shape: Vector3[];
  148583. radius?: number;
  148584. tessellation?: number;
  148585. clip?: number;
  148586. arc?: number;
  148587. closed?: boolean;
  148588. updatable?: boolean;
  148589. sideOrientation?: number;
  148590. frontUVs?: Vector4;
  148591. backUVs?: Vector4;
  148592. cap?: number;
  148593. invertUV?: boolean;
  148594. }, scene?: Nullable<Scene>): Mesh;
  148595. }
  148596. }
  148597. declare module BABYLON {
  148598. /**
  148599. * Class containing static functions to help procedurally build meshes
  148600. */
  148601. export class TiledPlaneBuilder {
  148602. /**
  148603. * Creates a tiled plane mesh
  148604. * * The parameter `pattern` will, depending on value, do nothing or
  148605. * * * flip (reflect about central vertical) alternate tiles across and up
  148606. * * * flip every tile on alternate rows
  148607. * * * rotate (180 degs) alternate tiles across and up
  148608. * * * rotate every tile on alternate rows
  148609. * * * flip and rotate alternate tiles across and up
  148610. * * * flip and rotate every tile on alternate rows
  148611. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  148612. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  148613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148615. * * 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)
  148616. * * 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)
  148617. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148618. * @param name defines the name of the mesh
  148619. * @param options defines the options used to create the mesh
  148620. * @param scene defines the hosting scene
  148621. * @returns the box mesh
  148622. */
  148623. static CreateTiledPlane(name: string, options: {
  148624. pattern?: number;
  148625. tileSize?: number;
  148626. tileWidth?: number;
  148627. tileHeight?: number;
  148628. size?: number;
  148629. width?: number;
  148630. height?: number;
  148631. alignHorizontal?: number;
  148632. alignVertical?: number;
  148633. sideOrientation?: number;
  148634. frontUVs?: Vector4;
  148635. backUVs?: Vector4;
  148636. updatable?: boolean;
  148637. }, scene?: Nullable<Scene>): Mesh;
  148638. }
  148639. }
  148640. declare module BABYLON {
  148641. /**
  148642. * Class containing static functions to help procedurally build meshes
  148643. */
  148644. export class TubeBuilder {
  148645. /**
  148646. * Creates a tube mesh.
  148647. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148648. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148649. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148650. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148651. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148652. * * 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)
  148653. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148654. * * 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
  148655. * * 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
  148656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148657. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148660. * @param name defines the name of the mesh
  148661. * @param options defines the options used to create the mesh
  148662. * @param scene defines the hosting scene
  148663. * @returns the tube mesh
  148664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148665. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148666. */
  148667. static CreateTube(name: string, options: {
  148668. path: Vector3[];
  148669. radius?: number;
  148670. tessellation?: number;
  148671. radiusFunction?: {
  148672. (i: number, distance: number): number;
  148673. };
  148674. cap?: number;
  148675. arc?: number;
  148676. updatable?: boolean;
  148677. sideOrientation?: number;
  148678. frontUVs?: Vector4;
  148679. backUVs?: Vector4;
  148680. instance?: Mesh;
  148681. invertUV?: boolean;
  148682. }, scene?: Nullable<Scene>): Mesh;
  148683. }
  148684. }
  148685. declare module BABYLON {
  148686. /**
  148687. * Class containing static functions to help procedurally build meshes
  148688. */
  148689. export class IcoSphereBuilder {
  148690. /**
  148691. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148692. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148693. * * 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`)
  148694. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148695. * * 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
  148696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148697. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148699. * @param name defines the name of the mesh
  148700. * @param options defines the options used to create the mesh
  148701. * @param scene defines the hosting scene
  148702. * @returns the icosahedron mesh
  148703. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148704. */
  148705. static CreateIcoSphere(name: string, options: {
  148706. radius?: number;
  148707. radiusX?: number;
  148708. radiusY?: number;
  148709. radiusZ?: number;
  148710. flat?: boolean;
  148711. subdivisions?: number;
  148712. sideOrientation?: number;
  148713. frontUVs?: Vector4;
  148714. backUVs?: Vector4;
  148715. updatable?: boolean;
  148716. }, scene?: Nullable<Scene>): Mesh;
  148717. }
  148718. }
  148719. declare module BABYLON {
  148720. /**
  148721. * Class containing static functions to help procedurally build meshes
  148722. */
  148723. export class DecalBuilder {
  148724. /**
  148725. * Creates a decal mesh.
  148726. * 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
  148727. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148728. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148729. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148730. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148731. * @param name defines the name of the mesh
  148732. * @param sourceMesh defines the mesh where the decal must be applied
  148733. * @param options defines the options used to create the mesh
  148734. * @param scene defines the hosting scene
  148735. * @returns the decal mesh
  148736. * @see https://doc.babylonjs.com/how_to/decals
  148737. */
  148738. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148739. position?: Vector3;
  148740. normal?: Vector3;
  148741. size?: Vector3;
  148742. angle?: number;
  148743. }): Mesh;
  148744. }
  148745. }
  148746. declare module BABYLON {
  148747. /**
  148748. * Class containing static functions to help procedurally build meshes
  148749. */
  148750. export class MeshBuilder {
  148751. /**
  148752. * Creates a box mesh
  148753. * * The parameter `size` sets the size (float) of each box side (default 1)
  148754. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  148755. * * 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)
  148756. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148760. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  148761. * @param name defines the name of the mesh
  148762. * @param options defines the options used to create the mesh
  148763. * @param scene defines the hosting scene
  148764. * @returns the box mesh
  148765. */
  148766. static CreateBox(name: string, options: {
  148767. size?: number;
  148768. width?: number;
  148769. height?: number;
  148770. depth?: number;
  148771. faceUV?: Vector4[];
  148772. faceColors?: Color4[];
  148773. sideOrientation?: number;
  148774. frontUVs?: Vector4;
  148775. backUVs?: Vector4;
  148776. wrap?: boolean;
  148777. topBaseAt?: number;
  148778. bottomBaseAt?: number;
  148779. updatable?: boolean;
  148780. }, scene?: Nullable<Scene>): Mesh;
  148781. /**
  148782. * Creates a tiled box mesh
  148783. * * faceTiles sets the pattern, tile size and number of tiles for a face
  148784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148785. * @param name defines the name of the mesh
  148786. * @param options defines the options used to create the mesh
  148787. * @param scene defines the hosting scene
  148788. * @returns the tiled box mesh
  148789. */
  148790. static CreateTiledBox(name: string, options: {
  148791. pattern?: number;
  148792. size?: number;
  148793. width?: number;
  148794. height?: number;
  148795. depth: number;
  148796. tileSize?: number;
  148797. tileWidth?: number;
  148798. tileHeight?: number;
  148799. faceUV?: Vector4[];
  148800. faceColors?: Color4[];
  148801. alignHorizontal?: number;
  148802. alignVertical?: number;
  148803. sideOrientation?: number;
  148804. updatable?: boolean;
  148805. }, scene?: Nullable<Scene>): Mesh;
  148806. /**
  148807. * Creates a sphere mesh
  148808. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  148809. * * 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`)
  148810. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  148811. * * 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
  148812. * * 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)
  148813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148814. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148816. * @param name defines the name of the mesh
  148817. * @param options defines the options used to create the mesh
  148818. * @param scene defines the hosting scene
  148819. * @returns the sphere mesh
  148820. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148821. */
  148822. static CreateSphere(name: string, options: {
  148823. segments?: number;
  148824. diameter?: number;
  148825. diameterX?: number;
  148826. diameterY?: number;
  148827. diameterZ?: number;
  148828. arc?: number;
  148829. slice?: number;
  148830. sideOrientation?: number;
  148831. frontUVs?: Vector4;
  148832. backUVs?: Vector4;
  148833. updatable?: boolean;
  148834. }, scene?: Nullable<Scene>): Mesh;
  148835. /**
  148836. * Creates a plane polygonal mesh. By default, this is a disc
  148837. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148838. * * 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
  148839. * * 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
  148840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148841. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148843. * @param name defines the name of the mesh
  148844. * @param options defines the options used to create the mesh
  148845. * @param scene defines the hosting scene
  148846. * @returns the plane polygonal mesh
  148847. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148848. */
  148849. static CreateDisc(name: string, options: {
  148850. radius?: number;
  148851. tessellation?: number;
  148852. arc?: number;
  148853. updatable?: boolean;
  148854. sideOrientation?: number;
  148855. frontUVs?: Vector4;
  148856. backUVs?: Vector4;
  148857. }, scene?: Nullable<Scene>): Mesh;
  148858. /**
  148859. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148860. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148861. * * 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`)
  148862. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148863. * * 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
  148864. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148865. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148867. * @param name defines the name of the mesh
  148868. * @param options defines the options used to create the mesh
  148869. * @param scene defines the hosting scene
  148870. * @returns the icosahedron mesh
  148871. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148872. */
  148873. static CreateIcoSphere(name: string, options: {
  148874. radius?: number;
  148875. radiusX?: number;
  148876. radiusY?: number;
  148877. radiusZ?: number;
  148878. flat?: boolean;
  148879. subdivisions?: number;
  148880. sideOrientation?: number;
  148881. frontUVs?: Vector4;
  148882. backUVs?: Vector4;
  148883. updatable?: boolean;
  148884. }, scene?: Nullable<Scene>): Mesh;
  148885. /**
  148886. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148887. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148888. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148889. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148890. * * 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
  148891. * * 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
  148892. * * 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
  148893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148894. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148895. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148896. * * 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
  148897. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148898. * * 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
  148899. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148901. * @param name defines the name of the mesh
  148902. * @param options defines the options used to create the mesh
  148903. * @param scene defines the hosting scene
  148904. * @returns the ribbon mesh
  148905. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148907. */
  148908. static CreateRibbon(name: string, options: {
  148909. pathArray: Vector3[][];
  148910. closeArray?: boolean;
  148911. closePath?: boolean;
  148912. offset?: number;
  148913. updatable?: boolean;
  148914. sideOrientation?: number;
  148915. frontUVs?: Vector4;
  148916. backUVs?: Vector4;
  148917. instance?: Mesh;
  148918. invertUV?: boolean;
  148919. uvs?: Vector2[];
  148920. colors?: Color4[];
  148921. }, scene?: Nullable<Scene>): Mesh;
  148922. /**
  148923. * Creates a cylinder or a cone mesh
  148924. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148925. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148926. * * 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.
  148927. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148928. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148929. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148930. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148931. * * 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).
  148932. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148933. * * 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).
  148934. * * 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
  148935. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148936. * * 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
  148937. * * 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.
  148938. * * If `enclose` is false, a ring surface is one element.
  148939. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148940. * * 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
  148941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148944. * @param name defines the name of the mesh
  148945. * @param options defines the options used to create the mesh
  148946. * @param scene defines the hosting scene
  148947. * @returns the cylinder mesh
  148948. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148949. */
  148950. static CreateCylinder(name: string, options: {
  148951. height?: number;
  148952. diameterTop?: number;
  148953. diameterBottom?: number;
  148954. diameter?: number;
  148955. tessellation?: number;
  148956. subdivisions?: number;
  148957. arc?: number;
  148958. faceColors?: Color4[];
  148959. faceUV?: Vector4[];
  148960. updatable?: boolean;
  148961. hasRings?: boolean;
  148962. enclose?: boolean;
  148963. cap?: number;
  148964. sideOrientation?: number;
  148965. frontUVs?: Vector4;
  148966. backUVs?: Vector4;
  148967. }, scene?: Nullable<Scene>): Mesh;
  148968. /**
  148969. * Creates a torus mesh
  148970. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148971. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148972. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148976. * @param name defines the name of the mesh
  148977. * @param options defines the options used to create the mesh
  148978. * @param scene defines the hosting scene
  148979. * @returns the torus mesh
  148980. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148981. */
  148982. static CreateTorus(name: string, options: {
  148983. diameter?: number;
  148984. thickness?: number;
  148985. tessellation?: number;
  148986. updatable?: boolean;
  148987. sideOrientation?: number;
  148988. frontUVs?: Vector4;
  148989. backUVs?: Vector4;
  148990. }, scene?: Nullable<Scene>): Mesh;
  148991. /**
  148992. * Creates a torus knot mesh
  148993. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148994. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148995. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148996. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148997. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148998. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  148999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149000. * @param name defines the name of the mesh
  149001. * @param options defines the options used to create the mesh
  149002. * @param scene defines the hosting scene
  149003. * @returns the torus knot mesh
  149004. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  149005. */
  149006. static CreateTorusKnot(name: string, options: {
  149007. radius?: number;
  149008. tube?: number;
  149009. radialSegments?: number;
  149010. tubularSegments?: number;
  149011. p?: number;
  149012. q?: number;
  149013. updatable?: boolean;
  149014. sideOrientation?: number;
  149015. frontUVs?: Vector4;
  149016. backUVs?: Vector4;
  149017. }, scene?: Nullable<Scene>): Mesh;
  149018. /**
  149019. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  149020. * * 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
  149021. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  149022. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  149023. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  149024. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  149025. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  149026. * * 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
  149027. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  149028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149029. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  149030. * @param name defines the name of the new line system
  149031. * @param options defines the options used to create the line system
  149032. * @param scene defines the hosting scene
  149033. * @returns a new line system mesh
  149034. */
  149035. static CreateLineSystem(name: string, options: {
  149036. lines: Vector3[][];
  149037. updatable?: boolean;
  149038. instance?: Nullable<LinesMesh>;
  149039. colors?: Nullable<Color4[][]>;
  149040. useVertexAlpha?: boolean;
  149041. }, scene: Nullable<Scene>): LinesMesh;
  149042. /**
  149043. * Creates a line mesh
  149044. * 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
  149045. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  149046. * * The parameter `points` is an array successive Vector3
  149047. * * 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
  149048. * * The optional parameter `colors` is an array of successive Color4, one per line point
  149049. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  149050. * * When updating an instance, remember that only point positions can change, not the number of points
  149051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149052. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  149053. * @param name defines the name of the new line system
  149054. * @param options defines the options used to create the line system
  149055. * @param scene defines the hosting scene
  149056. * @returns a new line mesh
  149057. */
  149058. static CreateLines(name: string, options: {
  149059. points: Vector3[];
  149060. updatable?: boolean;
  149061. instance?: Nullable<LinesMesh>;
  149062. colors?: Color4[];
  149063. useVertexAlpha?: boolean;
  149064. }, scene?: Nullable<Scene>): LinesMesh;
  149065. /**
  149066. * Creates a dashed line mesh
  149067. * * 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
  149068. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  149069. * * The parameter `points` is an array successive Vector3
  149070. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  149071. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  149072. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  149073. * * 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
  149074. * * When updating an instance, remember that only point positions can change, not the number of points
  149075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149076. * @param name defines the name of the mesh
  149077. * @param options defines the options used to create the mesh
  149078. * @param scene defines the hosting scene
  149079. * @returns the dashed line mesh
  149080. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  149081. */
  149082. static CreateDashedLines(name: string, options: {
  149083. points: Vector3[];
  149084. dashSize?: number;
  149085. gapSize?: number;
  149086. dashNb?: number;
  149087. updatable?: boolean;
  149088. instance?: LinesMesh;
  149089. }, scene?: Nullable<Scene>): LinesMesh;
  149090. /**
  149091. * 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.
  149092. * * 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.
  149093. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  149094. * * 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.
  149095. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  149096. * * 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
  149097. * * 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
  149098. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  149099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149101. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  149102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149103. * @param name defines the name of the mesh
  149104. * @param options defines the options used to create the mesh
  149105. * @param scene defines the hosting scene
  149106. * @returns the extruded shape mesh
  149107. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  149109. */
  149110. static ExtrudeShape(name: string, options: {
  149111. shape: Vector3[];
  149112. path: Vector3[];
  149113. scale?: number;
  149114. rotation?: number;
  149115. cap?: number;
  149116. updatable?: boolean;
  149117. sideOrientation?: number;
  149118. frontUVs?: Vector4;
  149119. backUVs?: Vector4;
  149120. instance?: Mesh;
  149121. invertUV?: boolean;
  149122. }, scene?: Nullable<Scene>): Mesh;
  149123. /**
  149124. * Creates an custom extruded shape mesh.
  149125. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  149126. * * 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.
  149127. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  149128. * * 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
  149129. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  149130. * * 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
  149131. * * It must returns a float value that will be the scale value applied to the shape on each path point
  149132. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  149133. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  149134. * * 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
  149135. * * 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
  149136. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  149137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149141. * @param name defines the name of the mesh
  149142. * @param options defines the options used to create the mesh
  149143. * @param scene defines the hosting scene
  149144. * @returns the custom extruded shape mesh
  149145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  149146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149147. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  149148. */
  149149. static ExtrudeShapeCustom(name: string, options: {
  149150. shape: Vector3[];
  149151. path: Vector3[];
  149152. scaleFunction?: any;
  149153. rotationFunction?: any;
  149154. ribbonCloseArray?: boolean;
  149155. ribbonClosePath?: boolean;
  149156. cap?: number;
  149157. updatable?: boolean;
  149158. sideOrientation?: number;
  149159. frontUVs?: Vector4;
  149160. backUVs?: Vector4;
  149161. instance?: Mesh;
  149162. invertUV?: boolean;
  149163. }, scene?: Nullable<Scene>): Mesh;
  149164. /**
  149165. * Creates lathe mesh.
  149166. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  149167. * * 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
  149168. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  149169. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  149170. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  149171. * * 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
  149172. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  149173. * * 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
  149174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149175. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149178. * @param name defines the name of the mesh
  149179. * @param options defines the options used to create the mesh
  149180. * @param scene defines the hosting scene
  149181. * @returns the lathe mesh
  149182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  149183. */
  149184. static CreateLathe(name: string, options: {
  149185. shape: Vector3[];
  149186. radius?: number;
  149187. tessellation?: number;
  149188. clip?: number;
  149189. arc?: number;
  149190. closed?: boolean;
  149191. updatable?: boolean;
  149192. sideOrientation?: number;
  149193. frontUVs?: Vector4;
  149194. backUVs?: Vector4;
  149195. cap?: number;
  149196. invertUV?: boolean;
  149197. }, scene?: Nullable<Scene>): Mesh;
  149198. /**
  149199. * Creates a tiled plane mesh
  149200. * * You can set a limited pattern arrangement with the tiles
  149201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149204. * @param name defines the name of the mesh
  149205. * @param options defines the options used to create the mesh
  149206. * @param scene defines the hosting scene
  149207. * @returns the plane mesh
  149208. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149209. */
  149210. static CreateTiledPlane(name: string, options: {
  149211. pattern?: number;
  149212. tileSize?: number;
  149213. tileWidth?: number;
  149214. tileHeight?: number;
  149215. size?: number;
  149216. width?: number;
  149217. height?: number;
  149218. alignHorizontal?: number;
  149219. alignVertical?: number;
  149220. sideOrientation?: number;
  149221. frontUVs?: Vector4;
  149222. backUVs?: Vector4;
  149223. updatable?: boolean;
  149224. }, scene?: Nullable<Scene>): Mesh;
  149225. /**
  149226. * Creates a plane mesh
  149227. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  149228. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  149229. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  149230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149233. * @param name defines the name of the mesh
  149234. * @param options defines the options used to create the mesh
  149235. * @param scene defines the hosting scene
  149236. * @returns the plane mesh
  149237. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  149238. */
  149239. static CreatePlane(name: string, options: {
  149240. size?: number;
  149241. width?: number;
  149242. height?: number;
  149243. sideOrientation?: number;
  149244. frontUVs?: Vector4;
  149245. backUVs?: Vector4;
  149246. updatable?: boolean;
  149247. sourcePlane?: Plane;
  149248. }, scene?: Nullable<Scene>): Mesh;
  149249. /**
  149250. * Creates a ground mesh
  149251. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  149252. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  149253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149254. * @param name defines the name of the mesh
  149255. * @param options defines the options used to create the mesh
  149256. * @param scene defines the hosting scene
  149257. * @returns the ground mesh
  149258. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  149259. */
  149260. static CreateGround(name: string, options: {
  149261. width?: number;
  149262. height?: number;
  149263. subdivisions?: number;
  149264. subdivisionsX?: number;
  149265. subdivisionsY?: number;
  149266. updatable?: boolean;
  149267. }, scene?: Nullable<Scene>): Mesh;
  149268. /**
  149269. * Creates a tiled ground mesh
  149270. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  149271. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  149272. * * 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
  149273. * * 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
  149274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149275. * @param name defines the name of the mesh
  149276. * @param options defines the options used to create the mesh
  149277. * @param scene defines the hosting scene
  149278. * @returns the tiled ground mesh
  149279. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  149280. */
  149281. static CreateTiledGround(name: string, options: {
  149282. xmin: number;
  149283. zmin: number;
  149284. xmax: number;
  149285. zmax: number;
  149286. subdivisions?: {
  149287. w: number;
  149288. h: number;
  149289. };
  149290. precision?: {
  149291. w: number;
  149292. h: number;
  149293. };
  149294. updatable?: boolean;
  149295. }, scene?: Nullable<Scene>): Mesh;
  149296. /**
  149297. * Creates a ground mesh from a height map
  149298. * * The parameter `url` sets the URL of the height map image resource.
  149299. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  149300. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  149301. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  149302. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  149303. * * 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.
  149304. * * 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).
  149305. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  149306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  149307. * @param name defines the name of the mesh
  149308. * @param url defines the url to the height map
  149309. * @param options defines the options used to create the mesh
  149310. * @param scene defines the hosting scene
  149311. * @returns the ground mesh
  149312. * @see https://doc.babylonjs.com/babylon101/height_map
  149313. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  149314. */
  149315. static CreateGroundFromHeightMap(name: string, url: string, options: {
  149316. width?: number;
  149317. height?: number;
  149318. subdivisions?: number;
  149319. minHeight?: number;
  149320. maxHeight?: number;
  149321. colorFilter?: Color3;
  149322. alphaFilter?: number;
  149323. updatable?: boolean;
  149324. onReady?: (mesh: GroundMesh) => void;
  149325. }, scene?: Nullable<Scene>): GroundMesh;
  149326. /**
  149327. * Creates a polygon mesh
  149328. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  149329. * * 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
  149330. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  149331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  149333. * * Remember you can only change the shape positions, not their number when updating a polygon
  149334. * @param name defines the name of the mesh
  149335. * @param options defines the options used to create the mesh
  149336. * @param scene defines the hosting scene
  149337. * @param earcutInjection can be used to inject your own earcut reference
  149338. * @returns the polygon mesh
  149339. */
  149340. static CreatePolygon(name: string, options: {
  149341. shape: Vector3[];
  149342. holes?: Vector3[][];
  149343. depth?: number;
  149344. faceUV?: Vector4[];
  149345. faceColors?: Color4[];
  149346. updatable?: boolean;
  149347. sideOrientation?: number;
  149348. frontUVs?: Vector4;
  149349. backUVs?: Vector4;
  149350. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149351. /**
  149352. * Creates an extruded polygon mesh, with depth in the Y direction.
  149353. * * 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)
  149354. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  149355. * @param name defines the name of the mesh
  149356. * @param options defines the options used to create the mesh
  149357. * @param scene defines the hosting scene
  149358. * @param earcutInjection can be used to inject your own earcut reference
  149359. * @returns the polygon mesh
  149360. */
  149361. static ExtrudePolygon(name: string, options: {
  149362. shape: Vector3[];
  149363. holes?: Vector3[][];
  149364. depth?: number;
  149365. faceUV?: Vector4[];
  149366. faceColors?: Color4[];
  149367. updatable?: boolean;
  149368. sideOrientation?: number;
  149369. frontUVs?: Vector4;
  149370. backUVs?: Vector4;
  149371. wrap?: boolean;
  149372. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  149373. /**
  149374. * Creates a tube mesh.
  149375. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  149376. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  149377. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  149378. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  149379. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  149380. * * 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)
  149381. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  149382. * * 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
  149383. * * 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
  149384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149385. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149386. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  149387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149388. * @param name defines the name of the mesh
  149389. * @param options defines the options used to create the mesh
  149390. * @param scene defines the hosting scene
  149391. * @returns the tube mesh
  149392. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  149393. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  149394. */
  149395. static CreateTube(name: string, options: {
  149396. path: Vector3[];
  149397. radius?: number;
  149398. tessellation?: number;
  149399. radiusFunction?: {
  149400. (i: number, distance: number): number;
  149401. };
  149402. cap?: number;
  149403. arc?: number;
  149404. updatable?: boolean;
  149405. sideOrientation?: number;
  149406. frontUVs?: Vector4;
  149407. backUVs?: Vector4;
  149408. instance?: Mesh;
  149409. invertUV?: boolean;
  149410. }, scene?: Nullable<Scene>): Mesh;
  149411. /**
  149412. * Creates a polyhedron mesh
  149413. * * 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
  149414. * * The parameter `size` (positive float, default 1) sets the polygon size
  149415. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  149416. * * 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`
  149417. * * 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
  149418. * * 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)`)
  149419. * * 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
  149420. * * 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
  149421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  149422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  149423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  149424. * @param name defines the name of the mesh
  149425. * @param options defines the options used to create the mesh
  149426. * @param scene defines the hosting scene
  149427. * @returns the polyhedron mesh
  149428. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  149429. */
  149430. static CreatePolyhedron(name: string, options: {
  149431. type?: number;
  149432. size?: number;
  149433. sizeX?: number;
  149434. sizeY?: number;
  149435. sizeZ?: number;
  149436. custom?: any;
  149437. faceUV?: Vector4[];
  149438. faceColors?: Color4[];
  149439. flat?: boolean;
  149440. updatable?: boolean;
  149441. sideOrientation?: number;
  149442. frontUVs?: Vector4;
  149443. backUVs?: Vector4;
  149444. }, scene?: Nullable<Scene>): Mesh;
  149445. /**
  149446. * Creates a decal mesh.
  149447. * 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
  149448. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  149449. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  149450. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  149451. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  149452. * @param name defines the name of the mesh
  149453. * @param sourceMesh defines the mesh where the decal must be applied
  149454. * @param options defines the options used to create the mesh
  149455. * @param scene defines the hosting scene
  149456. * @returns the decal mesh
  149457. * @see https://doc.babylonjs.com/how_to/decals
  149458. */
  149459. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  149460. position?: Vector3;
  149461. normal?: Vector3;
  149462. size?: Vector3;
  149463. angle?: number;
  149464. }): Mesh;
  149465. /**
  149466. * Creates a Capsule Mesh
  149467. * @param name defines the name of the mesh.
  149468. * @param options the constructors options used to shape the mesh.
  149469. * @param scene defines the scene the mesh is scoped to.
  149470. * @returns the capsule mesh
  149471. * @see https://doc.babylonjs.com/how_to/capsule_shape
  149472. */
  149473. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  149474. }
  149475. }
  149476. declare module BABYLON {
  149477. /**
  149478. * A simplifier interface for future simplification implementations
  149479. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149480. */
  149481. export interface ISimplifier {
  149482. /**
  149483. * Simplification of a given mesh according to the given settings.
  149484. * Since this requires computation, it is assumed that the function runs async.
  149485. * @param settings The settings of the simplification, including quality and distance
  149486. * @param successCallback A callback that will be called after the mesh was simplified.
  149487. * @param errorCallback in case of an error, this callback will be called. optional.
  149488. */
  149489. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  149490. }
  149491. /**
  149492. * Expected simplification settings.
  149493. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  149494. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149495. */
  149496. export interface ISimplificationSettings {
  149497. /**
  149498. * Gets or sets the expected quality
  149499. */
  149500. quality: number;
  149501. /**
  149502. * Gets or sets the distance when this optimized version should be used
  149503. */
  149504. distance: number;
  149505. /**
  149506. * Gets an already optimized mesh
  149507. */
  149508. optimizeMesh?: boolean;
  149509. }
  149510. /**
  149511. * Class used to specify simplification options
  149512. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149513. */
  149514. export class SimplificationSettings implements ISimplificationSettings {
  149515. /** expected quality */
  149516. quality: number;
  149517. /** distance when this optimized version should be used */
  149518. distance: number;
  149519. /** already optimized mesh */
  149520. optimizeMesh?: boolean | undefined;
  149521. /**
  149522. * Creates a SimplificationSettings
  149523. * @param quality expected quality
  149524. * @param distance distance when this optimized version should be used
  149525. * @param optimizeMesh already optimized mesh
  149526. */
  149527. constructor(
  149528. /** expected quality */
  149529. quality: number,
  149530. /** distance when this optimized version should be used */
  149531. distance: number,
  149532. /** already optimized mesh */
  149533. optimizeMesh?: boolean | undefined);
  149534. }
  149535. /**
  149536. * Interface used to define a simplification task
  149537. */
  149538. export interface ISimplificationTask {
  149539. /**
  149540. * Array of settings
  149541. */
  149542. settings: Array<ISimplificationSettings>;
  149543. /**
  149544. * Simplification type
  149545. */
  149546. simplificationType: SimplificationType;
  149547. /**
  149548. * Mesh to simplify
  149549. */
  149550. mesh: Mesh;
  149551. /**
  149552. * Callback called on success
  149553. */
  149554. successCallback?: () => void;
  149555. /**
  149556. * Defines if parallel processing can be used
  149557. */
  149558. parallelProcessing: boolean;
  149559. }
  149560. /**
  149561. * Queue used to order the simplification tasks
  149562. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149563. */
  149564. export class SimplificationQueue {
  149565. private _simplificationArray;
  149566. /**
  149567. * Gets a boolean indicating that the process is still running
  149568. */
  149569. running: boolean;
  149570. /**
  149571. * Creates a new queue
  149572. */
  149573. constructor();
  149574. /**
  149575. * Adds a new simplification task
  149576. * @param task defines a task to add
  149577. */
  149578. addTask(task: ISimplificationTask): void;
  149579. /**
  149580. * Execute next task
  149581. */
  149582. executeNext(): void;
  149583. /**
  149584. * Execute a simplification task
  149585. * @param task defines the task to run
  149586. */
  149587. runSimplification(task: ISimplificationTask): void;
  149588. private getSimplifier;
  149589. }
  149590. /**
  149591. * The implemented types of simplification
  149592. * At the moment only Quadratic Error Decimation is implemented
  149593. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149594. */
  149595. export enum SimplificationType {
  149596. /** Quadratic error decimation */
  149597. QUADRATIC = 0
  149598. }
  149599. /**
  149600. * An implementation of the Quadratic Error simplification algorithm.
  149601. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  149602. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  149603. * @author RaananW
  149604. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149605. */
  149606. export class QuadraticErrorSimplification implements ISimplifier {
  149607. private _mesh;
  149608. private triangles;
  149609. private vertices;
  149610. private references;
  149611. private _reconstructedMesh;
  149612. /** Gets or sets the number pf sync interations */
  149613. syncIterations: number;
  149614. /** Gets or sets the aggressiveness of the simplifier */
  149615. aggressiveness: number;
  149616. /** Gets or sets the number of allowed iterations for decimation */
  149617. decimationIterations: number;
  149618. /** Gets or sets the espilon to use for bounding box computation */
  149619. boundingBoxEpsilon: number;
  149620. /**
  149621. * Creates a new QuadraticErrorSimplification
  149622. * @param _mesh defines the target mesh
  149623. */
  149624. constructor(_mesh: Mesh);
  149625. /**
  149626. * Simplification of a given mesh according to the given settings.
  149627. * Since this requires computation, it is assumed that the function runs async.
  149628. * @param settings The settings of the simplification, including quality and distance
  149629. * @param successCallback A callback that will be called after the mesh was simplified.
  149630. */
  149631. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  149632. private runDecimation;
  149633. private initWithMesh;
  149634. private init;
  149635. private reconstructMesh;
  149636. private initDecimatedMesh;
  149637. private isFlipped;
  149638. private updateTriangles;
  149639. private identifyBorder;
  149640. private updateMesh;
  149641. private vertexError;
  149642. private calculateError;
  149643. }
  149644. }
  149645. declare module BABYLON {
  149646. interface Scene {
  149647. /** @hidden (Backing field) */
  149648. _simplificationQueue: SimplificationQueue;
  149649. /**
  149650. * Gets or sets the simplification queue attached to the scene
  149651. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  149652. */
  149653. simplificationQueue: SimplificationQueue;
  149654. }
  149655. interface Mesh {
  149656. /**
  149657. * Simplify the mesh according to the given array of settings.
  149658. * Function will return immediately and will simplify async
  149659. * @param settings a collection of simplification settings
  149660. * @param parallelProcessing should all levels calculate parallel or one after the other
  149661. * @param simplificationType the type of simplification to run
  149662. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  149663. * @returns the current mesh
  149664. */
  149665. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  149666. }
  149667. /**
  149668. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  149669. * created in a scene
  149670. */
  149671. export class SimplicationQueueSceneComponent implements ISceneComponent {
  149672. /**
  149673. * The component name helpfull to identify the component in the list of scene components.
  149674. */
  149675. readonly name: string;
  149676. /**
  149677. * The scene the component belongs to.
  149678. */
  149679. scene: Scene;
  149680. /**
  149681. * Creates a new instance of the component for the given scene
  149682. * @param scene Defines the scene to register the component in
  149683. */
  149684. constructor(scene: Scene);
  149685. /**
  149686. * Registers the component in a given scene
  149687. */
  149688. register(): void;
  149689. /**
  149690. * Rebuilds the elements related to this component in case of
  149691. * context lost for instance.
  149692. */
  149693. rebuild(): void;
  149694. /**
  149695. * Disposes the component and the associated ressources
  149696. */
  149697. dispose(): void;
  149698. private _beforeCameraUpdate;
  149699. }
  149700. }
  149701. declare module BABYLON {
  149702. interface Mesh {
  149703. /**
  149704. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  149705. */
  149706. thinInstanceEnablePicking: boolean;
  149707. /**
  149708. * Creates a new thin instance
  149709. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  149710. * @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
  149711. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  149712. */
  149713. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  149714. /**
  149715. * Adds the transformation (matrix) of the current mesh as a thin instance
  149716. * @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
  149717. * @returns the thin instance index number
  149718. */
  149719. thinInstanceAddSelf(refresh: boolean): number;
  149720. /**
  149721. * Registers a custom attribute to be used with thin instances
  149722. * @param kind name of the attribute
  149723. * @param stride size in floats of the attribute
  149724. */
  149725. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  149726. /**
  149727. * Sets the matrix of a thin instance
  149728. * @param index index of the thin instance
  149729. * @param matrix matrix to set
  149730. * @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
  149731. */
  149732. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  149733. /**
  149734. * Sets the value of a custom attribute for a thin instance
  149735. * @param kind name of the attribute
  149736. * @param index index of the thin instance
  149737. * @param value value to set
  149738. * @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
  149739. */
  149740. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  149741. /**
  149742. * 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.
  149743. */
  149744. thinInstanceCount: number;
  149745. /**
  149746. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  149747. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  149748. * @param buffer buffer to set
  149749. * @param stride size in floats of each value of the buffer
  149750. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  149751. */
  149752. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  149753. /**
  149754. * Gets the list of world matrices
  149755. * @return an array containing all the world matrices from the thin instances
  149756. */
  149757. thinInstanceGetWorldMatrices(): Matrix[];
  149758. /**
  149759. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  149760. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149761. */
  149762. thinInstanceBufferUpdated(kind: string): void;
  149763. /**
  149764. * Applies a partial update to a buffer directly on the GPU
  149765. * 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
  149766. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  149767. * @param data the data to set in the GPU buffer
  149768. * @param offset the offset in the GPU buffer where to update the data
  149769. */
  149770. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  149771. /**
  149772. * Refreshes the bounding info, taking into account all the thin instances defined
  149773. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  149774. */
  149775. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  149776. /** @hidden */
  149777. _thinInstanceInitializeUserStorage(): void;
  149778. /** @hidden */
  149779. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  149780. /** @hidden */
  149781. _userThinInstanceBuffersStorage: {
  149782. data: {
  149783. [key: string]: Float32Array;
  149784. };
  149785. sizes: {
  149786. [key: string]: number;
  149787. };
  149788. vertexBuffers: {
  149789. [key: string]: Nullable<VertexBuffer>;
  149790. };
  149791. strides: {
  149792. [key: string]: number;
  149793. };
  149794. };
  149795. }
  149796. }
  149797. declare module BABYLON {
  149798. /**
  149799. * Navigation plugin interface to add navigation constrained by a navigation mesh
  149800. */
  149801. export interface INavigationEnginePlugin {
  149802. /**
  149803. * plugin name
  149804. */
  149805. name: string;
  149806. /**
  149807. * Creates a navigation mesh
  149808. * @param meshes array of all the geometry used to compute the navigatio mesh
  149809. * @param parameters bunch of parameters used to filter geometry
  149810. */
  149811. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149812. /**
  149813. * Create a navigation mesh debug mesh
  149814. * @param scene is where the mesh will be added
  149815. * @returns debug display mesh
  149816. */
  149817. createDebugNavMesh(scene: Scene): Mesh;
  149818. /**
  149819. * Get a navigation mesh constrained position, closest to the parameter position
  149820. * @param position world position
  149821. * @returns the closest point to position constrained by the navigation mesh
  149822. */
  149823. getClosestPoint(position: Vector3): Vector3;
  149824. /**
  149825. * Get a navigation mesh constrained position, closest to the parameter position
  149826. * @param position world position
  149827. * @param result output the closest point to position constrained by the navigation mesh
  149828. */
  149829. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149830. /**
  149831. * Get a navigation mesh constrained position, within a particular radius
  149832. * @param position world position
  149833. * @param maxRadius the maximum distance to the constrained world position
  149834. * @returns the closest point to position constrained by the navigation mesh
  149835. */
  149836. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149837. /**
  149838. * Get a navigation mesh constrained position, within a particular radius
  149839. * @param position world position
  149840. * @param maxRadius the maximum distance to the constrained world position
  149841. * @param result output the closest point to position constrained by the navigation mesh
  149842. */
  149843. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149844. /**
  149845. * Compute the final position from a segment made of destination-position
  149846. * @param position world position
  149847. * @param destination world position
  149848. * @returns the resulting point along the navmesh
  149849. */
  149850. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149851. /**
  149852. * Compute the final position from a segment made of destination-position
  149853. * @param position world position
  149854. * @param destination world position
  149855. * @param result output the resulting point along the navmesh
  149856. */
  149857. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149858. /**
  149859. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149860. * @param start world position
  149861. * @param end world position
  149862. * @returns array containing world position composing the path
  149863. */
  149864. computePath(start: Vector3, end: Vector3): Vector3[];
  149865. /**
  149866. * If this plugin is supported
  149867. * @returns true if plugin is supported
  149868. */
  149869. isSupported(): boolean;
  149870. /**
  149871. * Create a new Crowd so you can add agents
  149872. * @param maxAgents the maximum agent count in the crowd
  149873. * @param maxAgentRadius the maximum radius an agent can have
  149874. * @param scene to attach the crowd to
  149875. * @returns the crowd you can add agents to
  149876. */
  149877. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149878. /**
  149879. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149880. * The queries will try to find a solution within those bounds
  149881. * default is (1,1,1)
  149882. * @param extent x,y,z value that define the extent around the queries point of reference
  149883. */
  149884. setDefaultQueryExtent(extent: Vector3): void;
  149885. /**
  149886. * Get the Bounding box extent specified by setDefaultQueryExtent
  149887. * @returns the box extent values
  149888. */
  149889. getDefaultQueryExtent(): Vector3;
  149890. /**
  149891. * build the navmesh from a previously saved state using getNavmeshData
  149892. * @param data the Uint8Array returned by getNavmeshData
  149893. */
  149894. buildFromNavmeshData(data: Uint8Array): void;
  149895. /**
  149896. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149897. * @returns data the Uint8Array that can be saved and reused
  149898. */
  149899. getNavmeshData(): Uint8Array;
  149900. /**
  149901. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149902. * @param result output the box extent values
  149903. */
  149904. getDefaultQueryExtentToRef(result: Vector3): void;
  149905. /**
  149906. * Set the time step of the navigation tick update.
  149907. * Default is 1/60.
  149908. * A value of 0 will disable fixed time update
  149909. * @param newTimeStep the new timestep to apply to this world.
  149910. */
  149911. setTimeStep(newTimeStep: number): void;
  149912. /**
  149913. * Get the time step of the navigation tick update.
  149914. * @returns the current time step
  149915. */
  149916. getTimeStep(): number;
  149917. /**
  149918. * If delta time in navigation tick update is greater than the time step
  149919. * a number of sub iterations are done. If more iterations are need to reach deltatime
  149920. * they will be discarded.
  149921. * A value of 0 will set to no maximum and update will use as many substeps as needed
  149922. * @param newStepCount the maximum number of iterations
  149923. */
  149924. setMaximumSubStepCount(newStepCount: number): void;
  149925. /**
  149926. * Get the maximum number of iterations per navigation tick update
  149927. * @returns the maximum number of iterations
  149928. */
  149929. getMaximumSubStepCount(): number;
  149930. /**
  149931. * Release all resources
  149932. */
  149933. dispose(): void;
  149934. }
  149935. /**
  149936. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149937. */
  149938. export interface ICrowd {
  149939. /**
  149940. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149941. * You can attach anything to that node. The node position is updated in the scene update tick.
  149942. * @param pos world position that will be constrained by the navigation mesh
  149943. * @param parameters agent parameters
  149944. * @param transform hooked to the agent that will be update by the scene
  149945. * @returns agent index
  149946. */
  149947. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149948. /**
  149949. * Returns the agent position in world space
  149950. * @param index agent index returned by addAgent
  149951. * @returns world space position
  149952. */
  149953. getAgentPosition(index: number): Vector3;
  149954. /**
  149955. * Gets the agent position result in world space
  149956. * @param index agent index returned by addAgent
  149957. * @param result output world space position
  149958. */
  149959. getAgentPositionToRef(index: number, result: Vector3): void;
  149960. /**
  149961. * Gets the agent velocity in world space
  149962. * @param index agent index returned by addAgent
  149963. * @returns world space velocity
  149964. */
  149965. getAgentVelocity(index: number): Vector3;
  149966. /**
  149967. * Gets the agent velocity result in world space
  149968. * @param index agent index returned by addAgent
  149969. * @param result output world space velocity
  149970. */
  149971. getAgentVelocityToRef(index: number, result: Vector3): void;
  149972. /**
  149973. * Gets the agent next target point on the path
  149974. * @param index agent index returned by addAgent
  149975. * @returns world space position
  149976. */
  149977. getAgentNextTargetPath(index: number): Vector3;
  149978. /**
  149979. * Gets the agent state
  149980. * @param index agent index returned by addAgent
  149981. * @returns agent state
  149982. */
  149983. getAgentState(index: number): number;
  149984. /**
  149985. * returns true if the agent in over an off mesh link connection
  149986. * @param index agent index returned by addAgent
  149987. * @returns true if over an off mesh link connection
  149988. */
  149989. overOffmeshConnection(index: number): boolean;
  149990. /**
  149991. * Gets the agent next target point on the path
  149992. * @param index agent index returned by addAgent
  149993. * @param result output world space position
  149994. */
  149995. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149996. /**
  149997. * remove a particular agent previously created
  149998. * @param index agent index returned by addAgent
  149999. */
  150000. removeAgent(index: number): void;
  150001. /**
  150002. * get the list of all agents attached to this crowd
  150003. * @returns list of agent indices
  150004. */
  150005. getAgents(): number[];
  150006. /**
  150007. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150008. * @param deltaTime in seconds
  150009. */
  150010. update(deltaTime: number): void;
  150011. /**
  150012. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150013. * @param index agent index returned by addAgent
  150014. * @param destination targeted world position
  150015. */
  150016. agentGoto(index: number, destination: Vector3): void;
  150017. /**
  150018. * Teleport the agent to a new position
  150019. * @param index agent index returned by addAgent
  150020. * @param destination targeted world position
  150021. */
  150022. agentTeleport(index: number, destination: Vector3): void;
  150023. /**
  150024. * Update agent parameters
  150025. * @param index agent index returned by addAgent
  150026. * @param parameters agent parameters
  150027. */
  150028. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150029. /**
  150030. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150031. * The queries will try to find a solution within those bounds
  150032. * default is (1,1,1)
  150033. * @param extent x,y,z value that define the extent around the queries point of reference
  150034. */
  150035. setDefaultQueryExtent(extent: Vector3): void;
  150036. /**
  150037. * Get the Bounding box extent specified by setDefaultQueryExtent
  150038. * @returns the box extent values
  150039. */
  150040. getDefaultQueryExtent(): Vector3;
  150041. /**
  150042. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150043. * @param result output the box extent values
  150044. */
  150045. getDefaultQueryExtentToRef(result: Vector3): void;
  150046. /**
  150047. * Release all resources
  150048. */
  150049. dispose(): void;
  150050. }
  150051. /**
  150052. * Configures an agent
  150053. */
  150054. export interface IAgentParameters {
  150055. /**
  150056. * Agent radius. [Limit: >= 0]
  150057. */
  150058. radius: number;
  150059. /**
  150060. * Agent height. [Limit: > 0]
  150061. */
  150062. height: number;
  150063. /**
  150064. * Maximum allowed acceleration. [Limit: >= 0]
  150065. */
  150066. maxAcceleration: number;
  150067. /**
  150068. * Maximum allowed speed. [Limit: >= 0]
  150069. */
  150070. maxSpeed: number;
  150071. /**
  150072. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  150073. */
  150074. collisionQueryRange: number;
  150075. /**
  150076. * The path visibility optimization range. [Limit: > 0]
  150077. */
  150078. pathOptimizationRange: number;
  150079. /**
  150080. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  150081. */
  150082. separationWeight: number;
  150083. }
  150084. /**
  150085. * Configures the navigation mesh creation
  150086. */
  150087. export interface INavMeshParameters {
  150088. /**
  150089. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  150090. */
  150091. cs: number;
  150092. /**
  150093. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  150094. */
  150095. ch: number;
  150096. /**
  150097. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  150098. */
  150099. walkableSlopeAngle: number;
  150100. /**
  150101. * Minimum floor to 'ceiling' height that will still allow the floor area to
  150102. * be considered walkable. [Limit: >= 3] [Units: vx]
  150103. */
  150104. walkableHeight: number;
  150105. /**
  150106. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  150107. */
  150108. walkableClimb: number;
  150109. /**
  150110. * The distance to erode/shrink the walkable area of the heightfield away from
  150111. * obstructions. [Limit: >=0] [Units: vx]
  150112. */
  150113. walkableRadius: number;
  150114. /**
  150115. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  150116. */
  150117. maxEdgeLen: number;
  150118. /**
  150119. * The maximum distance a simplfied contour's border edges should deviate
  150120. * the original raw contour. [Limit: >=0] [Units: vx]
  150121. */
  150122. maxSimplificationError: number;
  150123. /**
  150124. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  150125. */
  150126. minRegionArea: number;
  150127. /**
  150128. * Any regions with a span count smaller than this value will, if possible,
  150129. * be merged with larger regions. [Limit: >=0] [Units: vx]
  150130. */
  150131. mergeRegionArea: number;
  150132. /**
  150133. * The maximum number of vertices allowed for polygons generated during the
  150134. * contour to polygon conversion process. [Limit: >= 3]
  150135. */
  150136. maxVertsPerPoly: number;
  150137. /**
  150138. * Sets the sampling distance to use when generating the detail mesh.
  150139. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  150140. */
  150141. detailSampleDist: number;
  150142. /**
  150143. * The maximum distance the detail mesh surface should deviate from heightfield
  150144. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  150145. */
  150146. detailSampleMaxError: number;
  150147. }
  150148. }
  150149. declare module BABYLON {
  150150. /**
  150151. * RecastJS navigation plugin
  150152. */
  150153. export class RecastJSPlugin implements INavigationEnginePlugin {
  150154. /**
  150155. * Reference to the Recast library
  150156. */
  150157. bjsRECAST: any;
  150158. /**
  150159. * plugin name
  150160. */
  150161. name: string;
  150162. /**
  150163. * the first navmesh created. We might extend this to support multiple navmeshes
  150164. */
  150165. navMesh: any;
  150166. private _maximumSubStepCount;
  150167. private _timeStep;
  150168. /**
  150169. * Initializes the recastJS plugin
  150170. * @param recastInjection can be used to inject your own recast reference
  150171. */
  150172. constructor(recastInjection?: any);
  150173. /**
  150174. * Set the time step of the navigation tick update.
  150175. * Default is 1/60.
  150176. * A value of 0 will disable fixed time update
  150177. * @param newTimeStep the new timestep to apply to this world.
  150178. */
  150179. setTimeStep(newTimeStep?: number): void;
  150180. /**
  150181. * Get the time step of the navigation tick update.
  150182. * @returns the current time step
  150183. */
  150184. getTimeStep(): number;
  150185. /**
  150186. * If delta time in navigation tick update is greater than the time step
  150187. * a number of sub iterations are done. If more iterations are need to reach deltatime
  150188. * they will be discarded.
  150189. * A value of 0 will set to no maximum and update will use as many substeps as needed
  150190. * @param newStepCount the maximum number of iterations
  150191. */
  150192. setMaximumSubStepCount(newStepCount?: number): void;
  150193. /**
  150194. * Get the maximum number of iterations per navigation tick update
  150195. * @returns the maximum number of iterations
  150196. */
  150197. getMaximumSubStepCount(): number;
  150198. /**
  150199. * Creates a navigation mesh
  150200. * @param meshes array of all the geometry used to compute the navigatio mesh
  150201. * @param parameters bunch of parameters used to filter geometry
  150202. */
  150203. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  150204. /**
  150205. * Create a navigation mesh debug mesh
  150206. * @param scene is where the mesh will be added
  150207. * @returns debug display mesh
  150208. */
  150209. createDebugNavMesh(scene: Scene): Mesh;
  150210. /**
  150211. * Get a navigation mesh constrained position, closest to the parameter position
  150212. * @param position world position
  150213. * @returns the closest point to position constrained by the navigation mesh
  150214. */
  150215. getClosestPoint(position: Vector3): Vector3;
  150216. /**
  150217. * Get a navigation mesh constrained position, closest to the parameter position
  150218. * @param position world position
  150219. * @param result output the closest point to position constrained by the navigation mesh
  150220. */
  150221. getClosestPointToRef(position: Vector3, result: Vector3): void;
  150222. /**
  150223. * Get a navigation mesh constrained position, within a particular radius
  150224. * @param position world position
  150225. * @param maxRadius the maximum distance to the constrained world position
  150226. * @returns the closest point to position constrained by the navigation mesh
  150227. */
  150228. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  150229. /**
  150230. * Get a navigation mesh constrained position, within a particular radius
  150231. * @param position world position
  150232. * @param maxRadius the maximum distance to the constrained world position
  150233. * @param result output the closest point to position constrained by the navigation mesh
  150234. */
  150235. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  150236. /**
  150237. * Compute the final position from a segment made of destination-position
  150238. * @param position world position
  150239. * @param destination world position
  150240. * @returns the resulting point along the navmesh
  150241. */
  150242. moveAlong(position: Vector3, destination: Vector3): Vector3;
  150243. /**
  150244. * Compute the final position from a segment made of destination-position
  150245. * @param position world position
  150246. * @param destination world position
  150247. * @param result output the resulting point along the navmesh
  150248. */
  150249. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  150250. /**
  150251. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  150252. * @param start world position
  150253. * @param end world position
  150254. * @returns array containing world position composing the path
  150255. */
  150256. computePath(start: Vector3, end: Vector3): Vector3[];
  150257. /**
  150258. * Create a new Crowd so you can add agents
  150259. * @param maxAgents the maximum agent count in the crowd
  150260. * @param maxAgentRadius the maximum radius an agent can have
  150261. * @param scene to attach the crowd to
  150262. * @returns the crowd you can add agents to
  150263. */
  150264. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  150265. /**
  150266. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150267. * The queries will try to find a solution within those bounds
  150268. * default is (1,1,1)
  150269. * @param extent x,y,z value that define the extent around the queries point of reference
  150270. */
  150271. setDefaultQueryExtent(extent: Vector3): void;
  150272. /**
  150273. * Get the Bounding box extent specified by setDefaultQueryExtent
  150274. * @returns the box extent values
  150275. */
  150276. getDefaultQueryExtent(): Vector3;
  150277. /**
  150278. * build the navmesh from a previously saved state using getNavmeshData
  150279. * @param data the Uint8Array returned by getNavmeshData
  150280. */
  150281. buildFromNavmeshData(data: Uint8Array): void;
  150282. /**
  150283. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  150284. * @returns data the Uint8Array that can be saved and reused
  150285. */
  150286. getNavmeshData(): Uint8Array;
  150287. /**
  150288. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150289. * @param result output the box extent values
  150290. */
  150291. getDefaultQueryExtentToRef(result: Vector3): void;
  150292. /**
  150293. * Disposes
  150294. */
  150295. dispose(): void;
  150296. /**
  150297. * If this plugin is supported
  150298. * @returns true if plugin is supported
  150299. */
  150300. isSupported(): boolean;
  150301. }
  150302. /**
  150303. * Recast detour crowd implementation
  150304. */
  150305. export class RecastJSCrowd implements ICrowd {
  150306. /**
  150307. * Recast/detour plugin
  150308. */
  150309. bjsRECASTPlugin: RecastJSPlugin;
  150310. /**
  150311. * Link to the detour crowd
  150312. */
  150313. recastCrowd: any;
  150314. /**
  150315. * One transform per agent
  150316. */
  150317. transforms: TransformNode[];
  150318. /**
  150319. * All agents created
  150320. */
  150321. agents: number[];
  150322. /**
  150323. * Link to the scene is kept to unregister the crowd from the scene
  150324. */
  150325. private _scene;
  150326. /**
  150327. * Observer for crowd updates
  150328. */
  150329. private _onBeforeAnimationsObserver;
  150330. /**
  150331. * Constructor
  150332. * @param plugin recastJS plugin
  150333. * @param maxAgents the maximum agent count in the crowd
  150334. * @param maxAgentRadius the maximum radius an agent can have
  150335. * @param scene to attach the crowd to
  150336. * @returns the crowd you can add agents to
  150337. */
  150338. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  150339. /**
  150340. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  150341. * You can attach anything to that node. The node position is updated in the scene update tick.
  150342. * @param pos world position that will be constrained by the navigation mesh
  150343. * @param parameters agent parameters
  150344. * @param transform hooked to the agent that will be update by the scene
  150345. * @returns agent index
  150346. */
  150347. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  150348. /**
  150349. * Returns the agent position in world space
  150350. * @param index agent index returned by addAgent
  150351. * @returns world space position
  150352. */
  150353. getAgentPosition(index: number): Vector3;
  150354. /**
  150355. * Returns the agent position result in world space
  150356. * @param index agent index returned by addAgent
  150357. * @param result output world space position
  150358. */
  150359. getAgentPositionToRef(index: number, result: Vector3): void;
  150360. /**
  150361. * Returns the agent velocity in world space
  150362. * @param index agent index returned by addAgent
  150363. * @returns world space velocity
  150364. */
  150365. getAgentVelocity(index: number): Vector3;
  150366. /**
  150367. * Returns the agent velocity result in world space
  150368. * @param index agent index returned by addAgent
  150369. * @param result output world space velocity
  150370. */
  150371. getAgentVelocityToRef(index: number, result: Vector3): void;
  150372. /**
  150373. * Returns the agent next target point on the path
  150374. * @param index agent index returned by addAgent
  150375. * @returns world space position
  150376. */
  150377. getAgentNextTargetPath(index: number): Vector3;
  150378. /**
  150379. * Returns the agent next target point on the path
  150380. * @param index agent index returned by addAgent
  150381. * @param result output world space position
  150382. */
  150383. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  150384. /**
  150385. * Gets the agent state
  150386. * @param index agent index returned by addAgent
  150387. * @returns agent state
  150388. */
  150389. getAgentState(index: number): number;
  150390. /**
  150391. * returns true if the agent in over an off mesh link connection
  150392. * @param index agent index returned by addAgent
  150393. * @returns true if over an off mesh link connection
  150394. */
  150395. overOffmeshConnection(index: number): boolean;
  150396. /**
  150397. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  150398. * @param index agent index returned by addAgent
  150399. * @param destination targeted world position
  150400. */
  150401. agentGoto(index: number, destination: Vector3): void;
  150402. /**
  150403. * Teleport the agent to a new position
  150404. * @param index agent index returned by addAgent
  150405. * @param destination targeted world position
  150406. */
  150407. agentTeleport(index: number, destination: Vector3): void;
  150408. /**
  150409. * Update agent parameters
  150410. * @param index agent index returned by addAgent
  150411. * @param parameters agent parameters
  150412. */
  150413. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  150414. /**
  150415. * remove a particular agent previously created
  150416. * @param index agent index returned by addAgent
  150417. */
  150418. removeAgent(index: number): void;
  150419. /**
  150420. * get the list of all agents attached to this crowd
  150421. * @returns list of agent indices
  150422. */
  150423. getAgents(): number[];
  150424. /**
  150425. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  150426. * @param deltaTime in seconds
  150427. */
  150428. update(deltaTime: number): void;
  150429. /**
  150430. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  150431. * The queries will try to find a solution within those bounds
  150432. * default is (1,1,1)
  150433. * @param extent x,y,z value that define the extent around the queries point of reference
  150434. */
  150435. setDefaultQueryExtent(extent: Vector3): void;
  150436. /**
  150437. * Get the Bounding box extent specified by setDefaultQueryExtent
  150438. * @returns the box extent values
  150439. */
  150440. getDefaultQueryExtent(): Vector3;
  150441. /**
  150442. * Get the Bounding box extent result specified by setDefaultQueryExtent
  150443. * @param result output the box extent values
  150444. */
  150445. getDefaultQueryExtentToRef(result: Vector3): void;
  150446. /**
  150447. * Release all resources
  150448. */
  150449. dispose(): void;
  150450. }
  150451. }
  150452. declare module BABYLON {
  150453. /**
  150454. * Class used to enable access to IndexedDB
  150455. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  150456. */
  150457. export class Database implements IOfflineProvider {
  150458. private _callbackManifestChecked;
  150459. private _currentSceneUrl;
  150460. private _db;
  150461. private _enableSceneOffline;
  150462. private _enableTexturesOffline;
  150463. private _manifestVersionFound;
  150464. private _mustUpdateRessources;
  150465. private _hasReachedQuota;
  150466. private _isSupported;
  150467. private _idbFactory;
  150468. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  150469. private static IsUASupportingBlobStorage;
  150470. /**
  150471. * Gets a boolean indicating if Database storate is enabled (off by default)
  150472. */
  150473. static IDBStorageEnabled: boolean;
  150474. /**
  150475. * Gets a boolean indicating if scene must be saved in the database
  150476. */
  150477. get enableSceneOffline(): boolean;
  150478. /**
  150479. * Gets a boolean indicating if textures must be saved in the database
  150480. */
  150481. get enableTexturesOffline(): boolean;
  150482. /**
  150483. * Creates a new Database
  150484. * @param urlToScene defines the url to load the scene
  150485. * @param callbackManifestChecked defines the callback to use when manifest is checked
  150486. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  150487. */
  150488. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  150489. private static _ParseURL;
  150490. private static _ReturnFullUrlLocation;
  150491. private _checkManifestFile;
  150492. /**
  150493. * Open the database and make it available
  150494. * @param successCallback defines the callback to call on success
  150495. * @param errorCallback defines the callback to call on error
  150496. */
  150497. open(successCallback: () => void, errorCallback: () => void): void;
  150498. /**
  150499. * Loads an image from the database
  150500. * @param url defines the url to load from
  150501. * @param image defines the target DOM image
  150502. */
  150503. loadImage(url: string, image: HTMLImageElement): void;
  150504. private _loadImageFromDBAsync;
  150505. private _saveImageIntoDBAsync;
  150506. private _checkVersionFromDB;
  150507. private _loadVersionFromDBAsync;
  150508. private _saveVersionIntoDBAsync;
  150509. /**
  150510. * Loads a file from database
  150511. * @param url defines the URL to load from
  150512. * @param sceneLoaded defines a callback to call on success
  150513. * @param progressCallBack defines a callback to call when progress changed
  150514. * @param errorCallback defines a callback to call on error
  150515. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  150516. */
  150517. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  150518. private _loadFileAsync;
  150519. private _saveFileAsync;
  150520. /**
  150521. * Validates if xhr data is correct
  150522. * @param xhr defines the request to validate
  150523. * @param dataType defines the expected data type
  150524. * @returns true if data is correct
  150525. */
  150526. private static _ValidateXHRData;
  150527. }
  150528. }
  150529. declare module BABYLON {
  150530. /** @hidden */
  150531. export var gpuUpdateParticlesPixelShader: {
  150532. name: string;
  150533. shader: string;
  150534. };
  150535. }
  150536. declare module BABYLON {
  150537. /** @hidden */
  150538. export var gpuUpdateParticlesVertexShader: {
  150539. name: string;
  150540. shader: string;
  150541. };
  150542. }
  150543. declare module BABYLON {
  150544. /** @hidden */
  150545. export var clipPlaneFragmentDeclaration2: {
  150546. name: string;
  150547. shader: string;
  150548. };
  150549. }
  150550. declare module BABYLON {
  150551. /** @hidden */
  150552. export var gpuRenderParticlesPixelShader: {
  150553. name: string;
  150554. shader: string;
  150555. };
  150556. }
  150557. declare module BABYLON {
  150558. /** @hidden */
  150559. export var clipPlaneVertexDeclaration2: {
  150560. name: string;
  150561. shader: string;
  150562. };
  150563. }
  150564. declare module BABYLON {
  150565. /** @hidden */
  150566. export var gpuRenderParticlesVertexShader: {
  150567. name: string;
  150568. shader: string;
  150569. };
  150570. }
  150571. declare module BABYLON {
  150572. /**
  150573. * This represents a GPU particle system in Babylon
  150574. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  150575. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  150576. */
  150577. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  150578. /**
  150579. * The layer mask we are rendering the particles through.
  150580. */
  150581. layerMask: number;
  150582. private _capacity;
  150583. private _activeCount;
  150584. private _currentActiveCount;
  150585. private _accumulatedCount;
  150586. private _renderEffect;
  150587. private _updateEffect;
  150588. private _buffer0;
  150589. private _buffer1;
  150590. private _spriteBuffer;
  150591. private _updateVAO;
  150592. private _renderVAO;
  150593. private _targetIndex;
  150594. private _sourceBuffer;
  150595. private _targetBuffer;
  150596. private _currentRenderId;
  150597. private _started;
  150598. private _stopped;
  150599. private _timeDelta;
  150600. private _randomTexture;
  150601. private _randomTexture2;
  150602. private _attributesStrideSize;
  150603. private _updateEffectOptions;
  150604. private _randomTextureSize;
  150605. private _actualFrame;
  150606. private _customEffect;
  150607. private readonly _rawTextureWidth;
  150608. /**
  150609. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  150610. */
  150611. static get IsSupported(): boolean;
  150612. /**
  150613. * An event triggered when the system is disposed.
  150614. */
  150615. onDisposeObservable: Observable<IParticleSystem>;
  150616. /**
  150617. * An event triggered when the system is stopped
  150618. */
  150619. onStoppedObservable: Observable<IParticleSystem>;
  150620. /**
  150621. * Gets the maximum number of particles active at the same time.
  150622. * @returns The max number of active particles.
  150623. */
  150624. getCapacity(): number;
  150625. /**
  150626. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  150627. * to override the particles.
  150628. */
  150629. forceDepthWrite: boolean;
  150630. /**
  150631. * Gets or set the number of active particles
  150632. */
  150633. get activeParticleCount(): number;
  150634. set activeParticleCount(value: number);
  150635. private _preWarmDone;
  150636. /**
  150637. * Specifies if the particles are updated in emitter local space or world space.
  150638. */
  150639. isLocal: boolean;
  150640. /** Gets or sets a matrix to use to compute projection */
  150641. defaultProjectionMatrix: Matrix;
  150642. /**
  150643. * Is this system ready to be used/rendered
  150644. * @return true if the system is ready
  150645. */
  150646. isReady(): boolean;
  150647. /**
  150648. * Gets if the system has been started. (Note: this will still be true after stop is called)
  150649. * @returns True if it has been started, otherwise false.
  150650. */
  150651. isStarted(): boolean;
  150652. /**
  150653. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  150654. * @returns True if it has been stopped, otherwise false.
  150655. */
  150656. isStopped(): boolean;
  150657. /**
  150658. * Gets a boolean indicating that the system is stopping
  150659. * @returns true if the system is currently stopping
  150660. */
  150661. isStopping(): boolean;
  150662. /**
  150663. * Gets the number of particles active at the same time.
  150664. * @returns The number of active particles.
  150665. */
  150666. getActiveCount(): number;
  150667. /**
  150668. * Starts the particle system and begins to emit
  150669. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  150670. */
  150671. start(delay?: number): void;
  150672. /**
  150673. * Stops the particle system.
  150674. */
  150675. stop(): void;
  150676. /**
  150677. * Remove all active particles
  150678. */
  150679. reset(): void;
  150680. /**
  150681. * Returns the string "GPUParticleSystem"
  150682. * @returns a string containing the class name
  150683. */
  150684. getClassName(): string;
  150685. /**
  150686. * Gets the custom effect used to render the particles
  150687. * @param blendMode Blend mode for which the effect should be retrieved
  150688. * @returns The effect
  150689. */
  150690. getCustomEffect(blendMode?: number): Nullable<Effect>;
  150691. /**
  150692. * Sets the custom effect used to render the particles
  150693. * @param effect The effect to set
  150694. * @param blendMode Blend mode for which the effect should be set
  150695. */
  150696. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  150697. /** @hidden */
  150698. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  150699. /**
  150700. * Observable that will be called just before the particles are drawn
  150701. */
  150702. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  150703. /**
  150704. * Gets the name of the particle vertex shader
  150705. */
  150706. get vertexShaderName(): string;
  150707. private _colorGradientsTexture;
  150708. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  150709. /**
  150710. * Adds a new color gradient
  150711. * @param gradient defines the gradient to use (between 0 and 1)
  150712. * @param color1 defines the color to affect to the specified gradient
  150713. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  150714. * @returns the current particle system
  150715. */
  150716. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  150717. private _refreshColorGradient;
  150718. /** Force the system to rebuild all gradients that need to be resync */
  150719. forceRefreshGradients(): void;
  150720. /**
  150721. * Remove a specific color gradient
  150722. * @param gradient defines the gradient to remove
  150723. * @returns the current particle system
  150724. */
  150725. removeColorGradient(gradient: number): GPUParticleSystem;
  150726. private _angularSpeedGradientsTexture;
  150727. private _sizeGradientsTexture;
  150728. private _velocityGradientsTexture;
  150729. private _limitVelocityGradientsTexture;
  150730. private _dragGradientsTexture;
  150731. private _addFactorGradient;
  150732. /**
  150733. * Adds a new size gradient
  150734. * @param gradient defines the gradient to use (between 0 and 1)
  150735. * @param factor defines the size factor to affect to the specified gradient
  150736. * @returns the current particle system
  150737. */
  150738. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  150739. /**
  150740. * Remove a specific size gradient
  150741. * @param gradient defines the gradient to remove
  150742. * @returns the current particle system
  150743. */
  150744. removeSizeGradient(gradient: number): GPUParticleSystem;
  150745. private _refreshFactorGradient;
  150746. /**
  150747. * Adds a new angular speed gradient
  150748. * @param gradient defines the gradient to use (between 0 and 1)
  150749. * @param factor defines the angular speed to affect to the specified gradient
  150750. * @returns the current particle system
  150751. */
  150752. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  150753. /**
  150754. * Remove a specific angular speed gradient
  150755. * @param gradient defines the gradient to remove
  150756. * @returns the current particle system
  150757. */
  150758. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  150759. /**
  150760. * Adds a new velocity gradient
  150761. * @param gradient defines the gradient to use (between 0 and 1)
  150762. * @param factor defines the velocity to affect to the specified gradient
  150763. * @returns the current particle system
  150764. */
  150765. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150766. /**
  150767. * Remove a specific velocity gradient
  150768. * @param gradient defines the gradient to remove
  150769. * @returns the current particle system
  150770. */
  150771. removeVelocityGradient(gradient: number): GPUParticleSystem;
  150772. /**
  150773. * Adds a new limit velocity gradient
  150774. * @param gradient defines the gradient to use (between 0 and 1)
  150775. * @param factor defines the limit velocity value to affect to the specified gradient
  150776. * @returns the current particle system
  150777. */
  150778. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  150779. /**
  150780. * Remove a specific limit velocity gradient
  150781. * @param gradient defines the gradient to remove
  150782. * @returns the current particle system
  150783. */
  150784. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  150785. /**
  150786. * Adds a new drag gradient
  150787. * @param gradient defines the gradient to use (between 0 and 1)
  150788. * @param factor defines the drag value to affect to the specified gradient
  150789. * @returns the current particle system
  150790. */
  150791. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  150792. /**
  150793. * Remove a specific drag gradient
  150794. * @param gradient defines the gradient to remove
  150795. * @returns the current particle system
  150796. */
  150797. removeDragGradient(gradient: number): GPUParticleSystem;
  150798. /**
  150799. * Not supported by GPUParticleSystem
  150800. * @param gradient defines the gradient to use (between 0 and 1)
  150801. * @param factor defines the emit rate value to affect to the specified gradient
  150802. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150803. * @returns the current particle system
  150804. */
  150805. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150806. /**
  150807. * Not supported by GPUParticleSystem
  150808. * @param gradient defines the gradient to remove
  150809. * @returns the current particle system
  150810. */
  150811. removeEmitRateGradient(gradient: number): IParticleSystem;
  150812. /**
  150813. * Not supported by GPUParticleSystem
  150814. * @param gradient defines the gradient to use (between 0 and 1)
  150815. * @param factor defines the start size value to affect to the specified gradient
  150816. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150817. * @returns the current particle system
  150818. */
  150819. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150820. /**
  150821. * Not supported by GPUParticleSystem
  150822. * @param gradient defines the gradient to remove
  150823. * @returns the current particle system
  150824. */
  150825. removeStartSizeGradient(gradient: number): IParticleSystem;
  150826. /**
  150827. * Not supported by GPUParticleSystem
  150828. * @param gradient defines the gradient to use (between 0 and 1)
  150829. * @param min defines the color remap minimal range
  150830. * @param max defines the color remap maximal range
  150831. * @returns the current particle system
  150832. */
  150833. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150834. /**
  150835. * Not supported by GPUParticleSystem
  150836. * @param gradient defines the gradient to remove
  150837. * @returns the current particle system
  150838. */
  150839. removeColorRemapGradient(): IParticleSystem;
  150840. /**
  150841. * Not supported by GPUParticleSystem
  150842. * @param gradient defines the gradient to use (between 0 and 1)
  150843. * @param min defines the alpha remap minimal range
  150844. * @param max defines the alpha remap maximal range
  150845. * @returns the current particle system
  150846. */
  150847. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  150848. /**
  150849. * Not supported by GPUParticleSystem
  150850. * @param gradient defines the gradient to remove
  150851. * @returns the current particle system
  150852. */
  150853. removeAlphaRemapGradient(): IParticleSystem;
  150854. /**
  150855. * Not supported by GPUParticleSystem
  150856. * @param gradient defines the gradient to use (between 0 and 1)
  150857. * @param color defines the color to affect to the specified gradient
  150858. * @returns the current particle system
  150859. */
  150860. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  150861. /**
  150862. * Not supported by GPUParticleSystem
  150863. * @param gradient defines the gradient to remove
  150864. * @returns the current particle system
  150865. */
  150866. removeRampGradient(): IParticleSystem;
  150867. /**
  150868. * Not supported by GPUParticleSystem
  150869. * @returns the list of ramp gradients
  150870. */
  150871. getRampGradients(): Nullable<Array<Color3Gradient>>;
  150872. /**
  150873. * Not supported by GPUParticleSystem
  150874. * Gets or sets a boolean indicating that ramp gradients must be used
  150875. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  150876. */
  150877. get useRampGradients(): boolean;
  150878. set useRampGradients(value: boolean);
  150879. /**
  150880. * Not supported by GPUParticleSystem
  150881. * @param gradient defines the gradient to use (between 0 and 1)
  150882. * @param factor defines the life time factor to affect to the specified gradient
  150883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  150884. * @returns the current particle system
  150885. */
  150886. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  150887. /**
  150888. * Not supported by GPUParticleSystem
  150889. * @param gradient defines the gradient to remove
  150890. * @returns the current particle system
  150891. */
  150892. removeLifeTimeGradient(gradient: number): IParticleSystem;
  150893. /**
  150894. * Instantiates a GPU particle system.
  150895. * 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.
  150896. * @param name The name of the particle system
  150897. * @param options The options used to create the system
  150898. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150899. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150900. * @param customEffect a custom effect used to change the way particles are rendered by default
  150901. */
  150902. constructor(name: string, options: Partial<{
  150903. capacity: number;
  150904. randomTextureSize: number;
  150905. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150906. protected _reset(): void;
  150907. private _createUpdateVAO;
  150908. private _createRenderVAO;
  150909. private _initialize;
  150910. /** @hidden */
  150911. _recreateUpdateEffect(): void;
  150912. private _getEffect;
  150913. /**
  150914. * Fill the defines array according to the current settings of the particle system
  150915. * @param defines Array to be updated
  150916. * @param blendMode blend mode to take into account when updating the array
  150917. */
  150918. fillDefines(defines: Array<string>, blendMode?: number): void;
  150919. /**
  150920. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150921. * @param uniforms Uniforms array to fill
  150922. * @param attributes Attributes array to fill
  150923. * @param samplers Samplers array to fill
  150924. */
  150925. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150926. /** @hidden */
  150927. _recreateRenderEffect(): Effect;
  150928. /**
  150929. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150930. * @param preWarm defines if we are in the pre-warmimg phase
  150931. */
  150932. animate(preWarm?: boolean): void;
  150933. private _createFactorGradientTexture;
  150934. private _createSizeGradientTexture;
  150935. private _createAngularSpeedGradientTexture;
  150936. private _createVelocityGradientTexture;
  150937. private _createLimitVelocityGradientTexture;
  150938. private _createDragGradientTexture;
  150939. private _createColorGradientTexture;
  150940. /**
  150941. * Renders the particle system in its current state
  150942. * @param preWarm defines if the system should only update the particles but not render them
  150943. * @returns the current number of particles
  150944. */
  150945. render(preWarm?: boolean): number;
  150946. /**
  150947. * Rebuilds the particle system
  150948. */
  150949. rebuild(): void;
  150950. private _releaseBuffers;
  150951. private _releaseVAOs;
  150952. /**
  150953. * Disposes the particle system and free the associated resources
  150954. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150955. */
  150956. dispose(disposeTexture?: boolean): void;
  150957. /**
  150958. * Clones the particle system.
  150959. * @param name The name of the cloned object
  150960. * @param newEmitter The new emitter to use
  150961. * @returns the cloned particle system
  150962. */
  150963. clone(name: string, newEmitter: any): GPUParticleSystem;
  150964. /**
  150965. * Serializes the particle system to a JSON object
  150966. * @param serializeTexture defines if the texture must be serialized as well
  150967. * @returns the JSON object
  150968. */
  150969. serialize(serializeTexture?: boolean): any;
  150970. /**
  150971. * Parses a JSON object to create a GPU particle system.
  150972. * @param parsedParticleSystem The JSON object to parse
  150973. * @param sceneOrEngine The scene or the engine to create the particle system in
  150974. * @param rootUrl The root url to use to load external dependencies like texture
  150975. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150976. * @returns the parsed GPU particle system
  150977. */
  150978. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150979. }
  150980. }
  150981. declare module BABYLON {
  150982. /**
  150983. * Represents a set of particle systems working together to create a specific effect
  150984. */
  150985. export class ParticleSystemSet implements IDisposable {
  150986. /**
  150987. * Gets or sets base Assets URL
  150988. */
  150989. static BaseAssetsUrl: string;
  150990. private _emitterCreationOptions;
  150991. private _emitterNode;
  150992. /**
  150993. * Gets the particle system list
  150994. */
  150995. systems: IParticleSystem[];
  150996. /**
  150997. * Gets the emitter node used with this set
  150998. */
  150999. get emitterNode(): Nullable<TransformNode>;
  151000. /**
  151001. * Creates a new emitter mesh as a sphere
  151002. * @param options defines the options used to create the sphere
  151003. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  151004. * @param scene defines the hosting scene
  151005. */
  151006. setEmitterAsSphere(options: {
  151007. diameter: number;
  151008. segments: number;
  151009. color: Color3;
  151010. }, renderingGroupId: number, scene: Scene): void;
  151011. /**
  151012. * Starts all particle systems of the set
  151013. * @param emitter defines an optional mesh to use as emitter for the particle systems
  151014. */
  151015. start(emitter?: AbstractMesh): void;
  151016. /**
  151017. * Release all associated resources
  151018. */
  151019. dispose(): void;
  151020. /**
  151021. * Serialize the set into a JSON compatible object
  151022. * @param serializeTexture defines if the texture must be serialized as well
  151023. * @returns a JSON compatible representation of the set
  151024. */
  151025. serialize(serializeTexture?: boolean): any;
  151026. /**
  151027. * Parse a new ParticleSystemSet from a serialized source
  151028. * @param data defines a JSON compatible representation of the set
  151029. * @param scene defines the hosting scene
  151030. * @param gpu defines if we want GPU particles or CPU particles
  151031. * @returns a new ParticleSystemSet
  151032. */
  151033. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  151034. }
  151035. }
  151036. declare module BABYLON {
  151037. /**
  151038. * This class is made for on one-liner static method to help creating particle system set.
  151039. */
  151040. export class ParticleHelper {
  151041. /**
  151042. * Gets or sets base Assets URL
  151043. */
  151044. static BaseAssetsUrl: string;
  151045. /** Define the Url to load snippets */
  151046. static SnippetUrl: string;
  151047. /**
  151048. * Create a default particle system that you can tweak
  151049. * @param emitter defines the emitter to use
  151050. * @param capacity defines the system capacity (default is 500 particles)
  151051. * @param scene defines the hosting scene
  151052. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  151053. * @returns the new Particle system
  151054. */
  151055. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  151056. /**
  151057. * This is the main static method (one-liner) of this helper to create different particle systems
  151058. * @param type This string represents the type to the particle system to create
  151059. * @param scene The scene where the particle system should live
  151060. * @param gpu If the system will use gpu
  151061. * @returns the ParticleSystemSet created
  151062. */
  151063. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  151064. /**
  151065. * Static function used to export a particle system to a ParticleSystemSet variable.
  151066. * Please note that the emitter shape is not exported
  151067. * @param systems defines the particle systems to export
  151068. * @returns the created particle system set
  151069. */
  151070. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  151071. /**
  151072. * Creates a particle system from a snippet saved in a remote file
  151073. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  151074. * @param url defines the url to load from
  151075. * @param scene defines the hosting scene
  151076. * @param gpu If the system will use gpu
  151077. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  151078. * @returns a promise that will resolve to the new particle system
  151079. */
  151080. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  151081. /**
  151082. * Creates a particle system from a snippet saved by the particle system editor
  151083. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  151084. * @param scene defines the hosting scene
  151085. * @param gpu If the system will use gpu
  151086. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  151087. * @returns a promise that will resolve to the new particle system
  151088. */
  151089. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  151090. }
  151091. }
  151092. declare module BABYLON {
  151093. interface Engine {
  151094. /**
  151095. * Create an effect to use with particle systems.
  151096. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  151097. * the particle system for which you want to create a custom effect in the last parameter
  151098. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  151099. * @param uniformsNames defines a list of attribute names
  151100. * @param samplers defines an array of string used to represent textures
  151101. * @param defines defines the string containing the defines to use to compile the shaders
  151102. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  151103. * @param onCompiled defines a function to call when the effect creation is successful
  151104. * @param onError defines a function to call when the effect creation has failed
  151105. * @param particleSystem the particle system you want to create the effect for
  151106. * @returns the new Effect
  151107. */
  151108. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  151109. }
  151110. interface Mesh {
  151111. /**
  151112. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  151113. * @returns an array of IParticleSystem
  151114. */
  151115. getEmittedParticleSystems(): IParticleSystem[];
  151116. /**
  151117. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  151118. * @returns an array of IParticleSystem
  151119. */
  151120. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  151121. }
  151122. }
  151123. declare module BABYLON {
  151124. /** Defines the 4 color options */
  151125. export enum PointColor {
  151126. /** color value */
  151127. Color = 2,
  151128. /** uv value */
  151129. UV = 1,
  151130. /** random value */
  151131. Random = 0,
  151132. /** stated value */
  151133. Stated = 3
  151134. }
  151135. /**
  151136. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  151137. * 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.
  151138. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  151139. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  151140. *
  151141. * Full documentation here : TO BE ENTERED
  151142. */
  151143. export class PointsCloudSystem implements IDisposable {
  151144. /**
  151145. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  151146. * Example : var p = SPS.particles[i];
  151147. */
  151148. particles: CloudPoint[];
  151149. /**
  151150. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  151151. */
  151152. nbParticles: number;
  151153. /**
  151154. * This a counter for your own usage. It's not set by any SPS functions.
  151155. */
  151156. counter: number;
  151157. /**
  151158. * The PCS name. This name is also given to the underlying mesh.
  151159. */
  151160. name: string;
  151161. /**
  151162. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  151163. */
  151164. mesh: Mesh;
  151165. /**
  151166. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  151167. * Please read :
  151168. */
  151169. vars: any;
  151170. /**
  151171. * @hidden
  151172. */
  151173. _size: number;
  151174. private _scene;
  151175. private _promises;
  151176. private _positions;
  151177. private _indices;
  151178. private _normals;
  151179. private _colors;
  151180. private _uvs;
  151181. private _indices32;
  151182. private _positions32;
  151183. private _colors32;
  151184. private _uvs32;
  151185. private _updatable;
  151186. private _isVisibilityBoxLocked;
  151187. private _alwaysVisible;
  151188. private _groups;
  151189. private _groupCounter;
  151190. private _computeParticleColor;
  151191. private _computeParticleTexture;
  151192. private _computeParticleRotation;
  151193. private _computeBoundingBox;
  151194. private _isReady;
  151195. /**
  151196. * Creates a PCS (Points Cloud System) object
  151197. * @param name (String) is the PCS name, this will be the underlying mesh name
  151198. * @param pointSize (number) is the size for each point
  151199. * @param scene (Scene) is the scene in which the PCS is added
  151200. * @param options defines the options of the PCS e.g.
  151201. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  151202. */
  151203. constructor(name: string, pointSize: number, scene: Scene, options?: {
  151204. updatable?: boolean;
  151205. });
  151206. /**
  151207. * Builds the PCS underlying mesh. Returns a standard Mesh.
  151208. * If no points were added to the PCS, the returned mesh is just a single point.
  151209. * @returns a promise for the created mesh
  151210. */
  151211. buildMeshAsync(): Promise<Mesh>;
  151212. /**
  151213. * @hidden
  151214. */
  151215. private _buildMesh;
  151216. private _addParticle;
  151217. private _randomUnitVector;
  151218. private _getColorIndicesForCoord;
  151219. private _setPointsColorOrUV;
  151220. private _colorFromTexture;
  151221. private _calculateDensity;
  151222. /**
  151223. * Adds points to the PCS in random positions within a unit sphere
  151224. * @param nb (positive integer) the number of particles to be created from this model
  151225. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  151226. * @returns the number of groups in the system
  151227. */
  151228. addPoints(nb: number, pointFunction?: any): number;
  151229. /**
  151230. * Adds points to the PCS from the surface of the model shape
  151231. * @param mesh is any Mesh object that will be used as a surface model for the points
  151232. * @param nb (positive integer) the number of particles to be created from this model
  151233. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151234. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151235. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151236. * @returns the number of groups in the system
  151237. */
  151238. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151239. /**
  151240. * Adds points to the PCS inside the model shape
  151241. * @param mesh is any Mesh object that will be used as a surface model for the points
  151242. * @param nb (positive integer) the number of particles to be created from this model
  151243. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  151244. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  151245. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  151246. * @returns the number of groups in the system
  151247. */
  151248. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  151249. /**
  151250. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  151251. * This method calls `updateParticle()` for each particle of the SPS.
  151252. * For an animated SPS, it is usually called within the render loop.
  151253. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  151254. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  151255. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  151256. * @returns the PCS.
  151257. */
  151258. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  151259. /**
  151260. * Disposes the PCS.
  151261. */
  151262. dispose(): void;
  151263. /**
  151264. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  151265. * doc :
  151266. * @returns the PCS.
  151267. */
  151268. refreshVisibleSize(): PointsCloudSystem;
  151269. /**
  151270. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  151271. * @param size the size (float) of the visibility box
  151272. * note : this doesn't lock the PCS mesh bounding box.
  151273. * doc :
  151274. */
  151275. setVisibilityBox(size: number): void;
  151276. /**
  151277. * Gets whether the PCS is always visible or not
  151278. * doc :
  151279. */
  151280. get isAlwaysVisible(): boolean;
  151281. /**
  151282. * Sets the PCS as always visible or not
  151283. * doc :
  151284. */
  151285. set isAlwaysVisible(val: boolean);
  151286. /**
  151287. * Tells to `setParticles()` to compute the particle rotations or not
  151288. * Default value : false. The PCS is faster when it's set to false
  151289. * Note : particle rotations are only applied to parent particles
  151290. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  151291. */
  151292. set computeParticleRotation(val: boolean);
  151293. /**
  151294. * Tells to `setParticles()` to compute the particle colors or not.
  151295. * Default value : true. The PCS is faster when it's set to false.
  151296. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151297. */
  151298. set computeParticleColor(val: boolean);
  151299. set computeParticleTexture(val: boolean);
  151300. /**
  151301. * Gets if `setParticles()` computes the particle colors or not.
  151302. * Default value : false. The PCS is faster when it's set to false.
  151303. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  151304. */
  151305. get computeParticleColor(): boolean;
  151306. /**
  151307. * Gets if `setParticles()` computes the particle textures or not.
  151308. * Default value : false. The PCS is faster when it's set to false.
  151309. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  151310. */
  151311. get computeParticleTexture(): boolean;
  151312. /**
  151313. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  151314. */
  151315. set computeBoundingBox(val: boolean);
  151316. /**
  151317. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  151318. */
  151319. get computeBoundingBox(): boolean;
  151320. /**
  151321. * This function does nothing. It may be overwritten to set all the particle first values.
  151322. * The PCS doesn't call this function, you may have to call it by your own.
  151323. * doc :
  151324. */
  151325. initParticles(): void;
  151326. /**
  151327. * This function does nothing. It may be overwritten to recycle a particle
  151328. * The PCS doesn't call this function, you can to call it
  151329. * doc :
  151330. * @param particle The particle to recycle
  151331. * @returns the recycled particle
  151332. */
  151333. recycleParticle(particle: CloudPoint): CloudPoint;
  151334. /**
  151335. * Updates a particle : this function should be overwritten by the user.
  151336. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  151337. * doc :
  151338. * @example : just set a particle position or velocity and recycle conditions
  151339. * @param particle The particle to update
  151340. * @returns the updated particle
  151341. */
  151342. updateParticle(particle: CloudPoint): CloudPoint;
  151343. /**
  151344. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  151345. * This does nothing and may be overwritten by the user.
  151346. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151347. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151348. * @param update the boolean update value actually passed to setParticles()
  151349. */
  151350. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151351. /**
  151352. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  151353. * This will be passed three parameters.
  151354. * This does nothing and may be overwritten by the user.
  151355. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  151356. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  151357. * @param update the boolean update value actually passed to setParticles()
  151358. */
  151359. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  151360. }
  151361. }
  151362. declare module BABYLON {
  151363. /**
  151364. * Represents one particle of a points cloud system.
  151365. */
  151366. export class CloudPoint {
  151367. /**
  151368. * particle global index
  151369. */
  151370. idx: number;
  151371. /**
  151372. * The color of the particle
  151373. */
  151374. color: Nullable<Color4>;
  151375. /**
  151376. * The world space position of the particle.
  151377. */
  151378. position: Vector3;
  151379. /**
  151380. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  151381. */
  151382. rotation: Vector3;
  151383. /**
  151384. * The world space rotation quaternion of the particle.
  151385. */
  151386. rotationQuaternion: Nullable<Quaternion>;
  151387. /**
  151388. * The uv of the particle.
  151389. */
  151390. uv: Nullable<Vector2>;
  151391. /**
  151392. * The current speed of the particle.
  151393. */
  151394. velocity: Vector3;
  151395. /**
  151396. * The pivot point in the particle local space.
  151397. */
  151398. pivot: Vector3;
  151399. /**
  151400. * Must the particle be translated from its pivot point in its local space ?
  151401. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  151402. * Default : false
  151403. */
  151404. translateFromPivot: boolean;
  151405. /**
  151406. * Index of this particle in the global "positions" array (Internal use)
  151407. * @hidden
  151408. */
  151409. _pos: number;
  151410. /**
  151411. * @hidden Index of this particle in the global "indices" array (Internal use)
  151412. */
  151413. _ind: number;
  151414. /**
  151415. * Group this particle belongs to
  151416. */
  151417. _group: PointsGroup;
  151418. /**
  151419. * Group id of this particle
  151420. */
  151421. groupId: number;
  151422. /**
  151423. * Index of the particle in its group id (Internal use)
  151424. */
  151425. idxInGroup: number;
  151426. /**
  151427. * @hidden Particle BoundingInfo object (Internal use)
  151428. */
  151429. _boundingInfo: BoundingInfo;
  151430. /**
  151431. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  151432. */
  151433. _pcs: PointsCloudSystem;
  151434. /**
  151435. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  151436. */
  151437. _stillInvisible: boolean;
  151438. /**
  151439. * @hidden Last computed particle rotation matrix
  151440. */
  151441. _rotationMatrix: number[];
  151442. /**
  151443. * Parent particle Id, if any.
  151444. * Default null.
  151445. */
  151446. parentId: Nullable<number>;
  151447. /**
  151448. * @hidden Internal global position in the PCS.
  151449. */
  151450. _globalPosition: Vector3;
  151451. /**
  151452. * Creates a Point Cloud object.
  151453. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  151454. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  151455. * @param group (PointsGroup) is the group the particle belongs to
  151456. * @param groupId (integer) is the group identifier in the PCS.
  151457. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  151458. * @param pcs defines the PCS it is associated to
  151459. */
  151460. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  151461. /**
  151462. * get point size
  151463. */
  151464. get size(): Vector3;
  151465. /**
  151466. * Set point size
  151467. */
  151468. set size(scale: Vector3);
  151469. /**
  151470. * Legacy support, changed quaternion to rotationQuaternion
  151471. */
  151472. get quaternion(): Nullable<Quaternion>;
  151473. /**
  151474. * Legacy support, changed quaternion to rotationQuaternion
  151475. */
  151476. set quaternion(q: Nullable<Quaternion>);
  151477. /**
  151478. * Returns a boolean. True if the particle intersects a mesh, else false
  151479. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  151480. * @param target is the object (point or mesh) what the intersection is computed against
  151481. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  151482. * @returns true if it intersects
  151483. */
  151484. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  151485. /**
  151486. * get the rotation matrix of the particle
  151487. * @hidden
  151488. */
  151489. getRotationMatrix(m: Matrix): void;
  151490. }
  151491. /**
  151492. * Represents a group of points in a points cloud system
  151493. * * PCS internal tool, don't use it manually.
  151494. */
  151495. export class PointsGroup {
  151496. /**
  151497. * The group id
  151498. * @hidden
  151499. */
  151500. groupID: number;
  151501. /**
  151502. * image data for group (internal use)
  151503. * @hidden
  151504. */
  151505. _groupImageData: Nullable<ArrayBufferView>;
  151506. /**
  151507. * Image Width (internal use)
  151508. * @hidden
  151509. */
  151510. _groupImgWidth: number;
  151511. /**
  151512. * Image Height (internal use)
  151513. * @hidden
  151514. */
  151515. _groupImgHeight: number;
  151516. /**
  151517. * Custom position function (internal use)
  151518. * @hidden
  151519. */
  151520. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  151521. /**
  151522. * density per facet for surface points
  151523. * @hidden
  151524. */
  151525. _groupDensity: number[];
  151526. /**
  151527. * Only when points are colored by texture carries pointer to texture list array
  151528. * @hidden
  151529. */
  151530. _textureNb: number;
  151531. /**
  151532. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  151533. * PCS internal tool, don't use it manually.
  151534. * @hidden
  151535. */
  151536. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  151537. }
  151538. }
  151539. declare module BABYLON {
  151540. interface Scene {
  151541. /** @hidden (Backing field) */
  151542. _physicsEngine: Nullable<IPhysicsEngine>;
  151543. /** @hidden */
  151544. _physicsTimeAccumulator: number;
  151545. /**
  151546. * Gets the current physics engine
  151547. * @returns a IPhysicsEngine or null if none attached
  151548. */
  151549. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  151550. /**
  151551. * Enables physics to the current scene
  151552. * @param gravity defines the scene's gravity for the physics engine
  151553. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  151554. * @return a boolean indicating if the physics engine was initialized
  151555. */
  151556. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  151557. /**
  151558. * Disables and disposes the physics engine associated with the scene
  151559. */
  151560. disablePhysicsEngine(): void;
  151561. /**
  151562. * Gets a boolean indicating if there is an active physics engine
  151563. * @returns a boolean indicating if there is an active physics engine
  151564. */
  151565. isPhysicsEnabled(): boolean;
  151566. /**
  151567. * Deletes a physics compound impostor
  151568. * @param compound defines the compound to delete
  151569. */
  151570. deleteCompoundImpostor(compound: any): void;
  151571. /**
  151572. * An event triggered when physic simulation is about to be run
  151573. */
  151574. onBeforePhysicsObservable: Observable<Scene>;
  151575. /**
  151576. * An event triggered when physic simulation has been done
  151577. */
  151578. onAfterPhysicsObservable: Observable<Scene>;
  151579. }
  151580. interface AbstractMesh {
  151581. /** @hidden */
  151582. _physicsImpostor: Nullable<PhysicsImpostor>;
  151583. /**
  151584. * Gets or sets impostor used for physic simulation
  151585. * @see https://doc.babylonjs.com/features/physics_engine
  151586. */
  151587. physicsImpostor: Nullable<PhysicsImpostor>;
  151588. /**
  151589. * Gets the current physics impostor
  151590. * @see https://doc.babylonjs.com/features/physics_engine
  151591. * @returns a physics impostor or null
  151592. */
  151593. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  151594. /** Apply a physic impulse to the mesh
  151595. * @param force defines the force to apply
  151596. * @param contactPoint defines where to apply the force
  151597. * @returns the current mesh
  151598. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  151599. */
  151600. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  151601. /**
  151602. * Creates a physic joint between two meshes
  151603. * @param otherMesh defines the other mesh to use
  151604. * @param pivot1 defines the pivot to use on this mesh
  151605. * @param pivot2 defines the pivot to use on the other mesh
  151606. * @param options defines additional options (can be plugin dependent)
  151607. * @returns the current mesh
  151608. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  151609. */
  151610. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  151611. /** @hidden */
  151612. _disposePhysicsObserver: Nullable<Observer<Node>>;
  151613. }
  151614. /**
  151615. * Defines the physics engine scene component responsible to manage a physics engine
  151616. */
  151617. export class PhysicsEngineSceneComponent implements ISceneComponent {
  151618. /**
  151619. * The component name helpful to identify the component in the list of scene components.
  151620. */
  151621. readonly name: string;
  151622. /**
  151623. * The scene the component belongs to.
  151624. */
  151625. scene: Scene;
  151626. /**
  151627. * Creates a new instance of the component for the given scene
  151628. * @param scene Defines the scene to register the component in
  151629. */
  151630. constructor(scene: Scene);
  151631. /**
  151632. * Registers the component in a given scene
  151633. */
  151634. register(): void;
  151635. /**
  151636. * Rebuilds the elements related to this component in case of
  151637. * context lost for instance.
  151638. */
  151639. rebuild(): void;
  151640. /**
  151641. * Disposes the component and the associated ressources
  151642. */
  151643. dispose(): void;
  151644. }
  151645. }
  151646. declare module BABYLON {
  151647. /**
  151648. * A helper for physics simulations
  151649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151650. */
  151651. export class PhysicsHelper {
  151652. private _scene;
  151653. private _physicsEngine;
  151654. /**
  151655. * Initializes the Physics helper
  151656. * @param scene Babylon.js scene
  151657. */
  151658. constructor(scene: Scene);
  151659. /**
  151660. * Applies a radial explosion impulse
  151661. * @param origin the origin of the explosion
  151662. * @param radiusOrEventOptions the radius or the options of radial explosion
  151663. * @param strength the explosion strength
  151664. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151665. * @returns A physics radial explosion event, or null
  151666. */
  151667. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151668. /**
  151669. * Applies a radial explosion force
  151670. * @param origin the origin of the explosion
  151671. * @param radiusOrEventOptions the radius or the options of radial explosion
  151672. * @param strength the explosion strength
  151673. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151674. * @returns A physics radial explosion event, or null
  151675. */
  151676. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  151677. /**
  151678. * Creates a gravitational field
  151679. * @param origin the origin of the explosion
  151680. * @param radiusOrEventOptions the radius or the options of radial explosion
  151681. * @param strength the explosion strength
  151682. * @param falloff possible options: Constant & Linear. Defaults to Constant
  151683. * @returns A physics gravitational field event, or null
  151684. */
  151685. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  151686. /**
  151687. * Creates a physics updraft event
  151688. * @param origin the origin of the updraft
  151689. * @param radiusOrEventOptions the radius or the options of the updraft
  151690. * @param strength the strength of the updraft
  151691. * @param height the height of the updraft
  151692. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  151693. * @returns A physics updraft event, or null
  151694. */
  151695. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  151696. /**
  151697. * Creates a physics vortex event
  151698. * @param origin the of the vortex
  151699. * @param radiusOrEventOptions the radius or the options of the vortex
  151700. * @param strength the strength of the vortex
  151701. * @param height the height of the vortex
  151702. * @returns a Physics vortex event, or null
  151703. * A physics vortex event or null
  151704. */
  151705. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  151706. }
  151707. /**
  151708. * Represents a physics radial explosion event
  151709. */
  151710. class PhysicsRadialExplosionEvent {
  151711. private _scene;
  151712. private _options;
  151713. private _sphere;
  151714. private _dataFetched;
  151715. /**
  151716. * Initializes a radial explosioin event
  151717. * @param _scene BabylonJS scene
  151718. * @param _options The options for the vortex event
  151719. */
  151720. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  151721. /**
  151722. * Returns the data related to the radial explosion event (sphere).
  151723. * @returns The radial explosion event data
  151724. */
  151725. getData(): PhysicsRadialExplosionEventData;
  151726. /**
  151727. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  151728. * @param impostor A physics imposter
  151729. * @param origin the origin of the explosion
  151730. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  151731. */
  151732. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  151733. /**
  151734. * Triggers affecterd impostors callbacks
  151735. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  151736. */
  151737. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  151738. /**
  151739. * Disposes the sphere.
  151740. * @param force Specifies if the sphere should be disposed by force
  151741. */
  151742. dispose(force?: boolean): void;
  151743. /*** Helpers ***/
  151744. private _prepareSphere;
  151745. private _intersectsWithSphere;
  151746. }
  151747. /**
  151748. * Represents a gravitational field event
  151749. */
  151750. class PhysicsGravitationalFieldEvent {
  151751. private _physicsHelper;
  151752. private _scene;
  151753. private _origin;
  151754. private _options;
  151755. private _tickCallback;
  151756. private _sphere;
  151757. private _dataFetched;
  151758. /**
  151759. * Initializes the physics gravitational field event
  151760. * @param _physicsHelper A physics helper
  151761. * @param _scene BabylonJS scene
  151762. * @param _origin The origin position of the gravitational field event
  151763. * @param _options The options for the vortex event
  151764. */
  151765. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  151766. /**
  151767. * Returns the data related to the gravitational field event (sphere).
  151768. * @returns A gravitational field event
  151769. */
  151770. getData(): PhysicsGravitationalFieldEventData;
  151771. /**
  151772. * Enables the gravitational field.
  151773. */
  151774. enable(): void;
  151775. /**
  151776. * Disables the gravitational field.
  151777. */
  151778. disable(): void;
  151779. /**
  151780. * Disposes the sphere.
  151781. * @param force The force to dispose from the gravitational field event
  151782. */
  151783. dispose(force?: boolean): void;
  151784. private _tick;
  151785. }
  151786. /**
  151787. * Represents a physics updraft event
  151788. */
  151789. class PhysicsUpdraftEvent {
  151790. private _scene;
  151791. private _origin;
  151792. private _options;
  151793. private _physicsEngine;
  151794. private _originTop;
  151795. private _originDirection;
  151796. private _tickCallback;
  151797. private _cylinder;
  151798. private _cylinderPosition;
  151799. private _dataFetched;
  151800. /**
  151801. * Initializes the physics updraft event
  151802. * @param _scene BabylonJS scene
  151803. * @param _origin The origin position of the updraft
  151804. * @param _options The options for the updraft event
  151805. */
  151806. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  151807. /**
  151808. * Returns the data related to the updraft event (cylinder).
  151809. * @returns A physics updraft event
  151810. */
  151811. getData(): PhysicsUpdraftEventData;
  151812. /**
  151813. * Enables the updraft.
  151814. */
  151815. enable(): void;
  151816. /**
  151817. * Disables the updraft.
  151818. */
  151819. disable(): void;
  151820. /**
  151821. * Disposes the cylinder.
  151822. * @param force Specifies if the updraft should be disposed by force
  151823. */
  151824. dispose(force?: boolean): void;
  151825. private getImpostorHitData;
  151826. private _tick;
  151827. /*** Helpers ***/
  151828. private _prepareCylinder;
  151829. private _intersectsWithCylinder;
  151830. }
  151831. /**
  151832. * Represents a physics vortex event
  151833. */
  151834. class PhysicsVortexEvent {
  151835. private _scene;
  151836. private _origin;
  151837. private _options;
  151838. private _physicsEngine;
  151839. private _originTop;
  151840. private _tickCallback;
  151841. private _cylinder;
  151842. private _cylinderPosition;
  151843. private _dataFetched;
  151844. /**
  151845. * Initializes the physics vortex event
  151846. * @param _scene The BabylonJS scene
  151847. * @param _origin The origin position of the vortex
  151848. * @param _options The options for the vortex event
  151849. */
  151850. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  151851. /**
  151852. * Returns the data related to the vortex event (cylinder).
  151853. * @returns The physics vortex event data
  151854. */
  151855. getData(): PhysicsVortexEventData;
  151856. /**
  151857. * Enables the vortex.
  151858. */
  151859. enable(): void;
  151860. /**
  151861. * Disables the cortex.
  151862. */
  151863. disable(): void;
  151864. /**
  151865. * Disposes the sphere.
  151866. * @param force
  151867. */
  151868. dispose(force?: boolean): void;
  151869. private getImpostorHitData;
  151870. private _tick;
  151871. /*** Helpers ***/
  151872. private _prepareCylinder;
  151873. private _intersectsWithCylinder;
  151874. }
  151875. /**
  151876. * Options fot the radial explosion event
  151877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151878. */
  151879. export class PhysicsRadialExplosionEventOptions {
  151880. /**
  151881. * The radius of the sphere for the radial explosion.
  151882. */
  151883. radius: number;
  151884. /**
  151885. * The strenth of the explosion.
  151886. */
  151887. strength: number;
  151888. /**
  151889. * The strenght of the force in correspondence to the distance of the affected object
  151890. */
  151891. falloff: PhysicsRadialImpulseFalloff;
  151892. /**
  151893. * Sphere options for the radial explosion.
  151894. */
  151895. sphere: {
  151896. segments: number;
  151897. diameter: number;
  151898. };
  151899. /**
  151900. * Sphere options for the radial explosion.
  151901. */
  151902. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151903. }
  151904. /**
  151905. * Options fot the updraft event
  151906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151907. */
  151908. export class PhysicsUpdraftEventOptions {
  151909. /**
  151910. * The radius of the cylinder for the vortex
  151911. */
  151912. radius: number;
  151913. /**
  151914. * The strenth of the updraft.
  151915. */
  151916. strength: number;
  151917. /**
  151918. * The height of the cylinder for the updraft.
  151919. */
  151920. height: number;
  151921. /**
  151922. * The mode for the the updraft.
  151923. */
  151924. updraftMode: PhysicsUpdraftMode;
  151925. }
  151926. /**
  151927. * Options fot the vortex event
  151928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151929. */
  151930. export class PhysicsVortexEventOptions {
  151931. /**
  151932. * The radius of the cylinder for the vortex
  151933. */
  151934. radius: number;
  151935. /**
  151936. * The strenth of the vortex.
  151937. */
  151938. strength: number;
  151939. /**
  151940. * The height of the cylinder for the vortex.
  151941. */
  151942. height: number;
  151943. /**
  151944. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151945. */
  151946. centripetalForceThreshold: number;
  151947. /**
  151948. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151949. */
  151950. centripetalForceMultiplier: number;
  151951. /**
  151952. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151953. */
  151954. centrifugalForceMultiplier: number;
  151955. /**
  151956. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151957. */
  151958. updraftForceMultiplier: number;
  151959. }
  151960. /**
  151961. * The strenght of the force in correspondence to the distance of the affected object
  151962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151963. */
  151964. export enum PhysicsRadialImpulseFalloff {
  151965. /** Defines that impulse is constant in strength across it's whole radius */
  151966. Constant = 0,
  151967. /** Defines that impulse gets weaker if it's further from the origin */
  151968. Linear = 1
  151969. }
  151970. /**
  151971. * The strength of the force in correspondence to the distance of the affected object
  151972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151973. */
  151974. export enum PhysicsUpdraftMode {
  151975. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151976. Center = 0,
  151977. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151978. Perpendicular = 1
  151979. }
  151980. /**
  151981. * Interface for a physics hit data
  151982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151983. */
  151984. export interface PhysicsHitData {
  151985. /**
  151986. * The force applied at the contact point
  151987. */
  151988. force: Vector3;
  151989. /**
  151990. * The contact point
  151991. */
  151992. contactPoint: Vector3;
  151993. /**
  151994. * The distance from the origin to the contact point
  151995. */
  151996. distanceFromOrigin: number;
  151997. }
  151998. /**
  151999. * Interface for radial explosion event data
  152000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152001. */
  152002. export interface PhysicsRadialExplosionEventData {
  152003. /**
  152004. * A sphere used for the radial explosion event
  152005. */
  152006. sphere: Mesh;
  152007. }
  152008. /**
  152009. * Interface for gravitational field event data
  152010. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152011. */
  152012. export interface PhysicsGravitationalFieldEventData {
  152013. /**
  152014. * A sphere mesh used for the gravitational field event
  152015. */
  152016. sphere: Mesh;
  152017. }
  152018. /**
  152019. * Interface for updraft event data
  152020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152021. */
  152022. export interface PhysicsUpdraftEventData {
  152023. /**
  152024. * A cylinder used for the updraft event
  152025. */
  152026. cylinder: Mesh;
  152027. }
  152028. /**
  152029. * Interface for vortex event data
  152030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152031. */
  152032. export interface PhysicsVortexEventData {
  152033. /**
  152034. * A cylinder used for the vortex event
  152035. */
  152036. cylinder: Mesh;
  152037. }
  152038. /**
  152039. * Interface for an affected physics impostor
  152040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  152041. */
  152042. export interface PhysicsAffectedImpostorWithData {
  152043. /**
  152044. * The impostor affected by the effect
  152045. */
  152046. impostor: PhysicsImpostor;
  152047. /**
  152048. * The data about the hit/horce from the explosion
  152049. */
  152050. hitData: PhysicsHitData;
  152051. }
  152052. }
  152053. declare module BABYLON {
  152054. /** @hidden */
  152055. export var blackAndWhitePixelShader: {
  152056. name: string;
  152057. shader: string;
  152058. };
  152059. }
  152060. declare module BABYLON {
  152061. /**
  152062. * Post process used to render in black and white
  152063. */
  152064. export class BlackAndWhitePostProcess extends PostProcess {
  152065. /**
  152066. * Linear about to convert he result to black and white (default: 1)
  152067. */
  152068. degree: number;
  152069. /**
  152070. * Gets a string identifying the name of the class
  152071. * @returns "BlackAndWhitePostProcess" string
  152072. */
  152073. getClassName(): string;
  152074. /**
  152075. * Creates a black and white post process
  152076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  152077. * @param name The name of the effect.
  152078. * @param options The required width/height ratio to downsize to before computing the render pass.
  152079. * @param camera The camera to apply the render pass to.
  152080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152081. * @param engine The engine which the post process will be applied. (default: current engine)
  152082. * @param reusable If the post process can be reused on the same frame. (default: false)
  152083. */
  152084. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152085. /** @hidden */
  152086. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  152087. }
  152088. }
  152089. declare module BABYLON {
  152090. /**
  152091. * This represents a set of one or more post processes in Babylon.
  152092. * A post process can be used to apply a shader to a texture after it is rendered.
  152093. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152094. */
  152095. export class PostProcessRenderEffect {
  152096. private _postProcesses;
  152097. private _getPostProcesses;
  152098. private _singleInstance;
  152099. private _cameras;
  152100. private _indicesForCamera;
  152101. /**
  152102. * Name of the effect
  152103. * @hidden
  152104. */
  152105. _name: string;
  152106. /**
  152107. * Instantiates a post process render effect.
  152108. * A post process can be used to apply a shader to a texture after it is rendered.
  152109. * @param engine The engine the effect is tied to
  152110. * @param name The name of the effect
  152111. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  152112. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  152113. */
  152114. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  152115. /**
  152116. * Checks if all the post processes in the effect are supported.
  152117. */
  152118. get isSupported(): boolean;
  152119. /**
  152120. * Updates the current state of the effect
  152121. * @hidden
  152122. */
  152123. _update(): void;
  152124. /**
  152125. * Attaches the effect on cameras
  152126. * @param cameras The camera to attach to.
  152127. * @hidden
  152128. */
  152129. _attachCameras(cameras: Camera): void;
  152130. /**
  152131. * Attaches the effect on cameras
  152132. * @param cameras The camera to attach to.
  152133. * @hidden
  152134. */
  152135. _attachCameras(cameras: Camera[]): void;
  152136. /**
  152137. * Detaches the effect on cameras
  152138. * @param cameras The camera to detatch from.
  152139. * @hidden
  152140. */
  152141. _detachCameras(cameras: Camera): void;
  152142. /**
  152143. * Detatches the effect on cameras
  152144. * @param cameras The camera to detatch from.
  152145. * @hidden
  152146. */
  152147. _detachCameras(cameras: Camera[]): void;
  152148. /**
  152149. * Enables the effect on given cameras
  152150. * @param cameras The camera to enable.
  152151. * @hidden
  152152. */
  152153. _enable(cameras: Camera): void;
  152154. /**
  152155. * Enables the effect on given cameras
  152156. * @param cameras The camera to enable.
  152157. * @hidden
  152158. */
  152159. _enable(cameras: Nullable<Camera[]>): void;
  152160. /**
  152161. * Disables the effect on the given cameras
  152162. * @param cameras The camera to disable.
  152163. * @hidden
  152164. */
  152165. _disable(cameras: Camera): void;
  152166. /**
  152167. * Disables the effect on the given cameras
  152168. * @param cameras The camera to disable.
  152169. * @hidden
  152170. */
  152171. _disable(cameras: Nullable<Camera[]>): void;
  152172. /**
  152173. * Gets a list of the post processes contained in the effect.
  152174. * @param camera The camera to get the post processes on.
  152175. * @returns The list of the post processes in the effect.
  152176. */
  152177. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  152178. }
  152179. }
  152180. declare module BABYLON {
  152181. /** @hidden */
  152182. export var extractHighlightsPixelShader: {
  152183. name: string;
  152184. shader: string;
  152185. };
  152186. }
  152187. declare module BABYLON {
  152188. /**
  152189. * 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.
  152190. */
  152191. export class ExtractHighlightsPostProcess extends PostProcess {
  152192. /**
  152193. * The luminance threshold, pixels below this value will be set to black.
  152194. */
  152195. threshold: number;
  152196. /** @hidden */
  152197. _exposure: number;
  152198. /**
  152199. * Post process which has the input texture to be used when performing highlight extraction
  152200. * @hidden
  152201. */
  152202. _inputPostProcess: Nullable<PostProcess>;
  152203. /**
  152204. * Gets a string identifying the name of the class
  152205. * @returns "ExtractHighlightsPostProcess" string
  152206. */
  152207. getClassName(): string;
  152208. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152209. }
  152210. }
  152211. declare module BABYLON {
  152212. /** @hidden */
  152213. export var bloomMergePixelShader: {
  152214. name: string;
  152215. shader: string;
  152216. };
  152217. }
  152218. declare module BABYLON {
  152219. /**
  152220. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152221. */
  152222. export class BloomMergePostProcess extends PostProcess {
  152223. /** Weight of the bloom to be added to the original input. */
  152224. weight: number;
  152225. /**
  152226. * Gets a string identifying the name of the class
  152227. * @returns "BloomMergePostProcess" string
  152228. */
  152229. getClassName(): string;
  152230. /**
  152231. * Creates a new instance of @see BloomMergePostProcess
  152232. * @param name The name of the effect.
  152233. * @param originalFromInput Post process which's input will be used for the merge.
  152234. * @param blurred Blurred highlights post process which's output will be used.
  152235. * @param weight Weight of the bloom to be added to the original input.
  152236. * @param options The required width/height ratio to downsize to before computing the render pass.
  152237. * @param camera The camera to apply the render pass to.
  152238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152239. * @param engine The engine which the post process will be applied. (default: current engine)
  152240. * @param reusable If the post process can be reused on the same frame. (default: false)
  152241. * @param textureType Type of textures used when performing the post process. (default: 0)
  152242. * @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)
  152243. */
  152244. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  152245. /** Weight of the bloom to be added to the original input. */
  152246. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152247. }
  152248. }
  152249. declare module BABYLON {
  152250. /**
  152251. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  152252. */
  152253. export class BloomEffect extends PostProcessRenderEffect {
  152254. private bloomScale;
  152255. /**
  152256. * @hidden Internal
  152257. */
  152258. _effects: Array<PostProcess>;
  152259. /**
  152260. * @hidden Internal
  152261. */
  152262. _downscale: ExtractHighlightsPostProcess;
  152263. private _blurX;
  152264. private _blurY;
  152265. private _merge;
  152266. /**
  152267. * The luminance threshold to find bright areas of the image to bloom.
  152268. */
  152269. get threshold(): number;
  152270. set threshold(value: number);
  152271. /**
  152272. * The strength of the bloom.
  152273. */
  152274. get weight(): number;
  152275. set weight(value: number);
  152276. /**
  152277. * Specifies the size of the bloom blur kernel, relative to the final output size
  152278. */
  152279. get kernel(): number;
  152280. set kernel(value: number);
  152281. /**
  152282. * Creates a new instance of @see BloomEffect
  152283. * @param scene The scene the effect belongs to.
  152284. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  152285. * @param bloomKernel The size of the kernel to be used when applying the blur.
  152286. * @param bloomWeight The the strength of bloom.
  152287. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152288. * @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)
  152289. */
  152290. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  152291. /**
  152292. * Disposes each of the internal effects for a given camera.
  152293. * @param camera The camera to dispose the effect on.
  152294. */
  152295. disposeEffects(camera: Camera): void;
  152296. /**
  152297. * @hidden Internal
  152298. */
  152299. _updateEffects(): void;
  152300. /**
  152301. * Internal
  152302. * @returns if all the contained post processes are ready.
  152303. * @hidden
  152304. */
  152305. _isReady(): boolean;
  152306. }
  152307. }
  152308. declare module BABYLON {
  152309. /** @hidden */
  152310. export var chromaticAberrationPixelShader: {
  152311. name: string;
  152312. shader: string;
  152313. };
  152314. }
  152315. declare module BABYLON {
  152316. /**
  152317. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  152318. */
  152319. export class ChromaticAberrationPostProcess extends PostProcess {
  152320. /**
  152321. * The amount of seperation of rgb channels (default: 30)
  152322. */
  152323. aberrationAmount: number;
  152324. /**
  152325. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  152326. */
  152327. radialIntensity: number;
  152328. /**
  152329. * 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))
  152330. */
  152331. direction: Vector2;
  152332. /**
  152333. * 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))
  152334. */
  152335. centerPosition: Vector2;
  152336. /** The width of the screen to apply the effect on */
  152337. screenWidth: number;
  152338. /** The height of the screen to apply the effect on */
  152339. screenHeight: number;
  152340. /**
  152341. * Gets a string identifying the name of the class
  152342. * @returns "ChromaticAberrationPostProcess" string
  152343. */
  152344. getClassName(): string;
  152345. /**
  152346. * Creates a new instance ChromaticAberrationPostProcess
  152347. * @param name The name of the effect.
  152348. * @param screenWidth The width of the screen to apply the effect on.
  152349. * @param screenHeight The height of the screen to apply the effect on.
  152350. * @param options The required width/height ratio to downsize to before computing the render pass.
  152351. * @param camera The camera to apply the render pass to.
  152352. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152353. * @param engine The engine which the post process will be applied. (default: current engine)
  152354. * @param reusable If the post process can be reused on the same frame. (default: false)
  152355. * @param textureType Type of textures used when performing the post process. (default: 0)
  152356. * @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)
  152357. */
  152358. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152359. /** @hidden */
  152360. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  152361. }
  152362. }
  152363. declare module BABYLON {
  152364. /** @hidden */
  152365. export var circleOfConfusionPixelShader: {
  152366. name: string;
  152367. shader: string;
  152368. };
  152369. }
  152370. declare module BABYLON {
  152371. /**
  152372. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  152373. */
  152374. export class CircleOfConfusionPostProcess extends PostProcess {
  152375. /**
  152376. * 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.
  152377. */
  152378. lensSize: number;
  152379. /**
  152380. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152381. */
  152382. fStop: number;
  152383. /**
  152384. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152385. */
  152386. focusDistance: number;
  152387. /**
  152388. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  152389. */
  152390. focalLength: number;
  152391. /**
  152392. * Gets a string identifying the name of the class
  152393. * @returns "CircleOfConfusionPostProcess" string
  152394. */
  152395. getClassName(): string;
  152396. private _depthTexture;
  152397. /**
  152398. * Creates a new instance CircleOfConfusionPostProcess
  152399. * @param name The name of the effect.
  152400. * @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.
  152401. * @param options The required width/height ratio to downsize to before computing the render pass.
  152402. * @param camera The camera to apply the render pass to.
  152403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152404. * @param engine The engine which the post process will be applied. (default: current engine)
  152405. * @param reusable If the post process can be reused on the same frame. (default: false)
  152406. * @param textureType Type of textures used when performing the post process. (default: 0)
  152407. * @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)
  152408. */
  152409. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152410. /**
  152411. * 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.
  152412. */
  152413. set depthTexture(value: RenderTargetTexture);
  152414. }
  152415. }
  152416. declare module BABYLON {
  152417. /** @hidden */
  152418. export var colorCorrectionPixelShader: {
  152419. name: string;
  152420. shader: string;
  152421. };
  152422. }
  152423. declare module BABYLON {
  152424. /**
  152425. *
  152426. * This post-process allows the modification of rendered colors by using
  152427. * a 'look-up table' (LUT). This effect is also called Color Grading.
  152428. *
  152429. * The object needs to be provided an url to a texture containing the color
  152430. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  152431. * Use an image editing software to tweak the LUT to match your needs.
  152432. *
  152433. * For an example of a color LUT, see here:
  152434. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  152435. * For explanations on color grading, see here:
  152436. * @see http://udn.epicgames.com/Three/ColorGrading.html
  152437. *
  152438. */
  152439. export class ColorCorrectionPostProcess extends PostProcess {
  152440. private _colorTableTexture;
  152441. /**
  152442. * Gets the color table url used to create the LUT texture
  152443. */
  152444. colorTableUrl: string;
  152445. /**
  152446. * Gets a string identifying the name of the class
  152447. * @returns "ColorCorrectionPostProcess" string
  152448. */
  152449. getClassName(): string;
  152450. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152451. /** @hidden */
  152452. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  152453. }
  152454. }
  152455. declare module BABYLON {
  152456. /** @hidden */
  152457. export var convolutionPixelShader: {
  152458. name: string;
  152459. shader: string;
  152460. };
  152461. }
  152462. declare module BABYLON {
  152463. /**
  152464. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  152465. * input texture to perform effects such as edge detection or sharpening
  152466. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152467. */
  152468. export class ConvolutionPostProcess extends PostProcess {
  152469. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  152470. kernel: number[];
  152471. /**
  152472. * Gets a string identifying the name of the class
  152473. * @returns "ConvolutionPostProcess" string
  152474. */
  152475. getClassName(): string;
  152476. /**
  152477. * Creates a new instance ConvolutionPostProcess
  152478. * @param name The name of the effect.
  152479. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  152480. * @param options The required width/height ratio to downsize to before computing the render pass.
  152481. * @param camera The camera to apply the render pass to.
  152482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152483. * @param engine The engine which the post process will be applied. (default: current engine)
  152484. * @param reusable If the post process can be reused on the same frame. (default: false)
  152485. * @param textureType Type of textures used when performing the post process. (default: 0)
  152486. */
  152487. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152488. /** @hidden */
  152489. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  152490. /**
  152491. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152492. */
  152493. static EdgeDetect0Kernel: number[];
  152494. /**
  152495. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152496. */
  152497. static EdgeDetect1Kernel: number[];
  152498. /**
  152499. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152500. */
  152501. static EdgeDetect2Kernel: number[];
  152502. /**
  152503. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152504. */
  152505. static SharpenKernel: number[];
  152506. /**
  152507. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152508. */
  152509. static EmbossKernel: number[];
  152510. /**
  152511. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  152512. */
  152513. static GaussianKernel: number[];
  152514. }
  152515. }
  152516. declare module BABYLON {
  152517. /**
  152518. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  152519. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  152520. * based on samples that have a large difference in distance than the center pixel.
  152521. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  152522. */
  152523. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  152524. /**
  152525. * The direction the blur should be applied
  152526. */
  152527. direction: Vector2;
  152528. /**
  152529. * Gets a string identifying the name of the class
  152530. * @returns "DepthOfFieldBlurPostProcess" string
  152531. */
  152532. getClassName(): string;
  152533. /**
  152534. * Creates a new instance CircleOfConfusionPostProcess
  152535. * @param name The name of the effect.
  152536. * @param scene The scene the effect belongs to.
  152537. * @param direction The direction the blur should be applied.
  152538. * @param kernel The size of the kernel used to blur.
  152539. * @param options The required width/height ratio to downsize to before computing the render pass.
  152540. * @param camera The camera to apply the render pass to.
  152541. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  152542. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  152543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152544. * @param engine The engine which the post process will be applied. (default: current engine)
  152545. * @param reusable If the post process can be reused on the same frame. (default: false)
  152546. * @param textureType Type of textures used when performing the post process. (default: 0)
  152547. * @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)
  152548. */
  152549. 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);
  152550. }
  152551. }
  152552. declare module BABYLON {
  152553. /** @hidden */
  152554. export var depthOfFieldMergePixelShader: {
  152555. name: string;
  152556. shader: string;
  152557. };
  152558. }
  152559. declare module BABYLON {
  152560. /**
  152561. * Options to be set when merging outputs from the default pipeline.
  152562. */
  152563. export class DepthOfFieldMergePostProcessOptions {
  152564. /**
  152565. * The original image to merge on top of
  152566. */
  152567. originalFromInput: PostProcess;
  152568. /**
  152569. * Parameters to perform the merge of the depth of field effect
  152570. */
  152571. depthOfField?: {
  152572. circleOfConfusion: PostProcess;
  152573. blurSteps: Array<PostProcess>;
  152574. };
  152575. /**
  152576. * Parameters to perform the merge of bloom effect
  152577. */
  152578. bloom?: {
  152579. blurred: PostProcess;
  152580. weight: number;
  152581. };
  152582. }
  152583. /**
  152584. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  152585. */
  152586. export class DepthOfFieldMergePostProcess extends PostProcess {
  152587. private blurSteps;
  152588. /**
  152589. * Gets a string identifying the name of the class
  152590. * @returns "DepthOfFieldMergePostProcess" string
  152591. */
  152592. getClassName(): string;
  152593. /**
  152594. * Creates a new instance of DepthOfFieldMergePostProcess
  152595. * @param name The name of the effect.
  152596. * @param originalFromInput Post process which's input will be used for the merge.
  152597. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  152598. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  152599. * @param options The required width/height ratio to downsize to before computing the render pass.
  152600. * @param camera The camera to apply the render pass to.
  152601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152602. * @param engine The engine which the post process will be applied. (default: current engine)
  152603. * @param reusable If the post process can be reused on the same frame. (default: false)
  152604. * @param textureType Type of textures used when performing the post process. (default: 0)
  152605. * @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)
  152606. */
  152607. 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);
  152608. /**
  152609. * Updates the effect with the current post process compile time values and recompiles the shader.
  152610. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  152611. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  152612. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  152613. * @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
  152614. * @param onCompiled Called when the shader has been compiled.
  152615. * @param onError Called if there is an error when compiling a shader.
  152616. */
  152617. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  152618. }
  152619. }
  152620. declare module BABYLON {
  152621. /**
  152622. * Specifies the level of max blur that should be applied when using the depth of field effect
  152623. */
  152624. export enum DepthOfFieldEffectBlurLevel {
  152625. /**
  152626. * Subtle blur
  152627. */
  152628. Low = 0,
  152629. /**
  152630. * Medium blur
  152631. */
  152632. Medium = 1,
  152633. /**
  152634. * Large blur
  152635. */
  152636. High = 2
  152637. }
  152638. /**
  152639. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  152640. */
  152641. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  152642. private _circleOfConfusion;
  152643. /**
  152644. * @hidden Internal, blurs from high to low
  152645. */
  152646. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  152647. private _depthOfFieldBlurY;
  152648. private _dofMerge;
  152649. /**
  152650. * @hidden Internal post processes in depth of field effect
  152651. */
  152652. _effects: Array<PostProcess>;
  152653. /**
  152654. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  152655. */
  152656. set focalLength(value: number);
  152657. get focalLength(): number;
  152658. /**
  152659. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  152660. */
  152661. set fStop(value: number);
  152662. get fStop(): number;
  152663. /**
  152664. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  152665. */
  152666. set focusDistance(value: number);
  152667. get focusDistance(): number;
  152668. /**
  152669. * 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.
  152670. */
  152671. set lensSize(value: number);
  152672. get lensSize(): number;
  152673. /**
  152674. * Creates a new instance DepthOfFieldEffect
  152675. * @param scene The scene the effect belongs to.
  152676. * @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.
  152677. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  152678. * @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)
  152679. */
  152680. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  152681. /**
  152682. * Get the current class name of the current effet
  152683. * @returns "DepthOfFieldEffect"
  152684. */
  152685. getClassName(): string;
  152686. /**
  152687. * 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.
  152688. */
  152689. set depthTexture(value: RenderTargetTexture);
  152690. /**
  152691. * Disposes each of the internal effects for a given camera.
  152692. * @param camera The camera to dispose the effect on.
  152693. */
  152694. disposeEffects(camera: Camera): void;
  152695. /**
  152696. * @hidden Internal
  152697. */
  152698. _updateEffects(): void;
  152699. /**
  152700. * Internal
  152701. * @returns if all the contained post processes are ready.
  152702. * @hidden
  152703. */
  152704. _isReady(): boolean;
  152705. }
  152706. }
  152707. declare module BABYLON {
  152708. /** @hidden */
  152709. export var displayPassPixelShader: {
  152710. name: string;
  152711. shader: string;
  152712. };
  152713. }
  152714. declare module BABYLON {
  152715. /**
  152716. * DisplayPassPostProcess which produces an output the same as it's input
  152717. */
  152718. export class DisplayPassPostProcess extends PostProcess {
  152719. /**
  152720. * Gets a string identifying the name of the class
  152721. * @returns "DisplayPassPostProcess" string
  152722. */
  152723. getClassName(): string;
  152724. /**
  152725. * Creates the DisplayPassPostProcess
  152726. * @param name The name of the effect.
  152727. * @param options The required width/height ratio to downsize to before computing the render pass.
  152728. * @param camera The camera to apply the render pass to.
  152729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152730. * @param engine The engine which the post process will be applied. (default: current engine)
  152731. * @param reusable If the post process can be reused on the same frame. (default: false)
  152732. */
  152733. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152734. /** @hidden */
  152735. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  152736. }
  152737. }
  152738. declare module BABYLON {
  152739. /** @hidden */
  152740. export var filterPixelShader: {
  152741. name: string;
  152742. shader: string;
  152743. };
  152744. }
  152745. declare module BABYLON {
  152746. /**
  152747. * Applies a kernel filter to the image
  152748. */
  152749. export class FilterPostProcess extends PostProcess {
  152750. /** The matrix to be applied to the image */
  152751. kernelMatrix: Matrix;
  152752. /**
  152753. * Gets a string identifying the name of the class
  152754. * @returns "FilterPostProcess" string
  152755. */
  152756. getClassName(): string;
  152757. /**
  152758. *
  152759. * @param name The name of the effect.
  152760. * @param kernelMatrix The matrix to be applied to the image
  152761. * @param options The required width/height ratio to downsize to before computing the render pass.
  152762. * @param camera The camera to apply the render pass to.
  152763. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152764. * @param engine The engine which the post process will be applied. (default: current engine)
  152765. * @param reusable If the post process can be reused on the same frame. (default: false)
  152766. */
  152767. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152768. /** @hidden */
  152769. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  152770. }
  152771. }
  152772. declare module BABYLON {
  152773. /** @hidden */
  152774. export var fxaaPixelShader: {
  152775. name: string;
  152776. shader: string;
  152777. };
  152778. }
  152779. declare module BABYLON {
  152780. /** @hidden */
  152781. export var fxaaVertexShader: {
  152782. name: string;
  152783. shader: string;
  152784. };
  152785. }
  152786. declare module BABYLON {
  152787. /**
  152788. * Fxaa post process
  152789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  152790. */
  152791. export class FxaaPostProcess extends PostProcess {
  152792. /**
  152793. * Gets a string identifying the name of the class
  152794. * @returns "FxaaPostProcess" string
  152795. */
  152796. getClassName(): string;
  152797. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152798. private _getDefines;
  152799. /** @hidden */
  152800. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  152801. }
  152802. }
  152803. declare module BABYLON {
  152804. /** @hidden */
  152805. export var grainPixelShader: {
  152806. name: string;
  152807. shader: string;
  152808. };
  152809. }
  152810. declare module BABYLON {
  152811. /**
  152812. * The GrainPostProcess adds noise to the image at mid luminance levels
  152813. */
  152814. export class GrainPostProcess extends PostProcess {
  152815. /**
  152816. * The intensity of the grain added (default: 30)
  152817. */
  152818. intensity: number;
  152819. /**
  152820. * If the grain should be randomized on every frame
  152821. */
  152822. animated: boolean;
  152823. /**
  152824. * Gets a string identifying the name of the class
  152825. * @returns "GrainPostProcess" string
  152826. */
  152827. getClassName(): string;
  152828. /**
  152829. * Creates a new instance of @see GrainPostProcess
  152830. * @param name The name of the effect.
  152831. * @param options The required width/height ratio to downsize to before computing the render pass.
  152832. * @param camera The camera to apply the render pass to.
  152833. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152834. * @param engine The engine which the post process will be applied. (default: current engine)
  152835. * @param reusable If the post process can be reused on the same frame. (default: false)
  152836. * @param textureType Type of textures used when performing the post process. (default: 0)
  152837. * @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)
  152838. */
  152839. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152840. /** @hidden */
  152841. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  152842. }
  152843. }
  152844. declare module BABYLON {
  152845. /** @hidden */
  152846. export var highlightsPixelShader: {
  152847. name: string;
  152848. shader: string;
  152849. };
  152850. }
  152851. declare module BABYLON {
  152852. /**
  152853. * Extracts highlights from the image
  152854. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152855. */
  152856. export class HighlightsPostProcess extends PostProcess {
  152857. /**
  152858. * Gets a string identifying the name of the class
  152859. * @returns "HighlightsPostProcess" string
  152860. */
  152861. getClassName(): string;
  152862. /**
  152863. * Extracts highlights from the image
  152864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  152865. * @param name The name of the effect.
  152866. * @param options The required width/height ratio to downsize to before computing the render pass.
  152867. * @param camera The camera to apply the render pass to.
  152868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152869. * @param engine The engine which the post process will be applied. (default: current engine)
  152870. * @param reusable If the post process can be reused on the same frame. (default: false)
  152871. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  152872. */
  152873. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152874. }
  152875. }
  152876. declare module BABYLON {
  152877. /**
  152878. * Contains all parameters needed for the prepass to perform
  152879. * motion blur
  152880. */
  152881. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  152882. /**
  152883. * Is motion blur enabled
  152884. */
  152885. enabled: boolean;
  152886. /**
  152887. * Name of the configuration
  152888. */
  152889. name: string;
  152890. /**
  152891. * Textures that should be present in the MRT for this effect to work
  152892. */
  152893. readonly texturesRequired: number[];
  152894. }
  152895. }
  152896. declare module BABYLON {
  152897. interface Scene {
  152898. /** @hidden (Backing field) */
  152899. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152900. /**
  152901. * Gets or Sets the current geometry buffer associated to the scene.
  152902. */
  152903. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152904. /**
  152905. * Enables a GeometryBufferRender and associates it with the scene
  152906. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152907. * @returns the GeometryBufferRenderer
  152908. */
  152909. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152910. /**
  152911. * Disables the GeometryBufferRender associated with the scene
  152912. */
  152913. disableGeometryBufferRenderer(): void;
  152914. }
  152915. /**
  152916. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152917. * in several rendering techniques.
  152918. */
  152919. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152920. /**
  152921. * The component name helpful to identify the component in the list of scene components.
  152922. */
  152923. readonly name: string;
  152924. /**
  152925. * The scene the component belongs to.
  152926. */
  152927. scene: Scene;
  152928. /**
  152929. * Creates a new instance of the component for the given scene
  152930. * @param scene Defines the scene to register the component in
  152931. */
  152932. constructor(scene: Scene);
  152933. /**
  152934. * Registers the component in a given scene
  152935. */
  152936. register(): void;
  152937. /**
  152938. * Rebuilds the elements related to this component in case of
  152939. * context lost for instance.
  152940. */
  152941. rebuild(): void;
  152942. /**
  152943. * Disposes the component and the associated ressources
  152944. */
  152945. dispose(): void;
  152946. private _gatherRenderTargets;
  152947. }
  152948. }
  152949. declare module BABYLON {
  152950. /** @hidden */
  152951. export var motionBlurPixelShader: {
  152952. name: string;
  152953. shader: string;
  152954. };
  152955. }
  152956. declare module BABYLON {
  152957. /**
  152958. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152959. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152960. * As an example, all you have to do is to create the post-process:
  152961. * var mb = new BABYLON.MotionBlurPostProcess(
  152962. * 'mb', // The name of the effect.
  152963. * scene, // The scene containing the objects to blur according to their velocity.
  152964. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152965. * camera // The camera to apply the render pass to.
  152966. * );
  152967. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152968. */
  152969. export class MotionBlurPostProcess extends PostProcess {
  152970. /**
  152971. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152972. */
  152973. motionStrength: number;
  152974. /**
  152975. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152976. */
  152977. get motionBlurSamples(): number;
  152978. /**
  152979. * Sets the number of iterations to be used for motion blur quality
  152980. */
  152981. set motionBlurSamples(samples: number);
  152982. private _motionBlurSamples;
  152983. /**
  152984. * Gets wether or not the motion blur post-process is in object based mode.
  152985. */
  152986. get isObjectBased(): boolean;
  152987. /**
  152988. * Sets wether or not the motion blur post-process is in object based mode.
  152989. */
  152990. set isObjectBased(value: boolean);
  152991. private _isObjectBased;
  152992. private _forceGeometryBuffer;
  152993. private _geometryBufferRenderer;
  152994. private _prePassRenderer;
  152995. private _invViewProjection;
  152996. private _previousViewProjection;
  152997. /**
  152998. * Gets a string identifying the name of the class
  152999. * @returns "MotionBlurPostProcess" string
  153000. */
  153001. getClassName(): string;
  153002. /**
  153003. * Creates a new instance MotionBlurPostProcess
  153004. * @param name The name of the effect.
  153005. * @param scene The scene containing the objects to blur according to their velocity.
  153006. * @param options The required width/height ratio to downsize to before computing the render pass.
  153007. * @param camera The camera to apply the render pass to.
  153008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153009. * @param engine The engine which the post process will be applied. (default: current engine)
  153010. * @param reusable If the post process can be reused on the same frame. (default: false)
  153011. * @param textureType Type of textures used when performing the post process. (default: 0)
  153012. * @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: true)
  153013. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153014. */
  153015. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153016. /**
  153017. * Excludes the given skinned mesh from computing bones velocities.
  153018. * 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.
  153019. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  153020. */
  153021. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  153022. /**
  153023. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  153024. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  153025. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  153026. */
  153027. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  153028. /**
  153029. * Disposes the post process.
  153030. * @param camera The camera to dispose the post process on.
  153031. */
  153032. dispose(camera?: Camera): void;
  153033. /**
  153034. * Called on the mode changed (object based or screen based).
  153035. */
  153036. private _applyMode;
  153037. /**
  153038. * Called on the effect is applied when the motion blur post-process is in object based mode.
  153039. */
  153040. private _onApplyObjectBased;
  153041. /**
  153042. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  153043. */
  153044. private _onApplyScreenBased;
  153045. /**
  153046. * Called on the effect must be updated (changed mode, samples count, etc.).
  153047. */
  153048. private _updateEffect;
  153049. /** @hidden */
  153050. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  153051. }
  153052. }
  153053. declare module BABYLON {
  153054. /** @hidden */
  153055. export var refractionPixelShader: {
  153056. name: string;
  153057. shader: string;
  153058. };
  153059. }
  153060. declare module BABYLON {
  153061. /**
  153062. * Post process which applies a refractin texture
  153063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  153064. */
  153065. export class RefractionPostProcess extends PostProcess {
  153066. private _refTexture;
  153067. private _ownRefractionTexture;
  153068. /** the base color of the refraction (used to taint the rendering) */
  153069. color: Color3;
  153070. /** simulated refraction depth */
  153071. depth: number;
  153072. /** the coefficient of the base color (0 to remove base color tainting) */
  153073. colorLevel: number;
  153074. /** Gets the url used to load the refraction texture */
  153075. refractionTextureUrl: string;
  153076. /**
  153077. * Gets or sets the refraction texture
  153078. * Please note that you are responsible for disposing the texture if you set it manually
  153079. */
  153080. get refractionTexture(): Texture;
  153081. set refractionTexture(value: Texture);
  153082. /**
  153083. * Gets a string identifying the name of the class
  153084. * @returns "RefractionPostProcess" string
  153085. */
  153086. getClassName(): string;
  153087. /**
  153088. * Initializes the RefractionPostProcess
  153089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  153090. * @param name The name of the effect.
  153091. * @param refractionTextureUrl Url of the refraction texture to use
  153092. * @param color the base color of the refraction (used to taint the rendering)
  153093. * @param depth simulated refraction depth
  153094. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  153095. * @param camera The camera to apply the render pass to.
  153096. * @param options The required width/height ratio to downsize to before computing the render pass.
  153097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153098. * @param engine The engine which the post process will be applied. (default: current engine)
  153099. * @param reusable If the post process can be reused on the same frame. (default: false)
  153100. */
  153101. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153102. /**
  153103. * Disposes of the post process
  153104. * @param camera Camera to dispose post process on
  153105. */
  153106. dispose(camera: Camera): void;
  153107. /** @hidden */
  153108. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  153109. }
  153110. }
  153111. declare module BABYLON {
  153112. /** @hidden */
  153113. export var sharpenPixelShader: {
  153114. name: string;
  153115. shader: string;
  153116. };
  153117. }
  153118. declare module BABYLON {
  153119. /**
  153120. * The SharpenPostProcess applies a sharpen kernel to every pixel
  153121. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  153122. */
  153123. export class SharpenPostProcess extends PostProcess {
  153124. /**
  153125. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  153126. */
  153127. colorAmount: number;
  153128. /**
  153129. * How much sharpness should be applied (default: 0.3)
  153130. */
  153131. edgeAmount: number;
  153132. /**
  153133. * Gets a string identifying the name of the class
  153134. * @returns "SharpenPostProcess" string
  153135. */
  153136. getClassName(): string;
  153137. /**
  153138. * Creates a new instance ConvolutionPostProcess
  153139. * @param name The name of the effect.
  153140. * @param options The required width/height ratio to downsize to before computing the render pass.
  153141. * @param camera The camera to apply the render pass to.
  153142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153143. * @param engine The engine which the post process will be applied. (default: current engine)
  153144. * @param reusable If the post process can be reused on the same frame. (default: false)
  153145. * @param textureType Type of textures used when performing the post process. (default: 0)
  153146. * @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)
  153147. */
  153148. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153149. /** @hidden */
  153150. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  153151. }
  153152. }
  153153. declare module BABYLON {
  153154. /**
  153155. * PostProcessRenderPipeline
  153156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153157. */
  153158. export class PostProcessRenderPipeline {
  153159. private engine;
  153160. private _renderEffects;
  153161. private _renderEffectsForIsolatedPass;
  153162. /**
  153163. * List of inspectable custom properties (used by the Inspector)
  153164. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  153165. */
  153166. inspectableCustomProperties: IInspectable[];
  153167. /**
  153168. * @hidden
  153169. */
  153170. protected _cameras: Camera[];
  153171. /** @hidden */
  153172. _name: string;
  153173. /**
  153174. * Gets pipeline name
  153175. */
  153176. get name(): string;
  153177. /** Gets the list of attached cameras */
  153178. get cameras(): Camera[];
  153179. /**
  153180. * Initializes a PostProcessRenderPipeline
  153181. * @param engine engine to add the pipeline to
  153182. * @param name name of the pipeline
  153183. */
  153184. constructor(engine: Engine, name: string);
  153185. /**
  153186. * Gets the class name
  153187. * @returns "PostProcessRenderPipeline"
  153188. */
  153189. getClassName(): string;
  153190. /**
  153191. * If all the render effects in the pipeline are supported
  153192. */
  153193. get isSupported(): boolean;
  153194. /**
  153195. * Adds an effect to the pipeline
  153196. * @param renderEffect the effect to add
  153197. */
  153198. addEffect(renderEffect: PostProcessRenderEffect): void;
  153199. /** @hidden */
  153200. _rebuild(): void;
  153201. /** @hidden */
  153202. _enableEffect(renderEffectName: string, cameras: Camera): void;
  153203. /** @hidden */
  153204. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  153205. /** @hidden */
  153206. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153207. /** @hidden */
  153208. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  153209. /** @hidden */
  153210. _attachCameras(cameras: Camera, unique: boolean): void;
  153211. /** @hidden */
  153212. _attachCameras(cameras: Camera[], unique: boolean): void;
  153213. /** @hidden */
  153214. _detachCameras(cameras: Camera): void;
  153215. /** @hidden */
  153216. _detachCameras(cameras: Nullable<Camera[]>): void;
  153217. /** @hidden */
  153218. _update(): void;
  153219. /** @hidden */
  153220. _reset(): void;
  153221. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  153222. /**
  153223. * Sets the required values to the prepass renderer.
  153224. * @param prePassRenderer defines the prepass renderer to setup.
  153225. * @returns true if the pre pass is needed.
  153226. */
  153227. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  153228. /**
  153229. * Disposes of the pipeline
  153230. */
  153231. dispose(): void;
  153232. }
  153233. }
  153234. declare module BABYLON {
  153235. /**
  153236. * PostProcessRenderPipelineManager class
  153237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153238. */
  153239. export class PostProcessRenderPipelineManager {
  153240. private _renderPipelines;
  153241. /**
  153242. * Initializes a PostProcessRenderPipelineManager
  153243. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153244. */
  153245. constructor();
  153246. /**
  153247. * Gets the list of supported render pipelines
  153248. */
  153249. get supportedPipelines(): PostProcessRenderPipeline[];
  153250. /**
  153251. * Adds a pipeline to the manager
  153252. * @param renderPipeline The pipeline to add
  153253. */
  153254. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  153255. /**
  153256. * Attaches a camera to the pipeline
  153257. * @param renderPipelineName The name of the pipeline to attach to
  153258. * @param cameras the camera to attach
  153259. * @param unique if the camera can be attached multiple times to the pipeline
  153260. */
  153261. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  153262. /**
  153263. * Detaches a camera from the pipeline
  153264. * @param renderPipelineName The name of the pipeline to detach from
  153265. * @param cameras the camera to detach
  153266. */
  153267. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  153268. /**
  153269. * Enables an effect by name on a pipeline
  153270. * @param renderPipelineName the name of the pipeline to enable the effect in
  153271. * @param renderEffectName the name of the effect to enable
  153272. * @param cameras the cameras that the effect should be enabled on
  153273. */
  153274. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153275. /**
  153276. * Disables an effect by name on a pipeline
  153277. * @param renderPipelineName the name of the pipeline to disable the effect in
  153278. * @param renderEffectName the name of the effect to disable
  153279. * @param cameras the cameras that the effect should be disabled on
  153280. */
  153281. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  153282. /**
  153283. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  153284. */
  153285. update(): void;
  153286. /** @hidden */
  153287. _rebuild(): void;
  153288. /**
  153289. * Disposes of the manager and pipelines
  153290. */
  153291. dispose(): void;
  153292. }
  153293. }
  153294. declare module BABYLON {
  153295. interface Scene {
  153296. /** @hidden (Backing field) */
  153297. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153298. /**
  153299. * Gets the postprocess render pipeline manager
  153300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  153301. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153302. */
  153303. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  153304. }
  153305. /**
  153306. * Defines the Render Pipeline scene component responsible to rendering pipelines
  153307. */
  153308. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  153309. /**
  153310. * The component name helpfull to identify the component in the list of scene components.
  153311. */
  153312. readonly name: string;
  153313. /**
  153314. * The scene the component belongs to.
  153315. */
  153316. scene: Scene;
  153317. /**
  153318. * Creates a new instance of the component for the given scene
  153319. * @param scene Defines the scene to register the component in
  153320. */
  153321. constructor(scene: Scene);
  153322. /**
  153323. * Registers the component in a given scene
  153324. */
  153325. register(): void;
  153326. /**
  153327. * Rebuilds the elements related to this component in case of
  153328. * context lost for instance.
  153329. */
  153330. rebuild(): void;
  153331. /**
  153332. * Disposes the component and the associated ressources
  153333. */
  153334. dispose(): void;
  153335. private _gatherRenderTargets;
  153336. }
  153337. }
  153338. declare module BABYLON {
  153339. /**
  153340. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  153341. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  153342. */
  153343. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153344. private _scene;
  153345. private _camerasToBeAttached;
  153346. /**
  153347. * ID of the sharpen post process,
  153348. */
  153349. private readonly SharpenPostProcessId;
  153350. /**
  153351. * @ignore
  153352. * ID of the image processing post process;
  153353. */
  153354. readonly ImageProcessingPostProcessId: string;
  153355. /**
  153356. * @ignore
  153357. * ID of the Fast Approximate Anti-Aliasing post process;
  153358. */
  153359. readonly FxaaPostProcessId: string;
  153360. /**
  153361. * ID of the chromatic aberration post process,
  153362. */
  153363. private readonly ChromaticAberrationPostProcessId;
  153364. /**
  153365. * ID of the grain post process
  153366. */
  153367. private readonly GrainPostProcessId;
  153368. /**
  153369. * Sharpen post process which will apply a sharpen convolution to enhance edges
  153370. */
  153371. sharpen: SharpenPostProcess;
  153372. private _sharpenEffect;
  153373. private bloom;
  153374. /**
  153375. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  153376. */
  153377. depthOfField: DepthOfFieldEffect;
  153378. /**
  153379. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153380. */
  153381. fxaa: FxaaPostProcess;
  153382. /**
  153383. * Image post processing pass used to perform operations such as tone mapping or color grading.
  153384. */
  153385. imageProcessing: ImageProcessingPostProcess;
  153386. /**
  153387. * Chromatic aberration post process which will shift rgb colors in the image
  153388. */
  153389. chromaticAberration: ChromaticAberrationPostProcess;
  153390. private _chromaticAberrationEffect;
  153391. /**
  153392. * Grain post process which add noise to the image
  153393. */
  153394. grain: GrainPostProcess;
  153395. private _grainEffect;
  153396. /**
  153397. * Glow post process which adds a glow to emissive areas of the image
  153398. */
  153399. private _glowLayer;
  153400. /**
  153401. * Animations which can be used to tweak settings over a period of time
  153402. */
  153403. animations: Animation[];
  153404. private _imageProcessingConfigurationObserver;
  153405. private _sharpenEnabled;
  153406. private _bloomEnabled;
  153407. private _depthOfFieldEnabled;
  153408. private _depthOfFieldBlurLevel;
  153409. private _fxaaEnabled;
  153410. private _imageProcessingEnabled;
  153411. private _defaultPipelineTextureType;
  153412. private _bloomScale;
  153413. private _chromaticAberrationEnabled;
  153414. private _grainEnabled;
  153415. private _buildAllowed;
  153416. /**
  153417. * This is triggered each time the pipeline has been built.
  153418. */
  153419. onBuildObservable: Observable<DefaultRenderingPipeline>;
  153420. /**
  153421. * Gets active scene
  153422. */
  153423. get scene(): Scene;
  153424. /**
  153425. * Enable or disable the sharpen process from the pipeline
  153426. */
  153427. set sharpenEnabled(enabled: boolean);
  153428. get sharpenEnabled(): boolean;
  153429. private _resizeObserver;
  153430. private _hardwareScaleLevel;
  153431. private _bloomKernel;
  153432. /**
  153433. * Specifies the size of the bloom blur kernel, relative to the final output size
  153434. */
  153435. get bloomKernel(): number;
  153436. set bloomKernel(value: number);
  153437. /**
  153438. * Specifies the weight of the bloom in the final rendering
  153439. */
  153440. private _bloomWeight;
  153441. /**
  153442. * Specifies the luma threshold for the area that will be blurred by the bloom
  153443. */
  153444. private _bloomThreshold;
  153445. private _hdr;
  153446. /**
  153447. * The strength of the bloom.
  153448. */
  153449. set bloomWeight(value: number);
  153450. get bloomWeight(): number;
  153451. /**
  153452. * The strength of the bloom.
  153453. */
  153454. set bloomThreshold(value: number);
  153455. get bloomThreshold(): number;
  153456. /**
  153457. * The scale of the bloom, lower value will provide better performance.
  153458. */
  153459. set bloomScale(value: number);
  153460. get bloomScale(): number;
  153461. /**
  153462. * Enable or disable the bloom from the pipeline
  153463. */
  153464. set bloomEnabled(enabled: boolean);
  153465. get bloomEnabled(): boolean;
  153466. private _rebuildBloom;
  153467. /**
  153468. * If the depth of field is enabled.
  153469. */
  153470. get depthOfFieldEnabled(): boolean;
  153471. set depthOfFieldEnabled(enabled: boolean);
  153472. /**
  153473. * Blur level of the depth of field effect. (Higher blur will effect performance)
  153474. */
  153475. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  153476. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  153477. /**
  153478. * If the anti aliasing is enabled.
  153479. */
  153480. set fxaaEnabled(enabled: boolean);
  153481. get fxaaEnabled(): boolean;
  153482. private _samples;
  153483. /**
  153484. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153485. */
  153486. set samples(sampleCount: number);
  153487. get samples(): number;
  153488. /**
  153489. * If image processing is enabled.
  153490. */
  153491. set imageProcessingEnabled(enabled: boolean);
  153492. get imageProcessingEnabled(): boolean;
  153493. /**
  153494. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  153495. */
  153496. set glowLayerEnabled(enabled: boolean);
  153497. get glowLayerEnabled(): boolean;
  153498. /**
  153499. * Gets the glow layer (or null if not defined)
  153500. */
  153501. get glowLayer(): Nullable<GlowLayer>;
  153502. /**
  153503. * Enable or disable the chromaticAberration process from the pipeline
  153504. */
  153505. set chromaticAberrationEnabled(enabled: boolean);
  153506. get chromaticAberrationEnabled(): boolean;
  153507. /**
  153508. * Enable or disable the grain process from the pipeline
  153509. */
  153510. set grainEnabled(enabled: boolean);
  153511. get grainEnabled(): boolean;
  153512. /**
  153513. * @constructor
  153514. * @param name - The rendering pipeline name (default: "")
  153515. * @param hdr - If high dynamic range textures should be used (default: true)
  153516. * @param scene - The scene linked to this pipeline (default: the last created scene)
  153517. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  153518. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  153519. */
  153520. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  153521. /**
  153522. * Get the class name
  153523. * @returns "DefaultRenderingPipeline"
  153524. */
  153525. getClassName(): string;
  153526. /**
  153527. * Force the compilation of the entire pipeline.
  153528. */
  153529. prepare(): void;
  153530. private _hasCleared;
  153531. private _prevPostProcess;
  153532. private _prevPrevPostProcess;
  153533. private _setAutoClearAndTextureSharing;
  153534. private _depthOfFieldSceneObserver;
  153535. private _buildPipeline;
  153536. private _disposePostProcesses;
  153537. /**
  153538. * Adds a camera to the pipeline
  153539. * @param camera the camera to be added
  153540. */
  153541. addCamera(camera: Camera): void;
  153542. /**
  153543. * Removes a camera from the pipeline
  153544. * @param camera the camera to remove
  153545. */
  153546. removeCamera(camera: Camera): void;
  153547. /**
  153548. * Dispose of the pipeline and stop all post processes
  153549. */
  153550. dispose(): void;
  153551. /**
  153552. * Serialize the rendering pipeline (Used when exporting)
  153553. * @returns the serialized object
  153554. */
  153555. serialize(): any;
  153556. /**
  153557. * Parse the serialized pipeline
  153558. * @param source Source pipeline.
  153559. * @param scene The scene to load the pipeline to.
  153560. * @param rootUrl The URL of the serialized pipeline.
  153561. * @returns An instantiated pipeline from the serialized object.
  153562. */
  153563. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  153564. }
  153565. }
  153566. declare module BABYLON {
  153567. /** @hidden */
  153568. export var lensHighlightsPixelShader: {
  153569. name: string;
  153570. shader: string;
  153571. };
  153572. }
  153573. declare module BABYLON {
  153574. /** @hidden */
  153575. export var depthOfFieldPixelShader: {
  153576. name: string;
  153577. shader: string;
  153578. };
  153579. }
  153580. declare module BABYLON {
  153581. /**
  153582. * BABYLON.JS Chromatic Aberration GLSL Shader
  153583. * Author: Olivier Guyot
  153584. * Separates very slightly R, G and B colors on the edges of the screen
  153585. * Inspired by Francois Tarlier & Martins Upitis
  153586. */
  153587. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  153588. /**
  153589. * @ignore
  153590. * The chromatic aberration PostProcess id in the pipeline
  153591. */
  153592. LensChromaticAberrationEffect: string;
  153593. /**
  153594. * @ignore
  153595. * The highlights enhancing PostProcess id in the pipeline
  153596. */
  153597. HighlightsEnhancingEffect: string;
  153598. /**
  153599. * @ignore
  153600. * The depth-of-field PostProcess id in the pipeline
  153601. */
  153602. LensDepthOfFieldEffect: string;
  153603. private _scene;
  153604. private _depthTexture;
  153605. private _grainTexture;
  153606. private _chromaticAberrationPostProcess;
  153607. private _highlightsPostProcess;
  153608. private _depthOfFieldPostProcess;
  153609. private _edgeBlur;
  153610. private _grainAmount;
  153611. private _chromaticAberration;
  153612. private _distortion;
  153613. private _highlightsGain;
  153614. private _highlightsThreshold;
  153615. private _dofDistance;
  153616. private _dofAperture;
  153617. private _dofDarken;
  153618. private _dofPentagon;
  153619. private _blurNoise;
  153620. /**
  153621. * @constructor
  153622. *
  153623. * Effect parameters are as follow:
  153624. * {
  153625. * chromatic_aberration: number; // from 0 to x (1 for realism)
  153626. * edge_blur: number; // from 0 to x (1 for realism)
  153627. * distortion: number; // from 0 to x (1 for realism)
  153628. * grain_amount: number; // from 0 to 1
  153629. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  153630. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  153631. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  153632. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  153633. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  153634. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  153635. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  153636. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  153637. * }
  153638. * Note: if an effect parameter is unset, effect is disabled
  153639. *
  153640. * @param name The rendering pipeline name
  153641. * @param parameters - An object containing all parameters (see above)
  153642. * @param scene The scene linked to this pipeline
  153643. * @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)
  153644. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153645. */
  153646. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  153647. /**
  153648. * Get the class name
  153649. * @returns "LensRenderingPipeline"
  153650. */
  153651. getClassName(): string;
  153652. /**
  153653. * Gets associated scene
  153654. */
  153655. get scene(): Scene;
  153656. /**
  153657. * Gets or sets the edge blur
  153658. */
  153659. get edgeBlur(): number;
  153660. set edgeBlur(value: number);
  153661. /**
  153662. * Gets or sets the grain amount
  153663. */
  153664. get grainAmount(): number;
  153665. set grainAmount(value: number);
  153666. /**
  153667. * Gets or sets the chromatic aberration amount
  153668. */
  153669. get chromaticAberration(): number;
  153670. set chromaticAberration(value: number);
  153671. /**
  153672. * Gets or sets the depth of field aperture
  153673. */
  153674. get dofAperture(): number;
  153675. set dofAperture(value: number);
  153676. /**
  153677. * Gets or sets the edge distortion
  153678. */
  153679. get edgeDistortion(): number;
  153680. set edgeDistortion(value: number);
  153681. /**
  153682. * Gets or sets the depth of field distortion
  153683. */
  153684. get dofDistortion(): number;
  153685. set dofDistortion(value: number);
  153686. /**
  153687. * Gets or sets the darken out of focus amount
  153688. */
  153689. get darkenOutOfFocus(): number;
  153690. set darkenOutOfFocus(value: number);
  153691. /**
  153692. * Gets or sets a boolean indicating if blur noise is enabled
  153693. */
  153694. get blurNoise(): boolean;
  153695. set blurNoise(value: boolean);
  153696. /**
  153697. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  153698. */
  153699. get pentagonBokeh(): boolean;
  153700. set pentagonBokeh(value: boolean);
  153701. /**
  153702. * Gets or sets the highlight grain amount
  153703. */
  153704. get highlightsGain(): number;
  153705. set highlightsGain(value: number);
  153706. /**
  153707. * Gets or sets the highlight threshold
  153708. */
  153709. get highlightsThreshold(): number;
  153710. set highlightsThreshold(value: number);
  153711. /**
  153712. * Sets the amount of blur at the edges
  153713. * @param amount blur amount
  153714. */
  153715. setEdgeBlur(amount: number): void;
  153716. /**
  153717. * Sets edge blur to 0
  153718. */
  153719. disableEdgeBlur(): void;
  153720. /**
  153721. * Sets the amout of grain
  153722. * @param amount Amount of grain
  153723. */
  153724. setGrainAmount(amount: number): void;
  153725. /**
  153726. * Set grain amount to 0
  153727. */
  153728. disableGrain(): void;
  153729. /**
  153730. * Sets the chromatic aberration amount
  153731. * @param amount amount of chromatic aberration
  153732. */
  153733. setChromaticAberration(amount: number): void;
  153734. /**
  153735. * Sets chromatic aberration amount to 0
  153736. */
  153737. disableChromaticAberration(): void;
  153738. /**
  153739. * Sets the EdgeDistortion amount
  153740. * @param amount amount of EdgeDistortion
  153741. */
  153742. setEdgeDistortion(amount: number): void;
  153743. /**
  153744. * Sets edge distortion to 0
  153745. */
  153746. disableEdgeDistortion(): void;
  153747. /**
  153748. * Sets the FocusDistance amount
  153749. * @param amount amount of FocusDistance
  153750. */
  153751. setFocusDistance(amount: number): void;
  153752. /**
  153753. * Disables depth of field
  153754. */
  153755. disableDepthOfField(): void;
  153756. /**
  153757. * Sets the Aperture amount
  153758. * @param amount amount of Aperture
  153759. */
  153760. setAperture(amount: number): void;
  153761. /**
  153762. * Sets the DarkenOutOfFocus amount
  153763. * @param amount amount of DarkenOutOfFocus
  153764. */
  153765. setDarkenOutOfFocus(amount: number): void;
  153766. private _pentagonBokehIsEnabled;
  153767. /**
  153768. * Creates a pentagon bokeh effect
  153769. */
  153770. enablePentagonBokeh(): void;
  153771. /**
  153772. * Disables the pentagon bokeh effect
  153773. */
  153774. disablePentagonBokeh(): void;
  153775. /**
  153776. * Enables noise blur
  153777. */
  153778. enableNoiseBlur(): void;
  153779. /**
  153780. * Disables noise blur
  153781. */
  153782. disableNoiseBlur(): void;
  153783. /**
  153784. * Sets the HighlightsGain amount
  153785. * @param amount amount of HighlightsGain
  153786. */
  153787. setHighlightsGain(amount: number): void;
  153788. /**
  153789. * Sets the HighlightsThreshold amount
  153790. * @param amount amount of HighlightsThreshold
  153791. */
  153792. setHighlightsThreshold(amount: number): void;
  153793. /**
  153794. * Disables highlights
  153795. */
  153796. disableHighlights(): void;
  153797. /**
  153798. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  153799. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  153800. */
  153801. dispose(disableDepthRender?: boolean): void;
  153802. private _createChromaticAberrationPostProcess;
  153803. private _createHighlightsPostProcess;
  153804. private _createDepthOfFieldPostProcess;
  153805. private _createGrainTexture;
  153806. }
  153807. }
  153808. declare module BABYLON {
  153809. /**
  153810. * Contains all parameters needed for the prepass to perform
  153811. * screen space subsurface scattering
  153812. */
  153813. export class SSAO2Configuration implements PrePassEffectConfiguration {
  153814. /**
  153815. * Is subsurface enabled
  153816. */
  153817. enabled: boolean;
  153818. /**
  153819. * Name of the configuration
  153820. */
  153821. name: string;
  153822. /**
  153823. * Textures that should be present in the MRT for this effect to work
  153824. */
  153825. readonly texturesRequired: number[];
  153826. }
  153827. }
  153828. declare module BABYLON {
  153829. /** @hidden */
  153830. export var ssao2PixelShader: {
  153831. name: string;
  153832. shader: string;
  153833. };
  153834. }
  153835. declare module BABYLON {
  153836. /** @hidden */
  153837. export var ssaoCombinePixelShader: {
  153838. name: string;
  153839. shader: string;
  153840. };
  153841. }
  153842. declare module BABYLON {
  153843. /**
  153844. * Render pipeline to produce ssao effect
  153845. */
  153846. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  153847. /**
  153848. * @ignore
  153849. * The PassPostProcess id in the pipeline that contains the original scene color
  153850. */
  153851. SSAOOriginalSceneColorEffect: string;
  153852. /**
  153853. * @ignore
  153854. * The SSAO PostProcess id in the pipeline
  153855. */
  153856. SSAORenderEffect: string;
  153857. /**
  153858. * @ignore
  153859. * The horizontal blur PostProcess id in the pipeline
  153860. */
  153861. SSAOBlurHRenderEffect: string;
  153862. /**
  153863. * @ignore
  153864. * The vertical blur PostProcess id in the pipeline
  153865. */
  153866. SSAOBlurVRenderEffect: string;
  153867. /**
  153868. * @ignore
  153869. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153870. */
  153871. SSAOCombineRenderEffect: string;
  153872. /**
  153873. * The output strength of the SSAO post-process. Default value is 1.0.
  153874. */
  153875. totalStrength: number;
  153876. /**
  153877. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  153878. */
  153879. maxZ: number;
  153880. /**
  153881. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  153882. */
  153883. minZAspect: number;
  153884. private _samples;
  153885. /**
  153886. * Number of samples used for the SSAO calculations. Default value is 8
  153887. */
  153888. set samples(n: number);
  153889. get samples(): number;
  153890. private _textureSamples;
  153891. /**
  153892. * Number of samples to use for antialiasing
  153893. */
  153894. set textureSamples(n: number);
  153895. get textureSamples(): number;
  153896. /**
  153897. * Force rendering the geometry through geometry buffer
  153898. */
  153899. private _forceGeometryBuffer;
  153900. /**
  153901. * Ratio object used for SSAO ratio and blur ratio
  153902. */
  153903. private _ratio;
  153904. /**
  153905. * Dynamically generated sphere sampler.
  153906. */
  153907. private _sampleSphere;
  153908. /**
  153909. * Blur filter offsets
  153910. */
  153911. private _samplerOffsets;
  153912. private _expensiveBlur;
  153913. /**
  153914. * If bilateral blur should be used
  153915. */
  153916. set expensiveBlur(b: boolean);
  153917. get expensiveBlur(): boolean;
  153918. /**
  153919. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  153920. */
  153921. radius: number;
  153922. /**
  153923. * The base color of the SSAO post-process
  153924. * The final result is "base + ssao" between [0, 1]
  153925. */
  153926. base: number;
  153927. /**
  153928. * Support test.
  153929. */
  153930. static get IsSupported(): boolean;
  153931. private _scene;
  153932. private _randomTexture;
  153933. private _originalColorPostProcess;
  153934. private _ssaoPostProcess;
  153935. private _blurHPostProcess;
  153936. private _blurVPostProcess;
  153937. private _ssaoCombinePostProcess;
  153938. private _prePassRenderer;
  153939. /**
  153940. * Gets active scene
  153941. */
  153942. get scene(): Scene;
  153943. /**
  153944. * @constructor
  153945. * @param name The rendering pipeline name
  153946. * @param scene The scene linked to this pipeline
  153947. * @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 }
  153948. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153949. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153950. */
  153951. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153952. /**
  153953. * Get the class name
  153954. * @returns "SSAO2RenderingPipeline"
  153955. */
  153956. getClassName(): string;
  153957. /**
  153958. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153959. */
  153960. dispose(disableGeometryBufferRenderer?: boolean): void;
  153961. private _createBlurPostProcess;
  153962. /** @hidden */
  153963. _rebuild(): void;
  153964. private _bits;
  153965. private _radicalInverse_VdC;
  153966. private _hammersley;
  153967. private _hemisphereSample_uniform;
  153968. private _generateHemisphere;
  153969. private _getDefinesForSSAO;
  153970. private _createSSAOPostProcess;
  153971. private _createSSAOCombinePostProcess;
  153972. private _createRandomTexture;
  153973. /**
  153974. * Serialize the rendering pipeline (Used when exporting)
  153975. * @returns the serialized object
  153976. */
  153977. serialize(): any;
  153978. /**
  153979. * Parse the serialized pipeline
  153980. * @param source Source pipeline.
  153981. * @param scene The scene to load the pipeline to.
  153982. * @param rootUrl The URL of the serialized pipeline.
  153983. * @returns An instantiated pipeline from the serialized object.
  153984. */
  153985. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153986. }
  153987. }
  153988. declare module BABYLON {
  153989. /** @hidden */
  153990. export var ssaoPixelShader: {
  153991. name: string;
  153992. shader: string;
  153993. };
  153994. }
  153995. declare module BABYLON {
  153996. /**
  153997. * Render pipeline to produce ssao effect
  153998. */
  153999. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  154000. /**
  154001. * @ignore
  154002. * The PassPostProcess id in the pipeline that contains the original scene color
  154003. */
  154004. SSAOOriginalSceneColorEffect: string;
  154005. /**
  154006. * @ignore
  154007. * The SSAO PostProcess id in the pipeline
  154008. */
  154009. SSAORenderEffect: string;
  154010. /**
  154011. * @ignore
  154012. * The horizontal blur PostProcess id in the pipeline
  154013. */
  154014. SSAOBlurHRenderEffect: string;
  154015. /**
  154016. * @ignore
  154017. * The vertical blur PostProcess id in the pipeline
  154018. */
  154019. SSAOBlurVRenderEffect: string;
  154020. /**
  154021. * @ignore
  154022. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  154023. */
  154024. SSAOCombineRenderEffect: string;
  154025. /**
  154026. * The output strength of the SSAO post-process. Default value is 1.0.
  154027. */
  154028. totalStrength: number;
  154029. /**
  154030. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  154031. */
  154032. radius: number;
  154033. /**
  154034. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  154035. * Must not be equal to fallOff and superior to fallOff.
  154036. * Default value is 0.0075
  154037. */
  154038. area: number;
  154039. /**
  154040. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  154041. * Must not be equal to area and inferior to area.
  154042. * Default value is 0.000001
  154043. */
  154044. fallOff: number;
  154045. /**
  154046. * The base color of the SSAO post-process
  154047. * The final result is "base + ssao" between [0, 1]
  154048. */
  154049. base: number;
  154050. private _scene;
  154051. private _depthTexture;
  154052. private _randomTexture;
  154053. private _originalColorPostProcess;
  154054. private _ssaoPostProcess;
  154055. private _blurHPostProcess;
  154056. private _blurVPostProcess;
  154057. private _ssaoCombinePostProcess;
  154058. private _firstUpdate;
  154059. /**
  154060. * Gets active scene
  154061. */
  154062. get scene(): Scene;
  154063. /**
  154064. * @constructor
  154065. * @param name - The rendering pipeline name
  154066. * @param scene - The scene linked to this pipeline
  154067. * @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 }
  154068. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  154069. */
  154070. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  154071. /**
  154072. * Get the class name
  154073. * @returns "SSAORenderingPipeline"
  154074. */
  154075. getClassName(): string;
  154076. /**
  154077. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  154078. */
  154079. dispose(disableDepthRender?: boolean): void;
  154080. private _createBlurPostProcess;
  154081. /** @hidden */
  154082. _rebuild(): void;
  154083. private _createSSAOPostProcess;
  154084. private _createSSAOCombinePostProcess;
  154085. private _createRandomTexture;
  154086. }
  154087. }
  154088. declare module BABYLON {
  154089. /**
  154090. * Contains all parameters needed for the prepass to perform
  154091. * screen space reflections
  154092. */
  154093. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  154094. /**
  154095. * Is ssr enabled
  154096. */
  154097. enabled: boolean;
  154098. /**
  154099. * Name of the configuration
  154100. */
  154101. name: string;
  154102. /**
  154103. * Textures that should be present in the MRT for this effect to work
  154104. */
  154105. readonly texturesRequired: number[];
  154106. }
  154107. }
  154108. declare module BABYLON {
  154109. /** @hidden */
  154110. export var screenSpaceReflectionPixelShader: {
  154111. name: string;
  154112. shader: string;
  154113. };
  154114. }
  154115. declare module BABYLON {
  154116. /**
  154117. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  154118. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  154119. */
  154120. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  154121. /**
  154122. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  154123. */
  154124. threshold: number;
  154125. /**
  154126. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  154127. */
  154128. strength: number;
  154129. /**
  154130. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  154131. */
  154132. reflectionSpecularFalloffExponent: number;
  154133. /**
  154134. * 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]
  154135. */
  154136. step: number;
  154137. /**
  154138. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  154139. */
  154140. roughnessFactor: number;
  154141. private _forceGeometryBuffer;
  154142. private _geometryBufferRenderer;
  154143. private _prePassRenderer;
  154144. private _enableSmoothReflections;
  154145. private _reflectionSamples;
  154146. private _smoothSteps;
  154147. /**
  154148. * Gets a string identifying the name of the class
  154149. * @returns "ScreenSpaceReflectionPostProcess" string
  154150. */
  154151. getClassName(): string;
  154152. /**
  154153. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  154154. * @param name The name of the effect.
  154155. * @param scene The scene containing the objects to calculate reflections.
  154156. * @param options The required width/height ratio to downsize to before computing the render pass.
  154157. * @param camera The camera to apply the render pass to.
  154158. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154159. * @param engine The engine which the post process will be applied. (default: current engine)
  154160. * @param reusable If the post process can be reused on the same frame. (default: false)
  154161. * @param textureType Type of textures used when performing the post process. (default: 0)
  154162. * @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: true)
  154163. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  154164. */
  154165. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  154166. /**
  154167. * Gets wether or not smoothing reflections is enabled.
  154168. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  154169. */
  154170. get enableSmoothReflections(): boolean;
  154171. /**
  154172. * Sets wether or not smoothing reflections is enabled.
  154173. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  154174. */
  154175. set enableSmoothReflections(enabled: boolean);
  154176. /**
  154177. * Gets the number of samples taken while computing reflections. More samples count is high,
  154178. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  154179. */
  154180. get reflectionSamples(): number;
  154181. /**
  154182. * Sets the number of samples taken while computing reflections. More samples count is high,
  154183. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  154184. */
  154185. set reflectionSamples(samples: number);
  154186. /**
  154187. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  154188. * more the post-process will require GPU power and can generate a drop in FPS.
  154189. * Default value (5.0) work pretty well in all cases but can be adjusted.
  154190. */
  154191. get smoothSteps(): number;
  154192. set smoothSteps(steps: number);
  154193. private _updateEffectDefines;
  154194. /** @hidden */
  154195. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  154196. }
  154197. }
  154198. declare module BABYLON {
  154199. /** @hidden */
  154200. export var standardPixelShader: {
  154201. name: string;
  154202. shader: string;
  154203. };
  154204. }
  154205. declare module BABYLON {
  154206. /**
  154207. * Standard rendering pipeline
  154208. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154209. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  154210. */
  154211. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  154212. /**
  154213. * Public members
  154214. */
  154215. /**
  154216. * Post-process which contains the original scene color before the pipeline applies all the effects
  154217. */
  154218. originalPostProcess: Nullable<PostProcess>;
  154219. /**
  154220. * Post-process used to down scale an image x4
  154221. */
  154222. downSampleX4PostProcess: Nullable<PostProcess>;
  154223. /**
  154224. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  154225. */
  154226. brightPassPostProcess: Nullable<PostProcess>;
  154227. /**
  154228. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  154229. */
  154230. blurHPostProcesses: PostProcess[];
  154231. /**
  154232. * Post-process array storing all the vertical blur post-processes used by the pipeline
  154233. */
  154234. blurVPostProcesses: PostProcess[];
  154235. /**
  154236. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  154237. */
  154238. textureAdderPostProcess: Nullable<PostProcess>;
  154239. /**
  154240. * Post-process used to create volumetric lighting effect
  154241. */
  154242. volumetricLightPostProcess: Nullable<PostProcess>;
  154243. /**
  154244. * Post-process used to smooth the previous volumetric light post-process on the X axis
  154245. */
  154246. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  154247. /**
  154248. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  154249. */
  154250. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  154251. /**
  154252. * Post-process used to merge the volumetric light effect and the real scene color
  154253. */
  154254. volumetricLightMergePostProces: Nullable<PostProcess>;
  154255. /**
  154256. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  154257. */
  154258. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  154259. /**
  154260. * Base post-process used to calculate the average luminance of the final image for HDR
  154261. */
  154262. luminancePostProcess: Nullable<PostProcess>;
  154263. /**
  154264. * Post-processes used to create down sample post-processes in order to get
  154265. * the average luminance of the final image for HDR
  154266. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  154267. */
  154268. luminanceDownSamplePostProcesses: PostProcess[];
  154269. /**
  154270. * Post-process used to create a HDR effect (light adaptation)
  154271. */
  154272. hdrPostProcess: Nullable<PostProcess>;
  154273. /**
  154274. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  154275. */
  154276. textureAdderFinalPostProcess: Nullable<PostProcess>;
  154277. /**
  154278. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  154279. */
  154280. lensFlareFinalPostProcess: Nullable<PostProcess>;
  154281. /**
  154282. * Post-process used to merge the final HDR post-process and the real scene color
  154283. */
  154284. hdrFinalPostProcess: Nullable<PostProcess>;
  154285. /**
  154286. * Post-process used to create a lens flare effect
  154287. */
  154288. lensFlarePostProcess: Nullable<PostProcess>;
  154289. /**
  154290. * Post-process that merges the result of the lens flare post-process and the real scene color
  154291. */
  154292. lensFlareComposePostProcess: Nullable<PostProcess>;
  154293. /**
  154294. * Post-process used to create a motion blur effect
  154295. */
  154296. motionBlurPostProcess: Nullable<PostProcess>;
  154297. /**
  154298. * Post-process used to create a depth of field effect
  154299. */
  154300. depthOfFieldPostProcess: Nullable<PostProcess>;
  154301. /**
  154302. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  154303. */
  154304. fxaaPostProcess: Nullable<FxaaPostProcess>;
  154305. /**
  154306. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  154307. */
  154308. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  154309. /**
  154310. * Represents the brightness threshold in order to configure the illuminated surfaces
  154311. */
  154312. brightThreshold: number;
  154313. /**
  154314. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  154315. */
  154316. blurWidth: number;
  154317. /**
  154318. * Sets if the blur for highlighted surfaces must be only horizontal
  154319. */
  154320. horizontalBlur: boolean;
  154321. /**
  154322. * Gets the overall exposure used by the pipeline
  154323. */
  154324. get exposure(): number;
  154325. /**
  154326. * Sets the overall exposure used by the pipeline
  154327. */
  154328. set exposure(value: number);
  154329. /**
  154330. * Texture used typically to simulate "dirty" on camera lens
  154331. */
  154332. lensTexture: Nullable<Texture>;
  154333. /**
  154334. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  154335. */
  154336. volumetricLightCoefficient: number;
  154337. /**
  154338. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  154339. */
  154340. volumetricLightPower: number;
  154341. /**
  154342. * Used the set the blur intensity to smooth the volumetric lights
  154343. */
  154344. volumetricLightBlurScale: number;
  154345. /**
  154346. * Light (spot or directional) used to generate the volumetric lights rays
  154347. * The source light must have a shadow generate so the pipeline can get its
  154348. * depth map
  154349. */
  154350. sourceLight: Nullable<SpotLight | DirectionalLight>;
  154351. /**
  154352. * For eye adaptation, represents the minimum luminance the eye can see
  154353. */
  154354. hdrMinimumLuminance: number;
  154355. /**
  154356. * For eye adaptation, represents the decrease luminance speed
  154357. */
  154358. hdrDecreaseRate: number;
  154359. /**
  154360. * For eye adaptation, represents the increase luminance speed
  154361. */
  154362. hdrIncreaseRate: number;
  154363. /**
  154364. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154365. */
  154366. get hdrAutoExposure(): boolean;
  154367. /**
  154368. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  154369. */
  154370. set hdrAutoExposure(value: boolean);
  154371. /**
  154372. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  154373. */
  154374. lensColorTexture: Nullable<Texture>;
  154375. /**
  154376. * The overall strengh for the lens flare effect
  154377. */
  154378. lensFlareStrength: number;
  154379. /**
  154380. * Dispersion coefficient for lens flare ghosts
  154381. */
  154382. lensFlareGhostDispersal: number;
  154383. /**
  154384. * Main lens flare halo width
  154385. */
  154386. lensFlareHaloWidth: number;
  154387. /**
  154388. * Based on the lens distortion effect, defines how much the lens flare result
  154389. * is distorted
  154390. */
  154391. lensFlareDistortionStrength: number;
  154392. /**
  154393. * Configures the blur intensity used for for lens flare (halo)
  154394. */
  154395. lensFlareBlurWidth: number;
  154396. /**
  154397. * Lens star texture must be used to simulate rays on the flares and is available
  154398. * in the documentation
  154399. */
  154400. lensStarTexture: Nullable<Texture>;
  154401. /**
  154402. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  154403. * flare effect by taking account of the dirt texture
  154404. */
  154405. lensFlareDirtTexture: Nullable<Texture>;
  154406. /**
  154407. * Represents the focal length for the depth of field effect
  154408. */
  154409. depthOfFieldDistance: number;
  154410. /**
  154411. * Represents the blur intensity for the blurred part of the depth of field effect
  154412. */
  154413. depthOfFieldBlurWidth: number;
  154414. /**
  154415. * Gets how much the image is blurred by the movement while using the motion blur post-process
  154416. */
  154417. get motionStrength(): number;
  154418. /**
  154419. * Sets how much the image is blurred by the movement while using the motion blur post-process
  154420. */
  154421. set motionStrength(strength: number);
  154422. /**
  154423. * Gets wether or not the motion blur post-process is object based or screen based.
  154424. */
  154425. get objectBasedMotionBlur(): boolean;
  154426. /**
  154427. * Sets wether or not the motion blur post-process should be object based or screen based
  154428. */
  154429. set objectBasedMotionBlur(value: boolean);
  154430. /**
  154431. * List of animations for the pipeline (IAnimatable implementation)
  154432. */
  154433. animations: Animation[];
  154434. /**
  154435. * Private members
  154436. */
  154437. private _scene;
  154438. private _currentDepthOfFieldSource;
  154439. private _basePostProcess;
  154440. private _fixedExposure;
  154441. private _currentExposure;
  154442. private _hdrAutoExposure;
  154443. private _hdrCurrentLuminance;
  154444. private _motionStrength;
  154445. private _isObjectBasedMotionBlur;
  154446. private _floatTextureType;
  154447. private _camerasToBeAttached;
  154448. private _ratio;
  154449. private _bloomEnabled;
  154450. private _depthOfFieldEnabled;
  154451. private _vlsEnabled;
  154452. private _lensFlareEnabled;
  154453. private _hdrEnabled;
  154454. private _motionBlurEnabled;
  154455. private _fxaaEnabled;
  154456. private _screenSpaceReflectionsEnabled;
  154457. private _motionBlurSamples;
  154458. private _volumetricLightStepsCount;
  154459. private _samples;
  154460. /**
  154461. * @ignore
  154462. * Specifies if the bloom pipeline is enabled
  154463. */
  154464. get BloomEnabled(): boolean;
  154465. set BloomEnabled(enabled: boolean);
  154466. /**
  154467. * @ignore
  154468. * Specifies if the depth of field pipeline is enabed
  154469. */
  154470. get DepthOfFieldEnabled(): boolean;
  154471. set DepthOfFieldEnabled(enabled: boolean);
  154472. /**
  154473. * @ignore
  154474. * Specifies if the lens flare pipeline is enabed
  154475. */
  154476. get LensFlareEnabled(): boolean;
  154477. set LensFlareEnabled(enabled: boolean);
  154478. /**
  154479. * @ignore
  154480. * Specifies if the HDR pipeline is enabled
  154481. */
  154482. get HDREnabled(): boolean;
  154483. set HDREnabled(enabled: boolean);
  154484. /**
  154485. * @ignore
  154486. * Specifies if the volumetric lights scattering effect is enabled
  154487. */
  154488. get VLSEnabled(): boolean;
  154489. set VLSEnabled(enabled: boolean);
  154490. /**
  154491. * @ignore
  154492. * Specifies if the motion blur effect is enabled
  154493. */
  154494. get MotionBlurEnabled(): boolean;
  154495. set MotionBlurEnabled(enabled: boolean);
  154496. /**
  154497. * Specifies if anti-aliasing is enabled
  154498. */
  154499. get fxaaEnabled(): boolean;
  154500. set fxaaEnabled(enabled: boolean);
  154501. /**
  154502. * Specifies if screen space reflections are enabled.
  154503. */
  154504. get screenSpaceReflectionsEnabled(): boolean;
  154505. set screenSpaceReflectionsEnabled(enabled: boolean);
  154506. /**
  154507. * Specifies the number of steps used to calculate the volumetric lights
  154508. * Typically in interval [50, 200]
  154509. */
  154510. get volumetricLightStepsCount(): number;
  154511. set volumetricLightStepsCount(count: number);
  154512. /**
  154513. * Specifies the number of samples used for the motion blur effect
  154514. * Typically in interval [16, 64]
  154515. */
  154516. get motionBlurSamples(): number;
  154517. set motionBlurSamples(samples: number);
  154518. /**
  154519. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  154520. */
  154521. get samples(): number;
  154522. set samples(sampleCount: number);
  154523. /**
  154524. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  154525. * @constructor
  154526. * @param name The rendering pipeline name
  154527. * @param scene The scene linked to this pipeline
  154528. * @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)
  154529. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  154530. * @param cameras The array of cameras that the rendering pipeline will be attached to
  154531. */
  154532. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  154533. private _buildPipeline;
  154534. private _createDownSampleX4PostProcess;
  154535. private _createBrightPassPostProcess;
  154536. private _createBlurPostProcesses;
  154537. private _createTextureAdderPostProcess;
  154538. private _createVolumetricLightPostProcess;
  154539. private _createLuminancePostProcesses;
  154540. private _createHdrPostProcess;
  154541. private _createLensFlarePostProcess;
  154542. private _createDepthOfFieldPostProcess;
  154543. private _createMotionBlurPostProcess;
  154544. private _getDepthTexture;
  154545. private _disposePostProcesses;
  154546. /**
  154547. * Dispose of the pipeline and stop all post processes
  154548. */
  154549. dispose(): void;
  154550. /**
  154551. * Serialize the rendering pipeline (Used when exporting)
  154552. * @returns the serialized object
  154553. */
  154554. serialize(): any;
  154555. /**
  154556. * Parse the serialized pipeline
  154557. * @param source Source pipeline.
  154558. * @param scene The scene to load the pipeline to.
  154559. * @param rootUrl The URL of the serialized pipeline.
  154560. * @returns An instantiated pipeline from the serialized object.
  154561. */
  154562. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  154563. /**
  154564. * Luminance steps
  154565. */
  154566. static LuminanceSteps: number;
  154567. }
  154568. }
  154569. declare module BABYLON {
  154570. /** @hidden */
  154571. export var stereoscopicInterlacePixelShader: {
  154572. name: string;
  154573. shader: string;
  154574. };
  154575. }
  154576. declare module BABYLON {
  154577. /**
  154578. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  154579. */
  154580. export class StereoscopicInterlacePostProcessI extends PostProcess {
  154581. private _stepSize;
  154582. private _passedProcess;
  154583. /**
  154584. * Gets a string identifying the name of the class
  154585. * @returns "StereoscopicInterlacePostProcessI" string
  154586. */
  154587. getClassName(): string;
  154588. /**
  154589. * Initializes a StereoscopicInterlacePostProcessI
  154590. * @param name The name of the effect.
  154591. * @param rigCameras The rig cameras to be appled to the post process
  154592. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  154593. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  154594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154595. * @param engine The engine which the post process will be applied. (default: current engine)
  154596. * @param reusable If the post process can be reused on the same frame. (default: false)
  154597. */
  154598. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154599. }
  154600. /**
  154601. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  154602. */
  154603. export class StereoscopicInterlacePostProcess extends PostProcess {
  154604. private _stepSize;
  154605. private _passedProcess;
  154606. /**
  154607. * Gets a string identifying the name of the class
  154608. * @returns "StereoscopicInterlacePostProcess" string
  154609. */
  154610. getClassName(): string;
  154611. /**
  154612. * Initializes a StereoscopicInterlacePostProcess
  154613. * @param name The name of the effect.
  154614. * @param rigCameras The rig cameras to be appled to the post process
  154615. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  154616. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154617. * @param engine The engine which the post process will be applied. (default: current engine)
  154618. * @param reusable If the post process can be reused on the same frame. (default: false)
  154619. */
  154620. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  154621. }
  154622. }
  154623. declare module BABYLON {
  154624. /** @hidden */
  154625. export var tonemapPixelShader: {
  154626. name: string;
  154627. shader: string;
  154628. };
  154629. }
  154630. declare module BABYLON {
  154631. /** Defines operator used for tonemapping */
  154632. export enum TonemappingOperator {
  154633. /** Hable */
  154634. Hable = 0,
  154635. /** Reinhard */
  154636. Reinhard = 1,
  154637. /** HejiDawson */
  154638. HejiDawson = 2,
  154639. /** Photographic */
  154640. Photographic = 3
  154641. }
  154642. /**
  154643. * Defines a post process to apply tone mapping
  154644. */
  154645. export class TonemapPostProcess extends PostProcess {
  154646. private _operator;
  154647. /** Defines the required exposure adjustement */
  154648. exposureAdjustment: number;
  154649. /**
  154650. * Gets a string identifying the name of the class
  154651. * @returns "TonemapPostProcess" string
  154652. */
  154653. getClassName(): string;
  154654. /**
  154655. * Creates a new TonemapPostProcess
  154656. * @param name defines the name of the postprocess
  154657. * @param _operator defines the operator to use
  154658. * @param exposureAdjustment defines the required exposure adjustement
  154659. * @param camera defines the camera to use (can be null)
  154660. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  154661. * @param engine defines the hosting engine (can be ignore if camera is set)
  154662. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  154663. */
  154664. constructor(name: string, _operator: TonemappingOperator,
  154665. /** Defines the required exposure adjustement */
  154666. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  154667. }
  154668. }
  154669. declare module BABYLON {
  154670. /** @hidden */
  154671. export var volumetricLightScatteringPixelShader: {
  154672. name: string;
  154673. shader: string;
  154674. };
  154675. }
  154676. declare module BABYLON {
  154677. /** @hidden */
  154678. export var volumetricLightScatteringPassVertexShader: {
  154679. name: string;
  154680. shader: string;
  154681. };
  154682. }
  154683. declare module BABYLON {
  154684. /** @hidden */
  154685. export var volumetricLightScatteringPassPixelShader: {
  154686. name: string;
  154687. shader: string;
  154688. };
  154689. }
  154690. declare module BABYLON {
  154691. /**
  154692. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  154693. */
  154694. export class VolumetricLightScatteringPostProcess extends PostProcess {
  154695. private _volumetricLightScatteringPass;
  154696. private _volumetricLightScatteringRTT;
  154697. private _viewPort;
  154698. private _screenCoordinates;
  154699. private _cachedDefines;
  154700. /**
  154701. * If not undefined, the mesh position is computed from the attached node position
  154702. */
  154703. attachedNode: {
  154704. position: Vector3;
  154705. };
  154706. /**
  154707. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  154708. */
  154709. customMeshPosition: Vector3;
  154710. /**
  154711. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  154712. */
  154713. useCustomMeshPosition: boolean;
  154714. /**
  154715. * If the post-process should inverse the light scattering direction
  154716. */
  154717. invert: boolean;
  154718. /**
  154719. * The internal mesh used by the post-process
  154720. */
  154721. mesh: Mesh;
  154722. /**
  154723. * @hidden
  154724. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  154725. */
  154726. get useDiffuseColor(): boolean;
  154727. set useDiffuseColor(useDiffuseColor: boolean);
  154728. /**
  154729. * Array containing the excluded meshes not rendered in the internal pass
  154730. */
  154731. excludedMeshes: AbstractMesh[];
  154732. /**
  154733. * Controls the overall intensity of the post-process
  154734. */
  154735. exposure: number;
  154736. /**
  154737. * Dissipates each sample's contribution in range [0, 1]
  154738. */
  154739. decay: number;
  154740. /**
  154741. * Controls the overall intensity of each sample
  154742. */
  154743. weight: number;
  154744. /**
  154745. * Controls the density of each sample
  154746. */
  154747. density: number;
  154748. /**
  154749. * @constructor
  154750. * @param name The post-process name
  154751. * @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)
  154752. * @param camera The camera that the post-process will be attached to
  154753. * @param mesh The mesh used to create the light scattering
  154754. * @param samples The post-process quality, default 100
  154755. * @param samplingModeThe post-process filtering mode
  154756. * @param engine The babylon engine
  154757. * @param reusable If the post-process is reusable
  154758. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  154759. */
  154760. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  154761. /**
  154762. * Returns the string "VolumetricLightScatteringPostProcess"
  154763. * @returns "VolumetricLightScatteringPostProcess"
  154764. */
  154765. getClassName(): string;
  154766. private _isReady;
  154767. /**
  154768. * Sets the new light position for light scattering effect
  154769. * @param position The new custom light position
  154770. */
  154771. setCustomMeshPosition(position: Vector3): void;
  154772. /**
  154773. * Returns the light position for light scattering effect
  154774. * @return Vector3 The custom light position
  154775. */
  154776. getCustomMeshPosition(): Vector3;
  154777. /**
  154778. * Disposes the internal assets and detaches the post-process from the camera
  154779. */
  154780. dispose(camera: Camera): void;
  154781. /**
  154782. * Returns the render target texture used by the post-process
  154783. * @return the render target texture used by the post-process
  154784. */
  154785. getPass(): RenderTargetTexture;
  154786. private _meshExcluded;
  154787. private _createPass;
  154788. private _updateMeshScreenCoordinates;
  154789. /**
  154790. * Creates a default mesh for the Volumeric Light Scattering post-process
  154791. * @param name The mesh name
  154792. * @param scene The scene where to create the mesh
  154793. * @return the default mesh
  154794. */
  154795. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  154796. }
  154797. }
  154798. declare module BABYLON {
  154799. /** @hidden */
  154800. export var screenSpaceCurvaturePixelShader: {
  154801. name: string;
  154802. shader: string;
  154803. };
  154804. }
  154805. declare module BABYLON {
  154806. /**
  154807. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  154808. */
  154809. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  154810. /**
  154811. * Defines how much ridge the curvature effect displays.
  154812. */
  154813. ridge: number;
  154814. /**
  154815. * Defines how much valley the curvature effect displays.
  154816. */
  154817. valley: number;
  154818. private _geometryBufferRenderer;
  154819. /**
  154820. * Gets a string identifying the name of the class
  154821. * @returns "ScreenSpaceCurvaturePostProcess" string
  154822. */
  154823. getClassName(): string;
  154824. /**
  154825. * Creates a new instance ScreenSpaceCurvaturePostProcess
  154826. * @param name The name of the effect.
  154827. * @param scene The scene containing the objects to blur according to their velocity.
  154828. * @param options The required width/height ratio to downsize to before computing the render pass.
  154829. * @param camera The camera to apply the render pass to.
  154830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  154831. * @param engine The engine which the post process will be applied. (default: current engine)
  154832. * @param reusable If the post process can be reused on the same frame. (default: false)
  154833. * @param textureType Type of textures used when performing the post process. (default: 0)
  154834. * @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)
  154835. */
  154836. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  154837. /**
  154838. * Support test.
  154839. */
  154840. static get IsSupported(): boolean;
  154841. /** @hidden */
  154842. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  154843. }
  154844. }
  154845. declare module BABYLON {
  154846. interface Scene {
  154847. /** @hidden (Backing field) */
  154848. _boundingBoxRenderer: BoundingBoxRenderer;
  154849. /** @hidden (Backing field) */
  154850. _forceShowBoundingBoxes: boolean;
  154851. /**
  154852. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  154853. */
  154854. forceShowBoundingBoxes: boolean;
  154855. /**
  154856. * Gets the bounding box renderer associated with the scene
  154857. * @returns a BoundingBoxRenderer
  154858. */
  154859. getBoundingBoxRenderer(): BoundingBoxRenderer;
  154860. }
  154861. interface AbstractMesh {
  154862. /** @hidden (Backing field) */
  154863. _showBoundingBox: boolean;
  154864. /**
  154865. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  154866. */
  154867. showBoundingBox: boolean;
  154868. }
  154869. /**
  154870. * Component responsible of rendering the bounding box of the meshes in a scene.
  154871. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  154872. */
  154873. export class BoundingBoxRenderer implements ISceneComponent {
  154874. /**
  154875. * The component name helpfull to identify the component in the list of scene components.
  154876. */
  154877. readonly name: string;
  154878. /**
  154879. * The scene the component belongs to.
  154880. */
  154881. scene: Scene;
  154882. /**
  154883. * Color of the bounding box lines placed in front of an object
  154884. */
  154885. frontColor: Color3;
  154886. /**
  154887. * Color of the bounding box lines placed behind an object
  154888. */
  154889. backColor: Color3;
  154890. /**
  154891. * Defines if the renderer should show the back lines or not
  154892. */
  154893. showBackLines: boolean;
  154894. /**
  154895. * Observable raised before rendering a bounding box
  154896. */
  154897. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  154898. /**
  154899. * Observable raised after rendering a bounding box
  154900. */
  154901. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  154902. /**
  154903. * Observable raised after resources are created
  154904. */
  154905. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  154906. /**
  154907. * When false, no bounding boxes will be rendered
  154908. */
  154909. enabled: boolean;
  154910. /**
  154911. * @hidden
  154912. */
  154913. renderList: SmartArray<BoundingBox>;
  154914. private _colorShader;
  154915. private _vertexBuffers;
  154916. private _indexBuffer;
  154917. private _fillIndexBuffer;
  154918. private _fillIndexData;
  154919. /**
  154920. * Instantiates a new bounding box renderer in a scene.
  154921. * @param scene the scene the renderer renders in
  154922. */
  154923. constructor(scene: Scene);
  154924. /**
  154925. * Registers the component in a given scene
  154926. */
  154927. register(): void;
  154928. private _evaluateSubMesh;
  154929. private _preActiveMesh;
  154930. private _prepareResources;
  154931. private _createIndexBuffer;
  154932. /**
  154933. * Rebuilds the elements related to this component in case of
  154934. * context lost for instance.
  154935. */
  154936. rebuild(): void;
  154937. /**
  154938. * @hidden
  154939. */
  154940. reset(): void;
  154941. /**
  154942. * Render the bounding boxes of a specific rendering group
  154943. * @param renderingGroupId defines the rendering group to render
  154944. */
  154945. render(renderingGroupId: number): void;
  154946. /**
  154947. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154948. * @param mesh Define the mesh to render the occlusion bounding box for
  154949. */
  154950. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154951. /**
  154952. * Dispose and release the resources attached to this renderer.
  154953. */
  154954. dispose(): void;
  154955. }
  154956. }
  154957. declare module BABYLON {
  154958. interface Scene {
  154959. /** @hidden (Backing field) */
  154960. _depthRenderer: {
  154961. [id: string]: DepthRenderer;
  154962. };
  154963. /**
  154964. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154965. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154966. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154967. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154968. * @returns the created depth renderer
  154969. */
  154970. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154971. /**
  154972. * Disables a depth renderer for a given camera
  154973. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154974. */
  154975. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154976. }
  154977. /**
  154978. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154979. * in several rendering techniques.
  154980. */
  154981. export class DepthRendererSceneComponent implements ISceneComponent {
  154982. /**
  154983. * The component name helpfull to identify the component in the list of scene components.
  154984. */
  154985. readonly name: string;
  154986. /**
  154987. * The scene the component belongs to.
  154988. */
  154989. scene: Scene;
  154990. /**
  154991. * Creates a new instance of the component for the given scene
  154992. * @param scene Defines the scene to register the component in
  154993. */
  154994. constructor(scene: Scene);
  154995. /**
  154996. * Registers the component in a given scene
  154997. */
  154998. register(): void;
  154999. /**
  155000. * Rebuilds the elements related to this component in case of
  155001. * context lost for instance.
  155002. */
  155003. rebuild(): void;
  155004. /**
  155005. * Disposes the component and the associated ressources
  155006. */
  155007. dispose(): void;
  155008. private _gatherRenderTargets;
  155009. private _gatherActiveCameraRenderTargets;
  155010. }
  155011. }
  155012. declare module BABYLON {
  155013. interface AbstractScene {
  155014. /** @hidden (Backing field) */
  155015. _prePassRenderer: Nullable<PrePassRenderer>;
  155016. /**
  155017. * Gets or Sets the current prepass renderer associated to the scene.
  155018. */
  155019. prePassRenderer: Nullable<PrePassRenderer>;
  155020. /**
  155021. * Enables the prepass and associates it with the scene
  155022. * @returns the PrePassRenderer
  155023. */
  155024. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  155025. /**
  155026. * Disables the prepass associated with the scene
  155027. */
  155028. disablePrePassRenderer(): void;
  155029. }
  155030. /**
  155031. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  155032. * in several rendering techniques.
  155033. */
  155034. export class PrePassRendererSceneComponent implements ISceneComponent {
  155035. /**
  155036. * The component name helpful to identify the component in the list of scene components.
  155037. */
  155038. readonly name: string;
  155039. /**
  155040. * The scene the component belongs to.
  155041. */
  155042. scene: Scene;
  155043. /**
  155044. * Creates a new instance of the component for the given scene
  155045. * @param scene Defines the scene to register the component in
  155046. */
  155047. constructor(scene: Scene);
  155048. /**
  155049. * Registers the component in a given scene
  155050. */
  155051. register(): void;
  155052. private _beforeCameraDraw;
  155053. private _afterCameraDraw;
  155054. private _beforeClearStage;
  155055. private _beforeRenderingMeshStage;
  155056. private _afterRenderingMeshStage;
  155057. /**
  155058. * Rebuilds the elements related to this component in case of
  155059. * context lost for instance.
  155060. */
  155061. rebuild(): void;
  155062. /**
  155063. * Disposes the component and the associated ressources
  155064. */
  155065. dispose(): void;
  155066. }
  155067. }
  155068. declare module BABYLON {
  155069. /** @hidden */
  155070. export var fibonacci: {
  155071. name: string;
  155072. shader: string;
  155073. };
  155074. }
  155075. declare module BABYLON {
  155076. /** @hidden */
  155077. export var diffusionProfile: {
  155078. name: string;
  155079. shader: string;
  155080. };
  155081. }
  155082. declare module BABYLON {
  155083. /** @hidden */
  155084. export var subSurfaceScatteringPixelShader: {
  155085. name: string;
  155086. shader: string;
  155087. };
  155088. }
  155089. declare module BABYLON {
  155090. /**
  155091. * Sub surface scattering post process
  155092. */
  155093. export class SubSurfaceScatteringPostProcess extends PostProcess {
  155094. /**
  155095. * Gets a string identifying the name of the class
  155096. * @returns "SubSurfaceScatteringPostProcess" string
  155097. */
  155098. getClassName(): string;
  155099. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  155100. }
  155101. }
  155102. declare module BABYLON {
  155103. /**
  155104. * Contains all parameters needed for the prepass to perform
  155105. * screen space subsurface scattering
  155106. */
  155107. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  155108. /** @hidden */
  155109. static _SceneComponentInitialization: (scene: Scene) => void;
  155110. private _ssDiffusionS;
  155111. private _ssFilterRadii;
  155112. private _ssDiffusionD;
  155113. /**
  155114. * Post process to attach for screen space subsurface scattering
  155115. */
  155116. postProcess: SubSurfaceScatteringPostProcess;
  155117. /**
  155118. * Diffusion profile color for subsurface scattering
  155119. */
  155120. get ssDiffusionS(): number[];
  155121. /**
  155122. * Diffusion profile max color channel value for subsurface scattering
  155123. */
  155124. get ssDiffusionD(): number[];
  155125. /**
  155126. * Diffusion profile filter radius for subsurface scattering
  155127. */
  155128. get ssFilterRadii(): number[];
  155129. /**
  155130. * Is subsurface enabled
  155131. */
  155132. enabled: boolean;
  155133. /**
  155134. * Name of the configuration
  155135. */
  155136. name: string;
  155137. /**
  155138. * Diffusion profile colors for subsurface scattering
  155139. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  155140. * See ...
  155141. * Note that you can only store up to 5 of them
  155142. */
  155143. ssDiffusionProfileColors: Color3[];
  155144. /**
  155145. * Defines the ratio real world => scene units.
  155146. * Used for subsurface scattering
  155147. */
  155148. metersPerUnit: number;
  155149. /**
  155150. * Textures that should be present in the MRT for this effect to work
  155151. */
  155152. readonly texturesRequired: number[];
  155153. private _scene;
  155154. /**
  155155. * Builds a subsurface configuration object
  155156. * @param scene The scene
  155157. */
  155158. constructor(scene: Scene);
  155159. /**
  155160. * Adds a new diffusion profile.
  155161. * Useful for more realistic subsurface scattering on diverse materials.
  155162. * @param color The color of the diffusion profile. Should be the average color of the material.
  155163. * @return The index of the diffusion profile for the material subsurface configuration
  155164. */
  155165. addDiffusionProfile(color: Color3): number;
  155166. /**
  155167. * Creates the sss post process
  155168. * @return The created post process
  155169. */
  155170. createPostProcess(): SubSurfaceScatteringPostProcess;
  155171. /**
  155172. * Deletes all diffusion profiles.
  155173. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  155174. */
  155175. clearAllDiffusionProfiles(): void;
  155176. /**
  155177. * Disposes this object
  155178. */
  155179. dispose(): void;
  155180. /**
  155181. * @hidden
  155182. * https://zero-radiance.github.io/post/sampling-diffusion/
  155183. *
  155184. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  155185. * ------------------------------------------------------------------------------------
  155186. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  155187. * PDF[r, phi, s] = r * R[r, phi, s]
  155188. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  155189. * ------------------------------------------------------------------------------------
  155190. * We importance sample the color channel with the widest scattering distance.
  155191. */
  155192. getDiffusionProfileParameters(color: Color3): number;
  155193. /**
  155194. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  155195. * 'u' is the random number (the value of the CDF): [0, 1).
  155196. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  155197. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  155198. */
  155199. private _sampleBurleyDiffusionProfile;
  155200. }
  155201. }
  155202. declare module BABYLON {
  155203. interface AbstractScene {
  155204. /** @hidden (Backing field) */
  155205. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155206. /**
  155207. * Gets or Sets the current prepass renderer associated to the scene.
  155208. */
  155209. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  155210. /**
  155211. * Enables the subsurface effect for prepass
  155212. * @returns the SubSurfaceConfiguration
  155213. */
  155214. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  155215. /**
  155216. * Disables the subsurface effect for prepass
  155217. */
  155218. disableSubSurfaceForPrePass(): void;
  155219. }
  155220. /**
  155221. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  155222. * in several rendering techniques.
  155223. */
  155224. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  155225. /**
  155226. * The component name helpful to identify the component in the list of scene components.
  155227. */
  155228. readonly name: string;
  155229. /**
  155230. * The scene the component belongs to.
  155231. */
  155232. scene: Scene;
  155233. /**
  155234. * Creates a new instance of the component for the given scene
  155235. * @param scene Defines the scene to register the component in
  155236. */
  155237. constructor(scene: Scene);
  155238. /**
  155239. * Registers the component in a given scene
  155240. */
  155241. register(): void;
  155242. /**
  155243. * Serializes the component data to the specified json object
  155244. * @param serializationObject The object to serialize to
  155245. */
  155246. serialize(serializationObject: any): void;
  155247. /**
  155248. * Adds all the elements from the container to the scene
  155249. * @param container the container holding the elements
  155250. */
  155251. addFromContainer(container: AbstractScene): void;
  155252. /**
  155253. * Removes all the elements in the container from the scene
  155254. * @param container contains the elements to remove
  155255. * @param dispose if the removed element should be disposed (default: false)
  155256. */
  155257. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  155258. /**
  155259. * Rebuilds the elements related to this component in case of
  155260. * context lost for instance.
  155261. */
  155262. rebuild(): void;
  155263. /**
  155264. * Disposes the component and the associated ressources
  155265. */
  155266. dispose(): void;
  155267. }
  155268. }
  155269. declare module BABYLON {
  155270. /** @hidden */
  155271. export var outlinePixelShader: {
  155272. name: string;
  155273. shader: string;
  155274. };
  155275. }
  155276. declare module BABYLON {
  155277. /** @hidden */
  155278. export var outlineVertexShader: {
  155279. name: string;
  155280. shader: string;
  155281. };
  155282. }
  155283. declare module BABYLON {
  155284. interface Scene {
  155285. /** @hidden */
  155286. _outlineRenderer: OutlineRenderer;
  155287. /**
  155288. * Gets the outline renderer associated with the scene
  155289. * @returns a OutlineRenderer
  155290. */
  155291. getOutlineRenderer(): OutlineRenderer;
  155292. }
  155293. interface AbstractMesh {
  155294. /** @hidden (Backing field) */
  155295. _renderOutline: boolean;
  155296. /**
  155297. * Gets or sets a boolean indicating if the outline must be rendered as well
  155298. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  155299. */
  155300. renderOutline: boolean;
  155301. /** @hidden (Backing field) */
  155302. _renderOverlay: boolean;
  155303. /**
  155304. * Gets or sets a boolean indicating if the overlay must be rendered as well
  155305. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  155306. */
  155307. renderOverlay: boolean;
  155308. }
  155309. /**
  155310. * This class is responsible to draw bothe outline/overlay of meshes.
  155311. * It should not be used directly but through the available method on mesh.
  155312. */
  155313. export class OutlineRenderer implements ISceneComponent {
  155314. /**
  155315. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  155316. */
  155317. private static _StencilReference;
  155318. /**
  155319. * The name of the component. Each component must have a unique name.
  155320. */
  155321. name: string;
  155322. /**
  155323. * The scene the component belongs to.
  155324. */
  155325. scene: Scene;
  155326. /**
  155327. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  155328. */
  155329. zOffset: number;
  155330. private _engine;
  155331. private _effect;
  155332. private _cachedDefines;
  155333. private _savedDepthWrite;
  155334. /**
  155335. * Instantiates a new outline renderer. (There could be only one per scene).
  155336. * @param scene Defines the scene it belongs to
  155337. */
  155338. constructor(scene: Scene);
  155339. /**
  155340. * Register the component to one instance of a scene.
  155341. */
  155342. register(): void;
  155343. /**
  155344. * Rebuilds the elements related to this component in case of
  155345. * context lost for instance.
  155346. */
  155347. rebuild(): void;
  155348. /**
  155349. * Disposes the component and the associated ressources.
  155350. */
  155351. dispose(): void;
  155352. /**
  155353. * Renders the outline in the canvas.
  155354. * @param subMesh Defines the sumesh to render
  155355. * @param batch Defines the batch of meshes in case of instances
  155356. * @param useOverlay Defines if the rendering is for the overlay or the outline
  155357. */
  155358. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  155359. /**
  155360. * Returns whether or not the outline renderer is ready for a given submesh.
  155361. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  155362. * @param subMesh Defines the submesh to check readyness for
  155363. * @param useInstances Defines wheter wee are trying to render instances or not
  155364. * @returns true if ready otherwise false
  155365. */
  155366. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  155367. private _beforeRenderingMesh;
  155368. private _afterRenderingMesh;
  155369. }
  155370. }
  155371. declare module BABYLON {
  155372. /**
  155373. * Defines the basic options interface of a Sprite Frame Source Size.
  155374. */
  155375. export interface ISpriteJSONSpriteSourceSize {
  155376. /**
  155377. * number of the original width of the Frame
  155378. */
  155379. w: number;
  155380. /**
  155381. * number of the original height of the Frame
  155382. */
  155383. h: number;
  155384. }
  155385. /**
  155386. * Defines the basic options interface of a Sprite Frame Data.
  155387. */
  155388. export interface ISpriteJSONSpriteFrameData {
  155389. /**
  155390. * number of the x offset of the Frame
  155391. */
  155392. x: number;
  155393. /**
  155394. * number of the y offset of the Frame
  155395. */
  155396. y: number;
  155397. /**
  155398. * number of the width of the Frame
  155399. */
  155400. w: number;
  155401. /**
  155402. * number of the height of the Frame
  155403. */
  155404. h: number;
  155405. }
  155406. /**
  155407. * Defines the basic options interface of a JSON Sprite.
  155408. */
  155409. export interface ISpriteJSONSprite {
  155410. /**
  155411. * string name of the Frame
  155412. */
  155413. filename: string;
  155414. /**
  155415. * ISpriteJSONSpriteFrame basic object of the frame data
  155416. */
  155417. frame: ISpriteJSONSpriteFrameData;
  155418. /**
  155419. * boolean to flag is the frame was rotated.
  155420. */
  155421. rotated: boolean;
  155422. /**
  155423. * boolean to flag is the frame was trimmed.
  155424. */
  155425. trimmed: boolean;
  155426. /**
  155427. * ISpriteJSONSpriteFrame basic object of the source data
  155428. */
  155429. spriteSourceSize: ISpriteJSONSpriteFrameData;
  155430. /**
  155431. * ISpriteJSONSpriteFrame basic object of the source data
  155432. */
  155433. sourceSize: ISpriteJSONSpriteSourceSize;
  155434. }
  155435. /**
  155436. * Defines the basic options interface of a JSON atlas.
  155437. */
  155438. export interface ISpriteJSONAtlas {
  155439. /**
  155440. * Array of objects that contain the frame data.
  155441. */
  155442. frames: Array<ISpriteJSONSprite>;
  155443. /**
  155444. * object basic object containing the sprite meta data.
  155445. */
  155446. meta?: object;
  155447. }
  155448. }
  155449. declare module BABYLON {
  155450. /** @hidden */
  155451. export var spriteMapPixelShader: {
  155452. name: string;
  155453. shader: string;
  155454. };
  155455. }
  155456. declare module BABYLON {
  155457. /** @hidden */
  155458. export var spriteMapVertexShader: {
  155459. name: string;
  155460. shader: string;
  155461. };
  155462. }
  155463. declare module BABYLON {
  155464. /**
  155465. * Defines the basic options interface of a SpriteMap
  155466. */
  155467. export interface ISpriteMapOptions {
  155468. /**
  155469. * Vector2 of the number of cells in the grid.
  155470. */
  155471. stageSize?: Vector2;
  155472. /**
  155473. * Vector2 of the size of the output plane in World Units.
  155474. */
  155475. outputSize?: Vector2;
  155476. /**
  155477. * Vector3 of the position of the output plane in World Units.
  155478. */
  155479. outputPosition?: Vector3;
  155480. /**
  155481. * Vector3 of the rotation of the output plane.
  155482. */
  155483. outputRotation?: Vector3;
  155484. /**
  155485. * number of layers that the system will reserve in resources.
  155486. */
  155487. layerCount?: number;
  155488. /**
  155489. * number of max animation frames a single cell will reserve in resources.
  155490. */
  155491. maxAnimationFrames?: number;
  155492. /**
  155493. * number cell index of the base tile when the system compiles.
  155494. */
  155495. baseTile?: number;
  155496. /**
  155497. * boolean flip the sprite after its been repositioned by the framing data.
  155498. */
  155499. flipU?: boolean;
  155500. /**
  155501. * Vector3 scalar of the global RGB values of the SpriteMap.
  155502. */
  155503. colorMultiply?: Vector3;
  155504. }
  155505. /**
  155506. * Defines the IDisposable interface in order to be cleanable from resources.
  155507. */
  155508. export interface ISpriteMap extends IDisposable {
  155509. /**
  155510. * String name of the SpriteMap.
  155511. */
  155512. name: string;
  155513. /**
  155514. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  155515. */
  155516. atlasJSON: ISpriteJSONAtlas;
  155517. /**
  155518. * Texture of the SpriteMap.
  155519. */
  155520. spriteSheet: Texture;
  155521. /**
  155522. * The parameters to initialize the SpriteMap with.
  155523. */
  155524. options: ISpriteMapOptions;
  155525. }
  155526. /**
  155527. * Class used to manage a grid restricted sprite deployment on an Output plane.
  155528. */
  155529. export class SpriteMap implements ISpriteMap {
  155530. /** The Name of the spriteMap */
  155531. name: string;
  155532. /** The JSON file with the frame and meta data */
  155533. atlasJSON: ISpriteJSONAtlas;
  155534. /** The systems Sprite Sheet Texture */
  155535. spriteSheet: Texture;
  155536. /** Arguments passed with the Constructor */
  155537. options: ISpriteMapOptions;
  155538. /** Public Sprite Storage array, parsed from atlasJSON */
  155539. sprites: Array<ISpriteJSONSprite>;
  155540. /** Returns the Number of Sprites in the System */
  155541. get spriteCount(): number;
  155542. /** Returns the Position of Output Plane*/
  155543. get position(): Vector3;
  155544. /** Returns the Position of Output Plane*/
  155545. set position(v: Vector3);
  155546. /** Returns the Rotation of Output Plane*/
  155547. get rotation(): Vector3;
  155548. /** Returns the Rotation of Output Plane*/
  155549. set rotation(v: Vector3);
  155550. /** Sets the AnimationMap*/
  155551. get animationMap(): RawTexture;
  155552. /** Sets the AnimationMap*/
  155553. set animationMap(v: RawTexture);
  155554. /** Scene that the SpriteMap was created in */
  155555. private _scene;
  155556. /** Texture Buffer of Float32 that holds tile frame data*/
  155557. private _frameMap;
  155558. /** Texture Buffers of Float32 that holds tileMap data*/
  155559. private _tileMaps;
  155560. /** Texture Buffer of Float32 that holds Animation Data*/
  155561. private _animationMap;
  155562. /** Custom ShaderMaterial Central to the System*/
  155563. private _material;
  155564. /** Custom ShaderMaterial Central to the System*/
  155565. private _output;
  155566. /** Systems Time Ticker*/
  155567. private _time;
  155568. /**
  155569. * Creates a new SpriteMap
  155570. * @param name defines the SpriteMaps Name
  155571. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  155572. * @param spriteSheet is the Texture that the Sprites are on.
  155573. * @param options a basic deployment configuration
  155574. * @param scene The Scene that the map is deployed on
  155575. */
  155576. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  155577. /**
  155578. * Returns tileID location
  155579. * @returns Vector2 the cell position ID
  155580. */
  155581. getTileID(): Vector2;
  155582. /**
  155583. * Gets the UV location of the mouse over the SpriteMap.
  155584. * @returns Vector2 the UV position of the mouse interaction
  155585. */
  155586. getMousePosition(): Vector2;
  155587. /**
  155588. * Creates the "frame" texture Buffer
  155589. * -------------------------------------
  155590. * Structure of frames
  155591. * "filename": "Falling-Water-2.png",
  155592. * "frame": {"x":69,"y":103,"w":24,"h":32},
  155593. * "rotated": true,
  155594. * "trimmed": true,
  155595. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  155596. * "sourceSize": {"w":32,"h":32}
  155597. * @returns RawTexture of the frameMap
  155598. */
  155599. private _createFrameBuffer;
  155600. /**
  155601. * Creates the tileMap texture Buffer
  155602. * @param buffer normally and array of numbers, or a false to generate from scratch
  155603. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  155604. * @returns RawTexture of the tileMap
  155605. */
  155606. private _createTileBuffer;
  155607. /**
  155608. * Modifies the data of the tileMaps
  155609. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  155610. * @param pos is the iVector2 Coordinates of the Tile
  155611. * @param tile The SpriteIndex of the new Tile
  155612. */
  155613. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  155614. /**
  155615. * Creates the animationMap texture Buffer
  155616. * @param buffer normally and array of numbers, or a false to generate from scratch
  155617. * @returns RawTexture of the animationMap
  155618. */
  155619. private _createTileAnimationBuffer;
  155620. /**
  155621. * Modifies the data of the animationMap
  155622. * @param cellID is the Index of the Sprite
  155623. * @param _frame is the target Animation frame
  155624. * @param toCell is the Target Index of the next frame of the animation
  155625. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  155626. * @param speed is a global scalar of the time variable on the map.
  155627. */
  155628. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  155629. /**
  155630. * Exports the .tilemaps file
  155631. */
  155632. saveTileMaps(): void;
  155633. /**
  155634. * Imports the .tilemaps file
  155635. * @param url of the .tilemaps file
  155636. */
  155637. loadTileMaps(url: string): void;
  155638. /**
  155639. * Release associated resources
  155640. */
  155641. dispose(): void;
  155642. }
  155643. }
  155644. declare module BABYLON {
  155645. /**
  155646. * Class used to manage multiple sprites of different sizes on the same spritesheet
  155647. * @see https://doc.babylonjs.com/babylon101/sprites
  155648. */
  155649. export class SpritePackedManager extends SpriteManager {
  155650. /** defines the packed manager's name */
  155651. name: string;
  155652. /**
  155653. * Creates a new sprite manager from a packed sprite sheet
  155654. * @param name defines the manager's name
  155655. * @param imgUrl defines the sprite sheet url
  155656. * @param capacity defines the maximum allowed number of sprites
  155657. * @param scene defines the hosting scene
  155658. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  155659. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  155660. * @param samplingMode defines the smapling mode to use with spritesheet
  155661. * @param fromPacked set to true; do not alter
  155662. */
  155663. constructor(
  155664. /** defines the packed manager's name */
  155665. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  155666. }
  155667. }
  155668. declare module BABYLON {
  155669. /**
  155670. * Defines the list of states available for a task inside a AssetsManager
  155671. */
  155672. export enum AssetTaskState {
  155673. /**
  155674. * Initialization
  155675. */
  155676. INIT = 0,
  155677. /**
  155678. * Running
  155679. */
  155680. RUNNING = 1,
  155681. /**
  155682. * Done
  155683. */
  155684. DONE = 2,
  155685. /**
  155686. * Error
  155687. */
  155688. ERROR = 3
  155689. }
  155690. /**
  155691. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  155692. */
  155693. export abstract class AbstractAssetTask {
  155694. /**
  155695. * Task name
  155696. */ name: string;
  155697. /**
  155698. * Callback called when the task is successful
  155699. */
  155700. onSuccess: (task: any) => void;
  155701. /**
  155702. * Callback called when the task is not successful
  155703. */
  155704. onError: (task: any, message?: string, exception?: any) => void;
  155705. /**
  155706. * Creates a new AssetsManager
  155707. * @param name defines the name of the task
  155708. */
  155709. constructor(
  155710. /**
  155711. * Task name
  155712. */ name: string);
  155713. private _isCompleted;
  155714. private _taskState;
  155715. private _errorObject;
  155716. /**
  155717. * Get if the task is completed
  155718. */
  155719. get isCompleted(): boolean;
  155720. /**
  155721. * Gets the current state of the task
  155722. */
  155723. get taskState(): AssetTaskState;
  155724. /**
  155725. * Gets the current error object (if task is in error)
  155726. */
  155727. get errorObject(): {
  155728. message?: string;
  155729. exception?: any;
  155730. };
  155731. /**
  155732. * Internal only
  155733. * @hidden
  155734. */
  155735. _setErrorObject(message?: string, exception?: any): void;
  155736. /**
  155737. * Execute the current task
  155738. * @param scene defines the scene where you want your assets to be loaded
  155739. * @param onSuccess is a callback called when the task is successfully executed
  155740. * @param onError is a callback called if an error occurs
  155741. */
  155742. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155743. /**
  155744. * Execute the current task
  155745. * @param scene defines the scene where you want your assets to be loaded
  155746. * @param onSuccess is a callback called when the task is successfully executed
  155747. * @param onError is a callback called if an error occurs
  155748. */
  155749. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155750. /**
  155751. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  155752. * This can be used with failed tasks that have the reason for failure fixed.
  155753. */
  155754. reset(): void;
  155755. private onErrorCallback;
  155756. private onDoneCallback;
  155757. }
  155758. /**
  155759. * Define the interface used by progress events raised during assets loading
  155760. */
  155761. export interface IAssetsProgressEvent {
  155762. /**
  155763. * Defines the number of remaining tasks to process
  155764. */
  155765. remainingCount: number;
  155766. /**
  155767. * Defines the total number of tasks
  155768. */
  155769. totalCount: number;
  155770. /**
  155771. * Defines the task that was just processed
  155772. */
  155773. task: AbstractAssetTask;
  155774. }
  155775. /**
  155776. * Class used to share progress information about assets loading
  155777. */
  155778. export class AssetsProgressEvent implements IAssetsProgressEvent {
  155779. /**
  155780. * Defines the number of remaining tasks to process
  155781. */
  155782. remainingCount: number;
  155783. /**
  155784. * Defines the total number of tasks
  155785. */
  155786. totalCount: number;
  155787. /**
  155788. * Defines the task that was just processed
  155789. */
  155790. task: AbstractAssetTask;
  155791. /**
  155792. * Creates a AssetsProgressEvent
  155793. * @param remainingCount defines the number of remaining tasks to process
  155794. * @param totalCount defines the total number of tasks
  155795. * @param task defines the task that was just processed
  155796. */
  155797. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  155798. }
  155799. /**
  155800. * Define a task used by AssetsManager to load assets into a container
  155801. */
  155802. export class ContainerAssetTask extends AbstractAssetTask {
  155803. /**
  155804. * Defines the name of the task
  155805. */
  155806. name: string;
  155807. /**
  155808. * Defines the list of mesh's names you want to load
  155809. */
  155810. meshesNames: any;
  155811. /**
  155812. * Defines the root url to use as a base to load your meshes and associated resources
  155813. */
  155814. rootUrl: string;
  155815. /**
  155816. * Defines the filename or File of the scene to load from
  155817. */
  155818. sceneFilename: string | File;
  155819. /**
  155820. * Get the loaded asset container
  155821. */
  155822. loadedContainer: AssetContainer;
  155823. /**
  155824. * Gets the list of loaded meshes
  155825. */
  155826. loadedMeshes: Array<AbstractMesh>;
  155827. /**
  155828. * Gets the list of loaded particle systems
  155829. */
  155830. loadedParticleSystems: Array<IParticleSystem>;
  155831. /**
  155832. * Gets the list of loaded skeletons
  155833. */
  155834. loadedSkeletons: Array<Skeleton>;
  155835. /**
  155836. * Gets the list of loaded animation groups
  155837. */
  155838. loadedAnimationGroups: Array<AnimationGroup>;
  155839. /**
  155840. * Callback called when the task is successful
  155841. */
  155842. onSuccess: (task: ContainerAssetTask) => void;
  155843. /**
  155844. * Callback called when the task is successful
  155845. */
  155846. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  155847. /**
  155848. * Creates a new ContainerAssetTask
  155849. * @param name defines the name of the task
  155850. * @param meshesNames defines the list of mesh's names you want to load
  155851. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155852. * @param sceneFilename defines the filename or File of the scene to load from
  155853. */
  155854. constructor(
  155855. /**
  155856. * Defines the name of the task
  155857. */
  155858. name: string,
  155859. /**
  155860. * Defines the list of mesh's names you want to load
  155861. */
  155862. meshesNames: any,
  155863. /**
  155864. * Defines the root url to use as a base to load your meshes and associated resources
  155865. */
  155866. rootUrl: string,
  155867. /**
  155868. * Defines the filename or File of the scene to load from
  155869. */
  155870. sceneFilename: string | File);
  155871. /**
  155872. * Execute the current task
  155873. * @param scene defines the scene where you want your assets to be loaded
  155874. * @param onSuccess is a callback called when the task is successfully executed
  155875. * @param onError is a callback called if an error occurs
  155876. */
  155877. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155878. }
  155879. /**
  155880. * Define a task used by AssetsManager to load meshes
  155881. */
  155882. export class MeshAssetTask extends AbstractAssetTask {
  155883. /**
  155884. * Defines the name of the task
  155885. */
  155886. name: string;
  155887. /**
  155888. * Defines the list of mesh's names you want to load
  155889. */
  155890. meshesNames: any;
  155891. /**
  155892. * Defines the root url to use as a base to load your meshes and associated resources
  155893. */
  155894. rootUrl: string;
  155895. /**
  155896. * Defines the filename or File of the scene to load from
  155897. */
  155898. sceneFilename: string | File;
  155899. /**
  155900. * Gets the list of loaded meshes
  155901. */
  155902. loadedMeshes: Array<AbstractMesh>;
  155903. /**
  155904. * Gets the list of loaded particle systems
  155905. */
  155906. loadedParticleSystems: Array<IParticleSystem>;
  155907. /**
  155908. * Gets the list of loaded skeletons
  155909. */
  155910. loadedSkeletons: Array<Skeleton>;
  155911. /**
  155912. * Gets the list of loaded animation groups
  155913. */
  155914. loadedAnimationGroups: Array<AnimationGroup>;
  155915. /**
  155916. * Callback called when the task is successful
  155917. */
  155918. onSuccess: (task: MeshAssetTask) => void;
  155919. /**
  155920. * Callback called when the task is successful
  155921. */
  155922. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  155923. /**
  155924. * Creates a new MeshAssetTask
  155925. * @param name defines the name of the task
  155926. * @param meshesNames defines the list of mesh's names you want to load
  155927. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  155928. * @param sceneFilename defines the filename or File of the scene to load from
  155929. */
  155930. constructor(
  155931. /**
  155932. * Defines the name of the task
  155933. */
  155934. name: string,
  155935. /**
  155936. * Defines the list of mesh's names you want to load
  155937. */
  155938. meshesNames: any,
  155939. /**
  155940. * Defines the root url to use as a base to load your meshes and associated resources
  155941. */
  155942. rootUrl: string,
  155943. /**
  155944. * Defines the filename or File of the scene to load from
  155945. */
  155946. sceneFilename: string | File);
  155947. /**
  155948. * Execute the current task
  155949. * @param scene defines the scene where you want your assets to be loaded
  155950. * @param onSuccess is a callback called when the task is successfully executed
  155951. * @param onError is a callback called if an error occurs
  155952. */
  155953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155954. }
  155955. /**
  155956. * Define a task used by AssetsManager to load text content
  155957. */
  155958. export class TextFileAssetTask extends AbstractAssetTask {
  155959. /**
  155960. * Defines the name of the task
  155961. */
  155962. name: string;
  155963. /**
  155964. * Defines the location of the file to load
  155965. */
  155966. url: string;
  155967. /**
  155968. * Gets the loaded text string
  155969. */
  155970. text: string;
  155971. /**
  155972. * Callback called when the task is successful
  155973. */
  155974. onSuccess: (task: TextFileAssetTask) => void;
  155975. /**
  155976. * Callback called when the task is successful
  155977. */
  155978. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155979. /**
  155980. * Creates a new TextFileAssetTask object
  155981. * @param name defines the name of the task
  155982. * @param url defines the location of the file to load
  155983. */
  155984. constructor(
  155985. /**
  155986. * Defines the name of the task
  155987. */
  155988. name: string,
  155989. /**
  155990. * Defines the location of the file to load
  155991. */
  155992. url: string);
  155993. /**
  155994. * Execute the current task
  155995. * @param scene defines the scene where you want your assets to be loaded
  155996. * @param onSuccess is a callback called when the task is successfully executed
  155997. * @param onError is a callback called if an error occurs
  155998. */
  155999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156000. }
  156001. /**
  156002. * Define a task used by AssetsManager to load binary data
  156003. */
  156004. export class BinaryFileAssetTask extends AbstractAssetTask {
  156005. /**
  156006. * Defines the name of the task
  156007. */
  156008. name: string;
  156009. /**
  156010. * Defines the location of the file to load
  156011. */
  156012. url: string;
  156013. /**
  156014. * Gets the lodaded data (as an array buffer)
  156015. */
  156016. data: ArrayBuffer;
  156017. /**
  156018. * Callback called when the task is successful
  156019. */
  156020. onSuccess: (task: BinaryFileAssetTask) => void;
  156021. /**
  156022. * Callback called when the task is successful
  156023. */
  156024. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  156025. /**
  156026. * Creates a new BinaryFileAssetTask object
  156027. * @param name defines the name of the new task
  156028. * @param url defines the location of the file to load
  156029. */
  156030. constructor(
  156031. /**
  156032. * Defines the name of the task
  156033. */
  156034. name: string,
  156035. /**
  156036. * Defines the location of the file to load
  156037. */
  156038. url: string);
  156039. /**
  156040. * Execute the current task
  156041. * @param scene defines the scene where you want your assets to be loaded
  156042. * @param onSuccess is a callback called when the task is successfully executed
  156043. * @param onError is a callback called if an error occurs
  156044. */
  156045. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156046. }
  156047. /**
  156048. * Define a task used by AssetsManager to load images
  156049. */
  156050. export class ImageAssetTask extends AbstractAssetTask {
  156051. /**
  156052. * Defines the name of the task
  156053. */
  156054. name: string;
  156055. /**
  156056. * Defines the location of the image to load
  156057. */
  156058. url: string;
  156059. /**
  156060. * Gets the loaded images
  156061. */
  156062. image: HTMLImageElement;
  156063. /**
  156064. * Callback called when the task is successful
  156065. */
  156066. onSuccess: (task: ImageAssetTask) => void;
  156067. /**
  156068. * Callback called when the task is successful
  156069. */
  156070. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  156071. /**
  156072. * Creates a new ImageAssetTask
  156073. * @param name defines the name of the task
  156074. * @param url defines the location of the image to load
  156075. */
  156076. constructor(
  156077. /**
  156078. * Defines the name of the task
  156079. */
  156080. name: string,
  156081. /**
  156082. * Defines the location of the image to load
  156083. */
  156084. url: string);
  156085. /**
  156086. * Execute the current task
  156087. * @param scene defines the scene where you want your assets to be loaded
  156088. * @param onSuccess is a callback called when the task is successfully executed
  156089. * @param onError is a callback called if an error occurs
  156090. */
  156091. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156092. }
  156093. /**
  156094. * Defines the interface used by texture loading tasks
  156095. */
  156096. export interface ITextureAssetTask<TEX extends BaseTexture> {
  156097. /**
  156098. * Gets the loaded texture
  156099. */
  156100. texture: TEX;
  156101. }
  156102. /**
  156103. * Define a task used by AssetsManager to load 2D textures
  156104. */
  156105. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  156106. /**
  156107. * Defines the name of the task
  156108. */
  156109. name: string;
  156110. /**
  156111. * Defines the location of the file to load
  156112. */
  156113. url: string;
  156114. /**
  156115. * Defines if mipmap should not be generated (default is false)
  156116. */
  156117. noMipmap?: boolean | undefined;
  156118. /**
  156119. * Defines if texture must be inverted on Y axis (default is true)
  156120. */
  156121. invertY: boolean;
  156122. /**
  156123. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156124. */
  156125. samplingMode: number;
  156126. /**
  156127. * Gets the loaded texture
  156128. */
  156129. texture: Texture;
  156130. /**
  156131. * Callback called when the task is successful
  156132. */
  156133. onSuccess: (task: TextureAssetTask) => void;
  156134. /**
  156135. * Callback called when the task is successful
  156136. */
  156137. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  156138. /**
  156139. * Creates a new TextureAssetTask object
  156140. * @param name defines the name of the task
  156141. * @param url defines the location of the file to load
  156142. * @param noMipmap defines if mipmap should not be generated (default is false)
  156143. * @param invertY defines if texture must be inverted on Y axis (default is true)
  156144. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156145. */
  156146. constructor(
  156147. /**
  156148. * Defines the name of the task
  156149. */
  156150. name: string,
  156151. /**
  156152. * Defines the location of the file to load
  156153. */
  156154. url: string,
  156155. /**
  156156. * Defines if mipmap should not be generated (default is false)
  156157. */
  156158. noMipmap?: boolean | undefined,
  156159. /**
  156160. * Defines if texture must be inverted on Y axis (default is true)
  156161. */
  156162. invertY?: boolean,
  156163. /**
  156164. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  156165. */
  156166. samplingMode?: number);
  156167. /**
  156168. * Execute the current task
  156169. * @param scene defines the scene where you want your assets to be loaded
  156170. * @param onSuccess is a callback called when the task is successfully executed
  156171. * @param onError is a callback called if an error occurs
  156172. */
  156173. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156174. }
  156175. /**
  156176. * Define a task used by AssetsManager to load cube textures
  156177. */
  156178. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  156179. /**
  156180. * Defines the name of the task
  156181. */
  156182. name: string;
  156183. /**
  156184. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156185. */
  156186. url: string;
  156187. /**
  156188. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156189. */
  156190. extensions?: string[] | undefined;
  156191. /**
  156192. * Defines if mipmaps should not be generated (default is false)
  156193. */
  156194. noMipmap?: boolean | undefined;
  156195. /**
  156196. * Defines the explicit list of files (undefined by default)
  156197. */
  156198. files?: string[] | undefined;
  156199. /**
  156200. * Gets the loaded texture
  156201. */
  156202. texture: CubeTexture;
  156203. /**
  156204. * Callback called when the task is successful
  156205. */
  156206. onSuccess: (task: CubeTextureAssetTask) => void;
  156207. /**
  156208. * Callback called when the task is successful
  156209. */
  156210. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  156211. /**
  156212. * Creates a new CubeTextureAssetTask
  156213. * @param name defines the name of the task
  156214. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156215. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156216. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156217. * @param files defines the explicit list of files (undefined by default)
  156218. */
  156219. constructor(
  156220. /**
  156221. * Defines the name of the task
  156222. */
  156223. name: string,
  156224. /**
  156225. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  156226. */
  156227. url: string,
  156228. /**
  156229. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  156230. */
  156231. extensions?: string[] | undefined,
  156232. /**
  156233. * Defines if mipmaps should not be generated (default is false)
  156234. */
  156235. noMipmap?: boolean | undefined,
  156236. /**
  156237. * Defines the explicit list of files (undefined by default)
  156238. */
  156239. files?: string[] | undefined);
  156240. /**
  156241. * Execute the current task
  156242. * @param scene defines the scene where you want your assets to be loaded
  156243. * @param onSuccess is a callback called when the task is successfully executed
  156244. * @param onError is a callback called if an error occurs
  156245. */
  156246. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156247. }
  156248. /**
  156249. * Define a task used by AssetsManager to load HDR cube textures
  156250. */
  156251. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  156252. /**
  156253. * Defines the name of the task
  156254. */
  156255. name: string;
  156256. /**
  156257. * Defines the location of the file to load
  156258. */
  156259. url: string;
  156260. /**
  156261. * Defines the desired size (the more it increases the longer the generation will be)
  156262. */
  156263. size: number;
  156264. /**
  156265. * Defines if mipmaps should not be generated (default is false)
  156266. */
  156267. noMipmap: boolean;
  156268. /**
  156269. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156270. */
  156271. generateHarmonics: boolean;
  156272. /**
  156273. * 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)
  156274. */
  156275. gammaSpace: boolean;
  156276. /**
  156277. * Internal Use Only
  156278. */
  156279. reserved: boolean;
  156280. /**
  156281. * Gets the loaded texture
  156282. */
  156283. texture: HDRCubeTexture;
  156284. /**
  156285. * Callback called when the task is successful
  156286. */
  156287. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  156288. /**
  156289. * Callback called when the task is successful
  156290. */
  156291. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  156292. /**
  156293. * Creates a new HDRCubeTextureAssetTask object
  156294. * @param name defines the name of the task
  156295. * @param url defines the location of the file to load
  156296. * @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.
  156297. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156298. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156299. * @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)
  156300. * @param reserved Internal use only
  156301. */
  156302. constructor(
  156303. /**
  156304. * Defines the name of the task
  156305. */
  156306. name: string,
  156307. /**
  156308. * Defines the location of the file to load
  156309. */
  156310. url: string,
  156311. /**
  156312. * Defines the desired size (the more it increases the longer the generation will be)
  156313. */
  156314. size: number,
  156315. /**
  156316. * Defines if mipmaps should not be generated (default is false)
  156317. */
  156318. noMipmap?: boolean,
  156319. /**
  156320. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  156321. */
  156322. generateHarmonics?: boolean,
  156323. /**
  156324. * 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)
  156325. */
  156326. gammaSpace?: boolean,
  156327. /**
  156328. * Internal Use Only
  156329. */
  156330. reserved?: boolean);
  156331. /**
  156332. * Execute the current task
  156333. * @param scene defines the scene where you want your assets to be loaded
  156334. * @param onSuccess is a callback called when the task is successfully executed
  156335. * @param onError is a callback called if an error occurs
  156336. */
  156337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156338. }
  156339. /**
  156340. * Define a task used by AssetsManager to load Equirectangular cube textures
  156341. */
  156342. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  156343. /**
  156344. * Defines the name of the task
  156345. */
  156346. name: string;
  156347. /**
  156348. * Defines the location of the file to load
  156349. */
  156350. url: string;
  156351. /**
  156352. * Defines the desired size (the more it increases the longer the generation will be)
  156353. */
  156354. size: number;
  156355. /**
  156356. * Defines if mipmaps should not be generated (default is false)
  156357. */
  156358. noMipmap: boolean;
  156359. /**
  156360. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156361. * but the standard material would require them in Gamma space) (default is true)
  156362. */
  156363. gammaSpace: boolean;
  156364. /**
  156365. * Gets the loaded texture
  156366. */
  156367. texture: EquiRectangularCubeTexture;
  156368. /**
  156369. * Callback called when the task is successful
  156370. */
  156371. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  156372. /**
  156373. * Callback called when the task is successful
  156374. */
  156375. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  156376. /**
  156377. * Creates a new EquiRectangularCubeTextureAssetTask object
  156378. * @param name defines the name of the task
  156379. * @param url defines the location of the file to load
  156380. * @param size defines the desired size (the more it increases the longer the generation will be)
  156381. * If the size is omitted this implies you are using a preprocessed cubemap.
  156382. * @param noMipmap defines if mipmaps should not be generated (default is false)
  156383. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  156384. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  156385. * (default is true)
  156386. */
  156387. constructor(
  156388. /**
  156389. * Defines the name of the task
  156390. */
  156391. name: string,
  156392. /**
  156393. * Defines the location of the file to load
  156394. */
  156395. url: string,
  156396. /**
  156397. * Defines the desired size (the more it increases the longer the generation will be)
  156398. */
  156399. size: number,
  156400. /**
  156401. * Defines if mipmaps should not be generated (default is false)
  156402. */
  156403. noMipmap?: boolean,
  156404. /**
  156405. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  156406. * but the standard material would require them in Gamma space) (default is true)
  156407. */
  156408. gammaSpace?: boolean);
  156409. /**
  156410. * Execute the current task
  156411. * @param scene defines the scene where you want your assets to be loaded
  156412. * @param onSuccess is a callback called when the task is successfully executed
  156413. * @param onError is a callback called if an error occurs
  156414. */
  156415. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  156416. }
  156417. /**
  156418. * This class can be used to easily import assets into a scene
  156419. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  156420. */
  156421. export class AssetsManager {
  156422. private _scene;
  156423. private _isLoading;
  156424. protected _tasks: AbstractAssetTask[];
  156425. protected _waitingTasksCount: number;
  156426. protected _totalTasksCount: number;
  156427. /**
  156428. * Callback called when all tasks are processed
  156429. */
  156430. onFinish: (tasks: AbstractAssetTask[]) => void;
  156431. /**
  156432. * Callback called when a task is successful
  156433. */
  156434. onTaskSuccess: (task: AbstractAssetTask) => void;
  156435. /**
  156436. * Callback called when a task had an error
  156437. */
  156438. onTaskError: (task: AbstractAssetTask) => void;
  156439. /**
  156440. * Callback called when a task is done (whatever the result is)
  156441. */
  156442. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  156443. /**
  156444. * Observable called when all tasks are processed
  156445. */
  156446. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  156447. /**
  156448. * Observable called when a task had an error
  156449. */
  156450. onTaskErrorObservable: Observable<AbstractAssetTask>;
  156451. /**
  156452. * Observable called when all tasks were executed
  156453. */
  156454. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  156455. /**
  156456. * Observable called when a task is done (whatever the result is)
  156457. */
  156458. onProgressObservable: Observable<IAssetsProgressEvent>;
  156459. /**
  156460. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  156461. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  156462. */
  156463. useDefaultLoadingScreen: boolean;
  156464. /**
  156465. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  156466. * when all assets have been downloaded.
  156467. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  156468. */
  156469. autoHideLoadingUI: boolean;
  156470. /**
  156471. * Creates a new AssetsManager
  156472. * @param scene defines the scene to work on
  156473. */
  156474. constructor(scene: Scene);
  156475. /**
  156476. * Add a ContainerAssetTask to the list of active tasks
  156477. * @param taskName defines the name of the new task
  156478. * @param meshesNames defines the name of meshes to load
  156479. * @param rootUrl defines the root url to use to locate files
  156480. * @param sceneFilename defines the filename of the scene file
  156481. * @returns a new ContainerAssetTask object
  156482. */
  156483. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  156484. /**
  156485. * Add a MeshAssetTask to the list of active tasks
  156486. * @param taskName defines the name of the new task
  156487. * @param meshesNames defines the name of meshes to load
  156488. * @param rootUrl defines the root url to use to locate files
  156489. * @param sceneFilename defines the filename of the scene file
  156490. * @returns a new MeshAssetTask object
  156491. */
  156492. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  156493. /**
  156494. * Add a TextFileAssetTask to the list of active tasks
  156495. * @param taskName defines the name of the new task
  156496. * @param url defines the url of the file to load
  156497. * @returns a new TextFileAssetTask object
  156498. */
  156499. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  156500. /**
  156501. * Add a BinaryFileAssetTask to the list of active tasks
  156502. * @param taskName defines the name of the new task
  156503. * @param url defines the url of the file to load
  156504. * @returns a new BinaryFileAssetTask object
  156505. */
  156506. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  156507. /**
  156508. * Add a ImageAssetTask to the list of active tasks
  156509. * @param taskName defines the name of the new task
  156510. * @param url defines the url of the file to load
  156511. * @returns a new ImageAssetTask object
  156512. */
  156513. addImageTask(taskName: string, url: string): ImageAssetTask;
  156514. /**
  156515. * Add a TextureAssetTask to the list of active tasks
  156516. * @param taskName defines the name of the new task
  156517. * @param url defines the url of the file to load
  156518. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156519. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  156520. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  156521. * @returns a new TextureAssetTask object
  156522. */
  156523. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  156524. /**
  156525. * Add a CubeTextureAssetTask to the list of active tasks
  156526. * @param taskName defines the name of the new task
  156527. * @param url defines the url of the file to load
  156528. * @param extensions defines the extension to use to load the cube map (can be null)
  156529. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156530. * @param files defines the list of files to load (can be null)
  156531. * @returns a new CubeTextureAssetTask object
  156532. */
  156533. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  156534. /**
  156535. *
  156536. * Add a HDRCubeTextureAssetTask to the list of active tasks
  156537. * @param taskName defines the name of the new task
  156538. * @param url defines the url of the file to load
  156539. * @param size defines the size you want for the cubemap (can be null)
  156540. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156541. * @param generateHarmonics defines if you want to automatically generate (true by default)
  156542. * @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)
  156543. * @param reserved Internal use only
  156544. * @returns a new HDRCubeTextureAssetTask object
  156545. */
  156546. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  156547. /**
  156548. *
  156549. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  156550. * @param taskName defines the name of the new task
  156551. * @param url defines the url of the file to load
  156552. * @param size defines the size you want for the cubemap (can be null)
  156553. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  156554. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  156555. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  156556. * @returns a new EquiRectangularCubeTextureAssetTask object
  156557. */
  156558. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  156559. /**
  156560. * Remove a task from the assets manager.
  156561. * @param task the task to remove
  156562. */
  156563. removeTask(task: AbstractAssetTask): void;
  156564. private _decreaseWaitingTasksCount;
  156565. private _runTask;
  156566. /**
  156567. * Reset the AssetsManager and remove all tasks
  156568. * @return the current instance of the AssetsManager
  156569. */
  156570. reset(): AssetsManager;
  156571. /**
  156572. * Start the loading process
  156573. * @return the current instance of the AssetsManager
  156574. */
  156575. load(): AssetsManager;
  156576. /**
  156577. * Start the loading process as an async operation
  156578. * @return a promise returning the list of failed tasks
  156579. */
  156580. loadAsync(): Promise<void>;
  156581. }
  156582. }
  156583. declare module BABYLON {
  156584. /**
  156585. * Wrapper class for promise with external resolve and reject.
  156586. */
  156587. export class Deferred<T> {
  156588. /**
  156589. * The promise associated with this deferred object.
  156590. */
  156591. readonly promise: Promise<T>;
  156592. private _resolve;
  156593. private _reject;
  156594. /**
  156595. * The resolve method of the promise associated with this deferred object.
  156596. */
  156597. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  156598. /**
  156599. * The reject method of the promise associated with this deferred object.
  156600. */
  156601. get reject(): (reason?: any) => void;
  156602. /**
  156603. * Constructor for this deferred object.
  156604. */
  156605. constructor();
  156606. }
  156607. }
  156608. declare module BABYLON {
  156609. /**
  156610. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  156611. */
  156612. export class MeshExploder {
  156613. private _centerMesh;
  156614. private _meshes;
  156615. private _meshesOrigins;
  156616. private _toCenterVectors;
  156617. private _scaledDirection;
  156618. private _newPosition;
  156619. private _centerPosition;
  156620. /**
  156621. * Explodes meshes from a center mesh.
  156622. * @param meshes The meshes to explode.
  156623. * @param centerMesh The mesh to be center of explosion.
  156624. */
  156625. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  156626. private _setCenterMesh;
  156627. /**
  156628. * Get class name
  156629. * @returns "MeshExploder"
  156630. */
  156631. getClassName(): string;
  156632. /**
  156633. * "Exploded meshes"
  156634. * @returns Array of meshes with the centerMesh at index 0.
  156635. */
  156636. getMeshes(): Array<Mesh>;
  156637. /**
  156638. * Explodes meshes giving a specific direction
  156639. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  156640. */
  156641. explode(direction?: number): void;
  156642. }
  156643. }
  156644. declare module BABYLON {
  156645. /**
  156646. * Class used to help managing file picking and drag'n'drop
  156647. */
  156648. export class FilesInput {
  156649. /**
  156650. * List of files ready to be loaded
  156651. */
  156652. static get FilesToLoad(): {
  156653. [key: string]: File;
  156654. };
  156655. /**
  156656. * Callback called when a file is processed
  156657. */
  156658. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  156659. private _engine;
  156660. private _currentScene;
  156661. private _sceneLoadedCallback;
  156662. private _progressCallback;
  156663. private _additionalRenderLoopLogicCallback;
  156664. private _textureLoadingCallback;
  156665. private _startingProcessingFilesCallback;
  156666. private _onReloadCallback;
  156667. private _errorCallback;
  156668. private _elementToMonitor;
  156669. private _sceneFileToLoad;
  156670. private _filesToLoad;
  156671. /**
  156672. * Creates a new FilesInput
  156673. * @param engine defines the rendering engine
  156674. * @param scene defines the hosting scene
  156675. * @param sceneLoadedCallback callback called when scene is loaded
  156676. * @param progressCallback callback called to track progress
  156677. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  156678. * @param textureLoadingCallback callback called when a texture is loading
  156679. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  156680. * @param onReloadCallback callback called when a reload is requested
  156681. * @param errorCallback callback call if an error occurs
  156682. */
  156683. 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>);
  156684. private _dragEnterHandler;
  156685. private _dragOverHandler;
  156686. private _dropHandler;
  156687. /**
  156688. * Calls this function to listen to drag'n'drop events on a specific DOM element
  156689. * @param elementToMonitor defines the DOM element to track
  156690. */
  156691. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  156692. /** Gets the current list of files to load */
  156693. get filesToLoad(): File[];
  156694. /**
  156695. * Release all associated resources
  156696. */
  156697. dispose(): void;
  156698. private renderFunction;
  156699. private drag;
  156700. private drop;
  156701. private _traverseFolder;
  156702. private _processFiles;
  156703. /**
  156704. * Load files from a drop event
  156705. * @param event defines the drop event to use as source
  156706. */
  156707. loadFiles(event: any): void;
  156708. private _processReload;
  156709. /**
  156710. * Reload the current scene from the loaded files
  156711. */
  156712. reload(): void;
  156713. }
  156714. }
  156715. declare module BABYLON {
  156716. /**
  156717. * Defines the root class used to create scene optimization to use with SceneOptimizer
  156718. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156719. */
  156720. export class SceneOptimization {
  156721. /**
  156722. * Defines the priority of this optimization (0 by default which means first in the list)
  156723. */
  156724. priority: number;
  156725. /**
  156726. * Gets a string describing the action executed by the current optimization
  156727. * @returns description string
  156728. */
  156729. getDescription(): string;
  156730. /**
  156731. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156732. * @param scene defines the current scene where to apply this optimization
  156733. * @param optimizer defines the current optimizer
  156734. * @returns true if everything that can be done was applied
  156735. */
  156736. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156737. /**
  156738. * Creates the SceneOptimization object
  156739. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156740. * @param desc defines the description associated with the optimization
  156741. */
  156742. constructor(
  156743. /**
  156744. * Defines the priority of this optimization (0 by default which means first in the list)
  156745. */
  156746. priority?: number);
  156747. }
  156748. /**
  156749. * Defines an optimization used to reduce the size of render target textures
  156750. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156751. */
  156752. export class TextureOptimization extends SceneOptimization {
  156753. /**
  156754. * Defines the priority of this optimization (0 by default which means first in the list)
  156755. */
  156756. priority: number;
  156757. /**
  156758. * 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
  156759. */
  156760. maximumSize: number;
  156761. /**
  156762. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156763. */
  156764. step: number;
  156765. /**
  156766. * Gets a string describing the action executed by the current optimization
  156767. * @returns description string
  156768. */
  156769. getDescription(): string;
  156770. /**
  156771. * Creates the TextureOptimization object
  156772. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156773. * @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
  156774. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156775. */
  156776. constructor(
  156777. /**
  156778. * Defines the priority of this optimization (0 by default which means first in the list)
  156779. */
  156780. priority?: number,
  156781. /**
  156782. * 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
  156783. */
  156784. maximumSize?: number,
  156785. /**
  156786. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  156787. */
  156788. step?: number);
  156789. /**
  156790. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156791. * @param scene defines the current scene where to apply this optimization
  156792. * @param optimizer defines the current optimizer
  156793. * @returns true if everything that can be done was applied
  156794. */
  156795. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156796. }
  156797. /**
  156798. * Defines an optimization used to increase or decrease the rendering resolution
  156799. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156800. */
  156801. export class HardwareScalingOptimization extends SceneOptimization {
  156802. /**
  156803. * Defines the priority of this optimization (0 by default which means first in the list)
  156804. */
  156805. priority: number;
  156806. /**
  156807. * Defines the maximum scale to use (2 by default)
  156808. */
  156809. maximumScale: number;
  156810. /**
  156811. * Defines the step to use between two passes (0.5 by default)
  156812. */
  156813. step: number;
  156814. private _currentScale;
  156815. private _directionOffset;
  156816. /**
  156817. * Gets a string describing the action executed by the current optimization
  156818. * @return description string
  156819. */
  156820. getDescription(): string;
  156821. /**
  156822. * Creates the HardwareScalingOptimization object
  156823. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156824. * @param maximumScale defines the maximum scale to use (2 by default)
  156825. * @param step defines the step to use between two passes (0.5 by default)
  156826. */
  156827. constructor(
  156828. /**
  156829. * Defines the priority of this optimization (0 by default which means first in the list)
  156830. */
  156831. priority?: number,
  156832. /**
  156833. * Defines the maximum scale to use (2 by default)
  156834. */
  156835. maximumScale?: number,
  156836. /**
  156837. * Defines the step to use between two passes (0.5 by default)
  156838. */
  156839. step?: number);
  156840. /**
  156841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156842. * @param scene defines the current scene where to apply this optimization
  156843. * @param optimizer defines the current optimizer
  156844. * @returns true if everything that can be done was applied
  156845. */
  156846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156847. }
  156848. /**
  156849. * Defines an optimization used to remove shadows
  156850. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156851. */
  156852. export class ShadowsOptimization extends SceneOptimization {
  156853. /**
  156854. * Gets a string describing the action executed by the current optimization
  156855. * @return description string
  156856. */
  156857. getDescription(): string;
  156858. /**
  156859. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156860. * @param scene defines the current scene where to apply this optimization
  156861. * @param optimizer defines the current optimizer
  156862. * @returns true if everything that can be done was applied
  156863. */
  156864. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156865. }
  156866. /**
  156867. * Defines an optimization used to turn post-processes off
  156868. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156869. */
  156870. export class PostProcessesOptimization extends SceneOptimization {
  156871. /**
  156872. * Gets a string describing the action executed by the current optimization
  156873. * @return description string
  156874. */
  156875. getDescription(): string;
  156876. /**
  156877. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156878. * @param scene defines the current scene where to apply this optimization
  156879. * @param optimizer defines the current optimizer
  156880. * @returns true if everything that can be done was applied
  156881. */
  156882. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156883. }
  156884. /**
  156885. * Defines an optimization used to turn lens flares off
  156886. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156887. */
  156888. export class LensFlaresOptimization extends SceneOptimization {
  156889. /**
  156890. * Gets a string describing the action executed by the current optimization
  156891. * @return description string
  156892. */
  156893. getDescription(): string;
  156894. /**
  156895. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156896. * @param scene defines the current scene where to apply this optimization
  156897. * @param optimizer defines the current optimizer
  156898. * @returns true if everything that can be done was applied
  156899. */
  156900. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156901. }
  156902. /**
  156903. * Defines an optimization based on user defined callback.
  156904. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156905. */
  156906. export class CustomOptimization extends SceneOptimization {
  156907. /**
  156908. * Callback called to apply the custom optimization.
  156909. */
  156910. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  156911. /**
  156912. * Callback called to get custom description
  156913. */
  156914. onGetDescription: () => string;
  156915. /**
  156916. * Gets a string describing the action executed by the current optimization
  156917. * @returns description string
  156918. */
  156919. getDescription(): string;
  156920. /**
  156921. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156922. * @param scene defines the current scene where to apply this optimization
  156923. * @param optimizer defines the current optimizer
  156924. * @returns true if everything that can be done was applied
  156925. */
  156926. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156927. }
  156928. /**
  156929. * Defines an optimization used to turn particles off
  156930. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156931. */
  156932. export class ParticlesOptimization extends SceneOptimization {
  156933. /**
  156934. * Gets a string describing the action executed by the current optimization
  156935. * @return description string
  156936. */
  156937. getDescription(): string;
  156938. /**
  156939. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156940. * @param scene defines the current scene where to apply this optimization
  156941. * @param optimizer defines the current optimizer
  156942. * @returns true if everything that can be done was applied
  156943. */
  156944. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156945. }
  156946. /**
  156947. * Defines an optimization used to turn render targets off
  156948. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156949. */
  156950. export class RenderTargetsOptimization extends SceneOptimization {
  156951. /**
  156952. * Gets a string describing the action executed by the current optimization
  156953. * @return description string
  156954. */
  156955. getDescription(): string;
  156956. /**
  156957. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156958. * @param scene defines the current scene where to apply this optimization
  156959. * @param optimizer defines the current optimizer
  156960. * @returns true if everything that can be done was applied
  156961. */
  156962. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156963. }
  156964. /**
  156965. * Defines an optimization used to merge meshes with compatible materials
  156966. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156967. */
  156968. export class MergeMeshesOptimization extends SceneOptimization {
  156969. private static _UpdateSelectionTree;
  156970. /**
  156971. * Gets or sets a boolean which defines if optimization octree has to be updated
  156972. */
  156973. static get UpdateSelectionTree(): boolean;
  156974. /**
  156975. * Gets or sets a boolean which defines if optimization octree has to be updated
  156976. */
  156977. static set UpdateSelectionTree(value: boolean);
  156978. /**
  156979. * Gets a string describing the action executed by the current optimization
  156980. * @return description string
  156981. */
  156982. getDescription(): string;
  156983. private _canBeMerged;
  156984. /**
  156985. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156986. * @param scene defines the current scene where to apply this optimization
  156987. * @param optimizer defines the current optimizer
  156988. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156989. * @returns true if everything that can be done was applied
  156990. */
  156991. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156992. }
  156993. /**
  156994. * Defines a list of options used by SceneOptimizer
  156995. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156996. */
  156997. export class SceneOptimizerOptions {
  156998. /**
  156999. * Defines the target frame rate to reach (60 by default)
  157000. */
  157001. targetFrameRate: number;
  157002. /**
  157003. * Defines the interval between two checkes (2000ms by default)
  157004. */
  157005. trackerDuration: number;
  157006. /**
  157007. * Gets the list of optimizations to apply
  157008. */
  157009. optimizations: SceneOptimization[];
  157010. /**
  157011. * Creates a new list of options used by SceneOptimizer
  157012. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  157013. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  157014. */
  157015. constructor(
  157016. /**
  157017. * Defines the target frame rate to reach (60 by default)
  157018. */
  157019. targetFrameRate?: number,
  157020. /**
  157021. * Defines the interval between two checkes (2000ms by default)
  157022. */
  157023. trackerDuration?: number);
  157024. /**
  157025. * Add a new optimization
  157026. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  157027. * @returns the current SceneOptimizerOptions
  157028. */
  157029. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  157030. /**
  157031. * Add a new custom optimization
  157032. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  157033. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  157034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  157035. * @returns the current SceneOptimizerOptions
  157036. */
  157037. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  157038. /**
  157039. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  157040. * @param targetFrameRate defines the target frame rate (60 by default)
  157041. * @returns a SceneOptimizerOptions object
  157042. */
  157043. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157044. /**
  157045. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  157046. * @param targetFrameRate defines the target frame rate (60 by default)
  157047. * @returns a SceneOptimizerOptions object
  157048. */
  157049. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157050. /**
  157051. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  157052. * @param targetFrameRate defines the target frame rate (60 by default)
  157053. * @returns a SceneOptimizerOptions object
  157054. */
  157055. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  157056. }
  157057. /**
  157058. * Class used to run optimizations in order to reach a target frame rate
  157059. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  157060. */
  157061. export class SceneOptimizer implements IDisposable {
  157062. private _isRunning;
  157063. private _options;
  157064. private _scene;
  157065. private _currentPriorityLevel;
  157066. private _targetFrameRate;
  157067. private _trackerDuration;
  157068. private _currentFrameRate;
  157069. private _sceneDisposeObserver;
  157070. private _improvementMode;
  157071. /**
  157072. * Defines an observable called when the optimizer reaches the target frame rate
  157073. */
  157074. onSuccessObservable: Observable<SceneOptimizer>;
  157075. /**
  157076. * Defines an observable called when the optimizer enables an optimization
  157077. */
  157078. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  157079. /**
  157080. * Defines an observable called when the optimizer is not able to reach the target frame rate
  157081. */
  157082. onFailureObservable: Observable<SceneOptimizer>;
  157083. /**
  157084. * Gets a boolean indicating if the optimizer is in improvement mode
  157085. */
  157086. get isInImprovementMode(): boolean;
  157087. /**
  157088. * Gets the current priority level (0 at start)
  157089. */
  157090. get currentPriorityLevel(): number;
  157091. /**
  157092. * Gets the current frame rate checked by the SceneOptimizer
  157093. */
  157094. get currentFrameRate(): number;
  157095. /**
  157096. * Gets or sets the current target frame rate (60 by default)
  157097. */
  157098. get targetFrameRate(): number;
  157099. /**
  157100. * Gets or sets the current target frame rate (60 by default)
  157101. */
  157102. set targetFrameRate(value: number);
  157103. /**
  157104. * Gets or sets the current interval between two checks (every 2000ms by default)
  157105. */
  157106. get trackerDuration(): number;
  157107. /**
  157108. * Gets or sets the current interval between two checks (every 2000ms by default)
  157109. */
  157110. set trackerDuration(value: number);
  157111. /**
  157112. * Gets the list of active optimizations
  157113. */
  157114. get optimizations(): SceneOptimization[];
  157115. /**
  157116. * Creates a new SceneOptimizer
  157117. * @param scene defines the scene to work on
  157118. * @param options defines the options to use with the SceneOptimizer
  157119. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  157120. * @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)
  157121. */
  157122. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  157123. /**
  157124. * Stops the current optimizer
  157125. */
  157126. stop(): void;
  157127. /**
  157128. * Reset the optimizer to initial step (current priority level = 0)
  157129. */
  157130. reset(): void;
  157131. /**
  157132. * Start the optimizer. By default it will try to reach a specific framerate
  157133. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  157134. */
  157135. start(): void;
  157136. private _checkCurrentState;
  157137. /**
  157138. * Release all resources
  157139. */
  157140. dispose(): void;
  157141. /**
  157142. * Helper function to create a SceneOptimizer with one single line of code
  157143. * @param scene defines the scene to work on
  157144. * @param options defines the options to use with the SceneOptimizer
  157145. * @param onSuccess defines a callback to call on success
  157146. * @param onFailure defines a callback to call on failure
  157147. * @returns the new SceneOptimizer object
  157148. */
  157149. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  157150. }
  157151. }
  157152. declare module BABYLON {
  157153. /**
  157154. * Class used to serialize a scene into a string
  157155. */
  157156. export class SceneSerializer {
  157157. /**
  157158. * Clear cache used by a previous serialization
  157159. */
  157160. static ClearCache(): void;
  157161. /**
  157162. * Serialize a scene into a JSON compatible object
  157163. * @param scene defines the scene to serialize
  157164. * @returns a JSON compatible object
  157165. */
  157166. static Serialize(scene: Scene): any;
  157167. /**
  157168. * Serialize a mesh into a JSON compatible object
  157169. * @param toSerialize defines the mesh to serialize
  157170. * @param withParents defines if parents must be serialized as well
  157171. * @param withChildren defines if children must be serialized as well
  157172. * @returns a JSON compatible object
  157173. */
  157174. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  157175. }
  157176. }
  157177. declare module BABYLON {
  157178. /**
  157179. * Class used to host texture specific utilities
  157180. */
  157181. export class TextureTools {
  157182. /**
  157183. * Uses the GPU to create a copy texture rescaled at a given size
  157184. * @param texture Texture to copy from
  157185. * @param width defines the desired width
  157186. * @param height defines the desired height
  157187. * @param useBilinearMode defines if bilinear mode has to be used
  157188. * @return the generated texture
  157189. */
  157190. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  157191. }
  157192. }
  157193. declare module BABYLON {
  157194. /**
  157195. * This represents the different options available for the video capture.
  157196. */
  157197. export interface VideoRecorderOptions {
  157198. /** Defines the mime type of the video. */
  157199. mimeType: string;
  157200. /** Defines the FPS the video should be recorded at. */
  157201. fps: number;
  157202. /** Defines the chunk size for the recording data. */
  157203. recordChunckSize: number;
  157204. /** The audio tracks to attach to the recording. */
  157205. audioTracks?: MediaStreamTrack[];
  157206. }
  157207. /**
  157208. * This can help with recording videos from BabylonJS.
  157209. * This is based on the available WebRTC functionalities of the browser.
  157210. *
  157211. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  157212. */
  157213. export class VideoRecorder {
  157214. private static readonly _defaultOptions;
  157215. /**
  157216. * Returns whether or not the VideoRecorder is available in your browser.
  157217. * @param engine Defines the Babylon Engine.
  157218. * @returns true if supported otherwise false.
  157219. */
  157220. static IsSupported(engine: Engine): boolean;
  157221. private readonly _options;
  157222. private _canvas;
  157223. private _mediaRecorder;
  157224. private _recordedChunks;
  157225. private _fileName;
  157226. private _resolve;
  157227. private _reject;
  157228. /**
  157229. * True when a recording is already in progress.
  157230. */
  157231. get isRecording(): boolean;
  157232. /**
  157233. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  157234. * @param engine Defines the BabylonJS Engine you wish to record.
  157235. * @param options Defines options that can be used to customize the capture.
  157236. */
  157237. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  157238. /**
  157239. * Stops the current recording before the default capture timeout passed in the startRecording function.
  157240. */
  157241. stopRecording(): void;
  157242. /**
  157243. * Starts recording the canvas for a max duration specified in parameters.
  157244. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  157245. * If null no automatic download will start and you can rely on the promise to get the data back.
  157246. * @param maxDuration Defines the maximum recording time in seconds.
  157247. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  157248. * @return A promise callback at the end of the recording with the video data in Blob.
  157249. */
  157250. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  157251. /**
  157252. * Releases internal resources used during the recording.
  157253. */
  157254. dispose(): void;
  157255. private _handleDataAvailable;
  157256. private _handleError;
  157257. private _handleStop;
  157258. }
  157259. }
  157260. declare module BABYLON {
  157261. /**
  157262. * Class containing a set of static utilities functions for screenshots
  157263. */
  157264. export class ScreenshotTools {
  157265. /**
  157266. * Captures a screenshot of the current rendering
  157267. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157268. * @param engine defines the rendering engine
  157269. * @param camera defines the source camera
  157270. * @param size This parameter can be set to a single number or to an object with the
  157271. * following (optional) properties: precision, width, height. If a single number is passed,
  157272. * it will be used for both width and height. If an object is passed, the screenshot size
  157273. * will be derived from the parameters. The precision property is a multiplier allowing
  157274. * rendering at a higher or lower resolution
  157275. * @param successCallback defines the callback receives a single parameter which contains the
  157276. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157277. * src parameter of an <img> to display it
  157278. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157279. * Check your browser for supported MIME types
  157280. */
  157281. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  157282. /**
  157283. * Captures a screenshot of the current rendering
  157284. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157285. * @param engine defines the rendering engine
  157286. * @param camera defines the source camera
  157287. * @param size This parameter can be set to a single number or to an object with the
  157288. * following (optional) properties: precision, width, height. If a single number is passed,
  157289. * it will be used for both width and height. If an object is passed, the screenshot size
  157290. * will be derived from the parameters. The precision property is a multiplier allowing
  157291. * rendering at a higher or lower resolution
  157292. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  157293. * Check your browser for supported MIME types
  157294. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157295. * to the src parameter of an <img> to display it
  157296. */
  157297. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  157298. /**
  157299. * Generates an image screenshot from the specified camera.
  157300. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157301. * @param engine The engine to use for rendering
  157302. * @param camera The camera to use for rendering
  157303. * @param size This parameter can be set to a single number or to an object with the
  157304. * following (optional) properties: precision, width, height. If a single number is passed,
  157305. * it will be used for both width and height. If an object is passed, the screenshot size
  157306. * will be derived from the parameters. The precision property is a multiplier allowing
  157307. * rendering at a higher or lower resolution
  157308. * @param successCallback The callback receives a single parameter which contains the
  157309. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  157310. * src parameter of an <img> to display it
  157311. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157312. * Check your browser for supported MIME types
  157313. * @param samples Texture samples (default: 1)
  157314. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157315. * @param fileName A name for for the downloaded file.
  157316. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157317. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  157318. */
  157319. 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;
  157320. /**
  157321. * Generates an image screenshot from the specified camera.
  157322. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  157323. * @param engine The engine to use for rendering
  157324. * @param camera The camera to use for rendering
  157325. * @param size This parameter can be set to a single number or to an object with the
  157326. * following (optional) properties: precision, width, height. If a single number is passed,
  157327. * it will be used for both width and height. If an object is passed, the screenshot size
  157328. * will be derived from the parameters. The precision property is a multiplier allowing
  157329. * rendering at a higher or lower resolution
  157330. * @param mimeType The MIME type of the screenshot image (default: image/png).
  157331. * Check your browser for supported MIME types
  157332. * @param samples Texture samples (default: 1)
  157333. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  157334. * @param fileName A name for for the downloaded file.
  157335. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  157336. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  157337. * to the src parameter of an <img> to display it
  157338. */
  157339. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  157340. /**
  157341. * Gets height and width for screenshot size
  157342. * @private
  157343. */
  157344. private static _getScreenshotSize;
  157345. }
  157346. }
  157347. declare module BABYLON {
  157348. /**
  157349. * Interface for a data buffer
  157350. */
  157351. export interface IDataBuffer {
  157352. /**
  157353. * Reads bytes from the data buffer.
  157354. * @param byteOffset The byte offset to read
  157355. * @param byteLength The byte length to read
  157356. * @returns A promise that resolves when the bytes are read
  157357. */
  157358. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  157359. /**
  157360. * The byte length of the buffer.
  157361. */
  157362. readonly byteLength: number;
  157363. }
  157364. /**
  157365. * Utility class for reading from a data buffer
  157366. */
  157367. export class DataReader {
  157368. /**
  157369. * The data buffer associated with this data reader.
  157370. */
  157371. readonly buffer: IDataBuffer;
  157372. /**
  157373. * The current byte offset from the beginning of the data buffer.
  157374. */
  157375. byteOffset: number;
  157376. private _dataView;
  157377. private _dataByteOffset;
  157378. /**
  157379. * Constructor
  157380. * @param buffer The buffer to read
  157381. */
  157382. constructor(buffer: IDataBuffer);
  157383. /**
  157384. * Loads the given byte length.
  157385. * @param byteLength The byte length to load
  157386. * @returns A promise that resolves when the load is complete
  157387. */
  157388. loadAsync(byteLength: number): Promise<void>;
  157389. /**
  157390. * Read a unsigned 32-bit integer from the currently loaded data range.
  157391. * @returns The 32-bit integer read
  157392. */
  157393. readUint32(): number;
  157394. /**
  157395. * Read a byte array from the currently loaded data range.
  157396. * @param byteLength The byte length to read
  157397. * @returns The byte array read
  157398. */
  157399. readUint8Array(byteLength: number): Uint8Array;
  157400. /**
  157401. * Read a string from the currently loaded data range.
  157402. * @param byteLength The byte length to read
  157403. * @returns The string read
  157404. */
  157405. readString(byteLength: number): string;
  157406. /**
  157407. * Skips the given byte length the currently loaded data range.
  157408. * @param byteLength The byte length to skip
  157409. */
  157410. skipBytes(byteLength: number): void;
  157411. }
  157412. }
  157413. declare module BABYLON {
  157414. /**
  157415. * Class for storing data to local storage if available or in-memory storage otherwise
  157416. */
  157417. export class DataStorage {
  157418. private static _Storage;
  157419. private static _GetStorage;
  157420. /**
  157421. * Reads a string from the data storage
  157422. * @param key The key to read
  157423. * @param defaultValue The value if the key doesn't exist
  157424. * @returns The string value
  157425. */
  157426. static ReadString(key: string, defaultValue: string): string;
  157427. /**
  157428. * Writes a string to the data storage
  157429. * @param key The key to write
  157430. * @param value The value to write
  157431. */
  157432. static WriteString(key: string, value: string): void;
  157433. /**
  157434. * Reads a boolean from the data storage
  157435. * @param key The key to read
  157436. * @param defaultValue The value if the key doesn't exist
  157437. * @returns The boolean value
  157438. */
  157439. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  157440. /**
  157441. * Writes a boolean to the data storage
  157442. * @param key The key to write
  157443. * @param value The value to write
  157444. */
  157445. static WriteBoolean(key: string, value: boolean): void;
  157446. /**
  157447. * Reads a number from the data storage
  157448. * @param key The key to read
  157449. * @param defaultValue The value if the key doesn't exist
  157450. * @returns The number value
  157451. */
  157452. static ReadNumber(key: string, defaultValue: number): number;
  157453. /**
  157454. * Writes a number to the data storage
  157455. * @param key The key to write
  157456. * @param value The value to write
  157457. */
  157458. static WriteNumber(key: string, value: number): void;
  157459. }
  157460. }
  157461. declare module BABYLON {
  157462. /**
  157463. * Class used to record delta files between 2 scene states
  157464. */
  157465. export class SceneRecorder {
  157466. private _trackedScene;
  157467. private _savedJSON;
  157468. /**
  157469. * Track a given scene. This means the current scene state will be considered the original state
  157470. * @param scene defines the scene to track
  157471. */
  157472. track(scene: Scene): void;
  157473. /**
  157474. * Get the delta between current state and original state
  157475. * @returns a string containing the delta
  157476. */
  157477. getDelta(): any;
  157478. private _compareArray;
  157479. private _compareObjects;
  157480. private _compareCollections;
  157481. private static GetShadowGeneratorById;
  157482. /**
  157483. * Apply a given delta to a given scene
  157484. * @param deltaJSON defines the JSON containing the delta
  157485. * @param scene defines the scene to apply the delta to
  157486. */
  157487. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  157488. private static _ApplyPropertiesToEntity;
  157489. private static _ApplyDeltaForEntity;
  157490. }
  157491. }
  157492. declare module BABYLON {
  157493. /**
  157494. * A 3D trajectory consisting of an order list of vectors describing a
  157495. * path of motion through 3D space.
  157496. */
  157497. export class Trajectory {
  157498. private _points;
  157499. private readonly _segmentLength;
  157500. /**
  157501. * Serialize to JSON.
  157502. * @returns serialized JSON string
  157503. */
  157504. serialize(): string;
  157505. /**
  157506. * Deserialize from JSON.
  157507. * @param json serialized JSON string
  157508. * @returns deserialized Trajectory
  157509. */
  157510. static Deserialize(json: string): Trajectory;
  157511. /**
  157512. * Create a new empty Trajectory.
  157513. * @param segmentLength radius of discretization for Trajectory points
  157514. */
  157515. constructor(segmentLength?: number);
  157516. /**
  157517. * Get the length of the Trajectory.
  157518. * @returns length of the Trajectory
  157519. */
  157520. getLength(): number;
  157521. /**
  157522. * Append a new point to the Trajectory.
  157523. * NOTE: This implementation has many allocations.
  157524. * @param point point to append to the Trajectory
  157525. */
  157526. add(point: DeepImmutable<Vector3>): void;
  157527. /**
  157528. * Create a new Trajectory with a segment length chosen to make it
  157529. * probable that the new Trajectory will have a specified number of
  157530. * segments. This operation is imprecise.
  157531. * @param targetResolution number of segments desired
  157532. * @returns new Trajectory with approximately the requested number of segments
  157533. */
  157534. resampleAtTargetResolution(targetResolution: number): Trajectory;
  157535. /**
  157536. * Convert Trajectory segments into tokenized representation. This
  157537. * representation is an array of numbers where each nth number is the
  157538. * index of the token which is most similar to the nth segment of the
  157539. * Trajectory.
  157540. * @param tokens list of vectors which serve as discrete tokens
  157541. * @returns list of indices of most similar token per segment
  157542. */
  157543. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  157544. private static _forwardDir;
  157545. private static _inverseFromVec;
  157546. private static _upDir;
  157547. private static _fromToVec;
  157548. private static _lookMatrix;
  157549. /**
  157550. * Transform the rotation (i.e., direction) of a segment to isolate
  157551. * the relative transformation represented by the segment. This operation
  157552. * may or may not succeed due to singularities in the equations that define
  157553. * motion relativity in this context.
  157554. * @param priorVec the origin of the prior segment
  157555. * @param fromVec the origin of the current segment
  157556. * @param toVec the destination of the current segment
  157557. * @param result reference to output variable
  157558. * @returns whether or not transformation was successful
  157559. */
  157560. private static _transformSegmentDirToRef;
  157561. private static _bestMatch;
  157562. private static _score;
  157563. private static _bestScore;
  157564. /**
  157565. * Determine which token vector is most similar to the
  157566. * segment vector.
  157567. * @param segment segment vector
  157568. * @param tokens token vector list
  157569. * @returns index of the most similar token to the segment
  157570. */
  157571. private static _tokenizeSegment;
  157572. }
  157573. /**
  157574. * Class representing a set of known, named trajectories to which Trajectories can be
  157575. * added and using which Trajectories can be recognized.
  157576. */
  157577. export class TrajectoryClassifier {
  157578. private _maximumAllowableMatchCost;
  157579. private _vector3Alphabet;
  157580. private _levenshteinAlphabet;
  157581. private _nameToDescribedTrajectory;
  157582. /**
  157583. * Serialize to JSON.
  157584. * @returns JSON serialization
  157585. */
  157586. serialize(): string;
  157587. /**
  157588. * Deserialize from JSON.
  157589. * @param json JSON serialization
  157590. * @returns deserialized TrajectorySet
  157591. */
  157592. static Deserialize(json: string): TrajectoryClassifier;
  157593. /**
  157594. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  157595. * VERY naive, need to be generating these things from known
  157596. * sets. Better version later, probably eliminating this one.
  157597. * @returns auto-generated TrajectorySet
  157598. */
  157599. static Generate(): TrajectoryClassifier;
  157600. private constructor();
  157601. /**
  157602. * Add a new Trajectory to the set with a given name.
  157603. * @param trajectory new Trajectory to be added
  157604. * @param classification name to which to add the Trajectory
  157605. */
  157606. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  157607. /**
  157608. * Remove a known named trajectory and all Trajectories associated with it.
  157609. * @param classification name to remove
  157610. * @returns whether anything was removed
  157611. */
  157612. deleteClassification(classification: string): boolean;
  157613. /**
  157614. * Attempt to recognize a Trajectory from among all the classifications
  157615. * already known to the classifier.
  157616. * @param trajectory Trajectory to be recognized
  157617. * @returns classification of Trajectory if recognized, null otherwise
  157618. */
  157619. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  157620. }
  157621. }
  157622. declare module BABYLON {
  157623. /**
  157624. * An interface for all Hit test features
  157625. */
  157626. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  157627. /**
  157628. * Triggered when new babylon (transformed) hit test results are available
  157629. */
  157630. onHitTestResultObservable: Observable<T[]>;
  157631. }
  157632. /**
  157633. * Options used for hit testing
  157634. */
  157635. export interface IWebXRLegacyHitTestOptions {
  157636. /**
  157637. * Only test when user interacted with the scene. Default - hit test every frame
  157638. */
  157639. testOnPointerDownOnly?: boolean;
  157640. /**
  157641. * The node to use to transform the local results to world coordinates
  157642. */
  157643. worldParentNode?: TransformNode;
  157644. }
  157645. /**
  157646. * Interface defining the babylon result of raycasting/hit-test
  157647. */
  157648. export interface IWebXRLegacyHitResult {
  157649. /**
  157650. * Transformation matrix that can be applied to a node that will put it in the hit point location
  157651. */
  157652. transformationMatrix: Matrix;
  157653. /**
  157654. * The native hit test result
  157655. */
  157656. xrHitResult: XRHitResult | XRHitTestResult;
  157657. }
  157658. /**
  157659. * The currently-working hit-test module.
  157660. * Hit test (or Ray-casting) is used to interact with the real world.
  157661. * For further information read here - https://github.com/immersive-web/hit-test
  157662. */
  157663. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  157664. /**
  157665. * options to use when constructing this feature
  157666. */
  157667. readonly options: IWebXRLegacyHitTestOptions;
  157668. private _direction;
  157669. private _mat;
  157670. private _onSelectEnabled;
  157671. private _origin;
  157672. /**
  157673. * The module's name
  157674. */
  157675. static readonly Name: string;
  157676. /**
  157677. * The (Babylon) version of this module.
  157678. * This is an integer representing the implementation version.
  157679. * This number does not correspond to the WebXR specs version
  157680. */
  157681. static readonly Version: number;
  157682. /**
  157683. * Populated with the last native XR Hit Results
  157684. */
  157685. lastNativeXRHitResults: XRHitResult[];
  157686. /**
  157687. * Triggered when new babylon (transformed) hit test results are available
  157688. */
  157689. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  157690. /**
  157691. * Creates a new instance of the (legacy version) hit test feature
  157692. * @param _xrSessionManager an instance of WebXRSessionManager
  157693. * @param options options to use when constructing this feature
  157694. */
  157695. constructor(_xrSessionManager: WebXRSessionManager,
  157696. /**
  157697. * options to use when constructing this feature
  157698. */
  157699. options?: IWebXRLegacyHitTestOptions);
  157700. /**
  157701. * execute a hit test with an XR Ray
  157702. *
  157703. * @param xrSession a native xrSession that will execute this hit test
  157704. * @param xrRay the ray (position and direction) to use for ray-casting
  157705. * @param referenceSpace native XR reference space to use for the hit-test
  157706. * @param filter filter function that will filter the results
  157707. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157708. */
  157709. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  157710. /**
  157711. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  157712. * @param event the (select) event to use to select with
  157713. * @param referenceSpace the reference space to use for this hit test
  157714. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  157715. */
  157716. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157717. /**
  157718. * attach this feature
  157719. * Will usually be called by the features manager
  157720. *
  157721. * @returns true if successful.
  157722. */
  157723. attach(): boolean;
  157724. /**
  157725. * detach this feature.
  157726. * Will usually be called by the features manager
  157727. *
  157728. * @returns true if successful.
  157729. */
  157730. detach(): boolean;
  157731. /**
  157732. * Dispose this feature and all of the resources attached
  157733. */
  157734. dispose(): void;
  157735. protected _onXRFrame(frame: XRFrame): void;
  157736. private _onHitTestResults;
  157737. private _onSelect;
  157738. }
  157739. }
  157740. declare module BABYLON {
  157741. /**
  157742. * Options used for hit testing (version 2)
  157743. */
  157744. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  157745. /**
  157746. * Do not create a permanent hit test. Will usually be used when only
  157747. * transient inputs are needed.
  157748. */
  157749. disablePermanentHitTest?: boolean;
  157750. /**
  157751. * Enable transient (for example touch-based) hit test inspections
  157752. */
  157753. enableTransientHitTest?: boolean;
  157754. /**
  157755. * Offset ray for the permanent hit test
  157756. */
  157757. offsetRay?: Vector3;
  157758. /**
  157759. * Offset ray for the transient hit test
  157760. */
  157761. transientOffsetRay?: Vector3;
  157762. /**
  157763. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  157764. */
  157765. useReferenceSpace?: boolean;
  157766. /**
  157767. * Override the default entity type(s) of the hit-test result
  157768. */
  157769. entityTypes?: XRHitTestTrackableType[];
  157770. }
  157771. /**
  157772. * Interface defining the babylon result of hit-test
  157773. */
  157774. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  157775. /**
  157776. * The input source that generated this hit test (if transient)
  157777. */
  157778. inputSource?: XRInputSource;
  157779. /**
  157780. * Is this a transient hit test
  157781. */
  157782. isTransient?: boolean;
  157783. /**
  157784. * Position of the hit test result
  157785. */
  157786. position: Vector3;
  157787. /**
  157788. * Rotation of the hit test result
  157789. */
  157790. rotationQuaternion: Quaternion;
  157791. /**
  157792. * The native hit test result
  157793. */
  157794. xrHitResult: XRHitTestResult;
  157795. }
  157796. /**
  157797. * The currently-working hit-test module.
  157798. * Hit test (or Ray-casting) is used to interact with the real world.
  157799. * For further information read here - https://github.com/immersive-web/hit-test
  157800. *
  157801. * Tested on chrome (mobile) 80.
  157802. */
  157803. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  157804. /**
  157805. * options to use when constructing this feature
  157806. */
  157807. readonly options: IWebXRHitTestOptions;
  157808. private _tmpMat;
  157809. private _tmpPos;
  157810. private _tmpQuat;
  157811. private _transientXrHitTestSource;
  157812. private _xrHitTestSource;
  157813. private initHitTestSource;
  157814. /**
  157815. * The module's name
  157816. */
  157817. static readonly Name: string;
  157818. /**
  157819. * The (Babylon) version of this module.
  157820. * This is an integer representing the implementation version.
  157821. * This number does not correspond to the WebXR specs version
  157822. */
  157823. static readonly Version: number;
  157824. /**
  157825. * When set to true, each hit test will have its own position/rotation objects
  157826. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  157827. * the developers will clone them or copy them as they see fit.
  157828. */
  157829. autoCloneTransformation: boolean;
  157830. /**
  157831. * Triggered when new babylon (transformed) hit test results are available
  157832. * Note - this will be called when results come back from the device. It can be an empty array!!
  157833. */
  157834. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  157835. /**
  157836. * Use this to temporarily pause hit test checks.
  157837. */
  157838. paused: boolean;
  157839. /**
  157840. * Creates a new instance of the hit test feature
  157841. * @param _xrSessionManager an instance of WebXRSessionManager
  157842. * @param options options to use when constructing this feature
  157843. */
  157844. constructor(_xrSessionManager: WebXRSessionManager,
  157845. /**
  157846. * options to use when constructing this feature
  157847. */
  157848. options?: IWebXRHitTestOptions);
  157849. /**
  157850. * attach this feature
  157851. * Will usually be called by the features manager
  157852. *
  157853. * @returns true if successful.
  157854. */
  157855. attach(): boolean;
  157856. /**
  157857. * detach this feature.
  157858. * Will usually be called by the features manager
  157859. *
  157860. * @returns true if successful.
  157861. */
  157862. detach(): boolean;
  157863. /**
  157864. * Dispose this feature and all of the resources attached
  157865. */
  157866. dispose(): void;
  157867. protected _onXRFrame(frame: XRFrame): void;
  157868. private _processWebXRHitTestResult;
  157869. }
  157870. }
  157871. declare module BABYLON {
  157872. /**
  157873. * Configuration options of the anchor system
  157874. */
  157875. export interface IWebXRAnchorSystemOptions {
  157876. /**
  157877. * a node that will be used to convert local to world coordinates
  157878. */
  157879. worldParentNode?: TransformNode;
  157880. /**
  157881. * If set to true a reference of the created anchors will be kept until the next session starts
  157882. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  157883. */
  157884. doNotRemoveAnchorsOnSessionEnded?: boolean;
  157885. }
  157886. /**
  157887. * A babylon container for an XR Anchor
  157888. */
  157889. export interface IWebXRAnchor {
  157890. /**
  157891. * A babylon-assigned ID for this anchor
  157892. */
  157893. id: number;
  157894. /**
  157895. * Transformation matrix to apply to an object attached to this anchor
  157896. */
  157897. transformationMatrix: Matrix;
  157898. /**
  157899. * The native anchor object
  157900. */
  157901. xrAnchor: XRAnchor;
  157902. /**
  157903. * if defined, this object will be constantly updated by the anchor's position and rotation
  157904. */
  157905. attachedNode?: TransformNode;
  157906. /**
  157907. * Remove this anchor from the scene
  157908. */
  157909. remove(): void;
  157910. }
  157911. /**
  157912. * An implementation of the anchor system for WebXR.
  157913. * For further information see https://github.com/immersive-web/anchors/
  157914. */
  157915. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  157916. private _options;
  157917. private _lastFrameDetected;
  157918. private _trackedAnchors;
  157919. private _referenceSpaceForFrameAnchors;
  157920. private _futureAnchors;
  157921. /**
  157922. * The module's name
  157923. */
  157924. static readonly Name: string;
  157925. /**
  157926. * The (Babylon) version of this module.
  157927. * This is an integer representing the implementation version.
  157928. * This number does not correspond to the WebXR specs version
  157929. */
  157930. static readonly Version: number;
  157931. /**
  157932. * Observers registered here will be executed when a new anchor was added to the session
  157933. */
  157934. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  157935. /**
  157936. * Observers registered here will be executed when an anchor was removed from the session
  157937. */
  157938. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157939. /**
  157940. * Observers registered here will be executed when an existing anchor updates
  157941. * This can execute N times every frame
  157942. */
  157943. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157944. /**
  157945. * Set the reference space to use for anchor creation, when not using a hit test.
  157946. * Will default to the session's reference space if not defined
  157947. */
  157948. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157949. /**
  157950. * constructs a new anchor system
  157951. * @param _xrSessionManager an instance of WebXRSessionManager
  157952. * @param _options configuration object for this feature
  157953. */
  157954. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157955. private _tmpVector;
  157956. private _tmpQuaternion;
  157957. private _populateTmpTransformation;
  157958. /**
  157959. * Create a new anchor point using a hit test result at a specific point in the scene
  157960. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157961. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157962. *
  157963. * @param hitTestResult The hit test result to use for this anchor creation
  157964. * @param position an optional position offset for this anchor
  157965. * @param rotationQuaternion an optional rotation offset for this anchor
  157966. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  157967. */
  157968. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  157969. /**
  157970. * Add a new anchor at a specific position and rotation
  157971. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157972. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157973. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157974. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157975. *
  157976. * @param position the position in which to add an anchor
  157977. * @param rotationQuaternion an optional rotation for the anchor transformation
  157978. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157979. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  157980. */
  157981. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  157982. /**
  157983. * Get the list of anchors currently being tracked by the system
  157984. */
  157985. get anchors(): IWebXRAnchor[];
  157986. /**
  157987. * detach this feature.
  157988. * Will usually be called by the features manager
  157989. *
  157990. * @returns true if successful.
  157991. */
  157992. detach(): boolean;
  157993. /**
  157994. * Dispose this feature and all of the resources attached
  157995. */
  157996. dispose(): void;
  157997. protected _onXRFrame(frame: XRFrame): void;
  157998. /**
  157999. * avoiding using Array.find for global support.
  158000. * @param xrAnchor the plane to find in the array
  158001. */
  158002. private _findIndexInAnchorArray;
  158003. private _updateAnchorWithXRFrame;
  158004. private _createAnchorAtTransformation;
  158005. }
  158006. }
  158007. declare module BABYLON {
  158008. /**
  158009. * Options used in the plane detector module
  158010. */
  158011. export interface IWebXRPlaneDetectorOptions {
  158012. /**
  158013. * The node to use to transform the local results to world coordinates
  158014. */
  158015. worldParentNode?: TransformNode;
  158016. /**
  158017. * If set to true a reference of the created planes will be kept until the next session starts
  158018. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  158019. */
  158020. doNotRemovePlanesOnSessionEnded?: boolean;
  158021. }
  158022. /**
  158023. * A babylon interface for a WebXR plane.
  158024. * A Plane is actually a polygon, built from N points in space
  158025. *
  158026. * Supported in chrome 79, not supported in canary 81 ATM
  158027. */
  158028. export interface IWebXRPlane {
  158029. /**
  158030. * a babylon-assigned ID for this polygon
  158031. */
  158032. id: number;
  158033. /**
  158034. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  158035. */
  158036. polygonDefinition: Array<Vector3>;
  158037. /**
  158038. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  158039. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  158040. */
  158041. transformationMatrix: Matrix;
  158042. /**
  158043. * the native xr-plane object
  158044. */
  158045. xrPlane: XRPlane;
  158046. }
  158047. /**
  158048. * The plane detector is used to detect planes in the real world when in AR
  158049. * For more information see https://github.com/immersive-web/real-world-geometry/
  158050. */
  158051. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  158052. private _options;
  158053. private _detectedPlanes;
  158054. private _enabled;
  158055. private _lastFrameDetected;
  158056. /**
  158057. * The module's name
  158058. */
  158059. static readonly Name: string;
  158060. /**
  158061. * The (Babylon) version of this module.
  158062. * This is an integer representing the implementation version.
  158063. * This number does not correspond to the WebXR specs version
  158064. */
  158065. static readonly Version: number;
  158066. /**
  158067. * Observers registered here will be executed when a new plane was added to the session
  158068. */
  158069. onPlaneAddedObservable: Observable<IWebXRPlane>;
  158070. /**
  158071. * Observers registered here will be executed when a plane is no longer detected in the session
  158072. */
  158073. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  158074. /**
  158075. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  158076. * This can execute N times every frame
  158077. */
  158078. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  158079. /**
  158080. * construct a new Plane Detector
  158081. * @param _xrSessionManager an instance of xr Session manager
  158082. * @param _options configuration to use when constructing this feature
  158083. */
  158084. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  158085. /**
  158086. * detach this feature.
  158087. * Will usually be called by the features manager
  158088. *
  158089. * @returns true if successful.
  158090. */
  158091. detach(): boolean;
  158092. /**
  158093. * Dispose this feature and all of the resources attached
  158094. */
  158095. dispose(): void;
  158096. /**
  158097. * Check if the needed objects are defined.
  158098. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158099. */
  158100. isCompatible(): boolean;
  158101. protected _onXRFrame(frame: XRFrame): void;
  158102. private _init;
  158103. private _updatePlaneWithXRPlane;
  158104. /**
  158105. * avoiding using Array.find for global support.
  158106. * @param xrPlane the plane to find in the array
  158107. */
  158108. private findIndexInPlaneArray;
  158109. }
  158110. }
  158111. declare module BABYLON {
  158112. /**
  158113. * Options interface for the background remover plugin
  158114. */
  158115. export interface IWebXRBackgroundRemoverOptions {
  158116. /**
  158117. * Further background meshes to disable when entering AR
  158118. */
  158119. backgroundMeshes?: AbstractMesh[];
  158120. /**
  158121. * flags to configure the removal of the environment helper.
  158122. * If not set, the entire background will be removed. If set, flags should be set as well.
  158123. */
  158124. environmentHelperRemovalFlags?: {
  158125. /**
  158126. * Should the skybox be removed (default false)
  158127. */
  158128. skyBox?: boolean;
  158129. /**
  158130. * Should the ground be removed (default false)
  158131. */
  158132. ground?: boolean;
  158133. };
  158134. /**
  158135. * don't disable the environment helper
  158136. */
  158137. ignoreEnvironmentHelper?: boolean;
  158138. }
  158139. /**
  158140. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  158141. */
  158142. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  158143. /**
  158144. * read-only options to be used in this module
  158145. */
  158146. readonly options: IWebXRBackgroundRemoverOptions;
  158147. /**
  158148. * The module's name
  158149. */
  158150. static readonly Name: string;
  158151. /**
  158152. * The (Babylon) version of this module.
  158153. * This is an integer representing the implementation version.
  158154. * This number does not correspond to the WebXR specs version
  158155. */
  158156. static readonly Version: number;
  158157. /**
  158158. * registered observers will be triggered when the background state changes
  158159. */
  158160. onBackgroundStateChangedObservable: Observable<boolean>;
  158161. /**
  158162. * constructs a new background remover module
  158163. * @param _xrSessionManager the session manager for this module
  158164. * @param options read-only options to be used in this module
  158165. */
  158166. constructor(_xrSessionManager: WebXRSessionManager,
  158167. /**
  158168. * read-only options to be used in this module
  158169. */
  158170. options?: IWebXRBackgroundRemoverOptions);
  158171. /**
  158172. * attach this feature
  158173. * Will usually be called by the features manager
  158174. *
  158175. * @returns true if successful.
  158176. */
  158177. attach(): boolean;
  158178. /**
  158179. * detach this feature.
  158180. * Will usually be called by the features manager
  158181. *
  158182. * @returns true if successful.
  158183. */
  158184. detach(): boolean;
  158185. /**
  158186. * Dispose this feature and all of the resources attached
  158187. */
  158188. dispose(): void;
  158189. protected _onXRFrame(_xrFrame: XRFrame): void;
  158190. private _setBackgroundState;
  158191. }
  158192. }
  158193. declare module BABYLON {
  158194. /**
  158195. * Options for the controller physics feature
  158196. */
  158197. export class IWebXRControllerPhysicsOptions {
  158198. /**
  158199. * Should the headset get its own impostor
  158200. */
  158201. enableHeadsetImpostor?: boolean;
  158202. /**
  158203. * Optional parameters for the headset impostor
  158204. */
  158205. headsetImpostorParams?: {
  158206. /**
  158207. * The type of impostor to create. Default is sphere
  158208. */
  158209. impostorType: number;
  158210. /**
  158211. * the size of the impostor. Defaults to 10cm
  158212. */
  158213. impostorSize?: number | {
  158214. width: number;
  158215. height: number;
  158216. depth: number;
  158217. };
  158218. /**
  158219. * Friction definitions
  158220. */
  158221. friction?: number;
  158222. /**
  158223. * Restitution
  158224. */
  158225. restitution?: number;
  158226. };
  158227. /**
  158228. * The physics properties of the future impostors
  158229. */
  158230. physicsProperties?: {
  158231. /**
  158232. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  158233. * Note that this requires a physics engine that supports mesh impostors!
  158234. */
  158235. useControllerMesh?: boolean;
  158236. /**
  158237. * The type of impostor to create. Default is sphere
  158238. */
  158239. impostorType?: number;
  158240. /**
  158241. * the size of the impostor. Defaults to 10cm
  158242. */
  158243. impostorSize?: number | {
  158244. width: number;
  158245. height: number;
  158246. depth: number;
  158247. };
  158248. /**
  158249. * Friction definitions
  158250. */
  158251. friction?: number;
  158252. /**
  158253. * Restitution
  158254. */
  158255. restitution?: number;
  158256. };
  158257. /**
  158258. * the xr input to use with this pointer selection
  158259. */
  158260. xrInput: WebXRInput;
  158261. }
  158262. /**
  158263. * Add physics impostor to your webxr controllers,
  158264. * including naive calculation of their linear and angular velocity
  158265. */
  158266. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  158267. private readonly _options;
  158268. private _attachController;
  158269. private _controllers;
  158270. private _debugMode;
  158271. private _delta;
  158272. private _headsetImpostor?;
  158273. private _headsetMesh?;
  158274. private _lastTimestamp;
  158275. private _tmpQuaternion;
  158276. private _tmpVector;
  158277. /**
  158278. * The module's name
  158279. */
  158280. static readonly Name: string;
  158281. /**
  158282. * The (Babylon) version of this module.
  158283. * This is an integer representing the implementation version.
  158284. * This number does not correspond to the webxr specs version
  158285. */
  158286. static readonly Version: number;
  158287. /**
  158288. * Construct a new Controller Physics Feature
  158289. * @param _xrSessionManager the corresponding xr session manager
  158290. * @param _options options to create this feature with
  158291. */
  158292. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  158293. /**
  158294. * @hidden
  158295. * enable debugging - will show console outputs and the impostor mesh
  158296. */
  158297. _enablePhysicsDebug(): void;
  158298. /**
  158299. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  158300. * @param xrController the controller to add
  158301. */
  158302. addController(xrController: WebXRInputSource): void;
  158303. /**
  158304. * attach this feature
  158305. * Will usually be called by the features manager
  158306. *
  158307. * @returns true if successful.
  158308. */
  158309. attach(): boolean;
  158310. /**
  158311. * detach this feature.
  158312. * Will usually be called by the features manager
  158313. *
  158314. * @returns true if successful.
  158315. */
  158316. detach(): boolean;
  158317. /**
  158318. * Get the headset impostor, if enabled
  158319. * @returns the impostor
  158320. */
  158321. getHeadsetImpostor(): PhysicsImpostor | undefined;
  158322. /**
  158323. * Get the physics impostor of a specific controller.
  158324. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  158325. * @param controller the controller or the controller id of which to get the impostor
  158326. * @returns the impostor or null
  158327. */
  158328. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  158329. /**
  158330. * Update the physics properties provided in the constructor
  158331. * @param newProperties the new properties object
  158332. */
  158333. setPhysicsProperties(newProperties: {
  158334. impostorType?: number;
  158335. impostorSize?: number | {
  158336. width: number;
  158337. height: number;
  158338. depth: number;
  158339. };
  158340. friction?: number;
  158341. restitution?: number;
  158342. }): void;
  158343. protected _onXRFrame(_xrFrame: any): void;
  158344. private _detachController;
  158345. }
  158346. }
  158347. declare module BABYLON {
  158348. /**
  158349. * A babylon interface for a "WebXR" feature point.
  158350. * Represents the position and confidence value of a given feature point.
  158351. */
  158352. export interface IWebXRFeaturePoint {
  158353. /**
  158354. * Represents the position of the feature point in world space.
  158355. */
  158356. position: Vector3;
  158357. /**
  158358. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  158359. */
  158360. confidenceValue: number;
  158361. }
  158362. /**
  158363. * The feature point system is used to detect feature points from real world geometry.
  158364. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  158365. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  158366. */
  158367. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  158368. private _enabled;
  158369. private _featurePointCloud;
  158370. /**
  158371. * The module's name
  158372. */
  158373. static readonly Name: string;
  158374. /**
  158375. * The (Babylon) version of this module.
  158376. * This is an integer representing the implementation version.
  158377. * This number does not correspond to the WebXR specs version
  158378. */
  158379. static readonly Version: number;
  158380. /**
  158381. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  158382. * Will notify the observers about which feature points have been added.
  158383. */
  158384. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  158385. /**
  158386. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  158387. * Will notify the observers about which feature points have been updated.
  158388. */
  158389. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  158390. /**
  158391. * The current feature point cloud maintained across frames.
  158392. */
  158393. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  158394. /**
  158395. * construct the feature point system
  158396. * @param _xrSessionManager an instance of xr Session manager
  158397. */
  158398. constructor(_xrSessionManager: WebXRSessionManager);
  158399. /**
  158400. * Detach this feature.
  158401. * Will usually be called by the features manager
  158402. *
  158403. * @returns true if successful.
  158404. */
  158405. detach(): boolean;
  158406. /**
  158407. * Dispose this feature and all of the resources attached
  158408. */
  158409. dispose(): void;
  158410. /**
  158411. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  158412. */
  158413. protected _onXRFrame(frame: XRFrame): void;
  158414. /**
  158415. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  158416. */
  158417. private _init;
  158418. }
  158419. }
  158420. declare module BABYLON {
  158421. /**
  158422. * Configuration interface for the hand tracking feature
  158423. */
  158424. export interface IWebXRHandTrackingOptions {
  158425. /**
  158426. * The xrInput that will be used as source for new hands
  158427. */
  158428. xrInput: WebXRInput;
  158429. /**
  158430. * Configuration object for the joint meshes
  158431. */
  158432. jointMeshes?: {
  158433. /**
  158434. * Should the meshes created be invisible (defaults to false)
  158435. */
  158436. invisible?: boolean;
  158437. /**
  158438. * A source mesh to be used to create instances. Defaults to a sphere.
  158439. * This mesh will be the source for all other (25) meshes.
  158440. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  158441. */
  158442. sourceMesh?: Mesh;
  158443. /**
  158444. * This function will be called after a mesh was created for a specific joint.
  158445. * Using this function you can either manipulate the instance or return a new mesh.
  158446. * When returning a new mesh the instance created before will be disposed
  158447. */
  158448. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  158449. /**
  158450. * Should the source mesh stay visible. Defaults to false
  158451. */
  158452. keepOriginalVisible?: boolean;
  158453. /**
  158454. * Scale factor for all instances (defaults to 2)
  158455. */
  158456. scaleFactor?: number;
  158457. /**
  158458. * Should each instance have its own physics impostor
  158459. */
  158460. enablePhysics?: boolean;
  158461. /**
  158462. * If enabled, override default physics properties
  158463. */
  158464. physicsProps?: {
  158465. friction?: number;
  158466. restitution?: number;
  158467. impostorType?: number;
  158468. };
  158469. /**
  158470. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  158471. */
  158472. handMesh?: AbstractMesh;
  158473. };
  158474. }
  158475. /**
  158476. * Parts of the hands divided to writs and finger names
  158477. */
  158478. export const enum HandPart {
  158479. /**
  158480. * HandPart - Wrist
  158481. */
  158482. WRIST = "wrist",
  158483. /**
  158484. * HandPart - The THumb
  158485. */
  158486. THUMB = "thumb",
  158487. /**
  158488. * HandPart - Index finger
  158489. */
  158490. INDEX = "index",
  158491. /**
  158492. * HandPart - Middle finger
  158493. */
  158494. MIDDLE = "middle",
  158495. /**
  158496. * HandPart - Ring finger
  158497. */
  158498. RING = "ring",
  158499. /**
  158500. * HandPart - Little finger
  158501. */
  158502. LITTLE = "little"
  158503. }
  158504. /**
  158505. * Representing a single hand (with its corresponding native XRHand object)
  158506. */
  158507. export class WebXRHand implements IDisposable {
  158508. /** the controller to which the hand correlates */
  158509. readonly xrController: WebXRInputSource;
  158510. /** the meshes to be used to track the hand joints */
  158511. readonly trackedMeshes: AbstractMesh[];
  158512. /**
  158513. * Hand-parts definition (key is HandPart)
  158514. */
  158515. handPartsDefinition: {
  158516. [key: string]: number[];
  158517. };
  158518. /**
  158519. * Populate the HandPartsDefinition object.
  158520. * This is called as a side effect since certain browsers don't have XRHand defined.
  158521. */
  158522. private generateHandPartsDefinition;
  158523. /**
  158524. * Construct a new hand object
  158525. * @param xrController the controller to which the hand correlates
  158526. * @param trackedMeshes the meshes to be used to track the hand joints
  158527. */
  158528. constructor(
  158529. /** the controller to which the hand correlates */
  158530. xrController: WebXRInputSource,
  158531. /** the meshes to be used to track the hand joints */
  158532. trackedMeshes: AbstractMesh[]);
  158533. /**
  158534. * Update this hand from the latest xr frame
  158535. * @param xrFrame xrFrame to update from
  158536. * @param referenceSpace The current viewer reference space
  158537. * @param scaleFactor optional scale factor for the meshes
  158538. */
  158539. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  158540. /**
  158541. * Get meshes of part of the hand
  158542. * @param part the part of hand to get
  158543. * @returns An array of meshes that correlate to the hand part requested
  158544. */
  158545. getHandPartMeshes(part: HandPart): AbstractMesh[];
  158546. /**
  158547. * Dispose this Hand object
  158548. */
  158549. dispose(): void;
  158550. }
  158551. /**
  158552. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  158553. */
  158554. export class WebXRHandTracking extends WebXRAbstractFeature {
  158555. /**
  158556. * options to use when constructing this feature
  158557. */
  158558. readonly options: IWebXRHandTrackingOptions;
  158559. private static _idCounter;
  158560. /**
  158561. * The module's name
  158562. */
  158563. static readonly Name: string;
  158564. /**
  158565. * The (Babylon) version of this module.
  158566. * This is an integer representing the implementation version.
  158567. * This number does not correspond to the WebXR specs version
  158568. */
  158569. static readonly Version: number;
  158570. /**
  158571. * This observable will notify registered observers when a new hand object was added and initialized
  158572. */
  158573. onHandAddedObservable: Observable<WebXRHand>;
  158574. /**
  158575. * This observable will notify its observers right before the hand object is disposed
  158576. */
  158577. onHandRemovedObservable: Observable<WebXRHand>;
  158578. private _hands;
  158579. /**
  158580. * Creates a new instance of the hit test feature
  158581. * @param _xrSessionManager an instance of WebXRSessionManager
  158582. * @param options options to use when constructing this feature
  158583. */
  158584. constructor(_xrSessionManager: WebXRSessionManager,
  158585. /**
  158586. * options to use when constructing this feature
  158587. */
  158588. options: IWebXRHandTrackingOptions);
  158589. /**
  158590. * Check if the needed objects are defined.
  158591. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  158592. */
  158593. isCompatible(): boolean;
  158594. /**
  158595. * attach this feature
  158596. * Will usually be called by the features manager
  158597. *
  158598. * @returns true if successful.
  158599. */
  158600. attach(): boolean;
  158601. /**
  158602. * detach this feature.
  158603. * Will usually be called by the features manager
  158604. *
  158605. * @returns true if successful.
  158606. */
  158607. detach(): boolean;
  158608. /**
  158609. * Dispose this feature and all of the resources attached
  158610. */
  158611. dispose(): void;
  158612. /**
  158613. * Get the hand object according to the controller id
  158614. * @param controllerId the controller id to which we want to get the hand
  158615. * @returns null if not found or the WebXRHand object if found
  158616. */
  158617. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  158618. /**
  158619. * Get a hand object according to the requested handedness
  158620. * @param handedness the handedness to request
  158621. * @returns null if not found or the WebXRHand object if found
  158622. */
  158623. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  158624. protected _onXRFrame(_xrFrame: XRFrame): void;
  158625. private _attachHand;
  158626. private _detachHand;
  158627. }
  158628. }
  158629. declare module BABYLON {
  158630. /**
  158631. * The motion controller class for all microsoft mixed reality controllers
  158632. */
  158633. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  158634. protected readonly _mapping: {
  158635. defaultButton: {
  158636. valueNodeName: string;
  158637. unpressedNodeName: string;
  158638. pressedNodeName: string;
  158639. };
  158640. defaultAxis: {
  158641. valueNodeName: string;
  158642. minNodeName: string;
  158643. maxNodeName: string;
  158644. };
  158645. buttons: {
  158646. "xr-standard-trigger": {
  158647. rootNodeName: string;
  158648. componentProperty: string;
  158649. states: string[];
  158650. };
  158651. "xr-standard-squeeze": {
  158652. rootNodeName: string;
  158653. componentProperty: string;
  158654. states: string[];
  158655. };
  158656. "xr-standard-touchpad": {
  158657. rootNodeName: string;
  158658. labelAnchorNodeName: string;
  158659. touchPointNodeName: string;
  158660. };
  158661. "xr-standard-thumbstick": {
  158662. rootNodeName: string;
  158663. componentProperty: string;
  158664. states: string[];
  158665. };
  158666. };
  158667. axes: {
  158668. "xr-standard-touchpad": {
  158669. "x-axis": {
  158670. rootNodeName: string;
  158671. };
  158672. "y-axis": {
  158673. rootNodeName: string;
  158674. };
  158675. };
  158676. "xr-standard-thumbstick": {
  158677. "x-axis": {
  158678. rootNodeName: string;
  158679. };
  158680. "y-axis": {
  158681. rootNodeName: string;
  158682. };
  158683. };
  158684. };
  158685. };
  158686. /**
  158687. * The base url used to load the left and right controller models
  158688. */
  158689. static MODEL_BASE_URL: string;
  158690. /**
  158691. * The name of the left controller model file
  158692. */
  158693. static MODEL_LEFT_FILENAME: string;
  158694. /**
  158695. * The name of the right controller model file
  158696. */
  158697. static MODEL_RIGHT_FILENAME: string;
  158698. profileId: string;
  158699. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158700. protected _getFilenameAndPath(): {
  158701. filename: string;
  158702. path: string;
  158703. };
  158704. protected _getModelLoadingConstraints(): boolean;
  158705. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158706. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158707. protected _updateModel(): void;
  158708. }
  158709. }
  158710. declare module BABYLON {
  158711. /**
  158712. * The motion controller class for oculus touch (quest, rift).
  158713. * This class supports legacy mapping as well the standard xr mapping
  158714. */
  158715. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  158716. private _forceLegacyControllers;
  158717. private _modelRootNode;
  158718. /**
  158719. * The base url used to load the left and right controller models
  158720. */
  158721. static MODEL_BASE_URL: string;
  158722. /**
  158723. * The name of the left controller model file
  158724. */
  158725. static MODEL_LEFT_FILENAME: string;
  158726. /**
  158727. * The name of the right controller model file
  158728. */
  158729. static MODEL_RIGHT_FILENAME: string;
  158730. /**
  158731. * Base Url for the Quest controller model.
  158732. */
  158733. static QUEST_MODEL_BASE_URL: string;
  158734. profileId: string;
  158735. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  158736. protected _getFilenameAndPath(): {
  158737. filename: string;
  158738. path: string;
  158739. };
  158740. protected _getModelLoadingConstraints(): boolean;
  158741. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158742. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158743. protected _updateModel(): void;
  158744. /**
  158745. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  158746. * between the touch and touch 2.
  158747. */
  158748. private _isQuest;
  158749. }
  158750. }
  158751. declare module BABYLON {
  158752. /**
  158753. * The motion controller class for the standard HTC-Vive controllers
  158754. */
  158755. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  158756. private _modelRootNode;
  158757. /**
  158758. * The base url used to load the left and right controller models
  158759. */
  158760. static MODEL_BASE_URL: string;
  158761. /**
  158762. * File name for the controller model.
  158763. */
  158764. static MODEL_FILENAME: string;
  158765. profileId: string;
  158766. /**
  158767. * Create a new Vive motion controller object
  158768. * @param scene the scene to use to create this controller
  158769. * @param gamepadObject the corresponding gamepad object
  158770. * @param handedness the handedness of the controller
  158771. */
  158772. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  158773. protected _getFilenameAndPath(): {
  158774. filename: string;
  158775. path: string;
  158776. };
  158777. protected _getModelLoadingConstraints(): boolean;
  158778. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  158779. protected _setRootMesh(meshes: AbstractMesh[]): void;
  158780. protected _updateModel(): void;
  158781. }
  158782. }
  158783. declare module BABYLON {
  158784. /**
  158785. * A cursor which tracks a point on a path
  158786. */
  158787. export class PathCursor {
  158788. private path;
  158789. /**
  158790. * Stores path cursor callbacks for when an onchange event is triggered
  158791. */
  158792. private _onchange;
  158793. /**
  158794. * The value of the path cursor
  158795. */
  158796. value: number;
  158797. /**
  158798. * The animation array of the path cursor
  158799. */
  158800. animations: Animation[];
  158801. /**
  158802. * Initializes the path cursor
  158803. * @param path The path to track
  158804. */
  158805. constructor(path: Path2);
  158806. /**
  158807. * Gets the cursor point on the path
  158808. * @returns A point on the path cursor at the cursor location
  158809. */
  158810. getPoint(): Vector3;
  158811. /**
  158812. * Moves the cursor ahead by the step amount
  158813. * @param step The amount to move the cursor forward
  158814. * @returns This path cursor
  158815. */
  158816. moveAhead(step?: number): PathCursor;
  158817. /**
  158818. * Moves the cursor behind by the step amount
  158819. * @param step The amount to move the cursor back
  158820. * @returns This path cursor
  158821. */
  158822. moveBack(step?: number): PathCursor;
  158823. /**
  158824. * Moves the cursor by the step amount
  158825. * If the step amount is greater than one, an exception is thrown
  158826. * @param step The amount to move the cursor
  158827. * @returns This path cursor
  158828. */
  158829. move(step: number): PathCursor;
  158830. /**
  158831. * Ensures that the value is limited between zero and one
  158832. * @returns This path cursor
  158833. */
  158834. private ensureLimits;
  158835. /**
  158836. * Runs onchange callbacks on change (used by the animation engine)
  158837. * @returns This path cursor
  158838. */
  158839. private raiseOnChange;
  158840. /**
  158841. * Executes a function on change
  158842. * @param f A path cursor onchange callback
  158843. * @returns This path cursor
  158844. */
  158845. onchange(f: (cursor: PathCursor) => void): PathCursor;
  158846. }
  158847. }
  158848. declare module BABYLON {
  158849. /** @hidden */
  158850. export var blurPixelShader: {
  158851. name: string;
  158852. shader: string;
  158853. };
  158854. }
  158855. declare module BABYLON {
  158856. /** @hidden */
  158857. export var pointCloudVertexDeclaration: {
  158858. name: string;
  158859. shader: string;
  158860. };
  158861. }
  158862. // Mixins
  158863. interface Window {
  158864. mozIndexedDB: IDBFactory;
  158865. webkitIndexedDB: IDBFactory;
  158866. msIndexedDB: IDBFactory;
  158867. webkitURL: typeof URL;
  158868. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  158869. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  158870. WebGLRenderingContext: WebGLRenderingContext;
  158871. MSGesture: MSGesture;
  158872. CANNON: any;
  158873. AudioContext: AudioContext;
  158874. webkitAudioContext: AudioContext;
  158875. PointerEvent: any;
  158876. Math: Math;
  158877. Uint8Array: Uint8ArrayConstructor;
  158878. Float32Array: Float32ArrayConstructor;
  158879. mozURL: typeof URL;
  158880. msURL: typeof URL;
  158881. VRFrameData: any; // WebVR, from specs 1.1
  158882. DracoDecoderModule: any;
  158883. setImmediate(handler: (...args: any[]) => void): number;
  158884. }
  158885. interface HTMLCanvasElement {
  158886. requestPointerLock(): void;
  158887. msRequestPointerLock?(): void;
  158888. mozRequestPointerLock?(): void;
  158889. webkitRequestPointerLock?(): void;
  158890. /** Track wether a record is in progress */
  158891. isRecording: boolean;
  158892. /** Capture Stream method defined by some browsers */
  158893. captureStream(fps?: number): MediaStream;
  158894. }
  158895. interface CanvasRenderingContext2D {
  158896. msImageSmoothingEnabled: boolean;
  158897. }
  158898. interface MouseEvent {
  158899. mozMovementX: number;
  158900. mozMovementY: number;
  158901. webkitMovementX: number;
  158902. webkitMovementY: number;
  158903. msMovementX: number;
  158904. msMovementY: number;
  158905. }
  158906. interface Navigator {
  158907. mozGetVRDevices: (any: any) => any;
  158908. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158909. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158910. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  158911. webkitGetGamepads(): Gamepad[];
  158912. msGetGamepads(): Gamepad[];
  158913. webkitGamepads(): Gamepad[];
  158914. }
  158915. interface HTMLVideoElement {
  158916. mozSrcObject: any;
  158917. }
  158918. interface Math {
  158919. fround(x: number): number;
  158920. imul(a: number, b: number): number;
  158921. }
  158922. interface WebGLRenderingContext {
  158923. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  158924. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  158925. vertexAttribDivisor(index: number, divisor: number): void;
  158926. createVertexArray(): any;
  158927. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  158928. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  158929. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  158930. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  158931. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  158932. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  158933. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  158934. // Queries
  158935. createQuery(): WebGLQuery;
  158936. deleteQuery(query: WebGLQuery): void;
  158937. beginQuery(target: number, query: WebGLQuery): void;
  158938. endQuery(target: number): void;
  158939. getQueryParameter(query: WebGLQuery, pname: number): any;
  158940. getQuery(target: number, pname: number): any;
  158941. MAX_SAMPLES: number;
  158942. RGBA8: number;
  158943. READ_FRAMEBUFFER: number;
  158944. DRAW_FRAMEBUFFER: number;
  158945. UNIFORM_BUFFER: number;
  158946. HALF_FLOAT_OES: number;
  158947. RGBA16F: number;
  158948. RGBA32F: number;
  158949. R32F: number;
  158950. RG32F: number;
  158951. RGB32F: number;
  158952. R16F: number;
  158953. RG16F: number;
  158954. RGB16F: number;
  158955. RED: number;
  158956. RG: number;
  158957. R8: number;
  158958. RG8: number;
  158959. UNSIGNED_INT_24_8: number;
  158960. DEPTH24_STENCIL8: number;
  158961. MIN: number;
  158962. MAX: number;
  158963. /* Multiple Render Targets */
  158964. drawBuffers(buffers: number[]): void;
  158965. readBuffer(src: number): void;
  158966. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158967. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158968. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158969. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158970. // Occlusion Query
  158971. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158972. ANY_SAMPLES_PASSED: number;
  158973. QUERY_RESULT_AVAILABLE: number;
  158974. QUERY_RESULT: number;
  158975. }
  158976. interface WebGLProgram {
  158977. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158978. }
  158979. interface EXT_disjoint_timer_query {
  158980. QUERY_COUNTER_BITS_EXT: number;
  158981. TIME_ELAPSED_EXT: number;
  158982. TIMESTAMP_EXT: number;
  158983. GPU_DISJOINT_EXT: number;
  158984. QUERY_RESULT_EXT: number;
  158985. QUERY_RESULT_AVAILABLE_EXT: number;
  158986. queryCounterEXT(query: WebGLQuery, target: number): void;
  158987. createQueryEXT(): WebGLQuery;
  158988. beginQueryEXT(target: number, query: WebGLQuery): void;
  158989. endQueryEXT(target: number): void;
  158990. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158991. deleteQueryEXT(query: WebGLQuery): void;
  158992. }
  158993. interface WebGLUniformLocation {
  158994. _currentState: any;
  158995. }
  158996. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158997. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158998. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158999. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  159000. interface WebGLRenderingContext {
  159001. readonly RASTERIZER_DISCARD: number;
  159002. readonly DEPTH_COMPONENT24: number;
  159003. readonly TEXTURE_3D: number;
  159004. readonly TEXTURE_2D_ARRAY: number;
  159005. readonly TEXTURE_COMPARE_FUNC: number;
  159006. readonly TEXTURE_COMPARE_MODE: number;
  159007. readonly COMPARE_REF_TO_TEXTURE: number;
  159008. readonly TEXTURE_WRAP_R: number;
  159009. readonly HALF_FLOAT: number;
  159010. readonly RGB8: number;
  159011. readonly RED_INTEGER: number;
  159012. readonly RG_INTEGER: number;
  159013. readonly RGB_INTEGER: number;
  159014. readonly RGBA_INTEGER: number;
  159015. readonly R8_SNORM: number;
  159016. readonly RG8_SNORM: number;
  159017. readonly RGB8_SNORM: number;
  159018. readonly RGBA8_SNORM: number;
  159019. readonly R8I: number;
  159020. readonly RG8I: number;
  159021. readonly RGB8I: number;
  159022. readonly RGBA8I: number;
  159023. readonly R8UI: number;
  159024. readonly RG8UI: number;
  159025. readonly RGB8UI: number;
  159026. readonly RGBA8UI: number;
  159027. readonly R16I: number;
  159028. readonly RG16I: number;
  159029. readonly RGB16I: number;
  159030. readonly RGBA16I: number;
  159031. readonly R16UI: number;
  159032. readonly RG16UI: number;
  159033. readonly RGB16UI: number;
  159034. readonly RGBA16UI: number;
  159035. readonly R32I: number;
  159036. readonly RG32I: number;
  159037. readonly RGB32I: number;
  159038. readonly RGBA32I: number;
  159039. readonly R32UI: number;
  159040. readonly RG32UI: number;
  159041. readonly RGB32UI: number;
  159042. readonly RGBA32UI: number;
  159043. readonly RGB10_A2UI: number;
  159044. readonly R11F_G11F_B10F: number;
  159045. readonly RGB9_E5: number;
  159046. readonly RGB10_A2: number;
  159047. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  159048. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  159049. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  159050. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  159051. readonly DEPTH_COMPONENT32F: number;
  159052. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  159053. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  159054. 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;
  159055. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  159056. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  159057. readonly TRANSFORM_FEEDBACK: number;
  159058. readonly INTERLEAVED_ATTRIBS: number;
  159059. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  159060. createTransformFeedback(): WebGLTransformFeedback;
  159061. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  159062. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  159063. beginTransformFeedback(primitiveMode: number): void;
  159064. endTransformFeedback(): void;
  159065. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  159066. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159067. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159068. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  159069. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  159070. }
  159071. interface ImageBitmap {
  159072. readonly width: number;
  159073. readonly height: number;
  159074. close(): void;
  159075. }
  159076. interface WebGLQuery extends WebGLObject {
  159077. }
  159078. declare var WebGLQuery: {
  159079. prototype: WebGLQuery;
  159080. new(): WebGLQuery;
  159081. };
  159082. interface WebGLSampler extends WebGLObject {
  159083. }
  159084. declare var WebGLSampler: {
  159085. prototype: WebGLSampler;
  159086. new(): WebGLSampler;
  159087. };
  159088. interface WebGLSync extends WebGLObject {
  159089. }
  159090. declare var WebGLSync: {
  159091. prototype: WebGLSync;
  159092. new(): WebGLSync;
  159093. };
  159094. interface WebGLTransformFeedback extends WebGLObject {
  159095. }
  159096. declare var WebGLTransformFeedback: {
  159097. prototype: WebGLTransformFeedback;
  159098. new(): WebGLTransformFeedback;
  159099. };
  159100. interface WebGLVertexArrayObject extends WebGLObject {
  159101. }
  159102. declare var WebGLVertexArrayObject: {
  159103. prototype: WebGLVertexArrayObject;
  159104. new(): WebGLVertexArrayObject;
  159105. };
  159106. // Type definitions for WebVR API
  159107. // Project: https://w3c.github.io/webvr/
  159108. // Definitions by: six a <https://github.com/lostfictions>
  159109. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  159110. interface VRDisplay extends EventTarget {
  159111. /**
  159112. * Dictionary of capabilities describing the VRDisplay.
  159113. */
  159114. readonly capabilities: VRDisplayCapabilities;
  159115. /**
  159116. * z-depth defining the far plane of the eye view frustum
  159117. * enables mapping of values in the render target depth
  159118. * attachment to scene coordinates. Initially set to 10000.0.
  159119. */
  159120. depthFar: number;
  159121. /**
  159122. * z-depth defining the near plane of the eye view frustum
  159123. * enables mapping of values in the render target depth
  159124. * attachment to scene coordinates. Initially set to 0.01.
  159125. */
  159126. depthNear: number;
  159127. /**
  159128. * An identifier for this distinct VRDisplay. Used as an
  159129. * association point in the Gamepad API.
  159130. */
  159131. readonly displayId: number;
  159132. /**
  159133. * A display name, a user-readable name identifying it.
  159134. */
  159135. readonly displayName: string;
  159136. readonly isConnected: boolean;
  159137. readonly isPresenting: boolean;
  159138. /**
  159139. * If this VRDisplay supports room-scale experiences, the optional
  159140. * stage attribute contains details on the room-scale parameters.
  159141. */
  159142. readonly stageParameters: VRStageParameters | null;
  159143. /**
  159144. * Passing the value returned by `requestAnimationFrame` to
  159145. * `cancelAnimationFrame` will unregister the callback.
  159146. * @param handle Define the hanle of the request to cancel
  159147. */
  159148. cancelAnimationFrame(handle: number): void;
  159149. /**
  159150. * Stops presenting to the VRDisplay.
  159151. * @returns a promise to know when it stopped
  159152. */
  159153. exitPresent(): Promise<void>;
  159154. /**
  159155. * Return the current VREyeParameters for the given eye.
  159156. * @param whichEye Define the eye we want the parameter for
  159157. * @returns the eye parameters
  159158. */
  159159. getEyeParameters(whichEye: string): VREyeParameters;
  159160. /**
  159161. * Populates the passed VRFrameData with the information required to render
  159162. * the current frame.
  159163. * @param frameData Define the data structure to populate
  159164. * @returns true if ok otherwise false
  159165. */
  159166. getFrameData(frameData: VRFrameData): boolean;
  159167. /**
  159168. * Get the layers currently being presented.
  159169. * @returns the list of VR layers
  159170. */
  159171. getLayers(): VRLayer[];
  159172. /**
  159173. * Return a VRPose containing the future predicted pose of the VRDisplay
  159174. * when the current frame will be presented. The value returned will not
  159175. * change until JavaScript has returned control to the browser.
  159176. *
  159177. * The VRPose will contain the position, orientation, velocity,
  159178. * and acceleration of each of these properties.
  159179. * @returns the pose object
  159180. */
  159181. getPose(): VRPose;
  159182. /**
  159183. * Return the current instantaneous pose of the VRDisplay, with no
  159184. * prediction applied.
  159185. * @returns the current instantaneous pose
  159186. */
  159187. getImmediatePose(): VRPose;
  159188. /**
  159189. * The callback passed to `requestAnimationFrame` will be called
  159190. * any time a new frame should be rendered. When the VRDisplay is
  159191. * presenting the callback will be called at the native refresh
  159192. * rate of the HMD. When not presenting this function acts
  159193. * identically to how window.requestAnimationFrame acts. Content should
  159194. * make no assumptions of frame rate or vsync behavior as the HMD runs
  159195. * asynchronously from other displays and at differing refresh rates.
  159196. * @param callback Define the eaction to run next frame
  159197. * @returns the request handle it
  159198. */
  159199. requestAnimationFrame(callback: FrameRequestCallback): number;
  159200. /**
  159201. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  159202. * Repeat calls while already presenting will update the VRLayers being displayed.
  159203. * @param layers Define the list of layer to present
  159204. * @returns a promise to know when the request has been fulfilled
  159205. */
  159206. requestPresent(layers: VRLayer[]): Promise<void>;
  159207. /**
  159208. * Reset the pose for this display, treating its current position and
  159209. * orientation as the "origin/zero" values. VRPose.position,
  159210. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  159211. * updated when calling resetPose(). This should be called in only
  159212. * sitting-space experiences.
  159213. */
  159214. resetPose(): void;
  159215. /**
  159216. * The VRLayer provided to the VRDisplay will be captured and presented
  159217. * in the HMD. Calling this function has the same effect on the source
  159218. * canvas as any other operation that uses its source image, and canvases
  159219. * created without preserveDrawingBuffer set to true will be cleared.
  159220. * @param pose Define the pose to submit
  159221. */
  159222. submitFrame(pose?: VRPose): void;
  159223. }
  159224. declare var VRDisplay: {
  159225. prototype: VRDisplay;
  159226. new(): VRDisplay;
  159227. };
  159228. interface VRLayer {
  159229. leftBounds?: number[] | Float32Array | null;
  159230. rightBounds?: number[] | Float32Array | null;
  159231. source?: HTMLCanvasElement | null;
  159232. }
  159233. interface VRDisplayCapabilities {
  159234. readonly canPresent: boolean;
  159235. readonly hasExternalDisplay: boolean;
  159236. readonly hasOrientation: boolean;
  159237. readonly hasPosition: boolean;
  159238. readonly maxLayers: number;
  159239. }
  159240. interface VREyeParameters {
  159241. /** @deprecated */
  159242. readonly fieldOfView: VRFieldOfView;
  159243. readonly offset: Float32Array;
  159244. readonly renderHeight: number;
  159245. readonly renderWidth: number;
  159246. }
  159247. interface VRFieldOfView {
  159248. readonly downDegrees: number;
  159249. readonly leftDegrees: number;
  159250. readonly rightDegrees: number;
  159251. readonly upDegrees: number;
  159252. }
  159253. interface VRFrameData {
  159254. readonly leftProjectionMatrix: Float32Array;
  159255. readonly leftViewMatrix: Float32Array;
  159256. readonly pose: VRPose;
  159257. readonly rightProjectionMatrix: Float32Array;
  159258. readonly rightViewMatrix: Float32Array;
  159259. readonly timestamp: number;
  159260. }
  159261. interface VRPose {
  159262. readonly angularAcceleration: Float32Array | null;
  159263. readonly angularVelocity: Float32Array | null;
  159264. readonly linearAcceleration: Float32Array | null;
  159265. readonly linearVelocity: Float32Array | null;
  159266. readonly orientation: Float32Array | null;
  159267. readonly position: Float32Array | null;
  159268. readonly timestamp: number;
  159269. }
  159270. interface VRStageParameters {
  159271. sittingToStandingTransform?: Float32Array;
  159272. sizeX?: number;
  159273. sizeY?: number;
  159274. }
  159275. interface Navigator {
  159276. getVRDisplays(): Promise<VRDisplay[]>;
  159277. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  159278. }
  159279. interface Window {
  159280. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  159281. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  159282. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  159283. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159284. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  159285. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  159286. }
  159287. interface Gamepad {
  159288. readonly displayId: number;
  159289. }
  159290. /**
  159291. * Available session modes
  159292. */
  159293. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  159294. /**
  159295. * Reference space types
  159296. */
  159297. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  159298. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  159299. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  159300. /**
  159301. * Handedness types
  159302. */
  159303. type XRHandedness = "none" | "left" | "right";
  159304. /**
  159305. * InputSource target ray modes
  159306. */
  159307. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  159308. /**
  159309. * Eye types
  159310. */
  159311. type XREye = "none" | "left" | "right";
  159312. /**
  159313. * Type of XR events available
  159314. */
  159315. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  159316. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  159317. type XRPlaneSet = Set<XRPlane>;
  159318. type XRAnchorSet = Set<XRAnchor>;
  159319. type XREventHandler = (callback: any) => void;
  159320. interface XRLayer extends EventTarget {}
  159321. interface XRSessionInit {
  159322. optionalFeatures?: string[];
  159323. requiredFeatures?: string[];
  159324. }
  159325. interface XRSessionEvent extends Event {
  159326. readonly session: XRSession;
  159327. }
  159328. interface XRSystem {
  159329. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  159330. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  159331. }
  159332. interface XRViewport {
  159333. readonly x: number;
  159334. readonly y: number;
  159335. readonly width: number;
  159336. readonly height: number;
  159337. }
  159338. interface XRWebGLLayerInit {
  159339. antialias?: boolean;
  159340. depth?: boolean;
  159341. stencil?: boolean;
  159342. alpha?: boolean;
  159343. multiview?: boolean;
  159344. framebufferScaleFactor?: number;
  159345. }
  159346. declare class XRWebGLLayer {
  159347. static getNativeFramebufferScaleFactor(session: XRSession): number;
  159348. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  159349. readonly antialias: boolean;
  159350. readonly framebuffer: WebGLFramebuffer;
  159351. readonly framebufferWidth: number;
  159352. readonly framebufferHeight: number;
  159353. readonly ignoreDepthValues: boolean;
  159354. getViewport: (view: XRView) => XRViewport;
  159355. }
  159356. // tslint:disable-next-line no-empty-interface
  159357. interface XRSpace extends EventTarget {}
  159358. interface XRRenderState {
  159359. readonly baseLayer?: XRWebGLLayer;
  159360. readonly depthFar: number;
  159361. readonly depthNear: number;
  159362. readonly inlineVerticalFieldOfView?: number;
  159363. }
  159364. interface XRRenderStateInit extends XRRenderState {
  159365. baseLayer: XRWebGLLayer;
  159366. depthFar: number;
  159367. depthNear: number;
  159368. inlineVerticalFieldOfView?: number;
  159369. layers?: XRLayer[];
  159370. }
  159371. interface XRReferenceSpace extends XRSpace {
  159372. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  159373. onreset: XREventHandler;
  159374. }
  159375. interface XRBoundedReferenceSpace extends XRSpace {
  159376. readonly boundsGeometry: DOMPointReadOnly[];
  159377. }
  159378. interface XRInputSource {
  159379. readonly handedness: XRHandedness;
  159380. readonly targetRayMode: XRTargetRayMode;
  159381. readonly targetRaySpace: XRSpace;
  159382. readonly gripSpace?: XRSpace;
  159383. readonly gamepad?: Gamepad;
  159384. readonly profiles: Array<string>;
  159385. readonly hand?: XRHand;
  159386. }
  159387. interface XRPose {
  159388. readonly transform: XRRigidTransform;
  159389. readonly emulatedPosition: boolean;
  159390. }
  159391. interface XRFrame {
  159392. readonly session: XRSession;
  159393. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  159394. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  159395. // AR
  159396. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  159397. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  159398. // Anchors
  159399. trackedAnchors?: XRAnchorSet;
  159400. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  159401. // Planes
  159402. worldInformation?: {
  159403. detectedPlanes?: XRPlaneSet;
  159404. };
  159405. // Hand tracking
  159406. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  159407. }
  159408. interface XRInputSourceEvent extends Event {
  159409. readonly frame: XRFrame;
  159410. readonly inputSource: XRInputSource;
  159411. }
  159412. type XRInputSourceArray = XRInputSource[];
  159413. interface XRSession {
  159414. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  159415. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  159416. /**
  159417. * Returns a list of this session's XRInputSources, each representing an input device
  159418. * used to control the camera and/or scene.
  159419. */
  159420. readonly inputSources: Array<XRInputSource>;
  159421. /**
  159422. * object which contains options affecting how the imagery is rendered.
  159423. * This includes things such as the near and far clipping planes
  159424. */
  159425. readonly renderState: XRRenderState;
  159426. readonly visibilityState: XRVisibilityState;
  159427. /**
  159428. * Removes a callback from the animation frame painting callback from
  159429. * XRSession's set of animation frame rendering callbacks, given the
  159430. * identifying handle returned by a previous call to requestAnimationFrame().
  159431. */
  159432. cancelAnimationFrame: (handle: number) => void;
  159433. /**
  159434. * Ends the WebXR session. Returns a promise which resolves when the
  159435. * session has been shut down.
  159436. */
  159437. end(): Promise<void>;
  159438. /**
  159439. * Schedules the specified method to be called the next time the user agent
  159440. * is working on rendering an animation frame for the WebXR device. Returns an
  159441. * integer value which can be used to identify the request for the purposes of
  159442. * canceling the callback using cancelAnimationFrame(). This method is comparable
  159443. * to the Window.requestAnimationFrame() method.
  159444. */
  159445. requestAnimationFrame: XRFrameRequestCallback;
  159446. /**
  159447. * Requests that a new XRReferenceSpace of the specified type be created.
  159448. * Returns a promise which resolves with the XRReferenceSpace or
  159449. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  159450. * the requested space type isn't supported by the device.
  159451. */
  159452. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  159453. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  159454. onend: XREventHandler;
  159455. oninputsourceschange: XREventHandler;
  159456. onselect: XREventHandler;
  159457. onselectstart: XREventHandler;
  159458. onselectend: XREventHandler;
  159459. onsqueeze: XREventHandler;
  159460. onsqueezestart: XREventHandler;
  159461. onsqueezeend: XREventHandler;
  159462. onvisibilitychange: XREventHandler;
  159463. // hit test
  159464. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  159465. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  159466. // legacy AR hit test
  159467. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  159468. // legacy plane detection
  159469. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  159470. }
  159471. interface XRViewerPose extends XRPose {
  159472. readonly views: Array<XRView>;
  159473. }
  159474. declare class XRRigidTransform {
  159475. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  159476. position: DOMPointReadOnly;
  159477. orientation: DOMPointReadOnly;
  159478. matrix: Float32Array;
  159479. inverse: XRRigidTransform;
  159480. }
  159481. interface XRView {
  159482. readonly eye: XREye;
  159483. readonly projectionMatrix: Float32Array;
  159484. readonly transform: XRRigidTransform;
  159485. readonly recommendedViewportScale?: number;
  159486. requestViewportScale(scale: number): void;
  159487. }
  159488. interface XRInputSourceChangeEvent extends Event {
  159489. session: XRSession;
  159490. removed: Array<XRInputSource>;
  159491. added: Array<XRInputSource>;
  159492. }
  159493. // Experimental/Draft features
  159494. declare class XRRay {
  159495. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  159496. origin: DOMPointReadOnly;
  159497. direction: DOMPointReadOnly;
  159498. matrix: Float32Array;
  159499. }
  159500. declare enum XRHitTestTrackableType {
  159501. "point",
  159502. "plane",
  159503. "mesh",
  159504. }
  159505. interface XRHitResult {
  159506. hitMatrix: Float32Array;
  159507. }
  159508. interface XRTransientInputHitTestResult {
  159509. readonly inputSource: XRInputSource;
  159510. readonly results: Array<XRHitTestResult>;
  159511. }
  159512. interface XRHitTestResult {
  159513. getPose(baseSpace: XRSpace): XRPose | undefined;
  159514. // When anchor system is enabled
  159515. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  159516. }
  159517. interface XRHitTestSource {
  159518. cancel(): void;
  159519. }
  159520. interface XRTransientInputHitTestSource {
  159521. cancel(): void;
  159522. }
  159523. interface XRHitTestOptionsInit {
  159524. space: XRSpace;
  159525. entityTypes?: Array<XRHitTestTrackableType>;
  159526. offsetRay?: XRRay;
  159527. }
  159528. interface XRTransientInputHitTestOptionsInit {
  159529. profile: string;
  159530. entityTypes?: Array<XRHitTestTrackableType>;
  159531. offsetRay?: XRRay;
  159532. }
  159533. interface XRAnchor {
  159534. anchorSpace: XRSpace;
  159535. delete(): void;
  159536. }
  159537. interface XRPlane {
  159538. orientation: "Horizontal" | "Vertical";
  159539. planeSpace: XRSpace;
  159540. polygon: Array<DOMPointReadOnly>;
  159541. lastChangedTime: number;
  159542. }
  159543. interface XRJointSpace extends XRSpace {}
  159544. interface XRJointPose extends XRPose {
  159545. radius: number | undefined;
  159546. }
  159547. interface XRHand extends Iterable<XRJointSpace> {
  159548. readonly length: number;
  159549. [index: number]: XRJointSpace;
  159550. readonly WRIST: number;
  159551. readonly THUMB_METACARPAL: number;
  159552. readonly THUMB_PHALANX_PROXIMAL: number;
  159553. readonly THUMB_PHALANX_DISTAL: number;
  159554. readonly THUMB_PHALANX_TIP: number;
  159555. readonly INDEX_METACARPAL: number;
  159556. readonly INDEX_PHALANX_PROXIMAL: number;
  159557. readonly INDEX_PHALANX_INTERMEDIATE: number;
  159558. readonly INDEX_PHALANX_DISTAL: number;
  159559. readonly INDEX_PHALANX_TIP: number;
  159560. readonly MIDDLE_METACARPAL: number;
  159561. readonly MIDDLE_PHALANX_PROXIMAL: number;
  159562. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  159563. readonly MIDDLE_PHALANX_DISTAL: number;
  159564. readonly MIDDLE_PHALANX_TIP: number;
  159565. readonly RING_METACARPAL: number;
  159566. readonly RING_PHALANX_PROXIMAL: number;
  159567. readonly RING_PHALANX_INTERMEDIATE: number;
  159568. readonly RING_PHALANX_DISTAL: number;
  159569. readonly RING_PHALANX_TIP: number;
  159570. readonly LITTLE_METACARPAL: number;
  159571. readonly LITTLE_PHALANX_PROXIMAL: number;
  159572. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  159573. readonly LITTLE_PHALANX_DISTAL: number;
  159574. readonly LITTLE_PHALANX_TIP: number;
  159575. }
  159576. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  159577. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  159578. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  159579. interface XRSession {
  159580. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  159581. }
  159582. interface XRFrame {
  159583. featurePointCloud? : Array<number>;
  159584. }